diff --git a/shaders/wgsl/bloomBlur.wgsl b/shaders/wgsl/bloomBlur.wgsl index 4a8a63a..0c2d796 100644 --- a/shaders/wgsl/bloomBlur.wgsl +++ b/shaders/wgsl/bloomBlur.wgsl @@ -34,11 +34,11 @@ fn gaussianPDF(x : f32) -> f32 { var weightSum = gaussianPDF(0.0); var sum = textureSampleLevel( tex, linearSampler, uv, 0.0) * weightSum; - for (var x : f32 = 1.0; x < config.bloomRadius; x = x + 1.0) { + for (var x : f32 = 1.0; x < config.bloomRadius; x += 1.0) { var weight = gaussianPDF(x); - sum = sum + textureSampleLevel( tex, linearSampler, uv + uvOffset * x, 0.0) * weight; - sum = sum + textureSampleLevel( tex, linearSampler, uv - uvOffset * x, 0.0) * weight; - weightSum = weightSum + weight * 2.0; + sum += textureSampleLevel( tex, linearSampler, uv + uvOffset * x, 0.0) * weight; + sum += textureSampleLevel( tex, linearSampler, uv - uvOffset * x, 0.0) * weight; + weightSum += weight * 2.0; } textureStore(outputTex, coord, sum / weightSum); diff --git a/shaders/wgsl/bloomCombine.wgsl b/shaders/wgsl/bloomCombine.wgsl index 77b0385..d6f65d2 100644 --- a/shaders/wgsl/bloomCombine.wgsl +++ b/shaders/wgsl/bloomCombine.wgsl @@ -31,35 +31,35 @@ struct ComputeInput { var uv = (vec2(coord) + 0.5) / vec2(outputSize); var sum = vec4(0.0); - // for (var i = 0.0; i < config.pyramidHeight; i = i + 1.0) { + // for (var i = 0.0; i < config.pyramidHeight; i += 1.0) { // var weight = (1.0 - i / config.pyramidHeight); // weight = pow(weight + 0.5, 1.0 / 3.0); - // sum = sum + textureSampleLevel( tex, linearSampler, uv, i + 1.0 ) * weight; + // sum += textureSampleLevel( tex, linearSampler, uv, i + 1.0 ) * weight; // } { var i = 0.0; var weight = (1.0 - i / config.pyramidHeight); weight = pow(weight + 0.5, 1.0 / 3.0); - sum = sum + textureSampleLevel( tex1, linearSampler, uv, i + 1.0 ) * weight; + sum += textureSampleLevel( tex1, linearSampler, uv, i + 1.0 ) * weight; } { var i = 1.0; var weight = (1.0 - i / config.pyramidHeight); weight = pow(weight + 0.5, 1.0 / 3.0); - sum = sum + textureSampleLevel( tex2, linearSampler, uv, i + 1.0 ) * weight; + sum += textureSampleLevel( tex2, linearSampler, uv, i + 1.0 ) * weight; } { var i = 2.0; var weight = (1.0 - i / config.pyramidHeight); weight = pow(weight + 0.5, 1.0 / 3.0); - sum = sum + textureSampleLevel( tex3, linearSampler, uv, i + 1.0 ) * weight; + sum += textureSampleLevel( tex3, linearSampler, uv, i + 1.0 ) * weight; } { var i = 3.0; var weight = (1.0 - i / config.pyramidHeight); weight = pow(weight + 0.5, 1.0 / 3.0); - sum = sum + textureSampleLevel( tex4, linearSampler, uv, i + 1.0 ) * weight; + sum += textureSampleLevel( tex4, linearSampler, uv, i + 1.0 ) * weight; } textureStore(outputTex, coord, sum); diff --git a/shaders/wgsl/palettePass.wgsl b/shaders/wgsl/palettePass.wgsl index 67cb2e1..672baf7 100644 --- a/shaders/wgsl/palettePass.wgsl +++ b/shaders/wgsl/palettePass.wgsl @@ -60,7 +60,7 @@ fn getBrightness(uv : vec2) -> vec4 { var brightness = brightnessRGB.r + brightnessRGB.g + brightnessRGB.b; // Dither: subtract a random value from the brightness - brightness = brightness - randomFloat( uv + vec2(time.seconds) ) * config.ditherMagnitude; + brightness -= randomFloat( uv + vec2(time.seconds) ) * config.ditherMagnitude; var paletteIndex = clamp(i32(brightness * 512.0), 0, 511); diff --git a/shaders/wgsl/rainPass.wgsl b/shaders/wgsl/rainPass.wgsl index 25b6ccf..1df1a98 100644 --- a/shaders/wgsl/rainPass.wgsl +++ b/shaders/wgsl/rainPass.wgsl @@ -171,7 +171,7 @@ fn applyThunderBrightness(brightness : f32, simTime : f32, screenPos : vec2 thunder = log(thunder * 1.5) * 4.0; thunder = clamp(thunder, 0.0, 1.0); - thunder = thunder * pow(screenPos.y, 2.0) * 3.0; + thunder *= pow(screenPos.y, 2.0) * 3.0; return brightness + thunder; } @@ -338,8 +338,8 @@ fn computeResult (isFirstFrame : bool, previousResult : vec4, glyphPos : ve // Calculate the vertex's world space position var worldPosition = quadPosition * vec2(1.0, config.glyphVerticalSpacing); - worldPosition = worldPosition + quadCorner * vec2(config.density, 1.0); - worldPosition = worldPosition / quadGridSize; + worldPosition += quadCorner * vec2(config.density, 1.0); + worldPosition /= quadGridSize; worldPosition = (worldPosition - 0.5) * 2.0; // "Resurrected" columns are in the green channel, @@ -353,7 +353,7 @@ fn computeResult (isFirstFrame : bool, previousResult : vec4, glyphPos : ve // Convert the vertex's world space position to screen space var screenPosition = vec4(worldPosition, quadDepth, 1.0); if (volumetric) { - screenPosition.x = screenPosition.x / config.glyphHeightToWidth; + screenPosition.x /= config.glyphHeightToWidth; screenPosition = scene.camera * scene.transform * screenPosition; } else { screenPosition = vec4(screenPosition.xy * scene.screenSize, screenPosition.zw); @@ -392,9 +392,9 @@ fn getSymbolUV(glyphCycle : f32) -> vec2 { if (!volumetric) { if (bool(config.isPolar)) { // Curve space to make the letters appear to radiate from up above - uv = uv - 0.5; - uv = uv * 0.5; - uv.y = uv.y - 0.5; + uv -= 0.5; + uv *= 0.5; + uv.y -= 0.5; var radius = length(uv); var angle = atan2(uv.y, uv.x) / (2.0 * PI) + 0.5; uv = vec2(fract(angle * 4.0 - 0.5), 1.5 * (1.0 - sqrt(radius))); @@ -406,7 +406,7 @@ fn getSymbolUV(glyphCycle : f32) -> vec2 { (uv.y - 0.5) * config.slantVec.x - (uv.x - 0.5) * config.slantVec.y ) * config.slantScale + 0.5; } - uv.y = uv.y / config.glyphHeightToWidth; + uv.y /= config.glyphHeightToWidth; } // Retrieve values from the data texture @@ -426,15 +426,15 @@ fn getSymbolUV(glyphCycle : f32) -> vec2 { brightness = max(effect, brightness); // In volumetric mode, distant glyphs are dimmer if (volumetric) { - brightness = brightness * min(1.0, quadDepth); + brightness *= min(1.0, quadDepth); } // resolve UV to cropped position of glyph in MSDF texture var glyphUV = fract(uv * config.gridSize); glyphUV.y = 1.0 - glyphUV.y; // WebGL -> WebGPU y-flip - glyphUV = glyphUV - 0.5; - glyphUV = glyphUV * clamp(1.0 - config.glyphEdgeCrop, 0.0, 1.0); - glyphUV = glyphUV + 0.5; + glyphUV -= 0.5; + glyphUV *= clamp(1.0 - config.glyphEdgeCrop, 0.0, 1.0); + glyphUV += 0.5; var msdfUV = (glyphUV + symbolUV) / vec2(config.glyphTextureGridSize); // MSDF : calculate brightness of fragment based on distance to shape @@ -447,7 +447,7 @@ fn getSymbolUV(glyphCycle : f32) -> vec2 { if (bool(config.showComputationTexture)) { output.color = vec4(glyph.r - alpha, glyph.g * alpha, glyph.a - alpha, 1.0); if (volumetric) { - output.color.g = output.color.g * 0.9 + 0.1; + output.color.g *= 0.9 + 0.1; } } else { output.color = vec4(input.channel * brightness * alpha, 1.0); diff --git a/shaders/wgsl/resurrectionPass.wgsl b/shaders/wgsl/resurrectionPass.wgsl index 275132c..ea4e86a 100644 --- a/shaders/wgsl/resurrectionPass.wgsl +++ b/shaders/wgsl/resurrectionPass.wgsl @@ -33,8 +33,8 @@ fn randomFloat( uv : vec2 ) -> f32 { fn rgbComponent(p : f32, q : f32, t : f32) -> f32 { var t2 = t; - if (t2 < 0.0) { t2 = t2 + 1.0; } - if (t2 > 1.0) { t2 = t2 - 1.0; } + if (t2 < 0.0) { t2 += 1.0; } + if (t2 > 1.0) { t2 -= 1.0; } if (t2 < 1.0 / 6.0) { return p + (q - p) * 6.0 * t2; } if (t2 < 1.0 / 2.0) { return q; } if (t2 < 2.0 / 3.0) { return p + (q - p) * (2.0 / 3.0 - t2) * 6.0; } @@ -77,7 +77,7 @@ fn hslToRgb(h : f32, s : f32, l : f32) -> vec3 { ) * 1.25; // Dither: subtract a random value from the brightness - brightness = brightness - randomFloat( uv + vec2(time.seconds) ) * config.ditherMagnitude; + brightness -= randomFloat( uv + vec2(time.seconds) ) * config.ditherMagnitude; // Calculate a hue based on distance from center var hue = 0.35 + (length(vec2(uv.x, 1.0 - uv.y) - vec2(0.5, 1.0)) * -0.4 + 0.2); diff --git a/shaders/wgsl/stripePass.wgsl b/shaders/wgsl/stripePass.wgsl index 98518f2..4a1a03d 100644 --- a/shaders/wgsl/stripePass.wgsl +++ b/shaders/wgsl/stripePass.wgsl @@ -55,7 +55,7 @@ fn getBrightness(uv : vec2) -> vec4 { var brightness = getBrightness(uv).r; // Dither: subtract a random value from the brightness - brightness = brightness - randomFloat( uv + vec2(time.seconds) ) * config.ditherMagnitude; + brightness -= randomFloat( uv + vec2(time.seconds) ) * config.ditherMagnitude; textureStore(outputTex, coord, vec4(color * brightness + config.backgroundColor, 1.0)); }