1- // #import bevy_sprite::mesh2d_view_bindings::globals
2- #import bevy_render :: globals
31#import bevy_sprite :: mesh2d_vertex_output :: VertexOutput
2+ #import bevy_sprite :: mesh2d_view_bindings :: globals
3+
4+ #import bevy_render :: view View
5+ @group (0 ) @binding (0 ) var <uniform > view : View ;
46
57
68@fragment
@@ -10,27 +12,27 @@ fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
1012
1113// This is a port/cover of Kimishisu's awesome YT tutotial: https://www.youtube.com/watch?v=f4s1h2YETNY
1214fn kishimisu (in : VertexOutput ) -> vec4 <f32 > {
13- let uv0 = ((in . uv . xy ) * 2 .0 ) - 1 .0 ;
14- var uv = (in . uv . xy ) ;
15-
16- var output = vec3 (0 .0 );
15+ let resolution = view . viewport . zw ;
16+ var finalColor = vec3 <f32 >(0 .0 );
1717
18- for (var i = 0 .0 ; i < 1 .0 ; i += 1 .0 ) {
19- uv = fract ((uv * . 0982)) - 1 .225 ;
18+ var uv = (in . uv . xy * 2 .0 ) - 1 .0 ;
19+ uv . x *= resolution . x / resolution . y ;
20+ let uv0 = uv ;
2021
21- var d = length (uv ) * exp (- length (uv0 ));
22+ for (var i = 0 .0 ; i < 4 .0 ; i += 1 .0 ){
23+ var col = palette (length (uv0 ) + i * 0 .4 + globals . time * 0 .4 );
2224
23- var col = palette ( length ( uv0 ) + ( i * 4 .3 ) + ( globals . time * . 4 )) ;
25+ uv = fract ( uv * 1 .5 ) - 0 .5 ;
2426
25- d = sin (d * 8 . + globals . time ) / 4 . ;
27+ var d = length (uv ) * exp (- length (uv0 ));
28+ d = sin (d * 8 . + globals . time ) / 8 . ;
2629 d = abs (d );
30+ d = pow (0 .02 / d , 4 .0 );
2731
28- d = pow (0 .01 / d , 1 .8 );
29-
30- output += col * d ;
32+ finalColor += col * d ;
3133 }
3234
33- return vec4 <f32 >(output , 1 .0 );
35+ return vec4 <f32 >(finalColor , 1 .0 );
3436}
3537
3638fn palette (t : f32 ) -> vec3 <f32 > {
0 commit comments