Skip to content

Commit

Permalink
Fragment Shaderの更新 (#628)
Browse files Browse the repository at this point in the history
* fix: shader

* fix: android bottom bar

* fix: 最古地震情報の日時修正
  • Loading branch information
YumNumm authored Apr 7, 2024
1 parent f1d5ac6 commit 4c8c642
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class EarthquakeHistoryNotFound extends StatelessWidget {

@override
Widget build(BuildContext context) {
const before2021 = Text(
'2021年11月18日以前の地震情報は、本アプリでは扱っていません。',
const before2020 = Text(
'2020年11月18日以前の地震情報は、本アプリでは扱っていません。',
textAlign: TextAlign.center,
);
return const Center(
Expand All @@ -26,7 +26,7 @@ class EarthquakeHistoryNotFound extends StatelessWidget {
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
before2021,
before2020,
],
),
),
Expand All @@ -39,8 +39,8 @@ class EarthquakeHistoryAllFetched extends StatelessWidget {

@override
Widget build(BuildContext context) {
const before2021 = Text(
'2021年11月18日以前の地震情報は、本アプリでは扱っていません。',
const before2020 = Text(
'2020年11月18日以前の地震情報は、本アプリでは扱っていません。',
textAlign: TextAlign.center,
);
return const SafeArea(
Expand All @@ -59,7 +59,7 @@ class EarthquakeHistoryAllFetched extends StatelessWidget {
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
before2021,
before2020,
],
),
),
Expand Down
7 changes: 7 additions & 0 deletions app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:package_info_plus/package_info_plus.dart';
Expand All @@ -32,6 +33,12 @@ late final ProviderContainer container;
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();

SystemChrome.setSystemUIOverlayStyle(
const SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
systemNavigationBarContrastEnforced: true
),
);
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
Expand Down
75 changes: 67 additions & 8 deletions app/shaders/introduction.glsl
Original file line number Diff line number Diff line change
@@ -1,19 +1,78 @@
#include<flutter/runtime_effect.glsl>

precision highp float;
precision highp int;
uniform float time;
uniform vec2 resolution;

out vec4 FragColor;

float random (in vec2 st) {
return fract(sin(dot(st.xy,
vec2(12.9898,78.233)))*
43758.5453123);
}

// Based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in vec2 st) {
vec2 i = floor(st);
vec2 f = fract(st);

// Four corners in 2D of a tile
float a = random(i);
float b = random(i + vec2(1.0, 0.0));
float c = random(i + vec2(0.0, 1.0));
float d = random(i + vec2(1.0, 1.0));

vec2 u = f * f * (3.0 - 2.0 * f);

return mix(a, b, u.x) +
(c - a)* u.y * (1.0 - u.x) +
(d - b) * u.x * u.y;
}

#define OCTAVES 6
float fbm (in vec2 st) {
// Initial values
float value = 0.0;
float amplitude = .5;
float frequency = 0.;
//
// Loop of octaves
for (int i = 0; i < OCTAVES; i++) {
value += amplitude * noise(st);
st *= 2.;
amplitude *= .5;
}
return value;
}

vec3 baseColor(in vec2 pos) {
pos += vec2(cos(time/3.0), sin(time/5.0));
pos -= vec2(2.5);

float r = length(pos) * 0.5;
float g = length(pos) * 0.5;
float b = length(pos) * 0.5;

return vec3(r, g, b) / 60.;
}

void main(void){
vec2 p=(FlutterFragCoord().xy*2.-resolution)/min(resolution.x,resolution.y);
p+=vec2(cos(time/3.),sin(time/5.));
// 画面外に持っていく
p -= vec2(2.5,2.8);
float l=(1.+sin(time)/8.)/(length(p)+.5);
vec2 pos = (FlutterFragCoord().xy*2.-resolution)/min(resolution.x,resolution.y);
vec2 st = FlutterFragCoord().xy/resolution.xy;
st.x *= resolution.x/resolution.y;

float f = fbm(st*3.0 + time/50) / 4.0;

float r = (1.+cos(time)/8.)/(length(p + vec2(cos(time/6.),sin(time/8.)) )+.5) / 10.;
float g = (1.+cos(time)/6.)/(length(p + vec2(cos(time/8.),sin(time/6.)) )+.5) / 10.;
vec3 v = vec3(
f,
f,
f * 2.
);
FragColor = vec4(v + baseColor(pos) ,1.0);

FragColor=vec4(r,g,l,1.);
// FragColor=vec4(r,g,l,1.);
}

0 comments on commit 4c8c642

Please sign in to comment.