@@ -85,11 +85,11 @@ fn v21(a: Vec2) -> f32 {
85
85
a. x + a. y * 37.0
86
86
}
87
87
fn hash11 ( a : f32 ) -> f32 {
88
- ( a. sin ( ) * 10403.9 ) . gl_fract ( )
88
+ ( a. sin ( ) * 10403.9 ) . fract_gl ( )
89
89
}
90
90
fn hash21 ( uv : Vec2 ) -> f32 {
91
91
let f: f32 = uv. x + uv. y * 37.0 ;
92
- ( f. sin ( ) * 104003.9 ) . gl_fract ( )
92
+ ( f. sin ( ) * 104003.9 ) . fract_gl ( )
93
93
}
94
94
fn hash22 ( uv : Vec2 ) -> Vec2 {
95
95
let f: f32 = uv. x + uv. y * 37.0 ;
@@ -99,15 +99,15 @@ fn _hash12(f: f32) -> Vec2 {
99
99
( f. cos ( ) * vec2 ( 10003.579 , 37049.7 ) ) . fract_gl ( )
100
100
}
101
101
fn _hash1d ( u : f32 ) -> f32 {
102
- ( u. sin ( ) * 143.9 ) . gl_fract ( ) // scale this down to kill the jitters
102
+ ( u. sin ( ) * 143.9 ) . fract_gl ( ) // scale this down to kill the jitters
103
103
}
104
104
fn hash2d ( uv : Vec2 ) -> f32 {
105
105
let f: f32 = uv. x + uv. y * 37.0 ;
106
- ( f. sin ( ) * 104003.9 ) . gl_fract ( )
106
+ ( f. sin ( ) * 104003.9 ) . fract_gl ( )
107
107
}
108
108
fn hash3d ( uv : Vec3 ) -> f32 {
109
109
let f: f32 = uv. x + uv. y * 37.0 + uv. z * 521.0 ;
110
- ( f. sin ( ) * 110003.9 ) . gl_fract ( )
110
+ ( f. sin ( ) * 110003.9 ) . fract_gl ( )
111
111
}
112
112
fn mix_p ( f0 : f32 , f1 : f32 , a : f32 ) -> f32 {
113
113
mix ( f0, f1, a * a * ( 3.0 - 2.0 * a) )
@@ -415,7 +415,7 @@ impl<C0> State<C0> {
415
415
let mut repeat_dist: f32 = 0.25 ; // Car density bumper to bumper
416
416
// If we are going north/south instead of east/west (?) make cars that are
417
417
// stopped in the street so we don't have collisions.
418
- if ( rep. x . gl_fract ( ) - 0.5 ) . abs ( ) < 0.35 {
418
+ if ( rep. x . fract_gl ( ) - 0.5 ) . abs ( ) < 0.35 {
419
419
p2. x += 0.05 ;
420
420
p2 = ( p2. zx ( ) * vec2 ( -1.0 , 1.0 ) ) . extend ( p2. y ) . xzy ( ) ; // Rotate 90 degrees
421
421
rep = p2. xz ( ) . extend ( rep. y ) . xzy ( ) ;
@@ -463,7 +463,7 @@ fn calc_windows(
463
463
window = window. max ( mix (
464
464
0.2 ,
465
465
1.0 ,
466
- ( ( pos. y * 20.0 - 0.35 ) . gl_fract ( ) * 2.0 + 0.1 ) . floor ( ) ,
466
+ ( ( pos. y * 20.0 - 0.35 ) . fract_gl ( ) * 2.0 + 0.1 ) . floor ( ) ,
467
467
) ) ;
468
468
if pos. y < 0.05 {
469
469
window = 1.0 ;
@@ -475,12 +475,12 @@ fn calc_windows(
475
475
window = window. max ( mix (
476
476
0.2 ,
477
477
1.0 ,
478
- ( ( pos. x * 40.0 + 0.05 ) . gl_fract ( ) * win_width) . floor ( ) ,
478
+ ( ( pos. x * 40.0 + 0.05 ) . fract_gl ( ) * win_width) . floor ( ) ,
479
479
) ) ;
480
480
window = window. max ( mix (
481
481
0.2 ,
482
482
1.0 ,
483
- ( ( pos. z * 40.0 + 0.05 ) . gl_fract ( ) * win_width) . floor ( ) ,
483
+ ( ( pos. z * 40.0 + 0.05 ) . fract_gl ( ) * win_width) . floor ( ) ,
484
484
) ) ;
485
485
if window < 0.5 {
486
486
* window_ref += 1.0 ;
@@ -547,7 +547,7 @@ impl<C0: SampleCube> State<C0> {
547
547
let t5: f32 = 16.0;
548
548
let t6: f32 = 18.0;*/
549
549
// Repeat the animation after time t6
550
- self . local_time = ( self . local_time / t6) . gl_fract ( ) * t6;
550
+ self . local_time = ( self . local_time / t6) . fract_gl ( ) * t6;
551
551
if self . local_time < t1 {
552
552
let time: f32 = self . local_time - t0;
553
553
let alpha: f32 = time / ( t1 - t0) ;
@@ -648,16 +648,16 @@ impl<C0: SampleCube> State<C0> {
648
648
// The distance function is not continuous at city block boundaries,
649
649
// so we have to pause our ray march at each voxel boundary.
650
650
let mut walk: f32 = dist_and_mat. x ;
651
- let mut dx: f32 = -pos. x . gl_fract ( ) ;
651
+ let mut dx: f32 = -pos. x . fract_gl ( ) ;
652
652
if ray_vec. x > 0.0 {
653
- dx = ( -pos. x ) . gl_fract ( ) ;
653
+ dx = ( -pos. x ) . fract_gl ( ) ;
654
654
}
655
- let mut dz: f32 = -pos. z . gl_fract ( ) ;
655
+ let mut dz: f32 = -pos. z . fract_gl ( ) ;
656
656
if ray_vec. z > 0.0 {
657
- dz = ( -pos. z ) . gl_fract ( ) ;
657
+ dz = ( -pos. z ) . fract_gl ( ) ;
658
658
}
659
659
let mut nearest_voxel: f32 =
660
- ( dx / ray_vec. x ) . gl_fract ( ) . min ( ( dz / ray_vec. z ) . gl_fract ( ) ) + VOXEL_PAD ;
660
+ ( dx / ray_vec. x ) . fract_gl ( ) . min ( ( dz / ray_vec. z ) . fract_gl ( ) ) + VOXEL_PAD ;
661
661
nearest_voxel = VOXEL_PAD . max ( nearest_voxel) ; // hack that assumes streets and sidewalks are this wide.
662
662
//nearestVoxel = nearestVoxel.max(t * 0.02); // hack to stop voxel walking in the distance.
663
663
walk = walk. min ( nearest_voxel) ;
@@ -729,17 +729,17 @@ impl<C0: SampleCube> State<C0> {
729
729
}
730
730
731
731
let mut walk: f32 = temp_dist;
732
- let mut dx: f32 = -shadow_pos. x . gl_fract ( ) ;
732
+ let mut dx: f32 = -shadow_pos. x . fract_gl ( ) ;
733
733
if self . sun_dir . x > 0.0 {
734
- dx = ( -shadow_pos. x ) . gl_fract ( ) ;
734
+ dx = ( -shadow_pos. x ) . fract_gl ( ) ;
735
735
}
736
- let mut dz: f32 = -shadow_pos. z . gl_fract ( ) ;
736
+ let mut dz: f32 = -shadow_pos. z . fract_gl ( ) ;
737
737
if self . sun_dir . z > 0.0 {
738
- dz = ( -shadow_pos. z ) . gl_fract ( ) ;
738
+ dz = ( -shadow_pos. z ) . fract_gl ( ) ;
739
739
}
740
740
let mut nearest_voxel: f32 = ( dx / self . sun_dir . x )
741
- . gl_fract ( )
742
- . min ( ( dz / self . sun_dir . z ) . gl_fract ( ) )
741
+ . fract_gl ( )
742
+ . min ( ( dz / self . sun_dir . z ) . fract_gl ( ) )
743
743
+ small_val;
744
744
nearest_voxel = nearest_voxel. max ( 0.2 ) ; // hack that assumes streets and sidewalks are this wide.
745
745
walk = walk. min ( nearest_voxel) ;
@@ -825,8 +825,8 @@ impl<C0: SampleCube> State<C0> {
825
825
normal = ( normal + n_temp * 0.2 ) . normalize ( ) ;
826
826
} else {
827
827
// Draw the road
828
- let xroad: f32 = ( ( pos. x + 0.5 ) . gl_fract ( ) - 0.5 ) . abs ( ) ;
829
- let zroad: f32 = ( ( pos. z + 0.5 ) . gl_fract ( ) - 0.5 ) . abs ( ) ;
828
+ let xroad: f32 = ( ( pos. x + 0.5 ) . fract_gl ( ) - 0.5 ) . abs ( ) ;
829
+ let zroad: f32 = ( ( pos. z + 0.5 ) . fract_gl ( ) - 0.5 ) . abs ( ) ;
830
830
let road: f32 = saturate ( ( xroad. min ( zroad) - 0.143 ) * 480.0 ) ;
831
831
tex_color *= 1.0 - normal. y * 0.95 * hash21 ( block * 9.87 ) * road; // change rooftop color
832
832
tex_color *= mix ( 0.1 , 1.0 , road) ;
@@ -841,8 +841,8 @@ impl<C0: SampleCube> State<C0> {
841
841
let mut white_line: f32 = saturate ( 1.0 - ( xroad. min ( zroad) - 0.06 ) * 480.0 ) ;
842
842
white_line *= saturate ( ( xroad. min ( zroad) - 0.056 ) * 480.0 ) ;
843
843
white_line *= saturate ( ( xroad * xroad + zroad * zroad - 0.05 ) * 880.0 ) ;
844
- white_line *= saturate ( 1.0 - ( ( zroad * 8.0 ) . gl_fract ( ) - 0.5 ) * 280.0 ) ; // dotted line
845
- white_line *= saturate ( 1.0 - ( ( xroad * 8.0 ) . gl_fract ( ) - 0.5 ) * 280.0 ) ;
844
+ white_line *= saturate ( 1.0 - ( ( zroad * 8.0 ) . fract_gl ( ) - 0.5 ) * 280.0 ) ; // dotted line
845
+ white_line *= saturate ( 1.0 - ( ( xroad * 8.0 ) . fract_gl ( ) - 0.5 ) * 280.0 ) ;
846
846
tex_color = mix ( tex_color, Vec3 :: splat ( 0.5 ) , white_line) ;
847
847
848
848
white_line = saturate ( 1.0 - ( xroad. min ( zroad) - 0.11 ) * 480.0 ) ;
@@ -851,12 +851,12 @@ impl<C0: SampleCube> State<C0> {
851
851
tex_color = mix ( tex_color, Vec3 :: splat ( 0.5 ) , white_line) ;
852
852
853
853
// crosswalk
854
- let mut cross_walk: f32 = saturate ( 1.0 - ( ( xroad * 40.0 ) . gl_fract ( ) - 0.5 ) * 280.0 ) ;
854
+ let mut cross_walk: f32 = saturate ( 1.0 - ( ( xroad * 40.0 ) . fract_gl ( ) - 0.5 ) * 280.0 ) ;
855
855
cross_walk *= saturate ( ( zroad - 0.15 ) * 880.0 ) ;
856
856
cross_walk *= saturate ( ( -zroad + 0.21 ) * 880.0 ) * ( 1.0 - road) ;
857
857
cross_walk *= n * n;
858
858
tex_color = mix ( tex_color, Vec3 :: splat ( 0.25 ) , cross_walk) ;
859
- cross_walk = saturate ( 1.0 - ( ( zroad * 40.0 ) . gl_fract ( ) - 0.5 ) * 280.0 ) ;
859
+ cross_walk = saturate ( 1.0 - ( ( zroad * 40.0 ) . fract_gl ( ) - 0.5 ) * 280.0 ) ;
860
860
cross_walk *= saturate ( ( xroad - 0.15 ) * 880.0 ) ;
861
861
cross_walk *= saturate ( ( -xroad + 0.21 ) * 880.0 ) * ( 1.0 - road) ;
862
862
cross_walk *= n * n;
@@ -996,9 +996,9 @@ impl<C0: SampleCube> State<C0> {
996
996
let block_res: Vec2 = ( self . inputs . resolution . xy ( ) / block_size) . floor ( ) + Vec2 :: ONE ;
997
997
// ugly bug with mod.
998
998
//float blockX = mod(frame, blockRes.x);
999
- let block_x: f32 = ( frame / block_res. x ) . gl_fract ( ) * block_res. x ;
999
+ let block_x: f32 = ( frame / block_res. x ) . fract_gl ( ) * block_res. x ;
1000
1000
//float blockY = mod(floor(frame / blockRes.x), blockRes.y);
1001
- let block_y: f32 = ( ( frame / block_res. x ) . floor ( ) / block_res. y ) . gl_fract ( ) * block_res. y ;
1001
+ let block_y: f32 = ( ( frame / block_res. x ) . floor ( ) / block_res. y ) . fract_gl ( ) * block_res. y ;
1002
1002
// Don't draw anything outside the current block.
1003
1003
if ( frag_coord. x - block_x * block_size >= block_size)
1004
1004
|| ( frag_coord. x - ( block_x - 1.0 ) * block_size < block_size)
0 commit comments