Skip to content

Commit 26df2af

Browse files
committed
feat: add flutter by xor
1 parent ffde766 commit 26df2af

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

assets/screenshots/flutter-xor.png

577 KB
Loading

lib/main.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ final shaders = [
187187
ShaderInfo(
188188
assetKey: 'shaders/sea.frag',
189189
name: 'Seascape',
190-
description: 'fully-procedural sea surface computing. without textures. Try clicking and moving around with your mouse. Adapted to Flutter by @reNotANumber',
190+
description:
191+
'fully-procedural sea surface computing. without textures. Try clicking and moving around with your mouse. Adapted to Flutter by @reNotANumber',
191192
sourceUrl: 'https://www.shadertoy.com/view/Ms2SD1',
192193
author: 'TDM, reNotANumber',
193194
dateAdded: DateTime(2025, 9, 2),
@@ -196,6 +197,19 @@ final shaders = [
196197
backgroundColor: Colors.white,
197198
aspectRatio: 1,
198199
),
200+
201+
ShaderInfo(
202+
assetKey: 'shaders/flutter_xor.frag',
203+
name: 'Flutter by XOR',
204+
description: '',
205+
sourceUrl: 'https://x.com/XorDev/status/1963365613415621101',
206+
author: 'xor',
207+
dateAdded: DateTime(2025, 9, 4),
208+
builder: const CommonShaderBuilder(),
209+
path: 'flutter-xor',
210+
backgroundColor: Colors.black,
211+
aspectRatio: 16/9,
212+
),
199213
];
200214

201215
List<ShaderInfo> sortedShaders = List.from(shaders)..sort((a, b) => b.dateAdded.compareTo(a.dateAdded));

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@ flutter:
5555
- shaders/distorted_motion.frag
5656
- shaders/plasma_xor.frag
5757
- shaders/sea.frag
58+
- shaders/flutter_xor.frag

shaders/flutter_xor.frag

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Converted to Flutter with Claude Sonnet 3.7
2+
#version 460 core
3+
precision highp float;
4+
5+
#include <flutter/runtime_effect.glsl>
6+
7+
uniform vec2 iResolution;
8+
uniform float iTime;
9+
10+
out vec4 fragColor;
11+
12+
void main()
13+
{
14+
// Get fragment coordinates and flip the y-axis
15+
vec2 fragCoord = FlutterFragCoord().xy;
16+
fragCoord.y = iResolution.y - fragCoord.y;
17+
18+
// Initialize fragColor
19+
fragColor = vec4(0.0, 0.0, 0.0, 1.0);
20+
21+
// Declare all variables at the beginning
22+
float i = 0.0;
23+
float z = 0.0;
24+
float f = 0.0;
25+
vec3 p;
26+
27+
// Main shader loop with explicit initialization
28+
for(i = 0.0; i < 5e1; i += 1.0) {
29+
p = z * (vec3(fragCoord, 0.0) * 2.0 - vec3(iResolution.xy, iResolution.y)) / iResolution.y;
30+
p.z += 9.0;
31+
32+
// Unroll the inner loop completely to avoid loop constructs
33+
f = 1.0;
34+
p += sin(round(p.zxy/0.1) * 0.1 * f - iTime)/f;
35+
f = 2.0;
36+
p += sin(round(p.zxy/0.1) * 0.1 * f - iTime)/f;
37+
f = 3.0;
38+
p += sin(round(p.zxy/0.1) * 0.1 * f - iTime)/f;
39+
f = 4.0;
40+
p += sin(round(p.zxy/0.1) * 0.1 * f - iTime)/f;
41+
f = 5.0;
42+
p += sin(round(p.zxy/0.1) * 0.1 * f - iTime)/f;
43+
f = 6.0;
44+
p += sin(round(p.zxy/0.1) * 0.1 * f - iTime)/f;
45+
46+
f = 0.003 + 0.1 * abs(length(p) - 5.0);
47+
z += f;
48+
fragColor.rgb += (p/z + 0.8)/f;
49+
}
50+
51+
// Apply final transformation
52+
fragColor = vec4(tanh(fragColor.rgb / 2e3), 1.0);
53+
}

0 commit comments

Comments
 (0)