diff --git a/src/blur/blur.ts b/src/blur/blur.ts index 8446457..74a4d51 100644 --- a/src/blur/blur.ts +++ b/src/blur/blur.ts @@ -12,7 +12,8 @@ import { floor, max, convertToTexture, - exp + exp, + select } from "three/tsl"; import type { Node, TextureNode } from "three/webgpu"; @@ -79,8 +80,10 @@ function createGaussianBlurPass( condition: "<=" }, ({ i }) => { - const weight = exp( - float(i).mul(float(i)).negate().div(twoSigmaSq) + const weight = select( + twoSigmaSq.equal(0), + float(0.00001), + exp(float(i).mul(float(i)).negate().div(twoSigmaSq)) ); totalWeight.addAssign(weight); const offset = vec2( diff --git a/src/color/colorLookup.ts b/src/color/colorLookup.ts index ce8fb1e..cfdb456 100644 --- a/src/color/colorLookup.ts +++ b/src/color/colorLookup.ts @@ -120,10 +120,20 @@ export function gradient( const lowChromaThreshold = 0.001; const adjustedH1 = oklch1.y .lessThan(lowChromaThreshold) - .select(oklch2.z, oklch1.z); + .select( + oklch2.y + .greaterThanEqual(lowChromaThreshold) + .select(oklch2.z, float(0)), + oklch1.z + ); const adjustedH2 = oklch2.y .lessThan(lowChromaThreshold) - .select(oklch1.z, oklch2.z); + .select( + oklch1.y + .greaterThanEqual(lowChromaThreshold) + .select(oklch1.z, float(0)), + oklch2.z + ); // Interpolate in OKLCH space const l = mix(oklch1.x, oklch2.x, localT);