@@ -36,9 +36,9 @@ struct SceneUniforms {
36
36
metallicFactor: f32 ,
37
37
normalMapFactor: f32 ,
38
38
specularF0: f32 ,
39
- emitMultiplicative: i32 ,
40
- normalMapFlipY: i32 ,
41
- outputSRGB: i32 ,
39
+ emitMultiplicative: f32 ,
40
+ normalMapFlipY: f32 ,
41
+ outputSRGB: f32 ,
42
42
contrast : f32 ,
43
43
44
44
hsv : vec3f ,
@@ -414,9 +414,9 @@ fn initMaterial(vertexOutput: VertexOutput) -> MaterialUniforms {
414
414
let patternWidth = ceil (uvSize. x * vertexOutput. vPatternHeight / uvSize. y);
415
415
let plusGapWidth = patternWidth * (1.0 + myGap);
416
416
let animSpeed = myAnimSpeed / uniforms . animSpeedScale;
417
- linesofar += mod (uniforms . currentTime * - animSpeed * 0.2 , plusGapWidth) ;
418
- let patternx = mod (linesofar / plusGapWidth, 1.0 ) ;
419
- let patterny = mod (uniforms . flipY * vertexOutput. vNormalY, 1.0 ) ;
417
+ linesofar += (uniforms . currentTime * - animSpeed * 0.2 ) % plusGapWidth;
418
+ let patternx = (linesofar / plusGapWidth) % 1.0 ;
419
+ let patterny = (uniforms . flipY * vertexOutput. vNormalY) % 1.0 ;
420
420
uv = computeUV (vec2 (patternx * (1.0 + myGap) * uniforms . uvScale[0 ], patterny * uniforms . uvScale[1 ]));
421
421
let patternColor = textureSample (linePatternFile, linePatternFileSampler, uv );
422
422
let inGap = clamp (sign (1.0 / (1.0 + myGap) - patternx ) + 0.000001 , 0.0 , 1.0 );
@@ -476,7 +476,7 @@ fn initMaterial(vertexOutput: VertexOutput) -> MaterialUniforms {
476
476
477
477
materialUniforms. emit = uniforms . emissiveFactor;
478
478
#if HAS_EMISSIVE_MAP
479
- if (uniforms . emitMultiplicative == 1 ) {
479
+ if (uniforms . emitMultiplicative == 1.0 ) {
480
480
materialUniforms. emit *= sRGBToLinear (textureSample (emissiveTexture, emissiveTextureSampler, uv ). rgb);
481
481
} else {
482
482
materialUniforms. emit += sRGBToLinear (textureSample (emissiveTexture, emissiveTextureSampler, uv ). rgb);
@@ -494,15 +494,15 @@ fn initMaterial(vertexOutput: VertexOutput) -> MaterialUniforms {
494
494
495
495
#if HAS_NORMAL_MAP && HAS_TANGENT
496
496
var nmap = textureSample (normalTexture, normalTextureSampler, uv ). xyz * 2.0 - 1.0 ;
497
- nmap . y = uniforms . normalMapFlipY == 1 ? - nmap . y : nmap . y ;
497
+ nmap . y = select ( nmap . y, - namp . y, uniforms . normalMapFlipY == 1.0 ) ;
498
498
materialUniforms. normal = nmap ;
499
499
#else
500
500
materialUniforms. normal = normalize (vertexOutput. vModelNormal);
501
501
#endif
502
502
503
503
#if HAS_TERRAIN_NORMAL && HAS_TANGENT
504
504
var nmap = convertTerrainHeightToNormalMap (uv );
505
- nmap . y = uniforms . normalMapFlipY == 1 ? - nmap . y : nmap . y ;
505
+ nmap . y = select ( nmap . y, - namp . y, uniforms . normalMapFlipY == 1.0 ) ;
506
506
materialUniforms. normal = nmap ;
507
507
#endif
508
508
@@ -620,8 +620,8 @@ fn normalFiltering(roughness: f32, worldNormal: vec3f) -> f32 {
620
620
let z = fetchDepth (sampleUV. xy);
621
621
let depth = linearizeDepth (z );
622
622
let sampleDepth = - 1.0 / sampleUV. z;
623
- *startSteps = depth > sampleDepth ? *startSteps : steps ;
624
- *endSteps = depth > sampleDepth ? steps : *endSteps ;
623
+ *startSteps = select ( steps , *startSteps, depth > sampleDepth) ;
624
+ *endSteps = select (*endSteps, steps , depth > sampleDepth) ;
625
625
return steps ;
626
626
}
627
627
@@ -654,7 +654,7 @@ fn normalFiltering(roughness: f32, worldNormal: vec3f) -> f32 {
654
654
depthDiff *= clamp (sign (abs (depthDiff) - rayLen * invNumSteps * invNumSteps), 0.0 , 1.0 );
655
655
hit = abs (depthDiff + depthTolerance) < depthTolerance;
656
656
let timeLerp = clamp (diffSampleW. x / (diffSampleW. x - depthDiff), 0.0 , 1.0 );
657
- let hitTime = hit ? (diffSampleW. y + timeLerp * invNumSteps - invNumSteps) : 1.0 ;
657
+ let hitTime = select ( 1.0 , (diffSampleW. y + timeLerp * invNumSteps - invNumSteps), hit ) ;
658
658
diffSampleW. z = min (diffSampleW. z, hitTime);
659
659
diffSampleW. x = depthDiff;
660
660
if (hit ) {
@@ -701,7 +701,7 @@ fn normalFiltering(roughness: f32, worldNormal: vec3f) -> f32 {
701
701
var result = vec4f (0.0 );
702
702
var rough4 = roughness * roughness ;
703
703
rough4 = rough4 * rough4 ;
704
- let upVector = abs ( normal . z) < 0.999 ? vec3f (0 .0 , 0.0 , 1 .0 ) : vec3f (1 .0 , 0.0 , 0.0 );
704
+ let upVector = select ( vec3f (1 .0 , 0.0 , 0 .0 ), vec3f (0 .0 , 0.0 , 1.0 ), abs ( normal . z) < 0.999 );
705
705
let tangentX = normalize (cross (upVector, normal ));
706
706
let tangentY = cross (normal , tangentX);
707
707
var maskSsr = shaderUniforms. ssrFactor * clamp (- 4.0 * dot (eyeVector, normal ) + 3.8 , 0.0 , 1.0 );
@@ -719,7 +719,7 @@ fn normalFiltering(roughness: f32, worldNormal: vec3f) -> f32 {
719
719
result += fetchColorInRay (resRay, maskSsr, specularEnvironment, specularColor, roughness );
720
720
}
721
721
}
722
- return result . w > 0.0 ? result . rgb / result . w : specularEnvironment ;
722
+ return select (specularEnvironment, result . rgb / result . w, result . w > 0.0 ) ;
723
723
}
724
724
#endif
725
725
@@ -829,7 +829,7 @@ fn main(vertexOutput: VertexOutput) -> @location(0) vec4f {
829
829
diffuse += materialEmit;
830
830
831
831
var frag = specular + diffuse ;
832
- if (uniforms . outputSRGB == 1 ) {
832
+ if (uniforms . outputSRGB == 1.0 ) {
833
833
frag = linearTosRGB (frag );
834
834
}
835
835
0 commit comments