├── .github └── FUNDING.yml ├── .gitignore ├── CONTRIBUTE.md ├── DESIGN.md ├── EXAMPLES.md ├── LICENSE.md ├── README.md ├── README_GLSL.md ├── README_METAL.md ├── animation ├── easing.glsl ├── easing.hlsl ├── easing.wgsl ├── easing │ ├── back.glsl │ ├── back.hlsl │ ├── back.wgsl │ ├── backIn.glsl │ ├── backIn.wgsl │ ├── backInOut.glsl │ ├── backInOut.wgsl │ ├── backOut.glsl │ ├── backOut.wgsl │ ├── bounce.glsl │ ├── bounce.hlsl │ ├── bounce.wgsl │ ├── bounceIn.glsl │ ├── bounceIn.wgsl │ ├── bounceInOut.glsl │ ├── bounceInOut.wgsl │ ├── bounceOut.glsl │ ├── bounceOut.wgsl │ ├── circular.glsl │ ├── circular.hlsl │ ├── circular.wgsl │ ├── circularIn.glsl │ ├── circularIn.wgsl │ ├── circularInOut.glsl │ ├── circularInOut.wgsl │ ├── circularOut.glsl │ ├── circularOut.wgsl │ ├── cubic.glsl │ ├── cubic.hlsl │ ├── cubic.wgsl │ ├── cubicIn.glsl │ ├── cubicIn.wgsl │ ├── cubicInOut.glsl │ ├── cubicInOut.wgsl │ ├── cubicOut.glsl │ ├── cubicOut.wgsl │ ├── elastic.glsl │ ├── elastic.hlsl │ ├── elastic.wgsl │ ├── elasticIn.glsl │ ├── elasticIn.wgsl │ ├── elasticInOut.glsl │ ├── elasticInOut.wgsl │ ├── elasticOut.glsl │ ├── elasticOut.wgsl │ ├── exponential.glsl │ ├── exponential.hlsl │ ├── exponential.wgsl │ ├── exponentialIn.glsl │ ├── exponentialIn.wgsl │ ├── exponentialInOut.glsl │ ├── exponentialInOut.wgsl │ ├── exponentialOut.glsl │ ├── exponentialOut.wgsl │ ├── linear.glsl │ ├── linear.hlsl │ ├── linear.wgsl │ ├── linearIn.glsl │ ├── linearIn.wgsl │ ├── linearInOut.glsl │ ├── linearInOut.wgsl │ ├── linearOut.glsl │ ├── linearOut.wgsl │ ├── quadratic.glsl │ ├── quadratic.hlsl │ ├── quadratic.wgsl │ ├── quadraticIn.glsl │ ├── quadraticIn.wgsl │ ├── quadraticInOut.glsl │ ├── quadraticInOut.wgsl │ ├── quadraticOut.glsl │ ├── quadraticOut.wgsl │ ├── quartic.glsl │ ├── quartic.hlsl │ ├── quartic.wgsl │ ├── quarticIn.glsl │ ├── quarticIn.wgsl │ ├── quarticInOut.glsl │ ├── quarticInOut.wgsl │ ├── quarticOut.glsl │ ├── quarticOut.wgsl │ ├── quintic.glsl │ ├── quintic.hlsl │ ├── quintic.wgsl │ ├── quinticIn.glsl │ ├── quinticIn.wgsl │ ├── quinticInOut.glsl │ ├── quinticInOut.wgsl │ ├── quinticOut.glsl │ ├── quinticOut.wgsl │ ├── sine.glsl │ ├── sine.hlsl │ ├── sine.wgsl │ ├── sineIn.glsl │ ├── sineIn.wgsl │ ├── sineInOut.glsl │ ├── sineInOut.wgsl │ ├── sineOut.glsl │ └── sineOut.wgsl ├── spriteLoop.glsl ├── spriteLoop.hlsl └── spriteLoop.wgsl ├── color ├── blend.glsl ├── blend.hlsl ├── blend.msl ├── blend.wgsl ├── blend │ ├── add.glsl │ ├── add.hlsl │ ├── add.msl │ ├── add.wesl │ ├── add.wgsl │ ├── average.glsl │ ├── average.hlsl │ ├── average.msl │ ├── average.wesl │ ├── average.wgsl │ ├── color.glsl │ ├── color.hlsl │ ├── color.msl │ ├── color.wesl │ ├── color.wgsl │ ├── colorBurn.glsl │ ├── colorBurn.hlsl │ ├── colorBurn.msl │ ├── colorBurn.wesl │ ├── colorBurn.wgsl │ ├── colorDodge.glsl │ ├── colorDodge.hlsl │ ├── colorDodge.msl │ ├── colorDodge.wesl │ ├── colorDodge.wgsl │ ├── darken.glsl │ ├── darken.hlsl │ ├── darken.msl │ ├── darken.wesl │ ├── darken.wgsl │ ├── difference.glsl │ ├── difference.hlsl │ ├── difference.msl │ ├── difference.wesl │ ├── difference.wgsl │ ├── exclusion.glsl │ ├── exclusion.hlsl │ ├── exclusion.msl │ ├── exclusion.wesl │ ├── exclusion.wgsl │ ├── glow.glsl │ ├── glow.hlsl │ ├── glow.msl │ ├── glow.wesl │ ├── glow.wgsl │ ├── hardLight.glsl │ ├── hardLight.hlsl │ ├── hardLight.msl │ ├── hardLight.wesl │ ├── hardLight.wgsl │ ├── hardMix.glsl │ ├── hardMix.hlsl │ ├── hardMix.msl │ ├── hardMix.wesl │ ├── hardMix.wgsl │ ├── hue.glsl │ ├── hue.hlsl │ ├── hue.msl │ ├── hue.wesl │ ├── hue.wgsl │ ├── lighten.glsl │ ├── lighten.hlsl │ ├── lighten.msl │ ├── lighten.wesl │ ├── lighten.wgsl │ ├── linearBurn.glsl │ ├── linearBurn.hlsl │ ├── linearBurn.msl │ ├── linearBurn.wesl │ ├── linearBurn.wgsl │ ├── linearDodge.glsl │ ├── linearDodge.hlsl │ ├── linearDodge.msl │ ├── linearDodge.wesl │ ├── linearDodge.wgsl │ ├── linearLight.glsl │ ├── linearLight.hlsl │ ├── linearLight.msl │ ├── linearLight.wesl │ ├── linearLight.wgsl │ ├── luminosity.glsl │ ├── luminosity.hlsl │ ├── luminosity.msl │ ├── luminosity.wesl │ ├── luminosity.wgsl │ ├── multiply.glsl │ ├── multiply.hlsl │ ├── multiply.msl │ ├── multiply.wesl │ ├── multiply.wgsl │ ├── negation.glsl │ ├── negation.hlsl │ ├── negation.msl │ ├── negation.wesl │ ├── negation.wgsl │ ├── overlay.glsl │ ├── overlay.hlsl │ ├── overlay.msl │ ├── overlay.wesl │ ├── overlay.wgsl │ ├── phoenix.glsl │ ├── phoenix.hlsl │ ├── phoenix.msl │ ├── phoenix.wesl │ ├── phoenix.wgsl │ ├── pinLight.glsl │ ├── pinLight.hlsl │ ├── pinLight.msl │ ├── pinLight.wesl │ ├── pinLight.wgsl │ ├── reflect.glsl │ ├── reflect.hlsl │ ├── reflect.msl │ ├── reflect.wesl │ ├── reflect.wgsl │ ├── saturation.glsl │ ├── saturation.hlsl │ ├── saturation.msl │ ├── saturation.wesl │ ├── saturation.wgsl │ ├── screen.glsl │ ├── screen.hlsl │ ├── screen.msl │ ├── screen.wesl │ ├── screen.wgsl │ ├── softLight.glsl │ ├── softLight.hlsl │ ├── softLight.msl │ ├── softLight.wesl │ ├── softLight.wgsl │ ├── subtract.glsl │ ├── subtract.hlsl │ ├── subtract.msl │ ├── subtract.wesl │ ├── subtract.wgsl │ ├── vividLight.glsl │ ├── vividLight.hlsl │ ├── vividLight.msl │ ├── vividLight.wesl │ └── vividLight.wgsl ├── brightnessContrast.glsl ├── brightnessContrast.hlsl ├── brightnessContrast.msl ├── brightnessContrast.wesl ├── brightnessContrast.wgsl ├── brightnessMatrix.glsl ├── brightnessMatrix.hlsl ├── brightnessMatrix.msl ├── composite.glsl ├── composite.hlsl ├── composite.msl ├── composite │ ├── compositeXor.glsl │ ├── compositeXor.hlsl │ ├── compositeXor.msl │ ├── destinationAtop.glsl │ ├── destinationAtop.hlsl │ ├── destinationAtop.msl │ ├── destinationIn.glsl │ ├── destinationIn.hlsl │ ├── destinationIn.msl │ ├── destinationOut.glsl │ ├── destinationOut.hlsl │ ├── destinationOut.msl │ ├── destinationOver.glsl │ ├── destinationOver.hlsl │ ├── destinationOver.msl │ ├── sourceAtop.glsl │ ├── sourceAtop.hlsl │ ├── sourceAtop.msl │ ├── sourceIn.glsl │ ├── sourceIn.hlsl │ ├── sourceIn.msl │ ├── sourceOut.glsl │ ├── sourceOut.hlsl │ ├── sourceOut.msl │ ├── sourceOver.glsl │ ├── sourceOver.hlsl │ └── sourceOver.msl ├── contrast.glsl ├── contrast.hlsl ├── contrast.msl ├── contrastMatrix.glsl ├── contrastMatrix.hlsl ├── contrastMatrix.msl ├── daltonize.glsl ├── daltonize.hlsl ├── daltonize.msl ├── desaturate.glsl ├── desaturate.hlsl ├── desaturate.msl ├── distance.glsl ├── distance.hlsl ├── distance.msl ├── distance.wesl ├── distance.wgsl ├── dither.glsl ├── dither.hlsl ├── dither.msl ├── dither │ ├── bayer.glsl │ ├── bayer.msl │ ├── bayer.wesl │ ├── bayer.wgsl │ ├── blueNoise.glsl │ ├── blueNoise.hlsl │ ├── blueNoise.msl │ ├── blueNoise.wesl │ ├── blueNoise.wgsl │ ├── interleavedGradientNoise.glsl │ ├── interleavedGradientNoise.hlsl │ ├── interleavedGradientNoise.msl │ ├── shift.glsl │ ├── shift.hlsl │ ├── shift.msl │ ├── triangleNoise.glsl │ ├── triangleNoise.hlsl │ ├── triangleNoise.msl │ ├── vlachos.glsl │ ├── vlachos.hlsl │ ├── vlachos.msl │ ├── vlachos.wesl │ └── vlachos.wgsl ├── exposure.glsl ├── exposure.hlsl ├── exposure.msl ├── exposure.wesl ├── exposure.wgsl ├── hueShift.glsl ├── hueShift.hlsl ├── hueShift.msl ├── hueShift.wesl ├── hueShift.wgsl ├── hueShiftRYB.glsl ├── hueShiftRYB.hlsl ├── hueShiftRYB.msl ├── hueShiftRYB.wesl ├── hueShiftRYB.wgsl ├── layer.glsl ├── layer.hlsl ├── layer.msl ├── layer │ ├── addSourceOver.glsl │ ├── addSourceOver.hlsl │ ├── addSourceOver.msl │ ├── averageSourceOver.glsl │ ├── averageSourceOver.hlsl │ ├── averageSourceOver.msl │ ├── colorBurnSourceOver.glsl │ ├── colorBurnSourceOver.hlsl │ ├── colorBurnSourceOver.msl │ ├── colorDodgeSourceOver.glsl │ ├── colorDodgeSourceOver.hlsl │ ├── colorDodgeSourceOver.msl │ ├── colorSourceOver.glsl │ ├── colorSourceOver.hlsl │ ├── colorSourceOver.msl │ ├── darkenSourceOver.glsl │ ├── darkenSourceOver.hlsl │ ├── darkenSourceOver.msl │ ├── differenceSourceOver.glsl │ ├── differenceSourceOver.hlsl │ ├── differenceSourceOver.msl │ ├── exclusionSourceOver.glsl │ ├── exclusionSourceOver.hlsl │ ├── exclusionSourceOver.msl │ ├── glowSourceOver.glsl │ ├── glowSourceOver.hlsl │ ├── glowSourceOver.msl │ ├── hardLightSourceOver.glsl │ ├── hardLightSourceOver.hlsl │ ├── hardLightSourceOver.msl │ ├── hardMixSourceOver.glsl │ ├── hardMixSourceOver.hlsl │ ├── hardMixSourceOver.msl │ ├── hueSourceOver.glsl │ ├── hueSourceOver.hlsl │ ├── hueSourceOver.msl │ ├── lightenSourceOver.glsl │ ├── lightenSourceOver.hlsl │ ├── lightenSourceOver.msl │ ├── linearBurnSourceOver.glsl │ ├── linearBurnSourceOver.hlsl │ ├── linearBurnSourceOver.msl │ ├── linearDodgeSourceOver.glsl │ ├── linearDodgeSourceOver.hlsl │ ├── linearDodgeSourceOver.msl │ ├── linearLightSourceOver.glsl │ ├── linearLightSourceOver.hlsl │ ├── linearLightSourceOver.msl │ ├── luminositySourceOver.glsl │ ├── luminositySourceOver.hlsl │ ├── luminositySourceOver.msl │ ├── multiplySourceOver.glsl │ ├── multiplySourceOver.hlsl │ ├── multiplySourceOver.msl │ ├── negationSourceOver.glsl │ ├── negationSourceOver.hlsl │ ├── negationSourceOver.msl │ ├── overlaySourceOver.glsl │ ├── overlaySourceOver.hlsl │ ├── overlaySourceOver.msl │ ├── phoenixSourceOver.glsl │ ├── phoenixSourceOver.hlsl │ ├── phoenixSourceOver.msl │ ├── pinLightSourceOver.glsl │ ├── pinLightSourceOver.hlsl │ ├── pinLightSourceOver.msl │ ├── reflectSourceOver.glsl │ ├── reflectSourceOver.hlsl │ ├── reflectSourceOver.msl │ ├── saturationSourceOver.glsl │ ├── saturationSourceOver.hlsl │ ├── saturationSourceOver.msl │ ├── screenSourceOver.glsl │ ├── screenSourceOver.hlsl │ ├── screenSourceOver.msl │ ├── softLightSourceOver.glsl │ ├── softLightSourceOver.hlsl │ ├── softLightSourceOver.msl │ ├── subtractSourceOver.glsl │ ├── subtractSourceOver.hlsl │ ├── subtractSourceOver.msl │ ├── vividLightSourceOver.glsl │ ├── vividLightSourceOver.hlsl │ └── vividLightSourceOver.msl ├── levels.glsl ├── levels.hlsl ├── levels.msl ├── levels │ ├── gamma.glsl │ ├── gamma.hlsl │ ├── gamma.msl │ ├── inputRange.glsl │ ├── inputRange.hlsl │ ├── inputRange.msl │ ├── outputRange.glsl │ ├── outputRange.hlsl │ └── outputRange.msl ├── luma.glsl ├── luma.hlsl ├── luma.msl ├── luma.wesl ├── luma.wgsl ├── luminance.glsl ├── luminance.hlsl ├── luminance.msl ├── lut.glsl ├── lut.hlsl ├── lut.msl ├── mixOklab.glsl ├── mixOklab.hlsl ├── mixOklab.msl ├── mixOklab.wesl ├── mixOklab.wgsl ├── mixRYB.glsl ├── mixRYB.hlsl ├── mixRYB.msl ├── mixSpectral.glsl ├── mixSpectral.hlsl ├── mixSpectral.msl ├── mixSpectral.wesl ├── mixSpectral.wgsl ├── palette.glsl ├── palette.hlsl ├── palette.msl ├── palette │ ├── fire.cuh │ ├── fire.glsl │ ├── fire.hlsl │ ├── flexoki.glsl │ ├── flexoki.hlsl │ ├── heatmap.cuh │ ├── heatmap.glsl │ ├── heatmap.hlsl │ ├── heatmap.wesl │ ├── heatmap.wgsl │ ├── hue.cuh │ ├── hue.glsl │ ├── hue.hlsl │ ├── hue.wesl │ ├── hue.wgsl │ ├── lerp.glsl │ ├── macbeth.glsl │ ├── macbeth.hlsl │ ├── pigments.glsl │ ├── pigments.hlsl │ ├── pigments │ │ ├── gamblin_oil.glsl │ │ ├── gamblin_oil.hlsl │ │ ├── golden_acrylic.glsl │ │ ├── golden_acrylic.hlsl │ │ ├── liquitex_acrylic.glsl │ │ ├── liquitex_acrylic.hlsl │ │ ├── rembrandt_oil.glsl │ │ ├── rembrandt_oil.hlsl │ │ ├── winsor_acrylic.glsl │ │ ├── winsor_acrylic.hlsl │ │ ├── winsor_gouache.glsl │ │ ├── winsor_gouache.hlsl │ │ ├── winsor_oil.glsl │ │ └── winsor_oil.hlsl │ ├── ridgway.glsl │ ├── ridgway.hlsl │ ├── spectral.glsl │ ├── spectral.hlsl │ ├── spectral │ │ ├── gems.glsl │ │ ├── gems.hlsl │ │ ├── geoffrey.glsl │ │ ├── geoffrey.hlsl │ │ ├── soft.glsl │ │ ├── soft.hlsl │ │ ├── zucconi.glsl │ │ ├── zucconi.hlsl │ │ ├── zucconi6.glsl │ │ └── zucconi6.hlsl │ ├── spyder.glsl │ ├── spyder.hlsl │ ├── wada.glsl │ ├── wada.hlsl │ ├── wada │ │ ├── dyad.glsl │ │ ├── dyad.hlsl │ │ ├── tetrad.glsl │ │ ├── tetrad.hlsl │ │ ├── triad.glsl │ │ ├── triad.hlsl │ │ ├── value.glsl │ │ └── value.hlsl │ ├── water.cuh │ ├── water.glsl │ ├── water.hlsl │ └── zorn.glsl ├── saturationMatrix.glsl ├── saturationMatrix.hlsl ├── saturationMatrix.msl ├── saturationMatrix.wesl ├── saturationMatrix.wgsl ├── space.glsl ├── space.hlsl ├── space.msl ├── space │ ├── YCbCr2rgb.glsl │ ├── YCbCr2rgb.hlsl │ ├── YCbCr2rgb.msl │ ├── YCbCr2rgb.wesl │ ├── YCbCr2rgb.wgsl │ ├── YPbPr2rgb.glsl │ ├── YPbPr2rgb.hlsl │ ├── YPbPr2rgb.msl │ ├── YPbPr2rgb.wesl │ ├── YPbPr2rgb.wgsl │ ├── cmyk2rgb.glsl │ ├── cmyk2rgb.hlsl │ ├── cmyk2rgb.msl │ ├── cmyk2rgb.wesl │ ├── cmyk2rgb.wgsl │ ├── gamma2linear.glsl │ ├── gamma2linear.hlsl │ ├── gamma2linear.msl │ ├── gamma2linear.wesl │ ├── gamma2linear.wgsl │ ├── hcy2rgb.glsl │ ├── hcy2rgb.hlsl │ ├── hcy2rgb.msl │ ├── hcy2rgb.wesl │ ├── hcy2rgb.wgsl │ ├── hsl2rgb.glsl │ ├── hsl2rgb.hlsl │ ├── hsl2rgb.msl │ ├── hsl2rgb.wesl │ ├── hsl2rgb.wgsl │ ├── hsv2rgb.glsl │ ├── hsv2rgb.hlsl │ ├── hsv2rgb.msl │ ├── hsv2rgb.wesl │ ├── hsv2rgb.wgsl │ ├── hsv2ryb.glsl │ ├── hsv2ryb.hlsl │ ├── hsv2ryb.msl │ ├── hsv2ryb.wesl │ ├── hsv2ryb.wgsl │ ├── hue2rgb.glsl │ ├── hue2rgb.hlsl │ ├── hue2rgb.msl │ ├── hue2rgb.wesl │ ├── hue2rgb.wgsl │ ├── k2rgb.glsl │ ├── k2rgb.hlsl │ ├── k2rgb.msl │ ├── k2rgb.wesl │ ├── k2rgb.wgsl │ ├── lab2lch.glsl │ ├── lab2lch.hlsl │ ├── lab2lch.msl │ ├── lab2lch.wesl │ ├── lab2lch.wgsl │ ├── lab2rgb.glsl │ ├── lab2rgb.hlsl │ ├── lab2rgb.msl │ ├── lab2rgb.wesl │ ├── lab2rgb.wgsl │ ├── lab2srgb.glsl │ ├── lab2srgb.hlsl │ ├── lab2srgb.msl │ ├── lab2srgb.wesl │ ├── lab2srgb.wgsl │ ├── lab2xyz.glsl │ ├── lab2xyz.hlsl │ ├── lab2xyz.msl │ ├── lab2xyz.wesl │ ├── lab2xyz.wgsl │ ├── lch2lab.glsl │ ├── lch2lab.hlsl │ ├── lch2lab.msl │ ├── lch2lab.wesl │ ├── lch2lab.wgsl │ ├── lch2rgb.glsl │ ├── lch2rgb.hlsl │ ├── lch2rgb.msl │ ├── lch2rgb.wesl │ ├── lch2rgb.wgsl │ ├── lch2srgb.glsl │ ├── lch2srgb.msl │ ├── linear2gamma.glsl │ ├── linear2gamma.hlsl │ ├── linear2gamma.msl │ ├── linear2gamma.wesl │ ├── linear2gamma.wgsl │ ├── lms2rgb.glsl │ ├── lms2rgb.hlsl │ ├── lms2rgb.msl │ ├── lms2rgb.wesl │ ├── lms2rgb.wgsl │ ├── oklab2rgb.glsl │ ├── oklab2rgb.hlsl │ ├── oklab2rgb.msl │ ├── oklab2rgb.wesl │ ├── oklab2rgb.wgsl │ ├── oklab2srgb.glsl │ ├── oklab2srgb.hlsl │ ├── oklab2srgb.msl │ ├── oklab2srgb.wesl │ ├── oklab2srgb.wgsl │ ├── rgb2YCbCr.glsl │ ├── rgb2YCbCr.hlsl │ ├── rgb2YCbCr.msl │ ├── rgb2YCbCr.wesl │ ├── rgb2YCbCr.wgsl │ ├── rgb2YPbPr.glsl │ ├── rgb2YPbPr.hlsl │ ├── rgb2YPbPr.msl │ ├── rgb2YPbPr.wesl │ ├── rgb2YPbPr.wgsl │ ├── rgb2cmyk.glsl │ ├── rgb2cmyk.hlsl │ ├── rgb2cmyk.msl │ ├── rgb2cmyk.wesl │ ├── rgb2cmyk.wgsl │ ├── rgb2hcv.glsl │ ├── rgb2hcv.hlsl │ ├── rgb2hcv.msl │ ├── rgb2hcv.wesl │ ├── rgb2hcv.wgsl │ ├── rgb2hcy.glsl │ ├── rgb2hcy.hlsl │ ├── rgb2hcy.msl │ ├── rgb2hcy.wesl │ ├── rgb2hcy.wgsl │ ├── rgb2heat.glsl │ ├── rgb2heat.hlsl │ ├── rgb2heat.msl │ ├── rgb2heat.wesl │ ├── rgb2heat.wgsl │ ├── rgb2hsl.glsl │ ├── rgb2hsl.hlsl │ ├── rgb2hsl.msl │ ├── rgb2hsl.wesl │ ├── rgb2hsl.wgsl │ ├── rgb2hsv.glsl │ ├── rgb2hsv.hlsl │ ├── rgb2hsv.msl │ ├── rgb2hsv.wesl │ ├── rgb2hsv.wgsl │ ├── rgb2hue.glsl │ ├── rgb2hue.hlsl │ ├── rgb2hue.msl │ ├── rgb2hue.wesl │ ├── rgb2hue.wgsl │ ├── rgb2lab.glsl │ ├── rgb2lab.hlsl │ ├── rgb2lab.msl │ ├── rgb2lab.wesl │ ├── rgb2lab.wgsl │ ├── rgb2lch.glsl │ ├── rgb2lch.hlsl │ ├── rgb2lch.msl │ ├── rgb2lch.wesl │ ├── rgb2lch.wgsl │ ├── rgb2lms.glsl │ ├── rgb2lms.hlsl │ ├── rgb2lms.msl │ ├── rgb2lms.wesl │ ├── rgb2lms.wgsl │ ├── rgb2luma.glsl │ ├── rgb2luma.hlsl │ ├── rgb2luma.msl │ ├── rgb2luma.wesl │ ├── rgb2luma.wgsl │ ├── rgb2oklab.glsl │ ├── rgb2oklab.hlsl │ ├── rgb2oklab.msl │ ├── rgb2oklab.wesl │ ├── rgb2oklab.wgsl │ ├── rgb2ryb.glsl │ ├── rgb2ryb.hlsl │ ├── rgb2ryb.msl │ ├── rgb2ryb.wesl │ ├── rgb2ryb.wgsl │ ├── rgb2srgb.glsl │ ├── rgb2srgb.hlsl │ ├── rgb2srgb.msl │ ├── rgb2srgb.wesl │ ├── rgb2srgb.wgsl │ ├── rgb2xyY.glsl │ ├── rgb2xyY.hlsl │ ├── rgb2xyY.msl │ ├── rgb2xyY.wesl │ ├── rgb2xyY.wgsl │ ├── rgb2xyz.glsl │ ├── rgb2xyz.hlsl │ ├── rgb2xyz.msl │ ├── rgb2xyz.wesl │ ├── rgb2xyz.wgsl │ ├── rgb2yiq.glsl │ ├── rgb2yiq.hlsl │ ├── rgb2yiq.msl │ ├── rgb2yiq.wesl │ ├── rgb2yiq.wgsl │ ├── rgb2yuv.glsl │ ├── rgb2yuv.hlsl │ ├── rgb2yuv.msl │ ├── rgb2yuv.wesl │ ├── rgb2yuv.wgsl │ ├── ryb2rgb.glsl │ ├── ryb2rgb.hlsl │ ├── ryb2rgb.msl │ ├── ryb2rgb.wesl │ ├── ryb2rgb.wgsl │ ├── srgb2lab.glsl │ ├── srgb2lab.hlsl │ ├── srgb2lab.msl │ ├── srgb2lab.wesl │ ├── srgb2lab.wgsl │ ├── srgb2lch.glsl │ ├── srgb2lch.hlsl │ ├── srgb2lch.msl │ ├── srgb2lch.wesl │ ├── srgb2lch.wgsl │ ├── srgb2luma.glsl │ ├── srgb2luma.hlsl │ ├── srgb2luma.msl │ ├── srgb2luma.wesl │ ├── srgb2luma.wgsl │ ├── srgb2oklab.glsl │ ├── srgb2oklab.hlsl │ ├── srgb2oklab.msl │ ├── srgb2oklab.wesl │ ├── srgb2oklab.wgsl │ ├── srgb2rgb.glsl │ ├── srgb2rgb.hlsl │ ├── srgb2rgb.msl │ ├── srgb2rgb.wesl │ ├── srgb2rgb.wgsl │ ├── srgb2xyz.glsl │ ├── srgb2xyz.hlsl │ ├── srgb2xyz.msl │ ├── srgb2xyz.wesl │ ├── srgb2xyz.wgsl │ ├── w2rgb.glsl │ ├── w2rgb.hlsl │ ├── w2rgb.msl │ ├── xyY2rgb.glsl │ ├── xyY2rgb.hlsl │ ├── xyY2rgb.msl │ ├── xyY2rgb.wesl │ ├── xyY2rgb.wgsl │ ├── xyY2srgb.glsl │ ├── xyY2srgb.hlsl │ ├── xyY2srgb.msl │ ├── xyY2srgb.wesl │ ├── xyY2srgb.wgsl │ ├── xyY2xyz.glsl │ ├── xyY2xyz.hlsl │ ├── xyY2xyz.msl │ ├── xyY2xyz.wesl │ ├── xyY2xyz.wgsl │ ├── xyz2lab.glsl │ ├── xyz2lab.hlsl │ ├── xyz2lab.msl │ ├── xyz2lab.wesl │ ├── xyz2lab.wgsl │ ├── xyz2rgb.glsl │ ├── xyz2rgb.hlsl │ ├── xyz2rgb.msl │ ├── xyz2rgb.wesl │ ├── xyz2rgb.wgsl │ ├── xyz2srgb.glsl │ ├── xyz2srgb.hlsl │ ├── xyz2srgb.msl │ ├── xyz2srgb.wesl │ ├── xyz2srgb.wgsl │ ├── xyz2xyY.glsl │ ├── xyz2xyY.hlsl │ ├── xyz2xyY.msl │ ├── xyz2xyY.wesl │ ├── xyz2xyY.wgsl │ ├── yiq2rgb.glsl │ ├── yiq2rgb.hlsl │ ├── yiq2rgb.msl │ ├── yiq2rgb.wesl │ ├── yiq2rgb.wgsl │ ├── yuv2rgb.glsl │ ├── yuv2rgb.hlsl │ ├── yuv2rgb.msl │ ├── yuv2rgb.wesl │ └── yuv2rgb.wgsl ├── tonemap.glsl ├── tonemap.hlsl ├── tonemap.msl ├── tonemap │ ├── aces.glsl │ ├── aces.hlsl │ ├── aces.wesl │ ├── aces.wgsl │ ├── debug.glsl │ ├── debug.hlsl │ ├── filmic.glsl │ ├── filmic.hlsl │ ├── filmic.wesl │ ├── filmic.wgsl │ ├── linear.glsl │ ├── linear.hlsl │ ├── reinhard.glsl │ ├── reinhard.hlsl │ ├── reinhardJodie.glsl │ ├── reinhardJodie.hlsl │ ├── uncharted.glsl │ ├── uncharted.hlsl │ ├── uncharted.wesl │ ├── uncharted.wgsl │ ├── uncharted2.glsl │ ├── uncharted2.hlsl │ ├── uncharted2.wesl │ ├── uncharted2.wgsl │ ├── unreal.glsl │ └── unreal.hlsl ├── vibrance.glsl ├── vibrance.hlsl ├── vibrance.msl ├── vibrance.wesl ├── vibrance.wgsl ├── whiteBalance.glsl ├── whiteBalance.hlsl ├── whiteBalance.msl ├── whiteBalance.wesl └── whiteBalance.wgsl ├── distort ├── barrel.glsl ├── barrel.hlsl ├── barrel.msl ├── chromaAB.glsl ├── chromaAB.hlsl ├── chromaAB.msl ├── displace.glsl ├── grain.glsl ├── grain.hlsl ├── grain.msl ├── pincushion.glsl ├── pincushion.msl ├── stretch.glsl ├── stretch.hlsl └── stretch.msl ├── draw ├── arrows.glsl ├── arrows.msl ├── axis.glsl ├── axis.hlsl ├── bridge.glsl ├── bridge.hlsl ├── bridge.msl ├── char.glsl ├── circle.glsl ├── circle.hlsl ├── circle.msl ├── colorChecker.glsl ├── colorChecker.msl ├── colorPicker.glsl ├── colorPicker.hlsl ├── colorPicker.msl ├── digits.glsl ├── digits.hlsl ├── digits.msl ├── fill.glsl ├── fill.hlsl ├── fill.msl ├── flip.glsl ├── flip.hlsl ├── flip.msl ├── hex.glsl ├── hex.hlsl ├── hex.msl ├── line.glsl ├── line.hlsl ├── matrix.glsl ├── matrix.hlsl ├── matrix.msl ├── point.glsl ├── point.hlsl ├── point.msl ├── rect.glsl ├── rect.hlsl ├── rect.msl ├── stroke.glsl ├── stroke.hlsl ├── stroke.msl ├── stroke.wesl ├── stroke.wgsl ├── tri.glsl ├── tri.hlsl └── tri.msl ├── filter ├── bilateral.glsl ├── bilateral.hlsl ├── bilinear.glsl ├── boxBlur.glsl ├── boxBlur.hlsl ├── boxBlur.msl ├── boxBlur │ ├── 1D.glsl │ ├── 1D.hlsl │ ├── 1D.msl │ ├── 2D.glsl │ ├── 2D.hlsl │ ├── 2D.msl │ ├── 2D_fast9.glsl │ ├── 2D_fast9.hlsl │ └── 2D_fast9.msl ├── edge.glsl ├── edge.hlsl ├── edge │ ├── prewitt.glsl │ ├── prewitt.hlsl │ ├── prewitt.wesl │ ├── prewitt.wgsl │ ├── sobel.glsl │ ├── sobel.hlsl │ ├── sobelDirectional.glsl │ └── sobelDirectional.hlsl ├── fibonacciBokeh.glsl ├── gaussianBlur.glsl ├── gaussianBlur.hlsl ├── gaussianBlur.msl ├── gaussianBlur │ ├── 1D.glsl │ ├── 1D.hlsl │ ├── 1D.msl │ ├── 1D_fast13.glsl │ ├── 1D_fast13.hlsl │ ├── 1D_fast13.msl │ ├── 1D_fast5.glsl │ ├── 1D_fast5.hlsl │ ├── 1D_fast5.msl │ ├── 1D_fast9.glsl │ ├── 1D_fast9.hlsl │ ├── 1D_fast9.msl │ ├── 2D.glsl │ ├── 2D.hlsl │ └── 2D.msl ├── jointBilateral.glsl ├── kuwahara.glsl ├── kuwahara.hlsl ├── laplacian.glsl ├── laplacian.hlsl ├── mean.glsl ├── mean.hlsl ├── median.glsl ├── median.hlsl ├── median │ ├── 2D_fast3.glsl │ ├── 2D_fast3.hlsl │ ├── 2D_fast5.glsl │ └── 2D_fast5.hlsl ├── noiseBlur.glsl ├── noiseBlur.hlsl ├── radialBlur.glsl ├── radialBlur.hlsl ├── sharpen.glsl ├── sharpen.hlsl ├── sharpen │ ├── adaptive.glsl │ ├── adaptive.hlsl │ ├── adaptive.wesl │ ├── adaptive.wgsl │ ├── contrastAdaptive.glsl │ ├── contrastAdaptive.hlsl │ ├── fast.glsl │ ├── fast.hlsl │ ├── fast.wesl │ └── fast.wgsl └── smartDeNoise.glsl ├── generative ├── cnoise.glsl ├── cnoise.hlsl ├── cnoise.msl ├── cnoise.wesl ├── cnoise.wgsl ├── curl.glsl ├── curl.hlsl ├── curl.msl ├── fbm.glsl ├── fbm.hlsl ├── fbm.msl ├── gerstnerWave.glsl ├── gerstnerWave.hlsl ├── gerstnerWave.msl ├── gnoise.glsl ├── gnoise.msl ├── noised.glsl ├── noised.hlsl ├── noised.msl ├── noised.wesl ├── noised.wgsl ├── pnoise.glsl ├── pnoise.hlsl ├── pnoise.msl ├── pnoise.wesl ├── pnoise.wgsl ├── psrdnoise.glsl ├── psrdnoise.hlsl ├── psrdnoise.msl ├── random.glsl ├── random.hlsl ├── random.msl ├── random.wesl ├── random.wgsl ├── snoise.glsl ├── snoise.hlsl ├── snoise.msl ├── snoise.wesl ├── snoise.wgsl ├── srandom.glsl ├── srandom.hlsl ├── srandom.msl ├── srandom.wesl ├── srandom.wgsl ├── voronoi.glsl ├── voronoi.hlsl ├── voronoi.msl ├── voronoise.glsl ├── voronoise.hlsl ├── voronoise.msl ├── wavelet.glsl ├── wavelet.msl ├── wavelet.wesl ├── wavelet.wgsl ├── worley.glsl ├── worley.hlsl ├── worley.msl ├── worley.wesl └── worley.wgsl ├── geometry ├── aabb.cuh ├── aabb.glsl ├── aabb.hlsl ├── aabb │ ├── aabb.cuh │ ├── aabb.glsl │ ├── aabb.hlsl │ ├── centroid.cuh │ ├── centroid.glsl │ ├── centroid.hlsl │ ├── contain.cuh │ ├── contain.glsl │ ├── contain.hlsl │ ├── diagonal.cuh │ ├── diagonal.glsl │ ├── diagonal.hlsl │ ├── expand.cuh │ ├── expand.glsl │ ├── expand.hlsl │ ├── intersect.cuh │ ├── intersect.glsl │ ├── intersect.hlsl │ ├── intersection.cuh │ ├── square.cuh │ ├── square.glsl │ └── square.hlsl ├── triangle.cuh ├── triangle.glsl ├── triangle.hlsl └── triangle │ ├── area.cuh │ ├── area.glsl │ ├── area.hlsl │ ├── barycentric.cuh │ ├── barycentric.glsl │ ├── barycentric.hlsl │ ├── centroid.cuh │ ├── centroid.glsl │ ├── centroid.hlsl │ ├── closestPoint.cuh │ ├── closestPoint.glsl │ ├── closestPoint.hlsl │ ├── contain.cuh │ ├── contain.glsl │ ├── contain.hlsl │ ├── distanceSq.cuh │ ├── distanceSq.glsl │ ├── distanceSq.hlsl │ ├── intersect.cuh │ ├── intersect.glsl │ ├── intersect.hlsl │ ├── normal.cuh │ ├── normal.glsl │ ├── normal.hlsl │ ├── signedDistance.cuh │ ├── signedDistance.glsl │ ├── signedDistance.hlsl │ ├── triangle.cuh │ ├── triangle.glsl │ └── triangle.hlsl ├── lighting ├── atmosphere.glsl ├── atmosphere.hlsl ├── blackbody.glsl ├── blackbody.hlsl ├── camera.cuh ├── camera.glsl ├── camera.hlsl ├── common │ ├── ashikhmin.glsl │ ├── ashikhmin.hlsl │ ├── beckmann.glsl │ ├── beckmann.hlsl │ ├── charlie.glsl │ ├── charlie.hlsl │ ├── clampNoV.glsl │ ├── clampNoV.hlsl │ ├── envBRDFApprox.glsl │ ├── envBRDFApprox.hlsl │ ├── ggx.glsl │ ├── ggx.hlsl │ ├── ggx.wesl │ ├── ggx.wgsl │ ├── gtaoMultiBounce.glsl │ ├── gtaoMultiBounce.hlsl │ ├── henyeyGreenstein.glsl │ ├── henyeyGreenstein.hlsl │ ├── kelemen.glsl │ ├── kelemen.hlsl │ ├── penner.glsl │ ├── perceptual2linearRoughness.glsl │ ├── perceptual2linearRoughness.hlsl │ ├── preFilteredImportanceSampling.glsl │ ├── preFilteredImportanceSampling.hlsl │ ├── rayleigh.glsl │ ├── rayleigh.hlsl │ ├── schlick.glsl │ ├── schlick.hlsl │ ├── schlick.wesl │ ├── schlick.wgsl │ ├── smithGGXCorrelated.glsl │ ├── smithGGXCorrelated.hlsl │ ├── specularAO.glsl │ └── specularAO.hlsl ├── debugCube.glsl ├── debugCube.hlsl ├── diffuse.glsl ├── diffuse.hlsl ├── diffuse │ ├── burley.glsl │ ├── burley.hlsl │ ├── lambert.glsl │ ├── lambert.hlsl │ ├── orenNayar.glsl │ ├── orenNayar.hlsl │ ├── orenNayar.wesl │ └── orenNayar.wgsl ├── envMap.glsl ├── envMap.hlsl ├── exposure.glsl ├── exposure.hlsl ├── fakeCube.glsl ├── fakeCube.hlsl ├── fresnel.glsl ├── fresnel.hlsl ├── fresnel.wesl ├── fresnel.wgsl ├── fresnelReflection.glsl ├── fresnelReflection.hlsl ├── fresnelReflection.wesl ├── fresnelReflection.wgsl ├── gooch.glsl ├── gooch.hlsl ├── ior.glsl ├── ior.hlsl ├── ior │ ├── 2eta.glsl │ ├── 2eta.hlsl │ ├── 2f0.glsl │ ├── 2f0.hlsl │ ├── reflectance2f0.glsl │ └── reflectance2f0.hlsl ├── iridescence.glsl ├── iridescence.hlsl ├── light │ ├── attenuation.glsl │ ├── attenuation.hlsl │ ├── directional.glsl │ ├── directional.hlsl │ ├── directionalEvaluate.glsl │ ├── directionalEvaluate.hlsl │ ├── falloff.glsl │ ├── falloff.hlsl │ ├── iblEvaluate.glsl │ ├── iblEvaluate.hlsl │ ├── new.glsl │ ├── new.hlsl │ ├── point.glsl │ ├── point.hlsl │ ├── pointEvaluate.glsl │ ├── pointEvaluate.hlsl │ ├── resolve.glsl │ ├── resolve.hlsl │ ├── spot.glsl │ └── spot.hlsl ├── material.glsl ├── material.hlsl ├── material │ ├── add.glsl │ ├── add.hlsl │ ├── albedo.glsl │ ├── albedo.hlsl │ ├── emissive.glsl │ ├── emissive.hlsl │ ├── metallic.glsl │ ├── metallic.hlsl │ ├── multiply.glsl │ ├── multiply.hlsl │ ├── new.glsl │ ├── new.hlsl │ ├── normal.glsl │ ├── normal.hlsl │ ├── occlusion.glsl │ ├── occlusion.hlsl │ ├── roughness.glsl │ ├── roughness.hlsl │ ├── shininess.glsl │ ├── shininess.hlsl │ ├── specular.glsl │ ├── specular.hlsl │ ├── zero.glsl │ └── zero.hlsl ├── medium.glsl ├── medium.hlsl ├── medium │ ├── new.glsl │ └── new.hlsl ├── pbr.glsl ├── pbr.hlsl ├── pbrClearCoat.glsl ├── pbrClearCoat.hlsl ├── pbrGlass.glsl ├── pbrGlass.hlsl ├── pbrLittle.glsl ├── pbrLittle.hlsl ├── ray.cuh ├── ray.glsl ├── ray.hlsl ├── ray │ ├── cast.glsl │ ├── direction.glsl │ └── new.glsl ├── raymarch.glsl ├── raymarch.hlsl ├── raymarch │ ├── ao.cuh │ ├── ao.glsl │ ├── ao.hlsl │ ├── cast.cuh │ ├── cast.glsl │ ├── cast.hlsl │ ├── cast.wesl │ ├── cast.wgsl │ ├── fog.glsl │ ├── fog.hlsl │ ├── glass.glsl │ ├── glass.hlsl │ ├── map.cuh │ ├── map.glsl │ ├── map.hlsl │ ├── normal.cuh │ ├── normal.glsl │ ├── normal.hlsl │ ├── normal.wesl │ ├── normal.wgsl │ ├── render.glsl │ ├── render.hlsl │ ├── shading.glsl │ ├── shading.hlsl │ ├── softShadow.cuh │ ├── softShadow.glsl │ ├── softShadow.hlsl │ ├── volume.glsl │ └── volume.hlsl ├── reflection.glsl ├── reflection.hlsl ├── shadingData │ ├── new.glsl │ ├── new.hlsl │ ├── shadingData.glsl │ └── shadingData.hlsl ├── shadow.glsl ├── shadow.hlsl ├── specular.glsl ├── specular.hlsl ├── specular │ ├── beckmann.glsl │ ├── beckmann.hlsl │ ├── blinnPhong.glsl │ ├── blinnPhong.hlsl │ ├── cookTorrance.glsl │ ├── cookTorrance.hlsl │ ├── cookTorrance.wesl │ ├── cookTorrance.wgsl │ ├── gaussian.glsl │ ├── gaussian.hlsl │ ├── importanceSampling.glsl │ ├── importanceSampling.hlsl │ ├── phong.glsl │ ├── phong.hlsl │ ├── ward.glsl │ └── ward.hlsl ├── sphereMap.glsl ├── sphereMap.hlsl ├── sphericalHarmonics.glsl ├── sphericalHarmonics.hlsl ├── ssao.glsl ├── ssr.glsl ├── toMetallic.glsl ├── toMetallic.hlsl ├── toShininess.glsl ├── toShininess.hlsl ├── toShininess.wesl ├── toShininess.wgsl ├── transparent.glsl ├── transparent.hlsl ├── volumetricLightScattering.glsl ├── wavelength.glsl └── wavelength.hlsl ├── math.cuh ├── math.glsl ├── math.hlsl ├── math.msl ├── math.wgsl ├── math ├── aafloor.glsl ├── aafloor.hlsl ├── aafloor.msl ├── aafloor.wesl ├── aafloor.wgsl ├── aafract.glsl ├── aafract.hlsl ├── aafract.msl ├── aafract.wesl ├── aafract.wgsl ├── aamirror.glsl ├── aamirror.hlsl ├── aastep.glsl ├── aastep.hlsl ├── aastep.msl ├── aastep.wesl ├── aastep.wgsl ├── abs.cuh ├── absi.glsl ├── absi.msl ├── adaptiveThreshold.cuh ├── adaptiveThreshold.glsl ├── adaptiveThreshold.hlsl ├── adaptiveThreshold.msl ├── adaptiveThreshold.wesl ├── adaptiveThreshold.wgsl ├── asin.cuh ├── atan2.glsl ├── atan2.msl ├── bump.cuh ├── bump.glsl ├── bump.hlsl ├── bump.msl ├── bump.wesl ├── bump.wgsl ├── clamp.cuh ├── const.cuh ├── const.glsl ├── const.hlsl ├── const.msl ├── const.wgsl ├── consts.wesl ├── cross.cuh ├── cubic.cuh ├── cubic.glsl ├── cubic.hlsl ├── cubic.msl ├── cubic.wesl ├── cubic.wgsl ├── cubicMix.glsl ├── cubicMix.hlsl ├── cubicMix.msl ├── cubicMix.wesl ├── cubicMix.wgsl ├── decimate.cuh ├── decimate.glsl ├── decimate.hlsl ├── decimate.msl ├── decimate.wesl ├── decimate.wgsl ├── dist.glsl ├── dist.hlsl ├── dist.wesl ├── dist.wgsl ├── dot.cuh ├── equal.msl ├── fcos.glsl ├── fcos.hlsl ├── floor.cuh ├── frac.cuh ├── frac.glsl ├── frac.msl ├── fract.cuh ├── fract.hlsl ├── gain.cuh ├── gain.glsl ├── gain.hlsl ├── gain.msl ├── gain.wesl ├── gain.wgsl ├── gaussian.cuh ├── gaussian.glsl ├── gaussian.hlsl ├── gaussian.msl ├── gaussian.msl 2 ├── gaussian.wesl ├── gaussian.wgsl ├── grad4.cuh ├── grad4.glsl ├── grad4.hlsl ├── grad4.msl ├── grad4.wesl ├── grad4.wgsl ├── greaterThan.cuh ├── greaterThan.hlsl ├── greaterThan.msl ├── greaterThanEqual.msl ├── hammersley.glsl ├── hammersley.hlsl ├── highPass.cuh ├── highPass.glsl ├── highPass.hlsl ├── highPass.msl ├── highPass.wesl ├── highPass.wgsl ├── inside.glsl ├── inside.hlsl ├── inside.msl ├── inside.wesl ├── inside.wgsl ├── invCubic.cuh ├── invCubic.glsl ├── invCubic.hlsl ├── invCubic.msl ├── invCubic.wesl ├── invCubic.wgsl ├── invQuartic.cuh ├── invQuartic.glsl ├── invQuartic.hlsl ├── invQuartic.msl ├── invQuartic.wesl ├── invQuartic.wgsl ├── inverse.glsl ├── inverse.msl ├── inverse.wesl ├── inverse.wgsl ├── length.cuh ├── lengthSq.cuh ├── lengthSq.glsl ├── lengthSq.hlsl ├── lengthSq.msl ├── lengthSq.wesl ├── lengthSq.wgsl ├── lerp.cuh ├── lerp.glsl ├── lerp.msl ├── lessThan.msl ├── lessThanEqual.msl ├── make.cuh ├── map.cuh ├── map.glsl ├── map.hlsl ├── map.msl ├── map.wesl ├── map.wgsl ├── max.cuh ├── min.cuh ├── mirror.cuh ├── mirror.glsl ├── mirror.hlsl ├── mirror.msl ├── mirror.wesl ├── mirror.wgsl ├── mix.cuh ├── mix.hlsl ├── mmax.cuh ├── mmax.glsl ├── mmax.hlsl ├── mmax.msl ├── mmax.wesl ├── mmax.wgsl ├── mmin.cuh ├── mmin.glsl ├── mmin.hlsl ├── mmin.msl ├── mmin.wesl ├── mmin.wgsl ├── mmix.glsl ├── mmix.msl ├── mod.cuh ├── mod.hlsl ├── mod.msl ├── mod.wesl ├── mod.wgsl ├── mod2.glsl ├── mod2.hlsl ├── mod2.msl ├── mod289.cuh ├── mod289.glsl ├── mod289.hlsl ├── mod289.msl ├── mod289.wesl ├── mod289.wgsl ├── modi.glsl ├── normalize.cuh ├── notEqual.msl ├── nyquist.glsl ├── nyquist.hlsl ├── operations.cuh ├── pack.glsl ├── pack.hlsl ├── pack.msl ├── pack.wesl ├── pack.wgsl ├── parabola.cuh ├── parabola.glsl ├── parabola.hlsl ├── parabola.msl ├── parabola.wesl ├── parabola.wgsl ├── permute.cuh ├── permute.glsl ├── permute.hlsl ├── permute.msl ├── permute.wesl ├── permute.wgsl ├── pow.cuh ├── pow2.cuh ├── pow2.glsl ├── pow2.hlsl ├── pow2.msl ├── pow3.cuh ├── pow3.glsl ├── pow3.hlsl ├── pow3.msl ├── pow5.cuh ├── pow5.glsl ├── pow5.hlsl ├── pow5.msl ├── pow7.cuh ├── pow7.glsl ├── pow7.hlsl ├── pow7.msl ├── powFast.cuh ├── powFast.glsl ├── powFast.hlsl ├── powFast.msl ├── powFast.wesl ├── powFast.wgsl ├── quartic.cuh ├── quartic.glsl ├── quartic.hlsl ├── quartic.msl ├── quartic.wesl ├── quartic.wgsl ├── quat.glsl ├── quat.hlsl ├── quat.msl ├── quat.wesl ├── quat.wgsl ├── quat │ ├── 2mat3.glsl │ ├── 2mat3.hlsl │ ├── 2mat3.msl │ ├── 2mat3.wgsl │ ├── 2mat4.glsl │ ├── 2mat4.hlsl │ ├── 2mat4.msl │ ├── 2mat4.wgsl │ ├── add.glsl │ ├── add.hlsl │ ├── add.msl │ ├── add.wgsl │ ├── conj.glsl │ ├── conj.hlsl │ ├── conj.msl │ ├── conj.wgsl │ ├── div.glsl │ ├── div.hlsl │ ├── div.msl │ ├── div.wgsl │ ├── identity.glsl │ ├── identity.hlsl │ ├── identity.msl │ ├── identity.wgsl │ ├── inverse.glsl │ ├── inverse.hlsl │ ├── inverse.msl │ ├── inverse.wgsl │ ├── length.glsl │ ├── length.hlsl │ ├── length.msl │ ├── length.wgsl │ ├── lengthSq.glsl │ ├── lengthSq.hlsl │ ├── lengthSq.msl │ ├── lengthSq.wgsl │ ├── lerp.glsl │ ├── lerp.hlsl │ ├── lerp.msl │ ├── lerp.wgsl │ ├── mul.glsl │ ├── mul.hlsl │ ├── mul.msl │ ├── mul.wgsl │ ├── neg.glsl │ ├── neg.hlsl │ ├── neg.msl │ ├── neg.wgsl │ ├── norm.glsl │ ├── norm.hlsl │ ├── norm.msl │ ├── norm.wgsl │ ├── sub.glsl │ ├── sub.hlsl │ ├── sub.msl │ ├── sub.wgsl │ ├── type.glsl │ ├── type.hlsl │ └── type.msl ├── quintic.cuh ├── quintic.glsl ├── quintic.hlsl ├── quintic.msl ├── quintic.wesl ├── quintic.wgsl ├── radians.msl ├── reflect.cuh ├── rotate2d.glsl ├── rotate2d.hlsl ├── rotate2d.msl ├── rotate2d.wesl ├── rotate2d.wgsl ├── rotate3d.glsl ├── rotate3d.hlsl ├── rotate3d.msl ├── rotate3d.wesl ├── rotate3d.wgsl ├── rotate3dX.glsl ├── rotate3dX.hlsl ├── rotate3dX.msl ├── rotate3dX.wesl ├── rotate3dX.wgsl ├── rotate3dY.glsl ├── rotate3dY.hlsl ├── rotate3dY.msl ├── rotate3dY.wesl ├── rotate3dY.wgsl ├── rotate3dZ.glsl ├── rotate3dZ.hlsl ├── rotate3dZ.msl ├── rotate3dZ.wesl ├── rotate3dZ.wgsl ├── rotate4d.glsl ├── rotate4d.hlsl ├── rotate4d.msl ├── rotate4d.wesl ├── rotate4d.wgsl ├── rotate4dX.glsl ├── rotate4dX.hlsl ├── rotate4dX.msl ├── rotate4dX.wesl ├── rotate4dX.wgsl ├── rotate4dY.glsl ├── rotate4dY.hlsl ├── rotate4dY.msl ├── rotate4dY.wesl ├── rotate4dY.wgsl ├── rotate4dZ.glsl ├── rotate4dZ.hlsl ├── rotate4dZ.msl ├── rotate4dZ.wesl ├── rotate4dZ.wgsl ├── round.glsl ├── round.msl ├── round.wesl ├── round.wgsl ├── saturate.cuh ├── saturate.glsl ├── saturate.msl ├── saturate.msl 2 ├── saturateMediump.cuh ├── saturateMediump.glsl ├── saturateMediump.hlsl ├── saturateMediump.msl ├── scale2d.glsl ├── scale2d.hlsl ├── scale2d.msl ├── scale2d.wesl ├── scale2d.wgsl ├── scale3d.glsl ├── scale3d.hlsl ├── scale3d.msl ├── scale3d.wesl ├── scale3d.wgsl ├── scale4d.glsl ├── scale4d.hlsl ├── scale4d.msl ├── scale4d.wesl ├── scale4d.wgsl ├── select.glsl ├── select.hlsl ├── select.msl ├── sign.cuh ├── sin.cuh ├── smootherstep.cuh ├── smootherstep.glsl ├── smootherstep.hlsl ├── smootherstep.msl ├── smootherstep.wesl ├── smootherstep.wgsl ├── smoothstep.cuh ├── sqrt.cuh ├── step.cuh ├── sum.cuh ├── sum.glsl ├── sum.hlsl ├── sum.msl ├── sum.wesl ├── sum.wgsl ├── taylorInvSqrt.cuh ├── taylorInvSqrt.glsl ├── taylorInvSqrt.hlsl ├── taylorInvSqrt.msl ├── taylorInvSqrt.wesl ├── taylorInvSqrt.wgsl ├── toMat3.glsl ├── toMat4.glsl ├── toMat4.hlsl ├── toMat4.msl ├── toMat4.wesl ├── toMat4.wgsl ├── translate4d.glsl ├── translate4d.hlsl ├── translate4d.msl ├── translate4d.wesl ├── translate4d.wgsl ├── transpose.glsl ├── unpack.cuh ├── unpack.glsl ├── unpack.hlsl ├── unpack.msl ├── unpack.wesl ├── unpack.wgsl ├── within.cuh ├── within.glsl ├── within.hlsl ├── within.msl ├── within.wesl └── within.wgsl ├── morphological ├── alphaFill.glsl ├── alphaFill.hlsl ├── alphaHashing.glsl ├── dilation.glsl ├── dilation.hlsl ├── erosion.glsl ├── erosion.hlsl ├── jumpFlood.glsl ├── marchingSquares.glsl ├── pyramid.glsl └── pyramid │ ├── downscale.glsl │ └── upscale.glsl ├── package.json ├── pnpm-lock.yaml ├── prune.py ├── sample.glsl ├── sample.hlsl ├── sample ├── 2DCube.glsl ├── 2DCube.hlsl ├── 3DSdf.glsl ├── 3DSdf.hlsl ├── bicubic.glsl ├── bicubic.hlsl ├── bracketing.glsl ├── bracketing.hlsl ├── bumpMap.glsl ├── bumpMap.hlsl ├── clamp2edge.glsl ├── clamp2edge.hlsl ├── clamp2edge.msl ├── derivative.glsl ├── derivative.hlsl ├── dither.glsl ├── dof.glsl ├── dof.hlsl ├── equirect.glsl ├── equirect.hlsl ├── flow.glsl ├── flow.hlsl ├── fxaa.glsl ├── fxaa.hlsl ├── heatmap.glsl ├── heatmap.hlsl ├── hue.glsl ├── hue.hlsl ├── mirror.glsl ├── mirror.hlsl ├── nearest.glsl ├── nearest.hlsl ├── normalFromHeightMap.glsl ├── normalFromHeightMap.hlsl ├── normalMap.glsl ├── normalMap.hlsl ├── opticalFlow.glsl ├── opticalFlow.hlsl ├── quilt.glsl ├── quilt.hlsl ├── repeat.glsl ├── repeat.hlsl ├── shadow.glsl ├── shadow.hlsl ├── shadowLerp.glsl ├── shadowLerp.hlsl ├── shadowPCF.glsl ├── shadowPCF.hlsl ├── smooth.glsl ├── smooth.hlsl ├── sprite.glsl ├── sprite.hlsl ├── sprite.wgsl ├── triplanar.glsl ├── triplanar.hlsl ├── untile.glsl ├── untile.hlsl ├── viewPosition.glsl ├── viewPosition.hlsl ├── yuv.glsl ├── yuv.hlsl ├── zero.glsl └── zero.hlsl ├── sampler.glsl ├── sampler.hlsl ├── sampler.msl ├── sdf.glsl ├── sdf.hlsl ├── sdf.msl ├── sdf ├── arrowSDF.glsl ├── arrowSDF.msl ├── boxFrameSDF.glsl ├── boxFrameSDF.hlsl ├── boxFrameSDF.msl ├── boxSDF.glsl ├── boxSDF.hlsl ├── boxSDF.msl ├── boxSDF.wesl ├── boxSDF.wgsl ├── capsuleSDF.glsl ├── capsuleSDF.hlsl ├── capsuleSDF.msl ├── circleSDF.glsl ├── circleSDF.hlsl ├── circleSDF.msl ├── coneSDF.glsl ├── coneSDF.hlsl ├── coneSDF.msl ├── crossSDF.glsl ├── crossSDF.hlsl ├── crossSDF.msl ├── cubeSDF.glsl ├── cubeSDF.hlsl ├── cubeSDF.msl ├── cylinderSDF.glsl ├── cylinderSDF.hlsl ├── cylinderSDF.msl ├── cylinderSDF.wesl ├── cylinderSDF.wgsl ├── dodecahedronSDF.glsl ├── dodecahedronSDF.hlsl ├── dodecahedronSDF.msl ├── ellipsoidSDF.glsl ├── ellipsoidSDF.hlsl ├── ellipsoidSDF.msl ├── flowerSDF.glsl ├── flowerSDF.hlsl ├── flowerSDF.msl ├── gearSDF.glsl ├── gearSDF.hlsl ├── gearSDF.msl ├── heartSDF.glsl ├── heartSDF.hlsl ├── heartSDF.msl ├── hexPrismSDF.glsl ├── hexPrismSDF.hlsl ├── hexPrismSDF.msl ├── hexSDF.glsl ├── hexSDF.hlsl ├── hexSDF.msl ├── icosahedronSDF.glsl ├── icosahedronSDF.hlsl ├── icosahedronSDF.msl ├── juliaSDF.glsl ├── juliaSDF.hlsl ├── juliaSDF.msl ├── kochSDF.glsl ├── kochSDF.hlsl ├── kochSDF.msl ├── lineSDF.glsl ├── lineSDF.hlsl ├── lineSDF.msl ├── linkSDF.glsl ├── linkSDF.hlsl ├── linkSDF.msl ├── mandelbulbSDF.glsl ├── mandelbulbSDF.hlsl ├── mandelbulbSDF.msl ├── octahedronSDF.glsl ├── octahedronSDF.hlsl ├── octahedronSDF.msl ├── octogonPrismSDF.glsl ├── octogonPrismSDF.hlsl ├── octogonPrismSDF.msl ├── opElongate.glsl ├── opElongate.hlsl ├── opElongate.msl ├── opExtrude.glsl ├── opExtrude.hlsl ├── opExtrude.msl ├── opIntersection.glsl ├── opIntersection.hlsl ├── opIntersection.msl ├── opOnion.glsl ├── opOnion.hlsl ├── opOnion.msl ├── opRepeat.glsl ├── opRepeat.hlsl ├── opRepeat.msl ├── opRevolve.glsl ├── opRevolve.hlsl ├── opRevolve.msl ├── opRound.glsl ├── opRound.hlsl ├── opRound.msl ├── opSubtraction.glsl ├── opSubtraction.hlsl ├── opSubtraction.msl ├── opSubtraction.wesl ├── opSubtraction.wgsl ├── opUnion.cuh ├── opUnion.glsl ├── opUnion.hlsl ├── opUnion.msl ├── opUnion.wesl ├── opUnion.wgsl ├── planeSDF.cuh ├── planeSDF.glsl ├── planeSDF.hlsl ├── planeSDF.msl ├── polySDF.glsl ├── polySDF.hlsl ├── polySDF.msl ├── pyramidSDF.glsl ├── pyramidSDF.hlsl ├── pyramidSDF.msl ├── raysSDF.glsl ├── raysSDF.hlsl ├── raysSDF.msl ├── rectSDF.glsl ├── rectSDF.hlsl ├── rectSDF.msl ├── rectSDF.wesl ├── rectSDF.wgsl ├── rhombSDF.glsl ├── rhombSDF.hlsl ├── rhombSDF.msl ├── sphereSDF.cuh ├── sphereSDF.glsl ├── sphereSDF.hlsl ├── sphereSDF.msl ├── sphereSDF.wesl ├── sphereSDF.wgsl ├── spiralSDF.glsl ├── spiralSDF.hlsl ├── spiralSDF.msl ├── starSDF.glsl ├── starSDF.hlsl ├── starSDF.msl ├── superShapeSDF.glsl ├── superShapeSDF.hlsl ├── superShapeSDF.msl ├── tetrahedronSDF.glsl ├── tetrahedronSDF.hlsl ├── tetrahedronSDF.msl ├── torusSDF.glsl ├── torusSDF.hlsl ├── torusSDF.msl ├── torusSDF.wesl ├── torusSDF.wgsl ├── triPrismSDF.glsl ├── triPrismSDF.hlsl ├── triPrismSDF.msl ├── triSDF.glsl ├── triSDF.hlsl ├── triSDF.msl ├── vesicaSDF.glsl ├── vesicaSDF.hlsl └── vesicaSDF.msl ├── simulate ├── grayscott.glsl ├── latticeBoltzmann.glsl ├── ripple.glsl └── simpleAndFastFluid.glsl ├── space ├── aspect.glsl ├── aspect.hlsl ├── aspect.msl ├── bracketing.glsl ├── bracketing.hlsl ├── bracketing.msl ├── brickTile.glsl ├── brickTile.hlsl ├── brickTile.msl ├── cart2polar.glsl ├── cart2polar.hlsl ├── cart2polar.msl ├── center.glsl ├── center.hlsl ├── center.msl ├── checkerTile.glsl ├── checkerTile.hlsl ├── checkerTile.msl ├── depth2viewZ.glsl ├── depth2viewZ.hlsl ├── depth2viewZ.msl ├── displace.glsl ├── displace.hlsl ├── displace.msl ├── equirect2xyz.glsl ├── equirect2xyz.hlsl ├── equirect2xyz.msl ├── eulerView.glsl ├── eulerView.hlsl ├── fisheye2xyz.glsl ├── fisheye2xyz.hlsl ├── fisheye2xyz.msl ├── fisheye2xyz.wesl ├── fisheye2xyz.wgsl ├── flipY.glsl ├── flipY.hlsl ├── flipY.msl ├── hexTile.glsl ├── hexTile.hlsl ├── hexTile.msl ├── kaleidoscope.glsl ├── kaleidoscope.hlsl ├── kaleidoscope.msl ├── linearizeDepth.glsl ├── linearizeDepth.hlsl ├── linearizeDepth.msl ├── lookAt.glsl ├── lookAt.hlsl ├── lookAt.msl ├── lookAtView.glsl ├── lookAtView.hlsl ├── mirrorTile.glsl ├── mirrorTile.hlsl ├── mirrorTile.msl ├── nearest.glsl ├── nearest.hlsl ├── nearest.msl ├── nearest.wesl ├── nearest.wgsl ├── orthographic.glsl ├── orthographic.msl ├── parallaxMapping.glsl ├── parallaxMapping.hlsl ├── parallaxMapping.msl ├── perspective.glsl ├── perspective.msl ├── polar2cart.glsl ├── polar2cart.hlsl ├── polar2cart.msl ├── ratio.cuh ├── ratio.glsl ├── ratio.hlsl ├── ratio.msl ├── ratio.wesl ├── ratio.wgsl ├── rotate.glsl ├── rotate.hlsl ├── rotate.msl ├── rotate.wesl ├── rotate.wgsl ├── rotateX.glsl ├── rotateX.hlsl ├── rotateX.msl ├── rotateY.glsl ├── rotateY.hlsl ├── rotateY.msl ├── rotateZ.glsl ├── rotateZ.hlsl ├── rotateZ.msl ├── scale.glsl ├── scale.hlsl ├── scale.msl ├── scale.wesl ├── scale.wgsl ├── screen2viewPosition.glsl ├── screen2viewPosition.hlsl ├── screen2viewPosition.msl ├── sprite.glsl ├── sprite.hlsl ├── sprite.msl ├── sprite.wgsl ├── sqTile.glsl ├── sqTile.hlsl ├── sqTile.msl ├── tbn.glsl ├── tbn.hlsl ├── translate.glsl ├── translate.hlsl ├── triTile.glsl ├── triTile.hlsl ├── triTile.msl ├── uncenter.glsl ├── uncenter.hlsl ├── uncenter.msl ├── unratio.glsl ├── unratio.hlsl ├── unratio.msl ├── view2screenPosition.glsl ├── view2screenPosition.hlsl ├── view2screenPosition.msl ├── viewZ2depth.glsl ├── viewZ2depth.hlsl ├── viewZ2depth.msl ├── windmillTile.glsl ├── windmillTile.hlsl ├── windmillTile.msl ├── xyz2equirect.glsl ├── xyz2equirect.hlsl └── xyz2equirect.msl ├── version.glsl ├── version.hlsl ├── version.wesl ├── version.wgsl └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | */.DS_Store 3 | *.meta 4 | assets/* 5 | node_modules 6 | dist -------------------------------------------------------------------------------- /animation/easing.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | description: Include all available easing animations 3 | */ 4 | 5 | #include "easing/back.glsl" 6 | #include "easing/bounce.glsl" 7 | #include "easing/circular.glsl" 8 | #include "easing/cubic.glsl" 9 | #include "easing/elastic.glsl" 10 | #include "easing/exponential.glsl" 11 | #include "easing/linear.glsl" 12 | #include "easing/quadratic.glsl" 13 | #include "easing/quartic.glsl" 14 | #include "easing/quintic.glsl" 15 | #include "easing/sine.glsl" 16 | -------------------------------------------------------------------------------- /animation/easing.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | description: Include all available easing animations 3 | */ 4 | 5 | #include "easing/back.hlsl" 6 | #include "easing/bounce.hlsl" 7 | #include "easing/circular.hlsl" 8 | #include "easing/cubic.hlsl" 9 | #include "easing/elastic.hlsl" 10 | #include "easing/exponential.hlsl" 11 | #include "easing/linear.hlsl" 12 | #include "easing/quadratic.hlsl" 13 | #include "easing/quartic.hlsl" 14 | #include "easing/quintic.hlsl" 15 | #include "easing/sine.hlsl" 16 | -------------------------------------------------------------------------------- /animation/easing.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | description: Include all available easing animations 3 | */ 4 | 5 | #include "easing/back.wgsl" 6 | #include "easing/bounce.wgsl" 7 | #include "easing/circular.wgsl" 8 | #include "easing/cubic.wgsl" 9 | #include "easing/elastic.wgsl" 10 | #include "easing/exponential.wgsl" 11 | #include "easing/linear.wgsl" 12 | #include "easing/quadratic.wgsl" 13 | #include "easing/quartic.wgsl" 14 | #include "easing/quintic.wgsl" 15 | #include "easing/sine.wgsl" 16 | -------------------------------------------------------------------------------- /animation/easing/back.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Back easing. From https://github.com/stackgl/glsl-easings 4 | use: back( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "backIn.glsl" 10 | #include "backOut.glsl" 11 | #include "backInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/back.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Back easing. From https://github.com/stackgl/glsl-easings 4 | use: back( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "backIn.wgsl" 10 | #include "backOut.wgsl" 11 | #include "backInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/backIn.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Back in easing. From https://github.com/stackgl/glsl-easings 6 | use: backIn( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | #ifndef FNC_BACKIN 12 | #define FNC_BACKIN 13 | float backIn(in float t) { return pow(t, 3.) - t * sin(t * PI); } 14 | #endif -------------------------------------------------------------------------------- /animation/easing/backIn.wgsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Back in easing. From https://github.com/stackgl/glsl-easings 6 | use: backIn( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | fn backIn(t: f32) -> f32 { return pow(t, 3.0) - t * sin(t * PI); } 12 | -------------------------------------------------------------------------------- /animation/easing/backInOut.wgsl: -------------------------------------------------------------------------------- 1 | #include "backIn.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Back in/out easing. From https://github.com/stackgl/glsl-easings 6 | use: backInOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | fn backInOut(t: f32) -> f32 { 12 | let g = backIn(select(1.0 - (2.0 * t - 1.0), 2.0 * t, t < 0.5)); 13 | return select(0.5 * (1.0 - g) + 0.5, 0.5 * g, t < 0.5); 14 | } 15 | -------------------------------------------------------------------------------- /animation/easing/backOut.glsl: -------------------------------------------------------------------------------- 1 | #include "backIn.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Back out easing. From https://github.com/stackgl/glsl-easings 6 | use: backOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | #ifndef FNC_BACKOUT 12 | #define FNC_BACKOUT 13 | float backOut(in float t) { return 1. - backIn(1. - t); } 14 | #endif -------------------------------------------------------------------------------- /animation/easing/backOut.wgsl: -------------------------------------------------------------------------------- 1 | #include "backIn.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Back out easing. From https://github.com/stackgl/glsl-easings 6 | use: backOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | fn backOut(t: f32) -> f32 { return 1.0 - backIn(1.0 - t); } 12 | -------------------------------------------------------------------------------- /animation/easing/bounce.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Bounce easing. From https://github.com/stackgl/glsl-easings 6 | use: 7 | - bounceIn( x) 8 | - bounceOut( x) 9 | - bounceInOut( x) 10 | examples: 11 | - https://raw.githubusercontent.com/eduardfossas/lygia-study-examples/main/animation/e_EasingBounce.frag 12 | */ 13 | 14 | #include "bounceOut.glsl" 15 | #include "bounceIn.glsl" 16 | #include "bounceInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/bounce.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Bounce easing. From https://github.com/stackgl/glsl-easings 4 | use: 5 | - bounceIn( x) 6 | - bounceOut( x) 7 | - bounceInOut( x) 8 | examples: 9 | - https://raw.githubusercontent.com/eduardfossas/lygia-study-examples/main/animation/e_EasingBounce.frag 10 | */ 11 | 12 | #include "bounceIn.wgsl" 13 | #include "bounceOut.wgsl" 14 | #include "bounceInOut.wgsl" 15 | -------------------------------------------------------------------------------- /animation/easing/bounceIn.glsl: -------------------------------------------------------------------------------- 1 | #include "bounceOut.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Bounce in easing. From https://github.com/stackgl/glsl-easings 6 | use: bounceIn( x) 7 | examples: 8 | - https://raw.githubusercontent.com/eduardfossas/lygia-study-examples/main/animation/e_EasingBounce.frag 9 | */ 10 | 11 | #ifndef FNC_BOUNCEIN 12 | #define FNC_BOUNCEIN 13 | float bounceIn(in float t) { return 1.0 - bounceOut(1.0 - t); } 14 | #endif 15 | -------------------------------------------------------------------------------- /animation/easing/bounceIn.wgsl: -------------------------------------------------------------------------------- 1 | #include "bounceOut.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Bounce in easing. From https://github.com/stackgl/glsl-easings 6 | use: bounceIn( x) 7 | examples: 8 | - https://raw.githubusercontent.com/eduardfossas/lygia-study-examples/main/animation/e_EasingBounce.frag 9 | */ 10 | 11 | fn bounceIn(t: f32) -> f32 { return 1.0 - bounceOut(1.0 - t); } 12 | -------------------------------------------------------------------------------- /animation/easing/bounceInOut.wgsl: -------------------------------------------------------------------------------- 1 | #include "bounceOut.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Bounce in/out easing. From https://github.com/stackgl/glsl-easings 6 | use: bounceInOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/eduardfossas/lygia-study-examples/main/animation/e_EasingBounce.frag 9 | */ 10 | 11 | fn bounceInOut(t: f32) -> f32 { 12 | return select( 13 | 0.5 * bounceOut(t * 2.0 - 1.0) + 0.5, 14 | 0.5 * (1.0 - bounceOut(1.0 - t * 2.0)), 15 | t < 0.5 16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /animation/easing/circular.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Circular easing. From https://github.com/stackgl/glsl-easings 4 | use: circular( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "circularIn.glsl" 10 | #include "circularOut.glsl" 11 | #include "circularInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/circular.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Circular easing. From https://github.com/stackgl/glsl-easings 4 | use: circular( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "circularIn.wgsl" 10 | #include "circularOut.wgsl" 11 | #include "circularInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/circularIn.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Circular in easing. From https://github.com/stackgl/glsl-easings 4 | use: circularIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_CIRCULARIN 10 | #define FNC_CIRCULARIN 11 | float circularIn(in float t) { return 1.0 - sqrt(1.0 - t * t); } 12 | #endif -------------------------------------------------------------------------------- /animation/easing/circularIn.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Circular in easing. From https://github.com/stackgl/glsl-easings 4 | use: circularIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn circularIn(t: f32) -> f32 { return 1.0 - sqrt(1.0 - t * t); } 10 | -------------------------------------------------------------------------------- /animation/easing/circularInOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Circular in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: circularInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn circularInOut(t: f32) -> f32 { 10 | return select( 11 | 0.5 * (sqrt((3.0 - 2.0 * t) * (2.0 * t - 1.0)) + 1.0), 12 | 0.5 * (1.0 - sqrt(1.0 - 4.0 * t * t)), 13 | t < 0.5 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /animation/easing/circularOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Circular out easing. From https://github.com/stackgl/glsl-easings 4 | use: circularOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_CIRCULAROUT 10 | #define FNC_CIRCULAROUT 11 | float circularOut(in float t) { return sqrt((2.0 - t) * t); } 12 | #endif -------------------------------------------------------------------------------- /animation/easing/circularOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Circular out easing. From https://github.com/stackgl/glsl-easings 4 | use: circularOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn circularOut(t: f32) -> f32 { return sqrt((2.0 - t) * t); } 10 | -------------------------------------------------------------------------------- /animation/easing/cubic.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Cubic easing. From https://github.com/stackgl/glsl-easings 4 | use: cubic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "cubicIn.glsl" 10 | #include "cubicOut.glsl" 11 | #include "cubicInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/cubic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Cubic easing. From https://github.com/stackgl/glsl-easings 4 | use: cubic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "cubicIn.wgsl" 10 | #include "cubicOut.wgsl" 11 | #include "cubicInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/cubicIn.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Cubic in easing. From https://github.com/stackgl/glsl-easings 4 | use: cubicIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_CUBICIN 10 | #define FNC_CUBICIN 11 | float cubicIn(in float t) { return t * t * t; } 12 | #endif -------------------------------------------------------------------------------- /animation/easing/cubicIn.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Cubic in easing. From https://github.com/stackgl/glsl-easings 4 | use: cubicIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn cubicIn(t: f32) -> f32 { return t * t * t; } 10 | -------------------------------------------------------------------------------- /animation/easing/cubicInOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Cubic in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: cubicInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_CUBICINOUT 10 | #define FNC_CUBICINOUT 11 | float cubicInOut(in float t) { 12 | return t < 0.5 13 | ? 4.0 * t * t * t 14 | : 0.5 * pow(2.0 * t - 2.0, 3.0) + 1.0; 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /animation/easing/cubicInOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Cubic in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: cubicInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn cubicInOut(t: f32) -> f32 { 10 | return select( 11 | 0.5 * pow(2.0 * t - 2.0, 3.0) + 1.0, 12 | 4.0 * t * t * t, 13 | t < 0.5 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /animation/easing/cubicOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Cubic out easing. From https://github.com/stackgl/glsl-easings 4 | use: cubicOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_CUBICOUT 10 | #define FNC_CUBICOUT 11 | float cubicOut(in float t) { 12 | float f = t - 1.0; 13 | return f * f * f + 1.0; 14 | } 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /animation/easing/cubicOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Cubic out easing. From https://github.com/stackgl/glsl-easings 4 | use: cubicOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn cubicOut(t: f32) -> f32 { 10 | let f = t - 1.0; 11 | return f * f * f + 1.0; 12 | } 13 | -------------------------------------------------------------------------------- /animation/easing/elastic.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Elastic easing. From https://github.com/stackgl/glsl-easings 4 | use: elastic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "elasticIn.glsl" 10 | #include "elasticOut.glsl" 11 | #include "elasticInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/elastic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Elastic easing. From https://github.com/stackgl/glsl-easings 4 | use: elastic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "elasticIn.wgsl" 10 | #include "elasticOut.wgsl" 11 | #include "elasticInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/elasticIn.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Elastic in easing. From https://github.com/stackgl/glsl-easings 6 | use: elasticIn( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | #ifndef FNC_ELASTICIN 12 | #define FNC_ELASTICIN 13 | float elasticIn(in float t) { return sin(13.0 * t * HALF_PI) * pow(2.0, 10.0 * (t - 1.0)); } 14 | #endif -------------------------------------------------------------------------------- /animation/easing/elasticIn.wgsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Elastic in easing. From https://github.com/stackgl/glsl-easings 6 | use: elasticIn( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | fn elasticIn(t: f32) -> f32 { return sin(13.0 * t * HALF_PI) * pow(2.0, 10.0 * (t - 1.0)); } 12 | -------------------------------------------------------------------------------- /animation/easing/elasticOut.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Elastic out easing. From https://github.com/stackgl/glsl-easings 6 | use: elasticOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | #ifndef FNC_ELASTICOUT 12 | #define FNC_ELASTICOUT 13 | float elasticOut(in float t) { return sin(-13.0 * (t + 1.0) * HALF_PI) * pow(2.0, -10.0 * t) + 1.0; } 14 | #endif 15 | -------------------------------------------------------------------------------- /animation/easing/elasticOut.wgsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Elastic out easing. From https://github.com/stackgl/glsl-easings 6 | use: elasticOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | fn elasticOut(t: f32) -> f32 { return sin(-13.0 * (t + 1.0) * HALF_PI) * pow(2.0, -10.0 * t) + 1.0; } 12 | -------------------------------------------------------------------------------- /animation/easing/exponential.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Exponential easing. From https://github.com/stackgl/glsl-easings 4 | use: exponential( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "exponentialIn.glsl" 10 | #include "exponentialOut.glsl" 11 | #include "exponentialInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/exponential.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Exponential easing. From https://github.com/stackgl/glsl-easings 4 | use: exponential( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "exponentialIn.wgsl" 10 | #include "exponentialOut.wgsl" 11 | #include "exponentialInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/exponentialIn.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Exponential in easing. From https://github.com/stackgl/glsl-easings 4 | use: exponentialIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_EXPONENTIALIN 10 | #define FNC_EXPONENTIALIN 11 | float exponentialIn(in float t) { return t == 0.0 ? t : pow(2.0, 10.0 * (t - 1.0)); } 12 | #endif -------------------------------------------------------------------------------- /animation/easing/exponentialIn.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Exponential in easing. From https://github.com/stackgl/glsl-easings 4 | use: exponentialIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn exponentialIn(t: f32) -> f32 { 10 | return select( 11 | pow(2.0, 10.0 * (t - 1.0)), 12 | t, 13 | t == 0.0 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /animation/easing/exponentialOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Exponential out easing. From https://github.com/stackgl/glsl-easings 4 | use: exponentialOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_EXPONENTIALOUT 10 | #define FNC_EXPONENTIALOUT 11 | float exponentialOut(in float t) { return t == 1.0 ? t : 1.0 - pow(2.0, -10.0 * t); } 12 | #endif -------------------------------------------------------------------------------- /animation/easing/exponentialOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Exponential out easing. From https://github.com/stackgl/glsl-easings 4 | use: exponentialOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn exponentialOut(t: f32) -> f32 { 10 | return select( 11 | 1.0 - pow(2.0, -10.0 * t), 12 | t, 13 | t == 1.0 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /animation/easing/linear.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linear( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "linearIn.glsl" 10 | #include "linearOut.glsl" 11 | #include "linearInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/linear.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linear( x) 5 | */ 6 | 7 | #ifndef FNC_LINEAR 8 | #define FNC_LINEAR 9 | float linearIn(in float t) { 10 | return t; 11 | } 12 | 13 | float linearOut(in float t) { 14 | return t; 15 | } 16 | 17 | float linearInOut(in float t) { 18 | return t; 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /animation/easing/linear.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linear( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "linearIn.wgsl" 10 | #include "linearOut.wgsl" 11 | #include "linearInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/linearIn.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linearIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_LINEARIN 10 | #define FNC_LINEARIN 11 | float linearIn(in float t) { return t; } 12 | #endif 13 | -------------------------------------------------------------------------------- /animation/easing/linearIn.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linearIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn linearIn(t: f32) -> f32 { return t; } 10 | -------------------------------------------------------------------------------- /animation/easing/linearInOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linearInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_LINEARINOUT 10 | #define FNC_LINEARINOUT 11 | float linearInOut(in float t) { return t; } 12 | #endif 13 | -------------------------------------------------------------------------------- /animation/easing/linearInOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linearInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn linearInOut(t: f32) -> f32 { return t; } 10 | -------------------------------------------------------------------------------- /animation/easing/linearOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linearOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_LINEAROUT 10 | #define FNC_LINEAROUT 11 | float linearOut(in float t) { return t; } 12 | #endif 13 | -------------------------------------------------------------------------------- /animation/easing/linearOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Linear easing. From https://github.com/stackgl/glsl-easings 4 | use: linearOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn linearOut(t: f32) -> f32 { return t; } 10 | -------------------------------------------------------------------------------- /animation/easing/quadratic.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quadrtic easing. From https://github.com/stackgl/glsl-easings 4 | use: quadratic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "quadraticIn.glsl" 10 | #include "quadraticOut.glsl" 11 | #include "quadraticInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/quadratic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quadrtic easing. From https://github.com/stackgl/glsl-easings 4 | use: quadratic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "quadraticIn.wgsl" 10 | #include "quadraticOut.wgsl" 11 | #include "quadraticInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/quadraticIn.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quadrtic in easing. From https://github.com/stackgl/glsl-easings 4 | use: quadraticIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUADRATICIN 10 | #define FNC_QUADRATICIN 11 | float quadraticIn(in float t) { return t * t; } 12 | #endif 13 | -------------------------------------------------------------------------------- /animation/easing/quadraticIn.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quadrtic in easing. From https://github.com/stackgl/glsl-easings 4 | use: quadraticIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quadraticIn(t: f32) -> f32 { return t * t; } 10 | -------------------------------------------------------------------------------- /animation/easing/quadraticInOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quadrtic in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: quadraticInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUADRATICINOUT 10 | #define FNC_QUADRATICINOUT 11 | float quadraticInOut(in float t) { 12 | float p = 2.0 * t * t; 13 | return t < 0.5 ? p : -p + (4.0 * t) - 1.0; 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /animation/easing/quadraticInOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quadrtic in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: quadraticInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quadraticInOut(t: f32) -> f32 { 10 | let p = 2.0 * t * t; 11 | return select(-p + (4.0 * t) - 1.0, p, t < 0.5); 12 | } 13 | -------------------------------------------------------------------------------- /animation/easing/quadraticOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quadrtic out easing. From https://github.com/stackgl/glsl-easings 4 | use: quadraticOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUADRATICOUT 10 | #define FNC_QUADRATICOUT 11 | float quadraticOut(in float t) { return -t * (t - 2.0); } 12 | #endif -------------------------------------------------------------------------------- /animation/easing/quadraticOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quadrtic out easing. From https://github.com/stackgl/glsl-easings 4 | use: quadraticOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quadraticOut(t: f32) -> f32 { return -t * (t - 2.0); } 10 | -------------------------------------------------------------------------------- /animation/easing/quartic.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quartic easing. From https://github.com/stackgl/glsl-easings 4 | use: quartic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "quarticIn.glsl" 10 | #include "quarticOut.glsl" 11 | #include "quarticInOut.glsl" -------------------------------------------------------------------------------- /animation/easing/quartic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quartic easing. From https://github.com/stackgl/glsl-easings 4 | use: quartic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "quarticIn.wgsl" 10 | #include "quarticOut.wgsl" 11 | #include "quarticInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/quarticIn.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quartic in easing. From https://github.com/stackgl/glsl-easings 4 | use: quarticIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUARTICIN 10 | #define FNC_QUARTICIN 11 | float quarticIn(in float t) { return pow(t, 4.0); } 12 | #endif -------------------------------------------------------------------------------- /animation/easing/quarticIn.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quartic in easing. From https://github.com/stackgl/glsl-easings 4 | use: quarticIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quarticIn(t: f32) -> f32 { return pow(t, 4.0); } 10 | -------------------------------------------------------------------------------- /animation/easing/quarticInOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quartic in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: quarticInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUARTICINOUT 10 | #define FNC_QUARTICINOUT 11 | float quarticInOut(in float t) { 12 | return t < 0.5 13 | ? +8.0 * pow(t, 4.0) 14 | : -8.0 * pow(t - 1.0, 4.0) + 1.0; 15 | } 16 | #endif -------------------------------------------------------------------------------- /animation/easing/quarticInOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quartic in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: quarticInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quarticInOut(t: f32) -> f32 { 10 | return select( 11 | -8.0 * pow(t - 1.0, 4.0) + 1.0, 12 | 8.0 * pow(t, 4.0), 13 | t < 0.5 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /animation/easing/quarticOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quartic out easing. From https://github.com/stackgl/glsl-easings 4 | use: quarticOut x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUARTICOUT 10 | #define FNC_QUARTICOUT 11 | float quarticOut(in float t) { 12 | float it = t - 1.0; 13 | return it * it * it * (1.0 - t) + 1.0; 14 | } 15 | #endif -------------------------------------------------------------------------------- /animation/easing/quarticOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quartic out easing. From https://github.com/stackgl/glsl-easings 4 | use: quarticOut x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quarticOut(t: f32) -> f32 { 10 | let it = t - 1.0; 11 | return it * it * it * (1.0 - t) + 1.0; 12 | } 13 | -------------------------------------------------------------------------------- /animation/easing/quintic.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quintic easing. From https://github.com/stackgl/glsl-easings 4 | use: quintic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "quinticIn.glsl" 10 | #include "quinticOut.glsl" 11 | #include "quinticInOut.glsl" 12 | -------------------------------------------------------------------------------- /animation/easing/quintic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quintic easing. From https://github.com/stackgl/glsl-easings 4 | use: quintic( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "quinticIn.wgsl" 10 | #include "quinticOut.wgsl" 11 | #include "quinticInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/quinticIn.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: quintic in easing. From https://github.com/stackgl/glsl-easings 4 | use: quinticIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUINTICIN 10 | #define FNC_QUINTICIN 11 | float quinticIn(in float t) { return pow(t, 5.0); } 12 | #endif 13 | -------------------------------------------------------------------------------- /animation/easing/quinticIn.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: quintic in easing. From https://github.com/stackgl/glsl-easings 4 | use: quinticIn( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quinticIn(t: f32) -> f32 { return pow(t, 5.0); } 10 | -------------------------------------------------------------------------------- /animation/easing/quinticInOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quintic in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: quinticInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUINTICINOUT 10 | #define FNC_QUINTICINOUT 11 | float quinticInOut(in float t) { 12 | return t < 0.5 13 | ? +16.0 * pow(t, 5.0) 14 | : -0.5 * pow(2.0 * t - 2.0, 5.0) + 1.0; 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /animation/easing/quinticInOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quintic in/out easing. From https://github.com/stackgl/glsl-easings 4 | use: quinticInOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quinticInOut(t: f32) -> f32 { 10 | return select( 11 | -0.5 * pow(2.0 * t - 2.0, 5.0) + 1.0, 12 | 16.0 * pow(t, 5.0), 13 | t < 0.5 14 | ); 15 | } 16 | -------------------------------------------------------------------------------- /animation/easing/quinticOut.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quintic out easing. From https://github.com/stackgl/glsl-easings 4 | use: quinticOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #ifndef FNC_QUINTICOUT 10 | #define FNC_QUINTICOUT 11 | float quinticOut(in float t) { return 1.0 - (pow(t - 1.0, 5.0)); } 12 | #endif -------------------------------------------------------------------------------- /animation/easing/quinticOut.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Quintic out easing. From https://github.com/stackgl/glsl-easings 4 | use: quinticOut( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | fn quinticOut(t: f32) -> f32 { return 1.0 - (pow(t - 1.0, 5.0)); } 10 | -------------------------------------------------------------------------------- /animation/easing/sine.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Sine easing. From https://github.com/stackgl/glsl-easings 6 | use: sine( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | #include "sineIn.glsl" 12 | #include "sineOut.glsl" 13 | #include "sineInOut.glsl" 14 | -------------------------------------------------------------------------------- /animation/easing/sine.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Hugh Kennedy (https://github.com/hughsk) 3 | description: Sine easing. From https://github.com/stackgl/glsl-easings 4 | use: sine( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 7 | */ 8 | 9 | #include "sineIn.wgsl" 10 | #include "sineOut.wgsl" 11 | #include "sineInOut.wgsl" 12 | -------------------------------------------------------------------------------- /animation/easing/sineIn.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Sine in easing. From https://github.com/stackgl/glsl-easings 6 | use: sineIn( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | #ifndef FNC_SINEIN 12 | #define FNC_SINEIN 13 | float sineIn(in float t) { return sin((t - 1.0) * HALF_PI) + 1.0; } 14 | #endif -------------------------------------------------------------------------------- /animation/easing/sineIn.wgsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Sine in easing. From https://github.com/stackgl/glsl-easings 6 | use: sineIn( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | fn sineIn(t: f32) -> f32 { return sin((t - 1.0) * HALF_PI) + 1.0; } 12 | -------------------------------------------------------------------------------- /animation/easing/sineInOut.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Sine in/out easing. From https://github.com/stackgl/glsl-easings 6 | use: sineInOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | #ifndef FNC_SINEINOUT 12 | #define FNC_SINEINOUT 13 | float sineInOut(in float t) { return -0.5 * (cos(PI * t) - 1.0); } 14 | #endif 15 | -------------------------------------------------------------------------------- /animation/easing/sineInOut.wgsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Sine in/out easing. From https://github.com/stackgl/glsl-easings 6 | use: sineInOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | fn sineInOut(t: f32) -> f32 { return -0.5 * (cos(PI * t) - 1.0); } 12 | -------------------------------------------------------------------------------- /animation/easing/sineOut.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Sine out easing. From https://github.com/stackgl/glsl-easings 6 | use: sineOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | #ifndef FNC_SINEOUT 12 | #define FNC_SINEOUT 13 | float sineOut(in float t) { return sin(t * HALF_PI); } 14 | #endif -------------------------------------------------------------------------------- /animation/easing/sineOut.wgsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Sine out easing. From https://github.com/stackgl/glsl-easings 6 | use: sineOut( x) 7 | examples: 8 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/animation_easing.frag 9 | */ 10 | 11 | fn sineOut(t: f32) -> f32 { return sin(t * HALF_PI); } 12 | -------------------------------------------------------------------------------- /color/composite.glsl: -------------------------------------------------------------------------------- 1 | #include "composite/compositeXor.glsl" 2 | #include "composite/destinationAtop.glsl" 3 | #include "composite/destinationIn.glsl" 4 | #include "composite/destinationOut.glsl" 5 | #include "composite/destinationOver.glsl" 6 | #include "composite/sourceAtop.glsl" 7 | #include "composite/sourceIn.glsl" 8 | #include "composite/sourceOut.glsl" 9 | #include "composite/sourceOver.glsl" -------------------------------------------------------------------------------- /color/composite.hlsl: -------------------------------------------------------------------------------- 1 | #include "composite/compositeXor.hlsl" 2 | #include "composite/destinationAtop.hlsl" 3 | #include "composite/destinationIn.hlsl" 4 | #include "composite/destinationOut.hlsl" 5 | #include "composite/destinationOver.hlsl" 6 | #include "composite/sourceAtop.hlsl" 7 | #include "composite/sourceIn.hlsl" 8 | #include "composite/sourceOut.hlsl" 9 | #include "composite/sourceOver.hlsl" -------------------------------------------------------------------------------- /color/composite.msl: -------------------------------------------------------------------------------- 1 | #include "composite/compositeXor.msl" 2 | #include "composite/destinationAtop.msl" 3 | #include "composite/destinationIn.msl" 4 | #include "composite/destinationOut.msl" 5 | #include "composite/destinationOver.msl" 6 | #include "composite/sourceAtop.msl" 7 | #include "composite/sourceIn.msl" 8 | #include "composite/sourceOut.msl" 9 | #include "composite/sourceOver.msl" -------------------------------------------------------------------------------- /color/exposure.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Change the exposure of a color 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn exposure3(color : vec3f, amount : f32) -> vec3f { return color * pow(2., amount); } 10 | 11 | fn exposure4(color : vec4f, amount : f32) -> vec4f { return vec4(exposure3(color.rgb, amount), color.a); } -------------------------------------------------------------------------------- /color/exposure.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Change the exposure of a color 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn exposure3(color : vec3f, amount : f32) -> vec3f { return color * pow(2., amount); } 10 | 11 | fn exposure4(color : vec4f, amount : f32) -> vec4f { return vec4(exposure3(color.rgb, amount), color.a); } -------------------------------------------------------------------------------- /color/luma.glsl: -------------------------------------------------------------------------------- 1 | #include "space/rgb2luma.glsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Get the luminosity of a color. From https://github.com/hughsk/glsl-luma/blob/master/index.glsl 6 | use: luma( color) 7 | */ 8 | 9 | #ifndef FNC_LUMA 10 | #define FNC_LUMA 11 | float luma(float v) { return v; } 12 | float luma(in vec3 v) { return rgb2luma(v); } 13 | float luma(in vec4 v) { return rgb2luma(v.rgb); } 14 | #endif 15 | -------------------------------------------------------------------------------- /color/luma.hlsl: -------------------------------------------------------------------------------- 1 | #include "space/rgb2luma.hlsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Get the luminosity of a color. From https://github.com/hughsk/glsl-luma/blob/master/index.hlsl 6 | use: luma( color) 7 | */ 8 | 9 | #ifndef FNC_LUMA 10 | #define FNC_LUMA 11 | float luma(in float color) { 12 | return float(color); 13 | } 14 | 15 | float luma(in float3 color) { 16 | return rgb2luma(color); 17 | } 18 | 19 | float luma(in float4 color) { 20 | return rgb2luma(color.rgb); 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /color/luma.msl: -------------------------------------------------------------------------------- 1 | #include "space/rgb2luma.msl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Get the luminosity of a color. From https://github.com/hughsk/glsl-luma/blob/master/index.msl 6 | use: luma( color) 7 | */ 8 | 9 | #ifndef FNC_LUMA 10 | #define FNC_LUMA 11 | float luma(float v) { return v; } 12 | float luma(float3 v) { return rgb2luma(v); } 13 | float luma(float4 v) { return rgb2luma(v.rgb); } 14 | #endif 15 | -------------------------------------------------------------------------------- /color/luma.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::rgb2luma; 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Get the luminosity of a color. From https://github.com/hughsk/glsl-luma/blob/master/index.glsl 6 | */ 7 | 8 | 9 | fn luma(color: vec3f) -> f32 { 10 | return rgb2luma(color); 11 | } -------------------------------------------------------------------------------- /color/luma.wgsl: -------------------------------------------------------------------------------- 1 | #include "space/rgb2luma.wgsl" 2 | 3 | /* 4 | contributors: Hugh Kennedy (https://github.com/hughsk) 5 | description: Get the luminosity of a color. From https://github.com/hughsk/glsl-luma/blob/master/index.glsl 6 | */ 7 | 8 | 9 | fn luma(color: vec3f) -> f32 { 10 | return rgb2luma(color); 11 | } -------------------------------------------------------------------------------- /color/palette/fire.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Simpler fire color ramp 4 | use: fire( value) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_FIRE 11 | #define FNC_FIRE 12 | float3 fire(float x) { return float3(1.0, 0.25, 0.0625) * exp(4.0 * x - 1.0); } 13 | #endif -------------------------------------------------------------------------------- /color/palette/heatmap.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Heatmap palette 4 | use: heatmap( value) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_HEATMAP 11 | #define FNC_HEATMAP 12 | float3 heatmap(float v) { 13 | float3 r = v * 2.1 - float3(1.8, 1.14, 0.3); 14 | return 1.0 - r * r; 15 | } 16 | #endif -------------------------------------------------------------------------------- /color/palette/spectral/geoffrey.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: none 3 | description: none 4 | use: spectral_geoffrey( x) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/color_wavelength.frag 7 | */ 8 | 9 | #ifndef FNC_SPECTRAL_GEOFFREY 10 | #define FNC_SPECTRAL_GEOFFREY 11 | vec3 spectral_geoffrey(float t) { 12 | vec3 r = (t * 2.0 - 0.5) * 2.1 - vec3(1.8, 1.14, 0.3); 13 | return 0.99 - r * r; 14 | } 15 | #endif -------------------------------------------------------------------------------- /color/palette/spectral/geoffrey.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: none 3 | description: none 4 | use: spectral_geoffrey( x) 5 | */ 6 | 7 | #ifndef FNC_SPECTRAL_GEOFFREY 8 | #define FNC_SPECTRAL_GEOFFREY 9 | float3 spectral_geoffrey(float t) { 10 | float3 r = (t * 2.0 - 0.5) * 2.1 - float3(1.8, 1.14, 0.3); 11 | return 0.99 - r * r; 12 | } 13 | #endif -------------------------------------------------------------------------------- /color/palette/wada.glsl: -------------------------------------------------------------------------------- 1 | #include "wada/value.glsl" 2 | #include "wada/dyad.glsl" 3 | #include "wada/triad.glsl" 4 | #include "wada/tetrad.glsl" -------------------------------------------------------------------------------- /color/palette/wada.hlsl: -------------------------------------------------------------------------------- 1 | #include "wada/value.hlsl" 2 | #include "wada/dyad.hlsl" 3 | #include "wada/triad.hlsl" 4 | #include "wada/tetrad.hlsl" -------------------------------------------------------------------------------- /color/space/cmyk2rgb.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Convert CMYK to RGB 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn cmyk2rgb(cmyk: vec4f) -> vec3f { 10 | let invK: f32 = 1.0 - cmyk.w; 11 | return saturate(1.0 - min(vec3f(1.0), cmyk.xyz * invK + cmyk.w)); 12 | } 13 | -------------------------------------------------------------------------------- /color/space/cmyk2rgb.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Convert CMYK to RGB 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn cmyk2rgb(cmyk: vec4f) -> vec3f { 10 | let invK: f32 = 1.0 - cmyk.w; 11 | return saturate(1.0 - min(vec3f(1.0), cmyk.xyz * invK + cmyk.w)); 12 | } 13 | -------------------------------------------------------------------------------- /color/space/gamma2linear.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Convert from gamma to linear color space. 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn gamma2linear(gamma: vec3f) -> vec3f { 10 | return pow(gamma, vec3(2.2)); 11 | } 12 | -------------------------------------------------------------------------------- /color/space/gamma2linear.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Convert from gamma to linear color space. 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn gamma2linear(gamma: vec3f) -> vec3f { 10 | return pow(gamma, vec3(2.2)); 11 | } 12 | -------------------------------------------------------------------------------- /color/space/hsl2rgb.wgsl: -------------------------------------------------------------------------------- 1 | #include "hue2rgb.wgsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts a HSL color to linear RGB 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | 12 | fn hsl2rgb(hsl: vec3f) -> vec3f { 13 | let rgb = hue2rgb(hsl.x); 14 | let C = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y; 15 | return (rgb - 0.5) * C + hsl.z; 16 | } -------------------------------------------------------------------------------- /color/space/hsv2rgb.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/saturate.glsl" 2 | #include "hue2rgb.glsl" 3 | /* 4 | contributors: Inigo Quiles 5 | description: | 6 | Convert from HSV to linear RGB 7 | use: hsv2rgb( hsv) 8 | */ 9 | 10 | #ifndef FNC_HSV2RGB 11 | #define FNC_HSV2RGB 12 | vec3 hsv2rgb(const in vec3 hsv) { return ((hue2rgb(hsv.x) - 1.0) * hsv.y + 1.0) * hsv.z; } 13 | vec4 hsv2rgb(const in vec4 hsv) { return vec4(hsv2rgb(hsv.rgb), hsv.a); } 14 | #endif -------------------------------------------------------------------------------- /color/space/hsv2rgb.hlsl: -------------------------------------------------------------------------------- 1 | #include "hue2rgb.hlsl" 2 | /* 3 | contributors: Inigo Quiles 4 | description: | 5 | Convert from HSV to linear RGB 6 | use: hsv2rgb( hsv) 7 | */ 8 | 9 | #ifndef FNC_HSV2RGB 10 | #define FNC_HSV2RGB 11 | float3 hsv2rgb(in float3 hsv) { return ((hue2rgb(hsv.x) - 1.0) * hsv.y + 1.0) * hsv.z; } 12 | float4 hsv2rgb(in float4 hsv) { return float4(hsv2rgb(hsv.rgb), hsv.a); } 13 | #endif 14 | -------------------------------------------------------------------------------- /color/space/hsv2rgb.msl: -------------------------------------------------------------------------------- 1 | #include "../../math/saturate.msl" 2 | #include "hue2rgb.msl" 3 | /* 4 | contributors: Inigo Quiles 5 | description: | 6 | Convert from HSV to linear RGB 7 | use: hsv2rgb( hsv) 8 | */ 9 | 10 | #ifndef FNC_HSV2RGB 11 | #define FNC_HSV2RGB 12 | float3 hsv2rgb( float3 hsv) { return ((hue2rgb(hsv.x) - 1.0) * hsv.y + 1.0) * hsv.z; } 13 | float4 hsv2rgb( float4 hsv) { return float4(hsv2rgb(hsv.rgb), hsv.a); } 14 | #endif -------------------------------------------------------------------------------- /color/space/hsv2rgb.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::hue2rgb::hue2rgb; 2 | 3 | /* 4 | contributors: Inigo Quiles 5 | description: 'Convert from HSV to linear RGB' 6 | 7 | */ 8 | 9 | 10 | fn hsv2rgb(hsv : vec3f) -> vec3f { 11 | return ((hue2rgb(hsv.x) - 1.0) * hsv.y + 1.0) * hsv.z; 12 | } 13 | -------------------------------------------------------------------------------- /color/space/hsv2rgb.wgsl: -------------------------------------------------------------------------------- 1 | #include "hue2rgb.wgsl" 2 | 3 | /* 4 | contributors: Inigo Quiles 5 | description: 'Convert from HSV to linear RGB' 6 | 7 | */ 8 | 9 | 10 | fn hsv2rgb(hsv : vec3f) -> vec3f { 11 | return ((hue2rgb(hsv.x) - 1.0) * hsv.y + 1.0) * hsv.z; 12 | } 13 | -------------------------------------------------------------------------------- /color/space/lab2rgb.wgsl: -------------------------------------------------------------------------------- 1 | #include "lab2xyz.wgsl" 2 | #include "xyz2rgb.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: | 7 | Converts a Lab color to RGB color space. https://en.wikipedia.org/wiki/CIELAB_color_space 8 | license: 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 10 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 11 | */ 12 | 13 | 14 | fn lab2rgb(lab : vec3f) -> vec3f { return xyz2rgb( lab2xyz( lab ) ); } 15 | -------------------------------------------------------------------------------- /color/space/lab2srgb.wgsl: -------------------------------------------------------------------------------- 1 | #include "lab2xyz.wgsl" 2 | #include "xyz2srgb.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: 'Converts a Lab color to RGB color space. https://en.wikipedia.org/wiki/CIELAB_color_space' 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn lab2srgb(lab: vec3f) -> vec3f { return xyz2srgb( lab2xyz( lab ) ); } 14 | -------------------------------------------------------------------------------- /color/space/linear2gamma.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Convert from linear to gamma color space. 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn linear2gamma(v : vec3f) -> vec3f { 10 | return pow(v, vec3f(1. / 2.2)); 11 | } 12 | -------------------------------------------------------------------------------- /color/space/linear2gamma.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Convert from linear to gamma color space. 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn linear2gamma(v : vec3f) -> vec3f { 10 | return pow(v, vec3f(1. / 2.2)); 11 | } 12 | -------------------------------------------------------------------------------- /color/space/oklab2srgb.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::{oklab2rgb::oklab2rgb, rgb2srgb::rgb2srgb}; 2 | 3 | /* 4 | contributors: Bjorn Ottosson (@bjornornorn) 5 | description: oklab to sRGB https://bottosson.github.io/posts/oklab/ 6 | use: oklab2rgb( oklab) 7 | license: 8 | - MIT License (MIT) Copyright (c) 2020 Björn Ottosson 9 | */ 10 | 11 | fn oklab2srgb(oklab: vec3f) -> vec3f { return rgb2srgb(oklab2rgb(oklab)); } 12 | -------------------------------------------------------------------------------- /color/space/oklab2srgb.wgsl: -------------------------------------------------------------------------------- 1 | #include "oklab2rgb.wgsl" 2 | #include "rgb2srgb.wgsl" 3 | 4 | /* 5 | contributors: Bjorn Ottosson (@bjornornorn) 6 | description: oklab to sRGB https://bottosson.github.io/posts/oklab/ 7 | use: oklab2rgb( oklab) 8 | license: 9 | - MIT License (MIT) Copyright (c) 2020 Björn Ottosson 10 | */ 11 | 12 | fn oklab2srgb(oklab: vec3f) -> vec3f { return rgb2srgb(oklab2rgb(oklab)); } 13 | -------------------------------------------------------------------------------- /color/space/rgb2heat.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::rgb2hue::rgb2hue; 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts a RGB rainbow pattern back to a single float value 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | 12 | fn rgb2heat(c: vec3f) -> f32 { return 1.025 - rgb2hue(c) * 1.538461538; } 13 | -------------------------------------------------------------------------------- /color/space/rgb2heat.wgsl: -------------------------------------------------------------------------------- 1 | #include "rgb2hue.wgsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts a RGB rainbow pattern back to a single float value 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | 12 | fn rgb2heat(c: vec3f) -> f32 { return 1.025 - rgb2hue(c) * 1.538461538; } 13 | -------------------------------------------------------------------------------- /color/space/rgb2lab.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::{rgb2xyz::rgb2xyz, xyz2lab::xyz2lab}; 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts a RGB color to Lab color space. 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | 12 | fn rgb2lab(rgb: vec3f ) -> vec3f { return xyz2lab(rgb2xyz(rgb)); } 13 | -------------------------------------------------------------------------------- /color/space/rgb2lab.wgsl: -------------------------------------------------------------------------------- 1 | #include "rgb2xyz.wgsl" 2 | #include "xyz2lab.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts a RGB color to Lab color space. 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn rgb2lab(rgb: vec3f ) -> vec3f { return xyz2lab(rgb2xyz(rgb)); } 14 | -------------------------------------------------------------------------------- /color/space/rgb2lch.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::rgb2lab::rgb2lab; 2 | import lygia::color::space::lab2lch::lab2lch; 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts a RGB color to LCh color space. 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | fn rgb2lch(rgb: vec3f) -> vec3f { return lab2lch(rgb2lab(rgb)); } -------------------------------------------------------------------------------- /color/space/rgb2lch.wgsl: -------------------------------------------------------------------------------- 1 | #include "rgb2lab.wgsl" 2 | #include "lab2lch.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts a RGB color to LCh color space. 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn rgb2lch(rgb: vec3f ) -> vec3f { return lab2lch(rgb2lab(rgb)); } -------------------------------------------------------------------------------- /color/space/rgb2luma.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Gets the luminosity from linear RGB, based on Rec709 luminance (see https://en.wikipedia.org/wiki/Grayscale) 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rgb2luma(rgb: vec3f) -> f32 { return dot(rgb, vec3(0.2126, 0.7152, 0.0722)); } -------------------------------------------------------------------------------- /color/space/rgb2luma.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Gets the luminosity from linear RGB, based on Rec709 luminance (see https://en.wikipedia.org/wiki/Grayscale) 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rgb2luma(rgb: vec3f) -> f32 { return dot(rgb, vec3(0.2126, 0.7152, 0.0722)); } -------------------------------------------------------------------------------- /color/space/rgb2xyY.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::rgb2xyz::rgb2xyz; 2 | import lygia::color::space::xyz2xyY::xyz2xyY; 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts a linear RGB color to xyY color space. 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | fn rgb2xyY(rgb: vec3f) -> vec3f { return xyz2xyY(rgb2xyz(rgb)); } -------------------------------------------------------------------------------- /color/space/rgb2xyY.wgsl: -------------------------------------------------------------------------------- 1 | #include "rgb2xyz.wgsl" 2 | #include "xyz2xyY.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts a linear RGB color to xyY color space. 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | fn rgb2xyY(rgb: vec3f) -> vec3f { return xyz2xyY(rgb2xyz(rgb)); } -------------------------------------------------------------------------------- /color/space/srgb2lab.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::{rgb2lab::rgb2lab, srgb2rgb::srgb2rgb}; 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts a sRGB color to Lab 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | 12 | fn srgb2lab(srgb: vec3f) -> vec3f { return rgb2lab(srgb2rgb(srgb));} 13 | 14 | -------------------------------------------------------------------------------- /color/space/srgb2lab.wgsl: -------------------------------------------------------------------------------- 1 | #include "rgb2lab.wgsl" 2 | #include "srgb2rgb.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts a sRGB color to Lab 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn srgb2lab(srgb: vec3f) -> vec3f { return rgb2lab(srgb2rgb(srgb));} 14 | 15 | -------------------------------------------------------------------------------- /color/space/srgb2lch.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::{rgb2lch::rgb2lch, srgb2rgb::srgb2rgb}; 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts a sRGB color to LCH 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | fn srgb2lch(srgb: vec3f) -> vec3f { return rgb2lch(srgb2rgb(srgb)); } 12 | -------------------------------------------------------------------------------- /color/space/srgb2lch.wgsl: -------------------------------------------------------------------------------- 1 | #include "rgb2lch.wgsl" 2 | #include "srgb2rgb.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts a sRGB color to Lab 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn srgb2lch(srgb: vec3f) -> vec3f { return rgb2lch(srgb2rgb(srgb)); } 14 | -------------------------------------------------------------------------------- /color/space/srgb2luma.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Gets the luminosity from sRGB. Based on from Rec601 luma (see https://en.wikipedia.org/wiki/Grayscale) 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn srgb2luma(srgb : vec3f) -> f32 { return dot(srgb, vec3f(0.299, 0.587, 0.114)); } -------------------------------------------------------------------------------- /color/space/srgb2luma.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Gets the luminosity from sRGB. Based on from Rec601 luma (see https://en.wikipedia.org/wiki/Grayscale) 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn srgb2luma(srgb : vec3f) -> f32 { return dot(srgb, vec3f(0.299, 0.587, 0.114)); } -------------------------------------------------------------------------------- /color/space/srgb2oklab.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::srgb2rgb::srgb2rgb; 2 | import lygia::color::space::rgb2oklab::rgb2oklab; 3 | 4 | /* 5 | contributors: Bjorn Ottosson (@bjornornorn) 6 | description: 'sRGB to OKLab https://bottosson.github.io/posts/oklab/' 7 | license: 8 | - MIT License (MIT) Copyright (c) 2020 Björn Ottosson 9 | */ 10 | 11 | 12 | fn srgb2oklab(srgb: vec3f) -> vec3f { return rgb2oklab( srgb2rgb(srgb) ); } 13 | -------------------------------------------------------------------------------- /color/space/srgb2oklab.wgsl: -------------------------------------------------------------------------------- 1 | #include "srgb2rgb.wgsl" 2 | #include "rgb2oklab.wgsl" 3 | 4 | /* 5 | contributors: Bjorn Ottosson (@bjornornorn) 6 | description: 'sRGB to OKLab https://bottosson.github.io/posts/oklab/' 7 | license: 8 | - MIT License (MIT) Copyright (c) 2020 Björn Ottosson 9 | */ 10 | 11 | 12 | fn srgb2oklab(srgb: vec3f) -> vec3f { return rgb2oklab( srgb2rgb(srgb) ); } 13 | -------------------------------------------------------------------------------- /color/space/srgb2xyz.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::{rgb2xyz::rgb2xyz, srgb2rgb::srgb2rgb}; 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts a sRGB color to XYZ 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | 12 | fn srgb2xyz(srgb: vec3f) -> vec3f { return rgb2xyz(srgb2rgb(srgb)); } 13 | -------------------------------------------------------------------------------- /color/space/srgb2xyz.wgsl: -------------------------------------------------------------------------------- 1 | #include "rgb2xyz.wgsl" 2 | #include "srgb2rgb.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts a sRGB color to XYZ 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn srgb2xyz(srgb: vec3f) -> vec3f { return rgb2xyz(srgb2rgb(srgb)); } 14 | -------------------------------------------------------------------------------- /color/space/xyY2rgb.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::{xyz2rgb::xyz2rgb, xyY2xyz::xyY2xyz}; 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts from xyY to linear RGB 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | 12 | fn xyY2rgb(xyY: vec3f) -> vec3f { return xyz2rgb(xyY2xyz(xyY)); } -------------------------------------------------------------------------------- /color/space/xyY2rgb.wgsl: -------------------------------------------------------------------------------- 1 | #include "xyz2rgb.wgsl" 2 | #include "xyY2xyz.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts from xyY to linear RGB 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn xyY2rgb(xyY: vec3f) -> vec3f { return xyz2rgb(xyY2xyz(xyY)); } -------------------------------------------------------------------------------- /color/space/xyY2srgb.wesl: -------------------------------------------------------------------------------- 1 | import lygia::color::space::{xyz2srgb::xyz2srgb, xyY2xyz::xyY2xyz}; 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Converts from xyY to sRGB 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | fn xyY2srgb(xyY: vec3f) -> vec3f { return xyz2srgb(xyY2xyz(xyY)); } -------------------------------------------------------------------------------- /color/space/xyY2srgb.wgsl: -------------------------------------------------------------------------------- 1 | #include "xyz2srgb.wgsl" 2 | #include "xyY2xyz.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: Converts from xyY to sRGB 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn xyY2srgb(xyY: vec3f) -> vec3f { return xyz2srgb(xyY2xyz(xyY)); } -------------------------------------------------------------------------------- /color/space/xyY2xyz.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Converts from xyY to XYZ 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn xyY2xyz(xyY: vec3f) -> vec3f { 10 | let Y = xyY.z; 11 | let f = 1.0/xyY.y; 12 | let x = Y * xyY.x * f; 13 | let z = Y * (1.0 - xyY.x - xyY.y) * f; 14 | return vecf(x, Y, z); 15 | } 16 | -------------------------------------------------------------------------------- /color/space/xyY2xyz.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Converts from xyY to XYZ 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn xyY2xyz(xyY: vec3f) -> vec3f { 10 | let Y = xyY.z; 11 | let f = 1.0/xyY.y; 12 | let x = Y * xyY.x * f; 13 | let z = Y * (1.0 - xyY.x - xyY.y) * f; 14 | return vecf(x, Y, z); 15 | } 16 | -------------------------------------------------------------------------------- /color/space/xyz2srgb.wgsl: -------------------------------------------------------------------------------- 1 | #include "xyz2rgb.wgsl" 2 | #include "rgb2srgb.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: 'Converts a XYZ color to sRGB. From http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html' 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | 13 | fn xyz2srgb(xyz: vec3f) -> vec3f { return rgb2srgb(xyz2rgb(xyz)); } -------------------------------------------------------------------------------- /color/tonemap/linear.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: nan 3 | description: Linear tonemap (no modifications are applied) 4 | use: tonemapLinear( x) 5 | */ 6 | 7 | #ifndef FNC_TONEMAPLINEAR 8 | #define FNC_TONEMAPLINEAR 9 | vec3 tonemapLinear(const vec3 v) { return v; } 10 | vec4 tonemapLinear(const vec4 v) { return v; } 11 | #endif -------------------------------------------------------------------------------- /color/tonemap/linear.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: nan 3 | description: Linear tonemap (no modifications are applied) 4 | use: tonemapLinear( x) 5 | */ 6 | 7 | 8 | #ifndef FNC_TONEMAPLINEAR 9 | #define FNC_TONEMAPLINEAR 10 | float3 tonemapLinear(const float3 x) { return x; } 11 | float4 tonemapLinear(const float4 x) { return x; } 12 | #endif -------------------------------------------------------------------------------- /draw/flip.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Flips the float passed in, 0 becomes 1 and 1 becomes 0 4 | use: flip( v, pct) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_FLIP 11 | #define FNC_FLIP 12 | float flip(in float v, in float pct) { 13 | return lerp(v, 1. - v, pct); 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /geometry/aabb.cuh: -------------------------------------------------------------------------------- 1 | #include "aabb/centroid.cuh" 2 | #include "aabb/contain.cuh" 3 | #include "aabb/diagonal.cuh" 4 | #include "aabb/expand.cuh" 5 | #include "aabb/intersect.cuh" 6 | #include "aabb/square.cuh" -------------------------------------------------------------------------------- /geometry/aabb.glsl: -------------------------------------------------------------------------------- 1 | #include "aabb/centroid.glsl" 2 | #include "aabb/contain.glsl" 3 | #include "aabb/diagonal.glsl" 4 | #include "aabb/expand.glsl" 5 | #include "aabb/intersect.glsl" 6 | #include "aabb/square.glsl" -------------------------------------------------------------------------------- /geometry/aabb.hlsl: -------------------------------------------------------------------------------- 1 | #include "aabb/centroid.hlsl" 2 | #include "aabb/contain.hlsl" 3 | #include "aabb/diagonal.hlsl" 4 | #include "aabb/expand.hlsl" 5 | #include "aabb/intersect.hlsl" 6 | #include "aabb/square.hlsl" -------------------------------------------------------------------------------- /geometry/aabb/aabb.cuh: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: This file contains the definition of the AABB struct 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_AABB 10 | #define STR_AABB 11 | struct AABB { 12 | float3 min; 13 | float3 max; 14 | }; 15 | #endif -------------------------------------------------------------------------------- /geometry/aabb/aabb.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: This file contains the definition of the AABB struct 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_AABB 10 | #define STR_AABB 11 | struct AABB { 12 | vec3 min; 13 | vec3 max; 14 | }; 15 | #endif -------------------------------------------------------------------------------- /geometry/aabb/aabb.hlsl: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: This file contains the definition of the AABB struct 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | #ifndef STR_AABB 12 | #define STR_AABB 13 | struct AABB { 14 | float3 min; 15 | float3 max; 16 | }; 17 | #endif -------------------------------------------------------------------------------- /geometry/aabb/centroid.glsl: -------------------------------------------------------------------------------- 1 | #include "aabb.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Return center of a AABB 6 | use: centroid( box) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_AABB_CENTROID 13 | #define FNC_AABB_CENTROID 14 | vec3 centroid(const in AABB _box) { return (_box.min + _box.max) * 0.5; } 15 | #endif -------------------------------------------------------------------------------- /geometry/aabb/centroid.hlsl: -------------------------------------------------------------------------------- 1 | #include "aabb.cuh" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Return center of a AABB 6 | use: centroid( box) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_AABB_CENTROID 13 | #define FNC_AABB_CENTROID 14 | float3 centroid(AABB _box) { return (_box.min + _box.max) * 0.5; } 15 | #endif -------------------------------------------------------------------------------- /geometry/triangle.cuh: -------------------------------------------------------------------------------- 1 | #include "triangle/area.cuh" 2 | #include "triangle/barycentric.cuh" 3 | #include "triangle/centroid.cuh" 4 | #include "triangle/contain.cuh" 5 | #include "triangle/distanceSq.cuh" 6 | #include "triangle/signedDistance.cuh" 7 | #include "triangle/closestPoint.cuh" 8 | #include "triangle/intersect.cuh" 9 | #include "triangle/normal.cuh" -------------------------------------------------------------------------------- /geometry/triangle.glsl: -------------------------------------------------------------------------------- 1 | #include "triangle/area.glsl" 2 | #include "triangle/barycentric.glsl" 3 | #include "triangle/centroid.glsl" 4 | #include "triangle/contain.glsl" 5 | #include "triangle/distanceSq.glsl" 6 | #include "triangle/signedDistance.glsl" 7 | #include "triangle/closestPoint.glsl" 8 | #include "triangle/intersect.glsl" 9 | #include "triangle/normal.glsl" 10 | -------------------------------------------------------------------------------- /geometry/triangle.hlsl: -------------------------------------------------------------------------------- 1 | #include "triangle/area.hlsl" 2 | #include "triangle/barycentric.hlsl" 3 | #include "triangle/centroid.hlsl" 4 | #include "triangle/contain.hlsl" 5 | #include "triangle/distanceSq.hlsl" 6 | #include "triangle/signedDistance.hlsl" 7 | #include "triangle/closestPoint.hlsl" 8 | #include "triangle/intersect.hlsl" 9 | #include "triangle/normal.hlsl" -------------------------------------------------------------------------------- /geometry/triangle/triangle.cuh: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: This file contains the definition of the Triangle struct 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_TRIANGLE 10 | #define STR_TRIANGLE 11 | struct Triangle { 12 | float3 a, b, c; 13 | }; 14 | #endif -------------------------------------------------------------------------------- /geometry/triangle/triangle.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: This file contains the definition of the Triangle struct 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_TRINAGLE 10 | #define STR_TRINAGLE 11 | struct Triangle { 12 | vec3 a, b, c; 13 | }; 14 | #endif -------------------------------------------------------------------------------- /geometry/triangle/triangle.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: This file contains the definition of the Triangle struct 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_TRIANGLE 10 | #define STR_TRIANGLE 11 | struct Triangle { 12 | float3 a, b, c; 13 | }; 14 | #endif -------------------------------------------------------------------------------- /lighting/camera.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Generic Camera Structure 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_CAMERA 10 | #define STR_CAMERA 11 | struct Camera { 12 | vec3 pos; 13 | vec3 dir; 14 | 15 | vec3 up; 16 | vec3 side; 17 | 18 | float invhalffov; 19 | float maxdist; 20 | }; 21 | #endif -------------------------------------------------------------------------------- /lighting/common/ashikhmin.hlsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.hlsl" 2 | 3 | #ifndef FNC_ASHIKHMIN 4 | #define FNC_ASHIKHMIN 5 | float ashikhmin(float NoH, float roughness) { 6 | // Ashikhmin 2007, "Distribution-based BRDFs" 7 | float a2 = roughness * roughness; 8 | float cos2h = NoH * NoH; 9 | float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16 10 | float sin4h = sin2h * sin2h; 11 | float cot2 = -cos2h / (a2 * sin2h); 12 | return 1.0 / (PI * (4.0 * a2 + 1.0) * sin4h) * (4.0 * exp(cot2) + sin4h); 13 | } 14 | #endif -------------------------------------------------------------------------------- /lighting/common/beckmann.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | // https://github.com/glslify/glsl-specular-beckmann 4 | 5 | #ifndef FNC_BECKMANN 6 | #define FNC_BECKMANN 7 | float beckmann(const in float _NoH, const in float roughness) { 8 | float NoH = max(_NoH, 0.0001); 9 | float cos2Alpha = NoH * NoH; 10 | float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha; 11 | float roughness2 = roughness * roughness; 12 | float denom = PI * roughness2 * cos2Alpha * cos2Alpha; 13 | return exp(tan2Alpha / roughness2) / denom; 14 | } 15 | #endif -------------------------------------------------------------------------------- /lighting/common/beckmann.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef FNC_BECKMANN 2 | #define FNC_BECKMANN 3 | float beckmann(float _NoH, float roughness) { 4 | float NoH = max(_NoH, 0.0001); 5 | float cos2Alpha = NoH * NoH; 6 | float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha; 7 | float roughness2 = roughness * roughness; 8 | float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha; 9 | return exp(tan2Alpha / roughness2) / denom; 10 | } 11 | #endif -------------------------------------------------------------------------------- /lighting/common/charlie.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | #ifndef FNC_CHARLIE 4 | #define FNC_CHARLIE 5 | float charlie(const in float NoH, const in float roughness) { 6 | // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" 7 | float invAlpha = 1.0 / roughness; 8 | float cos2h = NoH * NoH; 9 | float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16 10 | return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / TAU; 11 | } 12 | #endif -------------------------------------------------------------------------------- /lighting/common/charlie.hlsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.hlsl" 2 | 3 | #ifndef FNC_CHARLIE 4 | #define FNC_CHARLIE 5 | float charlie(float NoH, float roughness) { 6 | // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" 7 | float invAlpha = 1.0 / roughness; 8 | float cos2h = NoH * NoH; 9 | float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16 10 | return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / TAU; 11 | } 12 | #endif -------------------------------------------------------------------------------- /lighting/common/clampNoV.glsl: -------------------------------------------------------------------------------- 1 | #ifndef FNC_CLAMPNOV 2 | #define FNC_CLAMPNOV 3 | 4 | #ifndef MIN_N_DOT_V 5 | #define MIN_N_DOT_V 1e-4 6 | #endif 7 | // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" 8 | float clampNoV(const in float NoV) { 9 | return max(NoV, MIN_N_DOT_V); 10 | } 11 | #endif -------------------------------------------------------------------------------- /lighting/common/clampNoV.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef FNC_CLAMPNOV 2 | #define FNC_CLAMPNOV 3 | 4 | #ifndef MIN_N_DOT_V 5 | #define MIN_N_DOT_V 1e-4 6 | #endif 7 | // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" 8 | float clampNoV(float NoV) { 9 | return max(NoV, MIN_N_DOT_V); 10 | } 11 | #endif -------------------------------------------------------------------------------- /lighting/common/ggx.wesl: -------------------------------------------------------------------------------- 1 | fn GGX(N: vec3f, H: vec3f, NoH: f32, roughness: f32) -> f32 { 2 | let NxH = cross(N, H); 3 | let oneMinusNoHSquared = dot(NxH, NxH); 4 | 5 | // let oneMinusNoHSquared = 1.0 - NoH * NoH; 6 | 7 | let a = NoH * roughness; 8 | let k = roughness / (oneMinusNoHSquared + a * a); 9 | let d = (k * k) * 0.31830988618379067153776752674503; // 1/PI 10 | return min(d, 65504.0); 11 | } -------------------------------------------------------------------------------- /lighting/common/ggx.wgsl: -------------------------------------------------------------------------------- 1 | fn GGX(N: vec3f, H: vec3f, NoH: f32, roughness: f32) -> f32 { 2 | let NxH = cross(N, H); 3 | let oneMinusNoHSquared = dot(NxH, NxH); 4 | 5 | // let oneMinusNoHSquared = 1.0 - NoH * NoH; 6 | 7 | let a = NoH * roughness; 8 | let k = roughness / (oneMinusNoHSquared + a * a); 9 | let d = (k * k) * 0.31830988618379067153776752674503; // 1/PI 10 | return min(d, 65504.0); 11 | } -------------------------------------------------------------------------------- /lighting/common/kelemen.glsl: -------------------------------------------------------------------------------- 1 | 2 | #include "../../math/saturateMediump.glsl" 3 | 4 | #ifndef FNC_KELEMEN 5 | #define FNC_KELEMEN 6 | 7 | // Kelemen 2001, "A Microfacet Based Coupled Specular-Matte BRDF Model with Importance Sampling" 8 | float kelemen(const in float LoH) { 9 | return saturateMediump(0.25 / (LoH * LoH)); 10 | } 11 | 12 | #endif -------------------------------------------------------------------------------- /lighting/common/kelemen.hlsl: -------------------------------------------------------------------------------- 1 | 2 | #include "../../math/saturateMediump.hlsl" 3 | 4 | #ifndef FNC_KELEMEN 5 | #define FNC_KELEMEN 6 | 7 | // Kelemen 2001, "A Microfacet Based Coupled Specular-Matte BRDF Model with Importance Sampling" 8 | float kelemen(float LoH) { 9 | return saturateMediump(0.25 / (LoH * LoH)); 10 | } 11 | 12 | #endif -------------------------------------------------------------------------------- /lighting/common/preFilteredImportanceSampling.glsl: -------------------------------------------------------------------------------- 1 | #ifndef FNC_PRE_FILTERED_IMPORTANCE_SAMPLING 2 | #define FNC_PRE_FILTERED_IMPORTANCE_SAMPLING 3 | 4 | float prefilteredImportanceSampling(float ipdf, float omegaP, int numSamples) { 5 | const float K = 4.0; 6 | float omegaS = ipdf / float(numSamples); 7 | float mipLevel = log2(K * omegaS / omegaP) * 0.5; // log4 8 | return mipLevel; 9 | } 10 | 11 | #endif -------------------------------------------------------------------------------- /lighting/common/preFilteredImportanceSampling.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef FNC_PRE_FILTERED_IMPORTANCE_SAMPLING 2 | #define FNC_PRE_FILTERED_IMPORTANCE_SAMPLING 3 | 4 | float prefilteredImportanceSampling(float ipdf, float omegaP, int numSamples) { 5 | const float K = 4.0; 6 | float omegaS = ipdf / float(numSamples); 7 | float mipLevel = log2(K * omegaS / omegaP) * 0.5; // log4 8 | return mipLevel; 9 | } 10 | 11 | #endif -------------------------------------------------------------------------------- /lighting/common/rayleigh.glsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.glsl" 2 | 3 | #ifndef FNC_RAYLEIGH 4 | #define FNC_RAYLEIGH 5 | 6 | // Rayleigh phase 7 | float rayleigh(const in float mu) { 8 | return 3. * (1. + mu*mu) / (16. * PI); 9 | } 10 | 11 | #endif -------------------------------------------------------------------------------- /lighting/common/rayleigh.hlsl: -------------------------------------------------------------------------------- 1 | #include "../../math/const.hlsl" 2 | 3 | #ifndef FNC_RAYLEIGH 4 | #define FNC_RAYLEIGH 5 | 6 | // Rayleigh phase 7 | float rayleigh(float mu) { 8 | return 3. * (1. + mu*mu) / (16. * PI); 9 | } 10 | 11 | #endif -------------------------------------------------------------------------------- /lighting/common/schlick.wesl: -------------------------------------------------------------------------------- 1 | fn schlick(f0: vec3f, f90: vec3f, cos0: f32) -> vec3f { 2 | return f0 + (f90 - f0) * pow(1.0 - cos0, 5.0); 3 | } -------------------------------------------------------------------------------- /lighting/common/schlick.wgsl: -------------------------------------------------------------------------------- 1 | fn schlick(f0: vec3f, f90: vec3f, cos0: f32) -> vec3f { 2 | return f0 + (f90 - f0) * pow(1.0 - cos0, 5.0); 3 | } -------------------------------------------------------------------------------- /lighting/exposure.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Shadi El Hajj 3 | description: Calculate camera exposure 4 | use: float exposure(float aperture, float shutterSpeed, float sensitivity) 5 | license: MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj 6 | */ 7 | 8 | #ifndef FNC_EXPOSURE 9 | #define FNC_EXPOSURE 10 | 11 | float exposure(float aperture, float shutterSpeed, float sensitivity) { 12 | float ev100 = log2((aperture * aperture) / shutterSpeed * 100.0 / sensitivity); 13 | return 1.0 / (pow(2.0, ev100) * 1.2); 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /lighting/exposure.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Shadi El Hajj 3 | description: Calculate camera exposure 4 | use: float exposure(float aperture, float shutterSpeed, float sensitivity) 5 | license: MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj 6 | */ 7 | 8 | #ifndef FNC_EXPOSURE 9 | #define FNC_EXPOSURE 10 | 11 | float exposure(float aperture, float shutterSpeed, float sensitivity) { 12 | float ev100 = log2((aperture * aperture) / shutterSpeed * 100.0 / sensitivity); 13 | return 1.0 / (pow(2.0, ev100) * 1.2); 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /lighting/fresnel.wesl: -------------------------------------------------------------------------------- 1 | import lygia::lighting::common::schlick::schlick; 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Resolve fresnel coefficient 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | fn fresnel(f0: f32, NoV: f32) -> f32 { 12 | return schlick(f0, 1.0, NoV); 13 | } 14 | -------------------------------------------------------------------------------- /lighting/fresnel.wgsl: -------------------------------------------------------------------------------- 1 | #include "common/schlick.wgsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Resolve fresnel coefficient 6 | license: 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 9 | */ 10 | 11 | fn fresnel(f0: f32, NoV: f32) -> f32 { 12 | return schlick(f0, 1.0, NoV); 13 | } 14 | -------------------------------------------------------------------------------- /lighting/ior/reflectance2f0.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Shadi El Hajj 3 | description: Compute F0 for perceptual reflectance parameter. From Sébastien Lagarde's paper "Moving Frostbite to PBR". 4 | use: reflectance2f0( reflectance) 5 | license: MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj 6 | */ 7 | 8 | #ifndef FNC_REFLECTANCE2F0 9 | #define FNC_REFLECTANCE2F0 10 | float reflectance2f0(const float reflectance) { return 0.16 * reflectance * reflectance; } 11 | #endif -------------------------------------------------------------------------------- /lighting/ior/reflectance2f0.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Shadi El Hajj 3 | description: Compute F0 for perceptual reflectance parameter. From Sébastien Lagarde's paper "Moving Frostbite to PBR". 4 | use: reflectance2f0( reflectance) 5 | license: MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj 6 | */ 7 | 8 | #ifndef FNC_REFLECTANCE2F0 9 | #define FNC_REFLECTANCE2F0 10 | float reflectance2f0(const float reflectance) { return 0.16 * reflectance * reflectance; } 11 | #endif -------------------------------------------------------------------------------- /lighting/light/directional.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Directional Light Structure 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_LIGHT_DIRECTIONAL 10 | #define STR_LIGHT_DIRECTIONAL 11 | struct LightDirectional { 12 | vec3 direction; 13 | vec3 color; 14 | float intensity; 15 | }; 16 | #endif 17 | -------------------------------------------------------------------------------- /lighting/light/directional.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Directional Light Structure 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_LIGHT_DIRECTIONAL 10 | #define STR_LIGHT_DIRECTIONAL 11 | struct LightDirectional { 12 | float3 direction; 13 | float3 color; 14 | float intensity; 15 | }; 16 | #endif 17 | -------------------------------------------------------------------------------- /lighting/light/point.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Point light structure 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_LIGHT_POINT 10 | #define STR_LIGHT_POINT 11 | struct LightPoint { 12 | vec3 position; 13 | vec3 color; 14 | float intensity; 15 | float falloff; 16 | }; 17 | #endif 18 | -------------------------------------------------------------------------------- /lighting/light/point.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Point light structure 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_LIGHT_POINT 10 | #define STR_LIGHT_POINT 11 | struct LightPoint { 12 | float3 position; 13 | float3 color; 14 | float intensity; 15 | float falloff; 16 | }; 17 | #endif 18 | -------------------------------------------------------------------------------- /lighting/light/resolve.glsl: -------------------------------------------------------------------------------- 1 | #include "point.glsl" 2 | #include "pointEvaluate.glsl" 3 | #include "directional.glsl" 4 | #include "directionalEvaluate.glsl" 5 | #include "../material.glsl" 6 | 7 | #ifndef FNC_LIGHT_RESOLVE 8 | #define FNC_LIGHT_RESOLVE 9 | 10 | void lightResolve(LightPoint L, Material mat, inout ShadingData shadingData) { 11 | lightPointEvaluate(L, mat, shadingData); 12 | } 13 | 14 | 15 | void lightResolve(LightDirectional L, Material mat, inout ShadingData shadingData) { 16 | lightDirectionalEvaluate(L, mat, shadingData); 17 | } 18 | 19 | #endif -------------------------------------------------------------------------------- /lighting/light/resolve.hlsl: -------------------------------------------------------------------------------- 1 | #include "point.hlsl" 2 | #include "pointEvaluate.hlsl" 3 | #include "directional.hlsl" 4 | #include "directionalEvaluate.hlsl" 5 | #include "../material.hlsl" 6 | 7 | #ifndef FNC_LIGHT_RESOLVE 8 | #define FNC_LIGHT_RESOLVE 9 | 10 | void lightResolve(LightPoint L, Material mat, inout ShadingData shadingData) { 11 | lightPointEvaluate(L, mat, shadingData); 12 | } 13 | 14 | 15 | void lightResolve(LightDirectional L, Material mat, inout ShadingData shadingData) { 16 | lightDirectionalEvaluate(L, mat, shadingData); 17 | } 18 | 19 | #endif -------------------------------------------------------------------------------- /lighting/medium.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Shadi El Hajj 3 | description: Medium Structure 4 | license: MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj 5 | */ 6 | 7 | #ifndef STR_MEDIUM 8 | #define STR_MEDIUM 9 | 10 | struct Medium { 11 | vec3 scattering; 12 | vec3 absorption; 13 | float sdf; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /lighting/medium.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Shadi El Hajj 3 | description: Medium Structure 4 | license: MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj 5 | */ 6 | 7 | #ifndef STR_MEDIUM 8 | #define STR_MEDIUM 9 | 10 | struct Medium { 11 | float3 scattering; 12 | float3 absorption; 13 | float sdf; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /lighting/ray.cuh: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Generic Ray Structure 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_RAY 10 | #define STR_RAY 11 | struct Ray { 12 | float3 origin; 13 | float3 direction; 14 | }; 15 | #endif -------------------------------------------------------------------------------- /lighting/ray.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Generic Ray Structure 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_RAY 10 | #define STR_RAY 11 | struct Ray { 12 | vec3 origin; 13 | vec3 direction; 14 | }; 15 | #endif -------------------------------------------------------------------------------- /lighting/ray.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Generic Ray Structure 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef STR_RAY 10 | #define STR_RAY 11 | struct Ray { 12 | float3 origin; 13 | float3 direction; 14 | }; 15 | #endif -------------------------------------------------------------------------------- /lighting/raymarch/cast.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: Cast a ray 4 | */ 5 | 6 | // #include "map.wgls" 7 | 8 | fn raymarchCast(ro: vec3f, rd: vec3f ) -> f32 { 9 | var dist = -1.0; 10 | var t = -1.0; 11 | for (var i = 0; i < 120 && t < 100.0; i++) { 12 | let h = map( ro + rd * t ); 13 | if (abs(h) < (0.001 * t)) { 14 | dist = t; 15 | break; 16 | } 17 | t += h; 18 | } 19 | return dist; 20 | } -------------------------------------------------------------------------------- /lighting/raymarch/cast.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: Cast a ray 4 | */ 5 | 6 | // #include "map.wgls" 7 | 8 | fn raymarchCast(ro: vec3f, rd: vec3f ) -> f32 { 9 | var dist = -1.0; 10 | var t = -1.0; 11 | for (var i = 0; i < 120 && t < 100.0; i++) { 12 | let h = map( ro + rd * t ); 13 | if (abs(h) < (0.001 * t)) { 14 | dist = t; 15 | break; 16 | } 17 | t += h; 18 | } 19 | return dist; 20 | } -------------------------------------------------------------------------------- /lighting/specular/beckmann.glsl: -------------------------------------------------------------------------------- 1 | #include "../common/beckmann.glsl" 2 | 3 | #ifndef FNC_SPECULAR_BECKMANN 4 | #define FNC_SPECULAR_BECKMANN 5 | 6 | float specularBeckmann(ShadingData shadingData) { 7 | return beckmann(shadingData.NoH, shadingData.roughness); 8 | } 9 | 10 | #endif -------------------------------------------------------------------------------- /lighting/specular/beckmann.hlsl: -------------------------------------------------------------------------------- 1 | #include "../common/beckmann.hlsl" 2 | 3 | #ifndef FNC_SPECULAR_BECKMANN 4 | #define FNC_SPECULAR_BECKMANN 5 | 6 | float specularBeckmann(ShadingData shadingData) { 7 | return beckmann(shadingData.NoH, shadingData.roughness); 8 | } 9 | 10 | #endif -------------------------------------------------------------------------------- /lighting/specular/gaussian.glsl: -------------------------------------------------------------------------------- 1 | #ifndef FNC_SPECULAR_GAUSSIAN 2 | #define FNC_SPECULAR_GAUSSIAN 3 | 4 | // https://github.com/glslify/glsl-specular-gaussian 5 | float specularGaussian(const in float NoH, const in float roughness) { 6 | float theta = acos(NoH); 7 | float w = theta / roughness; 8 | return exp(-w*w); 9 | } 10 | 11 | float specularGaussian(ShadingData shadingData) { 12 | return specularGaussian(shadingData.NoH, shadingData.roughness); 13 | } 14 | 15 | #endif -------------------------------------------------------------------------------- /lighting/specular/gaussian.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef FNC_SPECULAR_GAUSSIAN 2 | #define FNC_SPECULAR_GAUSSIAN 3 | 4 | // https://github.com/glslify/glsl-specular-gaussian 5 | float specularGaussian(const in float NoH, const in float roughness) { 6 | float theta = acos(NoH); 7 | float w = theta / roughness; 8 | return exp(-w*w); 9 | } 10 | 11 | float specularGaussian(ShadingData shadingData) { 12 | return specularGaussian(shadingData.NoH, shadingData.roughness); 13 | } 14 | 15 | #endif -------------------------------------------------------------------------------- /lighting/wavelength.glsl: -------------------------------------------------------------------------------- 1 | #include "../color/space/w2rgb.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Wavelength to RGB 6 | use: wavelength( wavelength) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_WAVELENGTH 13 | #define FNC_WAVELENGTH 14 | vec3 wavelength(float w) { return w2rgb(w); } 15 | #endif 16 | -------------------------------------------------------------------------------- /lighting/wavelength.hlsl: -------------------------------------------------------------------------------- 1 | #include "../color/space/w2rgb.hlsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: Wavelength to RGB 6 | use: wavelength( wavelength) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_WAVELENGTH 13 | #define FNC_WAVELENGTH 14 | float3 wavelength(float w) { return w2rgb(w); } 15 | #endif 16 | -------------------------------------------------------------------------------- /math/aastep.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Matt DesLauriers 3 | description: Performs a smoothstep using standard derivatives for anti-aliased edges at any level of magnification. From https://github.com/glslify/glsl-aastep 4 | */ 5 | 6 | fn aastep(threshold: f32, value: f32) -> f32 { 7 | let afwidth = 0.7 * fwidth(value); 8 | return smoothstep(threshold - afwidth, threshold + afwidth, value); 9 | } -------------------------------------------------------------------------------- /math/aastep.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Matt DesLauriers 3 | description: Performs a smoothstep using standard derivatives for anti-aliased edges at any level of magnification. From https://github.com/glslify/glsl-aastep 4 | */ 5 | 6 | fn aastep(threshold: f32, value: f32) -> f32 { 7 | let afwidth = 0.7 * fwidth(value); 8 | return smoothstep(threshold - afwidth, threshold + afwidth, value); 9 | } -------------------------------------------------------------------------------- /math/absi.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: absolute of integer 4 | use: absi( value) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_ABSI 11 | #define FNC_ABSI 12 | #define absi(x) ( (x < 0)? x * -1 : x ) 13 | #endif -------------------------------------------------------------------------------- /math/absi.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: absolute of integer 4 | use: absi( value) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_ABSI 11 | #define FNC_ABSI 12 | #define absi(x) ( (x < 0)? x * -1 : x ) 13 | #endif -------------------------------------------------------------------------------- /math/adaptiveThreshold.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Brad Larson, Ben Cochran, Hugues Lismonde, Keitaroh Kobayashi, Alaric Cole, Matthew Clark, Jacob Gundersen, Chris Williams] 3 | description: adaptive threshold from https://github.com/BradLarson/GPUImage/blob/master/framework/Source/GPUImageAdaptiveThresholdFilter.m 4 | */ 5 | 6 | fn adaptiveThreshold(v: f32, blur_v: f32, b: f32) -> f32 { return step(blur_v + b, v); } 7 | -------------------------------------------------------------------------------- /math/adaptiveThreshold.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Brad Larson, Ben Cochran, Hugues Lismonde, Keitaroh Kobayashi, Alaric Cole, Matthew Clark, Jacob Gundersen, Chris Williams] 3 | description: adaptive threshold from https://github.com/BradLarson/GPUImage/blob/master/framework/Source/GPUImageAdaptiveThresholdFilter.m 4 | */ 5 | 6 | fn adaptiveThreshold(v: f32, blur_v: f32, b: f32) -> f32 { return step(blur_v + b, v); } 7 | -------------------------------------------------------------------------------- /math/atan2.glsl: -------------------------------------------------------------------------------- 1 | #include "const.glsl" 2 | 3 | /* 4 | contributors: Alexander Griffis 5 | description: | 6 | The range here in degrees is 0 to pi (0-180 degrees) and -pi to 0 (181 to 359 degrees 7 | More about it at https://github.com/Yaazarai/GLSL-ATAN2-DOC 8 | 9 | use: atan2(y, x) 10 | */ 11 | 12 | #ifndef FNC_ATAN2 13 | #define FNC_ATAN2 14 | float atan2(float y, float x) { return mod(atan(y,x) + PI, TAU); } 15 | #endif -------------------------------------------------------------------------------- /math/atan2.msl: -------------------------------------------------------------------------------- 1 | #include "const.msl" 2 | #include "mod.msl" 3 | 4 | /* 5 | contributors: Alexander Griffis 6 | description: | 7 | The range here degrees is 0 to pi (0-180 degrees) and -pi to 0 (181 to 359 degrees 8 | More about it at https://github.com/Yaazarai/GLSL-ATAN2-DOC 9 | 10 | use: atan2(y, x) 11 | */ 12 | 13 | #ifndef FNC_ATAN2 14 | #define FNC_ATAN2 15 | float atan2(float y, float x) { return mod(atan(y,x) + PI, TAU); } 16 | #endif -------------------------------------------------------------------------------- /math/cubic.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: cubic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn cubic(v: f32) -> f32 { return v*v*(3.0-2.0*v); } 7 | fn cubic2(v: vec2f) -> vec2f { return v*v*(3.0-2.0*v); } 8 | fn cubic3(v: vec3f) -> vec3f { return v*v*(3.0-2.0*v); } 9 | fn cubic4(v: vec4f) -> vec4f { return v*v*(3.0-2.0*v); } -------------------------------------------------------------------------------- /math/cubic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: cubic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn cubic(v: f32) -> f32 { return v*v*(3.0-2.0*v); } 7 | fn cubic2(v: vec2f) -> vec2f { return v*v*(3.0-2.0*v); } 8 | fn cubic3(v: vec3f) -> vec3f { return v*v*(3.0-2.0*v); } 9 | fn cubic4(v: vec4f) -> vec4f { return v*v*(3.0-2.0*v); } -------------------------------------------------------------------------------- /math/fcos.glsl: -------------------------------------------------------------------------------- 1 | #include "const.glsl" 2 | 3 | /* 4 | contributors: Inigo Quiles 5 | description: A band-limited variant of cos(x) which reduces aliasing at high frequencies. From https://iquilezles.org/articles/bandlimiting/ 6 | use: fcos( value) 7 | */ 8 | 9 | #ifndef FNC_FCOS 10 | #define FNC_FCOS 11 | 12 | float fcos(in float x){ 13 | float w = fwidth(x); 14 | return cos(x) * smoothstep( TWO_PI, 0.0, w ); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /math/fcos.hlsl: -------------------------------------------------------------------------------- 1 | #include "const.hlsl" 2 | 3 | /* 4 | contributors: Inigo Quiles 5 | description: A band-limited variant of cos(x) which reduces aliasing at high frequencies. From https://iquilezles.org/articles/bandlimiting/ 6 | use: fcos( value) 7 | */ 8 | 9 | #ifndef FNC_FCOS 10 | #define FNC_FCOS 11 | 12 | float fcos(in float x){ 13 | float w = fwidth(x); 14 | return cos(x) * smoothstep( TWO_PI, 0.0, w ); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /math/gain.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: | 4 | Remapping the unit interval into the unit interval by expanding the sides and compressing the center, and keeping 1/2 mapped to 1/2, that can be done with the gain() function. From https://iquilezles.org/articles/functions/ 5 | use: gain( x, k) 6 | */ 7 | 8 | #ifndef FNC_GAIN 9 | #define FNC_GAIN 10 | float gain(float x, float k) { 11 | const float a = 0.5*pow(2.0*((x<0.5)?x:1.0-x), k); 12 | return (x<0.5)?a:1.0-a; 13 | } 14 | #endif -------------------------------------------------------------------------------- /math/gain.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: | 4 | Remapping the unit interval into the unit interval by expanding the sides and compressing the center, and keeping 1/2 mapped to 1/2, that can be done with the gain() function. From https://iquilezles.org/articles/functions/ 5 | */ 6 | 7 | fn gain(x: f32, k: f32) -> f32 { 8 | let a = 0.5 * pow(2.0 * select(1.0-x, x, x<0.5), k); 9 | return select(1.0-a, a, x<0.5); 10 | } -------------------------------------------------------------------------------- /math/gain.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: | 4 | Remapping the unit interval into the unit interval by expanding the sides and compressing the center, and keeping 1/2 mapped to 1/2, that can be done with the gain() function. From https://iquilezles.org/articles/functions/ 5 | */ 6 | 7 | fn gain(x: f32, k: f32) -> f32 { 8 | let a = 0.5 * pow(2.0 * select(1.0-x, x, x<0.5), k); 9 | return select(1.0-a, a, x<0.5); 10 | } -------------------------------------------------------------------------------- /math/grad4.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: grad4, used for snoise(vec4 v) 4 | use: grad4( j, ip) 5 | */ 6 | 7 | #ifndef FNC_GRAD4 8 | #define FNC_GRAD4 9 | vec4 grad4(float j, vec4 ip) { 10 | const vec4 ones = vec4(1.0, 1.0, 1.0, -1.0); 11 | vec4 p,s; 12 | p.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0; 13 | p.w = 1.5 - dot(abs(p.xyz), ones.xyz); 14 | s = vec4(lessThan(p, vec4(0.0))); 15 | p.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www; 16 | return p; 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /math/grad4.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: grad4, used for snoise(vec4 v) 4 | */ 5 | 6 | fn grad4(j: f32, ip: vec4f) -> vec4f { 7 | let ones = vec4(1.0, 1.0, 1.0, -1.0); 8 | var xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0; 9 | let w = 1.5 - dot(abs(xyz), ones.xyz); 10 | let s = select(vec4(0.0), vec4(1.0), vec4(xyz, w) < vec4(0.0)); 11 | xyz = xyz + (s.xyz*2.0 - 1.0) * s.www; 12 | return vec4f(xyz, w); 13 | } 14 | -------------------------------------------------------------------------------- /math/grad4.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: grad4, used for snoise(vec4 v) 4 | */ 5 | 6 | fn grad4(j: f32, ip: vec4f) -> vec4f { 7 | let ones = vec4(1.0, 1.0, 1.0, -1.0); 8 | var xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0; 9 | let w = 1.5 - dot(abs(xyz), ones.xyz); 10 | let s = select(vec4(0.0), vec4(1.0), vec4(xyz, w) < vec4(0.0)); 11 | xyz = xyz + (s.xyz*2.0 - 1.0) * s.www; 12 | return vec4f(xyz, w); 13 | } 14 | -------------------------------------------------------------------------------- /math/greaterThan.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: greaterThan, returns 1 if x > y, 0 otherwise 4 | use: greaterThan( x, y) 5 | */ 6 | 7 | #ifndef FNC_GREATERTHAN 8 | #define FNC_GREATERTHAN 9 | float greaterThan(float x, float y) { return step(y, x); } 10 | float2 greaterThan(float2 x, float2 y) { return step(y, x); } 11 | float3 greaterThan(float3 x, float3 y) { return step(y, x); } 12 | float4 greaterThan(float4 x, float4 y) { return step(y, x); } 13 | #endif 14 | -------------------------------------------------------------------------------- /math/highPass.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: bias high pass 4 | use: highPass( value, bias) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_HIGHPASS 11 | #define FNC_HIGHPASS 12 | float highPass(in float v, in float b) { return max(v - b, 0.0) / (1.0 - b); } 13 | #endif 14 | -------------------------------------------------------------------------------- /math/highPass.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: bias high pass 4 | use: highPass( value, bias) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_HIGHPASS 11 | #define FNC_HIGHPASS 12 | float highPass(in float value, in float bias) { return max(value - bias, 0.0) / (1.0 - bias); } 13 | #endif 14 | -------------------------------------------------------------------------------- /math/highPass.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: bias high pass 4 | use: highPass( value, bias) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_HIGHPASS 11 | #define FNC_HIGHPASS 12 | float highPass(float v, float b) { return max(v - b, 0.0) / (1.0 - b); } 13 | #endif 14 | -------------------------------------------------------------------------------- /math/highPass.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: bias high pass 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn highPass(v: f32, b: f32) -> f32 { return max(v - b, 0.0) / (1.0 - b); } -------------------------------------------------------------------------------- /math/highPass.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: bias high pass 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn highPass(v: f32, b: f32) -> f32 { return max(v - b, 0.0) / (1.0 - b); } -------------------------------------------------------------------------------- /math/invCubic.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: inverse cubic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn invCubic(v: f32) -> fn32 { return 0.5-sin(asin(1.0-2.0*v)/3.0); } 7 | fn invCubic2(v: vec2f) -> vec2f { return 0.5-sin(asin(1.0-2.0*v)/3.0); } 8 | fn invCubic3(v: vec3f) -> vec3f { return 0.5-sin(asin(1.0-2.0*v)/3.0); } 9 | fn invCubic4(v: vec4f) -> vec4f { return 0.5-sin(asin(1.0-2.0*v)/3.0); } 10 | -------------------------------------------------------------------------------- /math/invCubic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: inverse cubic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn invCubic(v: f32) -> fn32 { return 0.5-sin(asin(1.0-2.0*v)/3.0); } 7 | fn invCubic2(v: vec2f) -> vec2f { return 0.5-sin(asin(1.0-2.0*v)/3.0); } 8 | fn invCubic3(v: vec3f) -> vec3f { return 0.5-sin(asin(1.0-2.0*v)/3.0); } 9 | fn invCubic4(v: vec4f) -> vec4f { return 0.5-sin(asin(1.0-2.0*v)/3.0); } 10 | -------------------------------------------------------------------------------- /math/invQuartic.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: inverse quartic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn invQuartic(v: f32) -> f32 { return sqrt(1.0-sqrt(1.0-v)); } 7 | fn invQuartic2(v: vec2f) -> vec2f { return sqrt(1.0-sqrt(1.0-v)); } 8 | fn invQuartic3(v: vec3f) -> vec3f { return sqrt(1.0-sqrt(1.0-v)); } 9 | fn invQuartic4(v: vec4f) -> vec4f { return sqrt(1.0-sqrt(1.0-v)); } 10 | -------------------------------------------------------------------------------- /math/invQuartic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: inverse quartic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn invQuartic(v: f32) -> f32 { return sqrt(1.0-sqrt(1.0-v)); } 7 | fn invQuartic2(v: vec2f) -> vec2f { return sqrt(1.0-sqrt(1.0-v)); } 8 | fn invQuartic3(v: vec3f) -> vec3f { return sqrt(1.0-sqrt(1.0-v)); } 9 | fn invQuartic4(v: vec4f) -> vec4f { return sqrt(1.0-sqrt(1.0-v)); } 10 | -------------------------------------------------------------------------------- /math/lengthSq.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Squared length 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn lengthSq2(v: vec2f) -> f32 { return dot(v, v); } 10 | fn lengthSq3(v: vec3f) -> f32 { return dot(v, v); } 11 | fn lengthSq4(v: vec4f) -> f32 { return dot(v, v); } 12 | -------------------------------------------------------------------------------- /math/lengthSq.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Squared length 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn lengthSq2(v: vec2f) -> f32 { return dot(v, v); } 10 | fn lengthSq3(v: vec3f) -> f32 { return dot(v, v); } 11 | fn lengthSq4(v: vec4f) -> f32 { return dot(v, v); } 12 | -------------------------------------------------------------------------------- /math/mirror.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Ian Heisters 3 | description: Transforms the input signal into a triangle wave. For instance, if x goes between 0 and 2, the returned value will go from 0 to 1, and then 1 to 0 in a triangle shape. 4 | */ 5 | 6 | fn mirror(x: f32) -> f32 { 7 | let f = fract(x); 8 | let m = floor(x % 2.0); 9 | let fm = f * m; 10 | return f + m - fm * 2.0; 11 | } 12 | 13 | fn mirror2(xy: vec2f) -> vec2f { 14 | let f = fract(xy); 15 | let m = floor(xy % 2.0); 16 | let fm = f * m; 17 | return f + m - fm * 2.0; 18 | } -------------------------------------------------------------------------------- /math/mirror.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Ian Heisters 3 | description: Transforms the input signal into a triangle wave. For instance, if x goes between 0 and 2, the returned value will go from 0 to 1, and then 1 to 0 in a triangle shape. 4 | */ 5 | 6 | fn mirror(x: f32) -> f32 { 7 | let f = fract(x); 8 | let m = floor(x % 2.0); 9 | let fm = f * m; 10 | return f + m - fm * 2.0; 11 | } 12 | 13 | fn mirror2(xy: vec2f) -> vec2f { 14 | let f = fract(xy); 15 | let m = floor(xy % 2.0); 16 | let fm = f * m; 17 | return f + m - fm * 2.0; 18 | } -------------------------------------------------------------------------------- /math/mmax.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: extend GLSL Max function to add more arguments 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn mmax2(v: vec2f) -> f32 { return max(v.x, v.y); } 10 | fn mmax3(v: vec3f) -> f32 { return mmax(v.x, v.y, v.z); } 11 | fn mmax4(v: vec4f) -> f32 { return mmax(v.x, v.y, v.z, v.w); } 12 | -------------------------------------------------------------------------------- /math/mmax.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: extend GLSL Max function to add more arguments 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn mmax2(v: vec2f) -> f32 { return max(v.x, v.y); } 10 | fn mmax3(v: vec3f) -> f32 { return mmax(v.x, v.y, v.z); } 11 | fn mmax4(v: vec4f) -> f32 { return mmax(v.x, v.y, v.z, v.w); } 12 | -------------------------------------------------------------------------------- /math/mmin.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: extend GLSL min function to add more arguments 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn mmin2(v: vec2f) -> f32 { return min(v.x, v.y); } 10 | fn mmin3(v: vec3f) -> f32 { return mmin(v.x, v.y, v.z); } 11 | fn mmin4(v: vec4f) -> f32 { return mmin(v.x, v.y, v.z, v.w); } 12 | -------------------------------------------------------------------------------- /math/mmin.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: extend GLSL min function to add more arguments 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn mmin2(v: vec2f) -> f32 { return min(v.x, v.y); } 10 | fn mmin3(v: vec3f) -> f32 { return mmin(v.x, v.y, v.z); } 11 | fn mmin4(v: vec4f) -> f32 { return mmin(v.x, v.y, v.z, v.w); } 12 | -------------------------------------------------------------------------------- /math/mod289.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: modulus of 289 4 | use: mod289( x) 5 | */ 6 | 7 | #ifndef FNC_MOD289 8 | #define FNC_MOD289 9 | 10 | float mod289(const in float x) { return x - floor(x * (1. / 289.)) * 289.; } 11 | vec2 mod289(const in vec2 x) { return x - floor(x * (1. / 289.)) * 289.; } 12 | vec3 mod289(const in vec3 x) { return x - floor(x * (1. / 289.)) * 289.; } 13 | vec4 mod289(const in vec4 x) { return x - floor(x * (1. / 289.)) * 289.; } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /math/mod289.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: modulus of 289 4 | use: mod289( x) 5 | */ 6 | 7 | #ifndef FNC_MOD289 8 | #define FNC_MOD289 9 | 10 | float mod289(in float x) { return x - floor(x * (1. / 289.)) * 289.; } 11 | float2 mod289(in float2 x) { return x - floor(x * (1. / 289.)) * 289.; } 12 | float3 mod289(in float3 x) { return x - floor(x * (1. / 289.)) * 289.; } 13 | float4 mod289(in float4 x) { return x - floor(x * (1. / 289.)) * 289.; } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /math/mod289.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: modulus of 289 4 | use: mod289( x) 5 | */ 6 | 7 | #ifndef FNC_MOD289 8 | #define FNC_MOD289 9 | 10 | float mod289(const float x) { return x - floor(x * (1. / 289.)) * 289.; } 11 | float2 mod289(const float2 x) { return x - floor(x * (1. / 289.)) * 289.; } 12 | float3 mod289(const float3 x) { return x - floor(x * (1. / 289.)) * 289.; } 13 | float4 mod289(const float4 x) { return x - floor(x * (1. / 289.)) * 289.; } 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /math/mod289.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: modulus of 289 4 | */ 5 | 6 | fn mod289(x: f32) -> f32 { return x - floor(x * (1. / 289.)) * 289.; } 7 | fn mod289_2(x: vec2f) -> vec2f { return x - floor(x * (1. / 289.)) * 289.; } 8 | fn mod289_3(x: vec3f) -> vec3f { return x - floor(x * (1. / 289.)) * 289.; } 9 | fn mod289_4(x: vec4f) -> vec4f { return x - floor(x * (1. / 289.)) * 289.; } 10 | -------------------------------------------------------------------------------- /math/mod289.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: modulus of 289 4 | */ 5 | 6 | fn mod289(x: f32) -> f32 { return x - floor(x * (1. / 289.)) * 289.; } 7 | fn mod289_2(x: vec2f) -> vec2f { return x - floor(x * (1. / 289.)) * 289.; } 8 | fn mod289_3(x: vec3f) -> vec3f { return x - floor(x * (1. / 289.)) * 289.; } 9 | fn mod289_4(x: vec4f) -> vec4f { return x - floor(x * (1. / 289.)) * 289.; } 10 | -------------------------------------------------------------------------------- /math/modi.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: | 4 | Integer modulus, returns the remainder of a division of two integers. 5 | use: modi( x, y) 6 | */ 7 | 8 | #ifndef FNC_MODI 9 | #define FNC_MODI 10 | int modi(int x, int y) { 11 | #if __VERSION__ >= 130 12 | return x % y; 13 | #else 14 | return x - y * int(floor(float(x) / float(y))); 15 | #endif 16 | } 17 | #endif -------------------------------------------------------------------------------- /math/parabola.cuh: -------------------------------------------------------------------------------- 1 | #include "pow.cuh" 2 | 3 | /* 4 | contributors: Inigo Quiles 5 | description: | 6 | A nice choice to remap the 0..1 interval into 0..1, such that the corners are mapped to 0 and the center to 1. You can then rise the parabolar to a power k to control its shape. From https://iquilezles.org/articles/functions/ 7 | use: parabola( x, k) 8 | */ 9 | 10 | #ifndef FNC_PARABOLA 11 | #define FNC_PARABOLA 12 | 13 | inline __device__ __host__ float parabola( float x, float k ) { return pow( 4.0f * x * (1.0f - x), k ); } 14 | 15 | #endif -------------------------------------------------------------------------------- /math/parabola.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: | 4 | A nice choice to remap the 0..1 interval into 0..1, such that the corners are mapped to 0 and the center to 1. You can then rise the parabolar to a power k to control its shape. From https://iquilezles.org/articles/functions/ 5 | use: parabola( x, k) 6 | */ 7 | 8 | #ifndef FNC_PARABOLA 9 | #define FNC_PARABOLA 10 | float parabola( float x, float k ) { return pow( 4.0*x*(1.0-x), k ); } 11 | #endif -------------------------------------------------------------------------------- /math/parabola.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: | 4 | A nice choice to remap the 0..1 interval into 0..1, such that the corners are mapped to 0 and the center to 1. You can then rise the parabolar to a power k to control its shape. From https://iquilezles.org/articles/functions/ 5 | */ 6 | 7 | fn parabola(x: f32, k: f32) -> f32 { return pow( 4.0*x*(1.0-x), k ); } -------------------------------------------------------------------------------- /math/parabola.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: | 4 | A nice choice to remap the 0..1 interval into 0..1, such that the corners are mapped to 0 and the center to 1. You can then rise the parabolar to a power k to control its shape. From https://iquilezles.org/articles/functions/ 5 | */ 6 | 7 | fn parabola(x: f32, k: f32) -> f32 { return pow( 4.0*x*(1.0-x), k ); } -------------------------------------------------------------------------------- /math/permute.wesl: -------------------------------------------------------------------------------- 1 | import lygia::math::mod289::{mod289, mod289_2, mod289_3, mod289_4}; 2 | 3 | /* 4 | contributors: [Stefan Gustavson, Ian McEwan] 5 | description: permute 6 | */ 7 | 8 | fn permute(x: f32) -> f32 { return mod289(((x * 34.0) + 1.0) * x); } 9 | fn permute2(x: vec2f) -> vec2f { return mod289_2(((x * 34.0) + 1.0) * x); } 10 | fn permute3(x: vec3f) -> vec3f { return mod289_3(((x * 34.0) + 1.0) * x); } 11 | fn permute4(x: vec4f) -> vec4f { return mod289_4(((x * 34.0) + 1.0) * x); } 12 | -------------------------------------------------------------------------------- /math/permute.wgsl: -------------------------------------------------------------------------------- 1 | #include "mod289.wgsl" 2 | 3 | /* 4 | contributors: [Stefan Gustavson, Ian McEwan] 5 | description: permute 6 | */ 7 | 8 | fn permute(x: f32) -> f32 { return mod289(((x * 34.0) + 1.0) * x); } 9 | fn permute2(x: vec2f) -> vec2f { return mod289_2(((x * 34.0) + 1.0) * x); } 10 | fn permute3(x: vec3f) -> vec3f { return mod289_3(((x * 34.0) + 1.0) * x); } 11 | fn permute4(x: vec4f) -> vec4f { return mod289_4(((x * 34.0) + 1.0) * x); } 12 | -------------------------------------------------------------------------------- /math/powFast.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: fast approximation to pow() 4 | use: powFast( x, exp) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_POWFAST 11 | #define FNC_POWFAST 12 | 13 | float powFast(const in float a, const in float b) { return a / ((1. - b) * a + b); } 14 | 15 | #endif -------------------------------------------------------------------------------- /math/powFast.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: fast approximation to pow() 4 | use: powFast( x, exp) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_POWFAST 11 | #define FNC_POWFAST 12 | 13 | float powFast(const in float a, const in float b) { return a / ((1. - b) * a + b); } 14 | 15 | #endif -------------------------------------------------------------------------------- /math/powFast.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: fast approximation to pow() 4 | use: powFast( x, exp) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_POWFAST 11 | #define FNC_POWFAST 12 | 13 | float powFast(const float a, const float b) { return a / ((1. - b) * a + b); } 14 | 15 | #endif -------------------------------------------------------------------------------- /math/quartic.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: quartic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | use: quartic( value); 5 | */ 6 | 7 | #ifndef FNC_QUARTIC 8 | #define FNC_QUARTIC 9 | 10 | float quartic(const in float v) { return v*v*(2.0-v*v); } 11 | float2 quartic(const in float2 v) { return v*v*(2.0-v*v); } 12 | float3 quartic(const in float3 v) { return v*v*(2.0-v*v); } 13 | float4 quartic(const in float4 v) { return v*v*(2.0-v*v); } 14 | 15 | #endif -------------------------------------------------------------------------------- /math/quartic.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: quartic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn quartic(v: f32) -> f32 { return v*v*(2.0-v*v); } 7 | fn quartic2(v: vec2f) -> vec2f { return v*v*(2.0-v*v); } 8 | fn quartic3(v: vec3f) -> vec3f { return v*v*(2.0-v*v); } 9 | fn quartic4(v: vec4f) -> vec4f { return v*v*(2.0-v*v); } -------------------------------------------------------------------------------- /math/quartic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: quartic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn quartic(v: f32) -> f32 { return v*v*(2.0-v*v); } 7 | fn quartic2(v: vec2f) -> vec2f { return v*v*(2.0-v*v); } 8 | fn quartic3(v: vec3f) -> vec3f { return v*v*(2.0-v*v); } 9 | fn quartic4(v: vec4f) -> vec4f { return v*v*(2.0-v*v); } -------------------------------------------------------------------------------- /math/quat/2mat4.wgsl: -------------------------------------------------------------------------------- 1 | #include "2mat3.wgsl" 2 | #include "../toMat4.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: given a quaternion, returns a rotation 4x4 matrix 7 | use: quat2mat4( Q) 8 | license: 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 10 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 11 | */ 12 | 13 | fn quat2mat4(v q: vec4f) -> mat4x4 { return toMat4(quat2mat3(q)); } 14 | -------------------------------------------------------------------------------- /math/quat/add.glsl: -------------------------------------------------------------------------------- 1 | #include "type.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion addition \n" 6 | use: quatAdd( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATADD 13 | #define FNC_QUATADD 14 | QUAT quatAdd(QUAT a, QUAT b) { return QUAT(a.xyz + b.xyz, a.w + b.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/add.hlsl: -------------------------------------------------------------------------------- 1 | #include "type.hlsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion addition \n" 6 | use: quatAdd( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATADD 13 | #define FNC_QUATADD 14 | QUAT quatAdd(QUAT a, QUAT b) { return QUAT(a.xyz + b.xyz, a.w + b.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/add.msl: -------------------------------------------------------------------------------- 1 | #include "type.msl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion addition \n" 6 | use: quatAdd( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATADD 13 | #define FNC_QUATADD 14 | QUAT quatAdd(QUAT a, QUAT b) { return QUAT(a.xyz + b.xyz, a.w + b.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/add.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: "Quaternion addition \n" 4 | use: quatAdd( a, b) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | fn quatAdd(a: vec4f, b: vec4f) -> vec4f { return vec4f(a.xyz + b.xyz, a.w + b.w); } 11 | -------------------------------------------------------------------------------- /math/quat/conj.glsl: -------------------------------------------------------------------------------- 1 | #include "type.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: given a quaternion, returns its conjugate 6 | use: quatConj( Q) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATCONJ 13 | #define FNC_QUATCONJ 14 | QUAT quatConj(QUAT q) { return QUAT(-q.xyz, q.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/conj.hlsl: -------------------------------------------------------------------------------- 1 | #include "type.hlsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: given a quaternion, returns its conjugate 6 | use: quatConj( Q) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATCONJ 13 | #define FNC_QUATCONJ 14 | QUAT quatConj(QUAT q) { return QUAT(-q.xyz, q.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/conj.msl: -------------------------------------------------------------------------------- 1 | #include "type.msl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: given a quaternion, returns its conjugate 6 | use: quatConj( Q) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATCONJ 13 | #define FNC_QUATCONJ 14 | QUAT quatConj(QUAT q) { return QUAT(-q.xyz, q.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/conj.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: given a quaternion, returns its conjugate 4 | use: quatConj( Q) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | fn quatConj(q: vec4f) -> vec4f { return vec4f(-q.xyz, q.w); } -------------------------------------------------------------------------------- /math/quat/div.glsl: -------------------------------------------------------------------------------- 1 | #include "type.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion division \n" 6 | use: quatDiv( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATDIV 13 | #define FNC_QUATDIV 14 | QUAT quatDiv(QUAT q, float s) { return QUAT(q.xyz / s, q.w / s); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/div.hlsl: -------------------------------------------------------------------------------- 1 | #include "type.hlsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion division \n" 6 | use: quatDiv( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATDIV 13 | #define FNC_QUATDIV 14 | QUAT quatDiv(QUAT q, float s) { return QUAT(q.xyz / s, q.w / s); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/div.msl: -------------------------------------------------------------------------------- 1 | #include "type.msl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion division \n" 6 | use: quatDiv( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATDIV 13 | #define FNC_QUATDIV 14 | QUAT quatDiv(QUAT q, float s) { return QUAT(q.xyz / s, q.w / s); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/div.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: "Quaternion division \n" 4 | use: quatDiv( a, b) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | fn quatDiv(q: vec4f, s: f32) -> vec4f { return vec4f(q.xyz / s, q.w / s); } 11 | -------------------------------------------------------------------------------- /math/quat/identity.glsl: -------------------------------------------------------------------------------- 1 | #include "type.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: returns the identity quaternion 6 | use: QUAT_IDENTITY 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef QUAT_IDENTITY 13 | #define QUAT_IDENTITY QUAT(0.0, 0.0, 0.0, 1.0) 14 | #endif -------------------------------------------------------------------------------- /math/quat/identity.hlsl: -------------------------------------------------------------------------------- 1 | #include "type.hlsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: returns the identity quaternion 6 | use: QUAT_IDENTITY 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef QUAT_IDENTITY 13 | #define QUAT_IDENTITY QUAT(0.0, 0.0, 0.0, 1.0) 14 | #endif -------------------------------------------------------------------------------- /math/quat/identity.msl: -------------------------------------------------------------------------------- 1 | #include "type.msl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: returns the identity quaternion 6 | use: QUAT_IDENTITY 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef QUAT_IDENTITY 13 | #define QUAT_IDENTITY QUAT(0.0, 0.0, 0.0, 1.0) 14 | #endif -------------------------------------------------------------------------------- /math/quat/identity.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns the identity quaternion 4 | use: QUAT_IDENTITY 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | const QUAT_IDENTITY = vec4f(0.0, 0.0, 0.0, 1.0); -------------------------------------------------------------------------------- /math/quat/inverse.wgsl: -------------------------------------------------------------------------------- 1 | #include "div.wgsl" 2 | #include "conj.wgsl" 3 | #include "lengthSq.wgsl" 4 | 5 | /* 6 | contributors: Patricio Gonzalez Vivo 7 | description: "Quaternion inverse \n" 8 | use: quatDiv( a, b) 9 | license: 10 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 11 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 12 | */ 13 | 14 | fn quatInverse(q: vec4f) -> vec4f { return quatDiv(quatConj(q), quatLengthSq(q)); } -------------------------------------------------------------------------------- /math/quat/length.glsl: -------------------------------------------------------------------------------- 1 | #include "lengthSq.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: 'Returns the length of a quaternion' 6 | use: quatLength( q) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUADLENGTH 13 | #define FNC_QUADLENGTH 14 | float quatLength(QUAT q) { return sqrt(quatLengthSq(q)); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/length.hlsl: -------------------------------------------------------------------------------- 1 | #include "lengthSq.hlsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: 'Returns the length of a quaternion' 6 | use: quatLength( q) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUADLENGTH 13 | #define FNC_QUADLENGTH 14 | float quatLength(QUAT q) { return sqrt(quatLengthSq(q)); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/length.msl: -------------------------------------------------------------------------------- 1 | #include "lengthSq.msl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: 'Returns the length of a quaternion' 6 | use: quatLength( q) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUADLENGTH 13 | #define FNC_QUADLENGTH 14 | float quatLength(QUAT q) { return sqrt(quatLengthSq(q)); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/length.wgsl: -------------------------------------------------------------------------------- 1 | #include "lengthSq.wgsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: 'Returns the length of a quaternion' 6 | use: quatLength( q) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | fn quatLength(q: vec4f) -> f32 { return sqrt(quatLengthSq(q)); } -------------------------------------------------------------------------------- /math/quat/lengthSq.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: 'Returns the squared length of a quaternion.' 4 | use: quatLengthSq( q) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | fn quatLengthSq(q: vec4f) -> f32 { return dot(q.xyz, q.xyz) + q.w * q.w; } -------------------------------------------------------------------------------- /math/quat/neg.glsl: -------------------------------------------------------------------------------- 1 | #include "type.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion negative. \n" 6 | use: quatNeg( a) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATNEG 13 | #define FNC_QUATNEG 14 | QUAT quatNeg(QUAT q) { return QUAT(-q.xyz, -q.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/neg.hlsl: -------------------------------------------------------------------------------- 1 | #include "type.hlsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion negative. \n" 6 | use: quatNeg( a) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATNEG 13 | #define FNC_QUATNEG 14 | QUAT quatNeg(QUAT q) { return QUAT(-q.xyz, -q.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/neg.msl: -------------------------------------------------------------------------------- 1 | #include "type.msl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion negative. \n" 6 | use: quatNeg( a) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATNEG 13 | #define FNC_QUATNEG 14 | QUAT quatNeg(QUAT q) { return QUAT(-q.xyz, -q.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/neg.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: "Quaternion negative. \n" 4 | use: quatNeg( a) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | fn quatNeg(q: vec4f) -> vec4f { return vec4f(-q.xyz, -q.w); } -------------------------------------------------------------------------------- /math/quat/norm.glsl: -------------------------------------------------------------------------------- 1 | #include "length.glsl" 2 | #include "div.glsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: returns a normalized quaternion 7 | use: quatNorm( Q) 8 | license: 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 10 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 11 | */ 12 | 13 | #ifndef FNC_QUATNORM 14 | #define FNC_QUATNORM 15 | QUAT quatNorm(QUAT q) { return quatDiv(q, quatLength(q)); } 16 | #endif -------------------------------------------------------------------------------- /math/quat/norm.hlsl: -------------------------------------------------------------------------------- 1 | #include "length.hlsl" 2 | #include "div.hlsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: returns a normalized quaternion 7 | use: quatNorm( Q) 8 | license: 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 10 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 11 | */ 12 | 13 | #ifndef FNC_QUATNORM 14 | #define FNC_QUATNORM 15 | QUAT quatNorm(QUAT q) { return quatDiv(q, quatLength(q)); } 16 | #endif -------------------------------------------------------------------------------- /math/quat/norm.msl: -------------------------------------------------------------------------------- 1 | #include "length.msl" 2 | #include "div.msl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: returns a normalized quaternion 7 | use: quatNorm( Q) 8 | license: 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 10 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 11 | */ 12 | 13 | #ifndef FNC_QUATNORM 14 | #define FNC_QUATNORM 15 | QUAT quatNorm(QUAT q) { return quatDiv(q, quatLength(q)); } 16 | #endif -------------------------------------------------------------------------------- /math/quat/norm.wgsl: -------------------------------------------------------------------------------- 1 | #include "length.wgsl" 2 | #include "div.wgsl" 3 | 4 | /* 5 | contributors: Patricio Gonzalez Vivo 6 | description: returns a normalized quaternion 7 | use: quatNorm( Q) 8 | license: 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 10 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 11 | */ 12 | 13 | fn quatNorm(q: vec4f) -> vec4f { return quatDiv(q, quatLength(q)); } 14 | -------------------------------------------------------------------------------- /math/quat/sub.glsl: -------------------------------------------------------------------------------- 1 | #include "type.glsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion subtraction. \n" 6 | use: quatNeg( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATNEG 13 | #define FNC_QUATNEG 14 | QUAT quatSub(QUAT a, QUAT b) { return QUAT(a.xyz - b.xyz, a.w - b.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/sub.hlsl: -------------------------------------------------------------------------------- 1 | #include "type.hlsl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion subtraction. \n" 6 | use: quatNeg( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATNEG 13 | #define FNC_QUATNEG 14 | QUAT quatSub(QUAT a, QUAT b) { return QUAT(a.xyz - b.xyz, a.w - b.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/sub.msl: -------------------------------------------------------------------------------- 1 | #include "type.msl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo 5 | description: "Quaternion subtraction. \n" 6 | use: quatNeg( a, b) 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_QUATNEG 13 | #define FNC_QUATNEG 14 | QUAT quatSub(QUAT a, QUAT b) { return QUAT(a.xyz - b.xyz, a.w - b.w); } 15 | #endif -------------------------------------------------------------------------------- /math/quat/sub.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: "Quaternion subtraction. \n" 4 | use: quatNeg( a, b) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | fn quatSub(a: vec4f, b: vec4f) -> vec4f { return vec4f(a.xyz - b.xyz, a.w - b.w); } 11 | -------------------------------------------------------------------------------- /math/quat/type.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: quaternion type 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef QUAT 10 | #define QUAT vec4 11 | #endif -------------------------------------------------------------------------------- /math/quat/type.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: quaternion type 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef QUAT 10 | #define QUAT float4 11 | #endif -------------------------------------------------------------------------------- /math/quat/type.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: quaternion type 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | #ifndef QUAT 10 | #define QUAT float4 11 | #endif 12 | -------------------------------------------------------------------------------- /math/quintic.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: quintic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn quintic(v: f32) -> f32 { return v*v*v*(v*(v*6.0-15.0)+10.0); } 7 | fn quintic2(v: vec2f) -> vec2f { return v*v*v*(v*(v*6.0-15.0)+10.0); } 8 | fn quintic3(v: vec3f) -> vec3f { return v*v*v*(v*(v*6.0-15.0)+10.0); } 9 | fn quintic4(v: vec4f) -> vec4f { return v*v*v*(v*(v*6.0-15.0)+10.0); } 10 | -------------------------------------------------------------------------------- /math/quintic.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: quintic polynomial https://iquilezles.org/articles/smoothsteps/ 4 | */ 5 | 6 | fn quintic(v: f32) -> f32 { return v*v*v*(v*(v*6.0-15.0)+10.0); } 7 | fn quintic2(v: vec2f) -> vec2f { return v*v*v*(v*(v*6.0-15.0)+10.0); } 8 | fn quintic3(v: vec3f) -> vec3f { return v*v*v*(v*(v*6.0-15.0)+10.0); } 9 | fn quintic4(v: vec4f) -> vec4f { return v*v*v*(v*(v*6.0-15.0)+10.0); } 10 | -------------------------------------------------------------------------------- /math/radians.msl: -------------------------------------------------------------------------------- 1 | #include "const.msl" 2 | 3 | /* 4 | contributors: Patricio Gonzalez Vivo, Anton Marini 5 | description: radians polyfill 6 | use: radians() 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | #ifndef FNC_RADIANS 13 | #define FNC_RADIANS 14 | inline float radians(float angle) { return angle * DEG2RAD; } 15 | #endif 16 | -------------------------------------------------------------------------------- /math/rotate2d.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 2x2 rotation matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rotate2d(radians: f32) -> mat2x2 { 10 | let c = cos(radians); 11 | let s = sin(radians); 12 | return mat2x2(c, -s, s, c); 13 | } 14 | -------------------------------------------------------------------------------- /math/rotate2d.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 2x2 rotation matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rotate2d(radians: f32) -> mat2x2 { 10 | let c = cos(radians); 11 | let s = sin(radians); 12 | return mat2x2(c, -s, s, c); 13 | } 14 | -------------------------------------------------------------------------------- /math/rotate3dX.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 3x3 rotation matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rotate3dX(r: f32) -> mat3x3 { 10 | return mat3x3( vec3f(1.0, 0.0, 0.0), 11 | vec3f(0.0, cos(r), -sin(r)), 12 | vec3f(0.0, sin(r), cos(r)) ); 13 | } -------------------------------------------------------------------------------- /math/rotate3dX.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 3x3 rotation matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rotate3dX(r: f32) -> mat3x3 { 10 | return mat3x3( vec3f(1.0, 0.0, 0.0), 11 | vec3f(0.0, cos(r), -sin(r)), 12 | vec3f(0.0, sin(r), cos(r)) ); 13 | } -------------------------------------------------------------------------------- /math/rotate3dY.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 3x3 rotation matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rotate3dY(r: f32) -> mat3x3 { 10 | return mat3x3( vec3f(cos(r), 0.0, -sin(r)), 11 | vec3f(0.0, 1.0, 0.0), 12 | vec3f(sin(r), 0.0, cos(r)) ); 13 | } -------------------------------------------------------------------------------- /math/rotate3dY.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 3x3 rotation matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rotate3dY(r: f32) -> mat3x3 { 10 | return mat3x3( vec3f(cos(r), 0.0, -sin(r)), 11 | vec3f(0.0, 1.0, 0.0), 12 | vec3f(sin(r), 0.0, cos(r)) ); 13 | } -------------------------------------------------------------------------------- /math/rotate3dZ.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 3x3 rotation matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rotate3dZ(r: f32) -> mat3x3 { 10 | return mat3x3( vec3f(cos(r), -sin(r), 0.0), 11 | vec3f(sin(r), cos(r), 0.0), 12 | vec3f(0.0, 0.0, 1.0) ); 13 | } -------------------------------------------------------------------------------- /math/rotate3dZ.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 3x3 rotation matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn rotate3dZ(r: f32) -> mat3x3 { 10 | return mat3x3( vec3f(cos(r), -sin(r), 0.0), 11 | vec3f(sin(r), cos(r), 0.0), 12 | vec3f(0.0, 0.0, 1.0) ); 13 | } -------------------------------------------------------------------------------- /math/saturate.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: clamp a value between 0 and 1 4 | use: saturation( value) 5 | examples: 6 | - https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/math_functions.frag 7 | */ 8 | 9 | #if !defined(FNC_SATURATE) && !defined(saturate) 10 | #define FNC_SATURATE 11 | #define saturate(V) clamp(V, 0.0, 1.0) 12 | #endif -------------------------------------------------------------------------------- /math/scale2d.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 2x2 scale matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn scale2d(s: vec2f) -> mat2x2 { return mat2x2(s.x, 0.0, 0.0, s.y); } 10 | -------------------------------------------------------------------------------- /math/scale2d.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 2x2 scale matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn scale2d(s: vec2f) -> mat2x2 { return mat2x2(s.x, 0.0, 0.0, s.y); } 10 | -------------------------------------------------------------------------------- /math/scale3d.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 3x3 scale matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn scale3d(s: vec3f) -> mat3x3 { 10 | return mat3x3( s.x, 0.0, 0.0, 11 | 0.0, s.y, 0.0, 12 | 0.0, 0.0, s.z ); 13 | } 14 | -------------------------------------------------------------------------------- /math/scale3d.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: returns a 3x3 scale matrix 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn scale3d(s: vec3f) -> mat3x3 { 10 | return mat3x3( s.x, 0.0, 0.0, 11 | 0.0, s.y, 0.0, 12 | 0.0, 0.0, s.z ); 13 | } 14 | -------------------------------------------------------------------------------- /math/sum.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Sum elements of a vector 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn sum(v: f32 ) -> f32 { return v; } 10 | fn sum2(v: vec2f ) -> f32 { return v.x+v.y; } 11 | fn sum3(v: vec3f ) -> f32 { return v.x+v.y+v.z; } 12 | fn sum4(v: vec4f ) -> f32 { return v.x+v.y+v.z+v.w; } 13 | 14 | -------------------------------------------------------------------------------- /math/sum.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: Sum elements of a vector 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn sum(v: f32 ) -> f32 { return v; } 10 | fn sum2(v: vec2f ) -> f32 { return v.x+v.y; } 11 | fn sum3(v: vec3f ) -> f32 { return v.x+v.y+v.z; } 12 | fn sum4(v: vec4f ) -> f32 { return v.x+v.y+v.z+v.w; } 13 | 14 | -------------------------------------------------------------------------------- /math/taylorInvSqrt.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: Fast, accurate inverse square root. 4 | */ 5 | 6 | fn taylorInvSqrt(r: f32) -> f32 { return 1.79284291400159 - 0.85373472095314 * r; } 7 | fn taylorInvSqrt2(r: vec2f) -> vec2f { return 1.79284291400159 - 0.85373472095314 * r; } 8 | fn taylorInvSqrt3(r: vec3f) -> vec3f { return 1.79284291400159 - 0.85373472095314 * r; } 9 | fn taylorInvSqrt4(r: vec4f) -> vec4f { return 1.79284291400159 - 0.85373472095314 * r; } 10 | -------------------------------------------------------------------------------- /math/taylorInvSqrt.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Stefan Gustavson, Ian McEwan] 3 | description: Fast, accurate inverse square root. 4 | */ 5 | 6 | fn taylorInvSqrt(r: f32) -> f32 { return 1.79284291400159 - 0.85373472095314 * r; } 7 | fn taylorInvSqrt2(r: vec2f) -> vec2f { return 1.79284291400159 - 0.85373472095314 * r; } 8 | fn taylorInvSqrt3(r: vec3f) -> vec3f { return 1.79284291400159 - 0.85373472095314 * r; } 9 | fn taylorInvSqrt4(r: vec4f) -> vec4f { return 1.79284291400159 - 0.85373472095314 * r; } 10 | -------------------------------------------------------------------------------- /sdf/boxSDF.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a box 4 | use: boxSDF( in pos [, in borders ] ) 5 | */ 6 | 7 | #ifndef FNC_BOXSDF 8 | #define FNC_BOXSDF 9 | 10 | float boxSDF( vec3 p ) { 11 | vec3 d = abs(p); 12 | return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)); 13 | } 14 | 15 | float boxSDF( vec3 p, vec3 b ) { 16 | vec3 d = abs(p) - b; 17 | return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)); 18 | } 19 | 20 | #endif -------------------------------------------------------------------------------- /sdf/boxSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a box 4 | use: boxSDF( in pos [, in borders ] ) 5 | */ 6 | 7 | #ifndef FNC_BOXSDF 8 | #define FNC_BOXSDF 9 | 10 | float boxSDF( float3 p ) { 11 | float3 d = abs(p); 12 | return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)); 13 | } 14 | 15 | float boxSDF( float3 p, float3 b ) { 16 | float3 d = abs(p) - b; 17 | return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)); 18 | } 19 | 20 | #endif -------------------------------------------------------------------------------- /sdf/boxSDF.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a box 4 | use: boxSDF( pos [, borders ] ) 5 | */ 6 | 7 | #ifndef FNC_BOXSDF 8 | #define FNC_BOXSDF 9 | 10 | float boxSDF( float3 p ) { 11 | float3 d = abs(p); 12 | return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)); 13 | } 14 | 15 | float boxSDF( float3 p, float3 b ) { 16 | float3 d = abs(p) - b; 17 | return min(max(d.x,max(d.y,d.z)),0.0) + length(max(d,0.0)); 18 | } 19 | 20 | #endif -------------------------------------------------------------------------------- /sdf/boxSDF.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a box 4 | 5 | */ 6 | 7 | fn boxSDF( p: vec3f, b: vec3f ) -> f32 { 8 | let d = abs(p) - b; 9 | return min(max(d.x,max(d.y,d.z)),0.0) + length(vec3f(max(d.x, 0.0), max(d.y, 0.0), max(d.z, 0.0))); 10 | } 11 | -------------------------------------------------------------------------------- /sdf/boxSDF.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a box 4 | 5 | */ 6 | 7 | fn boxSDF( p: vec3f, b: vec3f ) -> f32 { 8 | let d = abs(p) - b; 9 | return min(max(d.x,max(d.y,d.z)),0.0) + length(vec3f(max(d.x, 0.0), max(d.y, 0.0), max(d.z, 0.0))); 10 | } 11 | -------------------------------------------------------------------------------- /sdf/capsuleSDF.glsl: -------------------------------------------------------------------------------- 1 | #include "../math/saturate.glsl" 2 | /* 3 | contributors: Inigo Quiles 4 | description: generate a SDF of a capsule 5 | use: capusleSDF( in pos, in a, b, r ) 6 | */ 7 | 8 | #ifndef FNC_CAPSULESDF 9 | #define FNC_CAPSULESDF 10 | 11 | float capsuleSDF( vec3 p, vec3 a, vec3 b, float r ) { 12 | vec3 pa = p-a, ba = b-a; 13 | float h = saturate( dot(pa,ba)/dot(ba,ba) ); 14 | return length( pa - ba*h ) - r; 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /sdf/capsuleSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate a SDF of a capsule 4 | use: capusleSDF( in pos, in a, b, r ) 5 | */ 6 | 7 | #ifndef FNC_CAPSULESDF 8 | #define FNC_CAPSULESDF 9 | 10 | float capsuleSDF( float3 p, float3 a, float3 b, float r ) { 11 | float3 pa = p-a, ba = b-a; 12 | float h = saturate( dot(pa,ba)/dot(ba,ba) ); 13 | return length( pa - ba*h ) - r; 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /sdf/capsuleSDF.msl: -------------------------------------------------------------------------------- 1 | #include "../math/saturate.msl" 2 | /* 3 | contributors: Inigo Quiles 4 | description: generate a SDF of a capsule 5 | use: capusleSDF( pos, a, b, r ) 6 | */ 7 | 8 | #ifndef FNC_CAPSULESDF 9 | #define FNC_CAPSULESDF 10 | 11 | float capsuleSDF( float3 p, float3 a, float3 b, float r ) { 12 | float3 pa = p-a, ba = b-a; 13 | float h = saturate( dot(pa,ba)/dot(ba,ba) ); 14 | return length( pa - ba*h ) - r; 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /sdf/cubeSDF.glsl: -------------------------------------------------------------------------------- 1 | #include "boxSDF.glsl" 2 | 3 | /* 4 | description: generate the SDF of a cube 5 | use: cubeSDF( in pos, in size ) 6 | */ 7 | 8 | #ifndef FNC_CUBESDF 9 | #define FNC_CUBESDF 10 | float cubeSDF(vec3 p, float s) { return boxSDF(p, vec3(s)); } 11 | #endif -------------------------------------------------------------------------------- /sdf/cubeSDF.hlsl: -------------------------------------------------------------------------------- 1 | #include "boxSDF.hlsl" 2 | 3 | /* 4 | description: generate the SDF of a cube 5 | use: cubeSDF( in pos, in size ) 6 | */ 7 | 8 | #ifndef FNC_CUBESDF 9 | #define FNC_CUBESDF 10 | float cubeSDF(float3 p, float s) { return boxSDF(p, float3(s, s, s)); } 11 | #endif -------------------------------------------------------------------------------- /sdf/cubeSDF.msl: -------------------------------------------------------------------------------- 1 | #include "boxSDF.msl" 2 | 3 | /* 4 | description: generate the SDF of a cube 5 | use: cubeSDF( pos, size ) 6 | */ 7 | 8 | #ifndef FNC_CUBESDF 9 | #define FNC_CUBESDF 10 | float cubeSDF(float3 p, float s) { return boxSDF(p, float3(s)); } 11 | #endif -------------------------------------------------------------------------------- /sdf/cylinderSDF.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a cylinder 4 | 5 | */ 6 | 7 | fn cylinderSDF(p: vec3f, h: vec2f) -> f32 { 8 | let d = abs(vec2f(length(p.xz),p.y)) - h; 9 | return min(max(d.x,d.y),0.0) + length(vec2f(max(d.x, 0.0), max(d.y, 0.0))); 10 | } -------------------------------------------------------------------------------- /sdf/cylinderSDF.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a cylinder 4 | 5 | */ 6 | 7 | fn cylinderSDF(p: vec3f, h: vec2f) -> f32 { 8 | let d = abs(vec2f(length(p.xz),p.y)) - h; 9 | return min(max(d.x,d.y),0.0) + length(vec2f(max(d.x, 0.0), max(d.y, 0.0))); 10 | } -------------------------------------------------------------------------------- /sdf/ellipsoidSDF.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of an approximated ellipsoid 4 | use: ellipsoidSDF( in p, in r ) 5 | */ 6 | 7 | #ifndef FNC_ELLIPSOIDSDF 8 | #define FNC_ELLIPSOIDSDF 9 | 10 | float ellipsoidSDF( in vec3 p, in vec3 r ) { 11 | float k0 = length(p/r); 12 | float k1 = length(p/(r*r)); 13 | return k0*(k0-1.0)/k1; 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /sdf/ellipsoidSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of an approximated ellipsoid 4 | use: ellipsoidSDF( in p, in r ) 5 | */ 6 | 7 | #ifndef FNC_ELLIPSOIDSDF 8 | #define FNC_ELLIPSOIDSDF 9 | 10 | float ellipsoidSDF( in float3 p, in float3 r ) { 11 | float k0 = length(p/r); 12 | float k1 = length(p/(r*r)); 13 | return k0*(k0-1.0)/k1; 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /sdf/ellipsoidSDF.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of an approximated ellipsoid 4 | use: ellipsoidSDF( p, r ) 5 | */ 6 | 7 | #ifndef FNC_ELLIPSOIDSDF 8 | #define FNC_ELLIPSOIDSDF 9 | 10 | float ellipsoidSDF( float3 p, float3 r ) { 11 | float k0 = length(p/r); 12 | float k1 = length(p/(r*r)); 13 | return k0*(k0-1.0)/k1; 14 | } 15 | 16 | #endif -------------------------------------------------------------------------------- /sdf/hexPrismSDF.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a hexagonal prism 4 | use: hexPrismSDF( in pos, in h ) 5 | */ 6 | 7 | #ifndef FNC_HEXPRISMSDF 8 | #define FNC_HEXPRISMSDF 9 | 10 | float hexPrismSDF( vec3 p, vec2 h ) { 11 | vec3 q = abs(p); 12 | float d1 = q.z-h.y; 13 | float d2 = max((q.x*0.866025+q.y*0.5),q.y)-h.x; 14 | return length(max(vec2(d1,d2),0.0)) + min(max(d1,d2), 0.); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /sdf/hexPrismSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a hexagonal prism 4 | use: hexPrismSDF( in pos, in h ) 5 | */ 6 | 7 | #ifndef FNC_HEXPRISMSDF 8 | #define FNC_HEXPRISMSDF 9 | 10 | float hexPrismSDF( float3 p, float2 h ) { 11 | float3 q = abs(p); 12 | float d1 = q.z-h.y; 13 | float d2 = max((q.x*0.866025+q.y*0.5),q.y)-h.x; 14 | return length(max(float2(d1,d2),0.0)) + min(max(d1,d2), 0.); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /sdf/hexPrismSDF.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a hexagonal prism 4 | use: hexPrismSDF( pos, h ) 5 | */ 6 | 7 | #ifndef FNC_HEXPRISMSDF 8 | #define FNC_HEXPRISMSDF 9 | 10 | float hexPrismSDF( float3 p, float2 h ) { 11 | float3 q = abs(p); 12 | float d1 = q.z-h.y; 13 | float d2 = max((q.x*0.866025+q.y*0.5),q.y)-h.x; 14 | return length(max(float2(d1,d2),0.0)) + min(max(d1,d2), 0.); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /sdf/lineSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: Segment SDF 4 | use: lineSDF( st, A, B) 5 | */ 6 | 7 | #ifndef FNC_LINESDF 8 | #define FNC_LINESDF 9 | float lineSDF( in float2 st, in float2 a, in float2 b ) { 10 | float2 b_to_a = b - a; 11 | float2 to_a = st - a; 12 | float h = saturate(dot(to_a, b_to_a)/dot(b_to_a, b_to_a)); 13 | return length(to_a - h * b_to_a ); 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /sdf/linkSDF.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a link 4 | use: linkSDF( p, le, r1, r2 ) 5 | */ 6 | 7 | #ifndef FNC_LINKSDF 8 | #define FNC_LINKSDF 9 | float linkSDF( vec3 p, float le, float r1, float r2 ) { 10 | vec3 q = vec3( p.x, max(abs(p.y)-le,0.0), p.z ); 11 | return length(vec2(length(q.xy)-r1,q.z)) - r2; 12 | } 13 | #endif -------------------------------------------------------------------------------- /sdf/linkSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a link 4 | use: linkSDF( p, le, r1, r2 ) 5 | */ 6 | 7 | #ifndef FNC_LINKSDF 8 | #define FNC_LINKSDF 9 | float linkSDF( float3 p, float le, float r1, float r2 ) { 10 | float3 q = float3( p.x, max(abs(p.y)-le,0.0), p.z ); 11 | return length(float2(length(q.xy)-r1,q.z)) - r2; 12 | } 13 | #endif -------------------------------------------------------------------------------- /sdf/linkSDF.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a link 4 | use: linkSDF( p, le, r1, r2 ) 5 | */ 6 | 7 | #ifndef FNC_LINKSDF 8 | #define FNC_LINKSDF 9 | float linkSDF( float3 p, float le, float r1, float r2 ) { 10 | float3 q = float3( p.x, max(abs(p.y)-le,0.0), p.z ); 11 | return length(float2(length(q.xy)-r1,q.z)) - r2; 12 | } 13 | #endif -------------------------------------------------------------------------------- /sdf/opExtrude.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: extrude operation of a 2D SDFs into a 3D one 4 | use: opExtrude( in p, in sdf, in h ) 5 | */ 6 | 7 | #ifndef FNC_OPEXTRUDE 8 | #define FNC_OPEXTRUDE 9 | 10 | float opExtrude( in vec3 p, in float sdf, in float h ) { 11 | vec2 w = vec2( sdf, abs(p.z) - h ); 12 | return min(max(w.x,w.y),0.0) + length(max(w,0.0)); 13 | } 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /sdf/opExtrude.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: extrude operation of a 2D SDFs into a 3D one 4 | use: opExtrude( in p, in sdf, in h ) 5 | */ 6 | 7 | #ifndef FNC_OPEXTRUDE 8 | #define FNC_OPEXTRUDE 9 | 10 | float opExtrude( in float3 p, in float sdf, in float h ) { 11 | float2 w = float2( sdf, abs(p.z) - h ); 12 | return min(max(w.x,w.y),0.0) + length(max(w,0.0)); 13 | } 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /sdf/opExtrude.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: extrude operation of a 2D SDFs into a 3D one 4 | use: opExtrude( p, sdf, h ) 5 | */ 6 | 7 | #ifndef FNC_OPEXTRUDE 8 | #define FNC_OPEXTRUDE 9 | 10 | float opExtrude( float3 p, float sdf, float h ) { 11 | float2 w = float2( sdf, abs(p.z) - h ); 12 | return min(max(w.x,w.y),0.0) + length(max(w,0.0)); 13 | } 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /sdf/opIntersection.msl: -------------------------------------------------------------------------------- 1 | #include "../math/saturate.msl" 2 | 3 | /* 4 | contributors: Inigo Quiles 5 | description: intersection operation of two SDFs 6 | use: opIntersection( d1, d2 [, smooth_factor] ) 7 | */ 8 | 9 | #ifndef FNC_OPINTERSECTION 10 | #define FNC_OPINTERSECTION 11 | 12 | float opIntersection( float d1, float d2 ) { return max(d1,d2); } 13 | 14 | float opIntersection( float d1, float d2, float k ) { 15 | float h = saturate( 0.5 - 0.5*(d2-d1)/k ); 16 | return mix( d2, d1, h ) + k*h*(1.0-h); 17 | } 18 | 19 | #endif -------------------------------------------------------------------------------- /sdf/opOnion.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: onion operation of one SDFs 4 | use: opOnion( in d, in h ) 5 | */ 6 | 7 | #ifndef FNC_OPONION 8 | #define FNC_OPONION 9 | 10 | float opOnion( in float d, in float h ) { 11 | return abs(d)-h; 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opOnion.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: onion operation of one SDFs 4 | use: opOnion( in d, in h ) 5 | */ 6 | 7 | #ifndef FNC_OPONION 8 | #define FNC_OPONION 9 | 10 | float opOnion( in float d, in float h ) { 11 | return abs(d)-h; 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opOnion.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: onion operation of one SDFs 4 | use: opOnion( d, h ) 5 | */ 6 | 7 | #ifndef FNC_OPONION 8 | #define FNC_OPONION 9 | 10 | float opOnion( float d, float h ) { 11 | return abs(d)-h; 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opRevolve.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: revolve operation of a 2D SDFs into a 3D one 4 | use: opRevolve( in p, w ) 5 | */ 6 | 7 | #ifndef FNC_OPREVOLVE 8 | #define FNC_OPREVOLVE 9 | 10 | vec2 opRevolve( in vec3 p, float w ) { 11 | return vec2( length(p.xz) - w, p.y ); 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opRevolve.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: revolve operation of a 2D SDFs into a 3D one 4 | use: opRevolve( in p, w ) 5 | */ 6 | 7 | #ifndef FNC_OPREVOLVE 8 | #define FNC_OPREVOLVE 9 | 10 | float2 opRevolve( in float3 p, float w ) { 11 | return float2( length(p.xz) - w, p.y ); 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opRevolve.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: revolve operation of a 2D SDFs into a 3D one 4 | use: opRevolve( p, w ) 5 | */ 6 | 7 | #ifndef FNC_OPREVOLVE 8 | #define FNC_OPREVOLVE 9 | 10 | float2 opRevolve( float3 p, float w ) { 11 | return float2( length(p.xz) - w, p.y ); 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opRound.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: round SDFs 4 | use: opRound( in d, h ) 5 | */ 6 | 7 | #ifndef FNC_OPROUND 8 | #define FNC_OPROUND 9 | 10 | float opRound( in float d, in float h ) { 11 | return d - h; 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opRound.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: round SDFs 4 | use: opRound( in d, h ) 5 | */ 6 | 7 | #ifndef FNC_OPREVOLVE 8 | #define FNC_OPREVOLVE 9 | 10 | float opRound( in float d, in float h ) { 11 | return d - h; 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opRound.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: round SDFs 4 | use: opRound( d, h ) 5 | */ 6 | 7 | #ifndef FNC_OPROUND 8 | #define FNC_OPROUND 9 | 10 | float opRound( float d, float h ) { 11 | return d - h; 12 | } 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /sdf/opSubtraction.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: Subtraction operation of two SDFs 4 | use: opSubstraction( in d1, in d2 [, smooth_factor]) 5 | */ 6 | 7 | #ifndef FNC_OPSUBSTRACTION 8 | #define FNC_OPSUBSTRACTION 9 | 10 | float opSubtraction( float d1, float d2 ) { return max(-d1,d2); } 11 | 12 | float opSubtraction( float d1, float d2, float k ) { 13 | float h = saturate( 0.5 - 0.5*(d2+d1)/k ); 14 | return lerp( d2, -d1, h ) + k*h*(1.0-h); 15 | } 16 | 17 | #endif -------------------------------------------------------------------------------- /sdf/opSubtraction.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: Subtraction operation of two SDFs 4 | 5 | */ 6 | 7 | fn opSubtraction( d1: f32, d2: f32 )-> f32 { return max(-d1, d2); } -------------------------------------------------------------------------------- /sdf/opSubtraction.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: Subtraction operation of two SDFs 4 | 5 | */ 6 | 7 | fn opSubtraction( d1: f32, d2: f32 )-> f32 { return max(-d1, d2); } -------------------------------------------------------------------------------- /sdf/opUnion.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: Union operation of two SDFs 4 | 5 | */ 6 | 7 | fn opUnion( d1: f32, d2:f32 ) -> f32 { return min(d1, d2); } -------------------------------------------------------------------------------- /sdf/opUnion.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: Union operation of two SDFs 4 | 5 | */ 6 | 7 | fn opUnion( d1: f32, d2:f32 ) -> f32 { return min(d1, d2); } -------------------------------------------------------------------------------- /sdf/planeSDF.cuh: -------------------------------------------------------------------------------- 1 | #include "../math/dot.cuh" 2 | #include "../math/length.cuh" 3 | 4 | /* 5 | contributors: Inigo Quiles 6 | description: generate the SDF of a plane 7 | use: planeSDF( in pos, in h ) 8 | */ 9 | 10 | #ifndef FNC_PLANESDF 11 | #define FNC_PLANESDF 12 | 13 | inline __host__ __device__ float planeSDF(float3 p) { return p.y; } 14 | inline __host__ __device__ float planeSDF(float3 p, float3 planePoint, float3 planeNormal) { return (dot(planeNormal, p) + dot(planeNormal, planePoint)) / length(planeNormal); } 15 | 16 | #endif -------------------------------------------------------------------------------- /sdf/planeSDF.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a plane 4 | use: planeSDF( in pos, in h ) 5 | */ 6 | 7 | #ifndef FNC_PLANESDF 8 | #define FNC_PLANESDF 9 | float planeSDF( vec3 p ) { 10 | return p.y; 11 | } 12 | 13 | float planeSDF(vec3 p, vec3 planePoint, vec3 planeNormal) { 14 | return (dot(planeNormal, p) + dot(planeNormal, planePoint)) / length(planeNormal); 15 | } 16 | #endif -------------------------------------------------------------------------------- /sdf/planeSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a plane 4 | use: planeSDF( in pos, in h ) 5 | */ 6 | 7 | #ifndef FNC_PLANESDF 8 | #define FNC_PLANESDF 9 | float planeSDF( float3 p ) { 10 | return p.y; 11 | } 12 | 13 | float planeSDF(float3 p, float3 planePoint, float3 planeNormal) { 14 | return (dot(planeNormal, p) + dot(planeNormal, planePoint)) / length(planeNormal); 15 | } 16 | #endif -------------------------------------------------------------------------------- /sdf/planeSDF.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a plane 4 | use: planeSDF( pos, h ) 5 | */ 6 | 7 | #ifndef FNC_PLANESDF 8 | #define FNC_PLANESDF 9 | float planeSDF( float3 p ) { 10 | return p.y; 11 | } 12 | 13 | float planeSDF(float3 p, float3 planePoint, float3 planeNormal) { 14 | return (dot(planeNormal, p) + dot(planeNormal, planePoint)) / length(planeNormal); 15 | } 16 | #endif -------------------------------------------------------------------------------- /sdf/sphereSDF.cuh: -------------------------------------------------------------------------------- 1 | #include "../math/length.cuh" 2 | 3 | /* 4 | contributors: Inigo Quiles 5 | description: generate the SDF of a sphere 6 | use: sphereSDF( in pos[], in size] ) 7 | */ 8 | 9 | #ifndef FNC_SPHERESDF 10 | #define FNC_SPHERESDF 11 | 12 | inline __host__ __device__ float sphereSDF(float3 p) { return length(p); } 13 | inline __host__ __device__ float sphereSDF(float3 p, float s) { return sphereSDF(p) - s; } 14 | 15 | #endif -------------------------------------------------------------------------------- /sdf/sphereSDF.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a sphere 4 | use: sphereSDF( in pos[], in size] ) 5 | */ 6 | 7 | #ifndef FNC_SPHERESDF 8 | #define FNC_SPHERESDF 9 | float sphereSDF(vec3 p) { return length(p); } 10 | float sphereSDF(vec3 p, float s) { return sphereSDF(p) - s; } 11 | #endif -------------------------------------------------------------------------------- /sdf/sphereSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a sphere 4 | use: sphereSDF( in pos[], in size] ) 5 | */ 6 | 7 | #ifndef FNC_SPHERESDF 8 | #define FNC_SPHERESDF 9 | float sphereSDF(float3 p) { return length(p); } 10 | float sphereSDF(float3 p, float s) { return sphereSDF(p) - s; } 11 | #endif -------------------------------------------------------------------------------- /sdf/sphereSDF.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a sphere 4 | use: sphereSDF( pos[], size] ) 5 | */ 6 | 7 | #ifndef FNC_SPHERESDF 8 | #define FNC_SPHERESDF 9 | float sphereSDF(float3 p) { return length(p); } 10 | float sphereSDF(float3 p, float s) { return sphereSDF(p) - s; } 11 | #endif -------------------------------------------------------------------------------- /sdf/sphereSDF.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a sphere 4 | 5 | */ 6 | 7 | fn sphereSDF(p: vec3f, s: f32) -> f32 { 8 | return length(p) - s; 9 | } -------------------------------------------------------------------------------- /sdf/sphereSDF.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a sphere 4 | 5 | */ 6 | 7 | fn sphereSDF(p: vec3f, s: f32) -> f32 { 8 | return length(p) - s; 9 | } -------------------------------------------------------------------------------- /sdf/tetrahedronSDF.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a tetrahedron 4 | use: tetrahedronSDF( in pos, in h ) 5 | */ 6 | 7 | #ifndef FNC_TETRAHEDRONSDF 8 | #define FNC_TETRAHEDRONSDF 9 | float tetrahedronSDF(vec3 p, float h) { 10 | vec3 q = abs(p); 11 | 12 | float y = p.y; 13 | float d1 = q.z-max(0.,y); 14 | float d2 = max(q.x*.5 + y*.5,.0) - min(h, h+y); 15 | return length(max(vec2(d1,d2),.005)) + min(max(d1,d2), 0.0); 16 | } 17 | #endif -------------------------------------------------------------------------------- /sdf/tetrahedronSDF.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a tetrahedron 4 | use: tetrahedronSDF( in pos, in h ) 5 | */ 6 | 7 | #ifndef FNC_TETRAHEDRONSDF 8 | #define FNC_TETRAHEDRONSDF 9 | float tetrahedronSDF(float3 p, float h) { 10 | float3 q = abs(p); 11 | 12 | float y = p.y; 13 | float d1 = q.z-max(0.,y); 14 | float d2 = max(q.x*.5 + y*.5,.0) - min(h, h+y); 15 | return length(max(float2(d1,d2),.005)) + min(max(d1,d2), 0.0); 16 | } 17 | #endif -------------------------------------------------------------------------------- /sdf/tetrahedronSDF.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a tetrahedron 4 | use: tetrahedronSDF( pos, h ) 5 | */ 6 | 7 | #ifndef FNC_TETRAHEDRONSDF 8 | #define FNC_TETRAHEDRONSDF 9 | float tetrahedronSDF(float3 p, float h) { 10 | float3 q = abs(p); 11 | 12 | float y = p.y; 13 | float d1 = q.z-max(0.,y); 14 | float d2 = max(q.x*.5 + y*.5,.0) - min(h, h+y); 15 | return length(max(float2(d1,d2),.005)) + min(max(d1,d2), 0.0); 16 | } 17 | #endif -------------------------------------------------------------------------------- /sdf/torusSDF.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a torus 4 | use: torusSDF( pos, h [, ra, rb] ) 5 | */ 6 | 7 | #ifndef FNC_TORUSSDF 8 | #define FNC_TORUSSDF 9 | float torusSDF( float3 p, float2 t ) { return length( float2(length(p.xz)-t.x,p.y) )-t.y; } 10 | 11 | float torusSDF(float3 p, float2 sc, float ra, float rb) { 12 | p.x = abs(p.x); 13 | float k = (sc.y*p.x>sc.x*p.y) ? dot(p.xy,sc) : length(p.xy); 14 | return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb; 15 | } 16 | #endif -------------------------------------------------------------------------------- /sdf/torusSDF.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a torus 4 | 5 | */ 6 | 7 | fn torusSDF(p: vec3f, t: vec2f ) -> f32 { 8 | return length( vec2f(length(p.xz) - t.x, p.y) ) - t.y; 9 | } -------------------------------------------------------------------------------- /sdf/torusSDF.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Inigo Quiles 3 | description: generate the SDF of a torus 4 | 5 | */ 6 | 7 | fn torusSDF(p: vec3f, t: vec2f ) -> f32 { 8 | return length( vec2f(length(p.xz) - t.x, p.y) ) - t.y; 9 | } -------------------------------------------------------------------------------- /space/cart2polar.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: [Ivan Dianov, Kathy McGuiness] 3 | description: cartesian to polar transformation. 4 | use: cart2polar( st) 5 | */ 6 | 7 | #ifndef FNC_CART2POLAR 8 | #define FNC_CART2POLAR 9 | 10 | float2 cart2polar(float2 st) { 11 | return float2(atan2(st.y, st.x), length(st)); 12 | } 13 | 14 | float3 cart2polar( float3 st ) { 15 | float r = length(st); 16 | float theta = acos(st.z/r); 17 | float phi = atan2(st.y, st.x); 18 | return float3(r, theta, phi); 19 | } 20 | 21 | #endif -------------------------------------------------------------------------------- /space/nearest.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: sampling function to make a texture behave like GL_NEAREST 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn nearest(v: vec2f, res: vec2f) -> vec2f { 10 | let offset = 0.5 / (res - 1.0); 11 | return floor(v * res) / res + offset; 12 | } -------------------------------------------------------------------------------- /space/nearest.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: sampling function to make a texture behave like GL_NEAREST 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | 9 | fn nearest(v: vec2f, res: vec2f) -> vec2f { 10 | let offset = 0.5 / (res - 1.0); 11 | return floor(v * res) / res + offset; 12 | } -------------------------------------------------------------------------------- /space/polar2cart.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Ivan Dianov 3 | description: polar to cartesian conversion. 4 | use: polar2cart( polar) 5 | */ 6 | 7 | #ifndef FNC_POLAR2CART 8 | #define FNC_POLAR2CART 9 | float2 polar2cart(float2 polar) { return float2(cos(polar.x), sin(polar.x)) * polar.y; } 10 | #endif -------------------------------------------------------------------------------- /space/scale.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: scale a 2D space variable 4 | options: 5 | - CENTER_2D 6 | - CENTER_3D 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | fn scale(st: vec2f, s: vec2f) -> vec2f { 13 | return (st - 0.5) * s + 0.5; 14 | } -------------------------------------------------------------------------------- /space/scale.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: scale a 2D space variable 4 | options: 5 | - CENTER_2D 6 | - CENTER_3D 7 | license: 8 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 9 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 10 | */ 11 | 12 | fn scale(st: vec2f, s: vec2f) -> vec2f { 13 | return (st - 0.5) * s + 0.5; 14 | } -------------------------------------------------------------------------------- /space/tbn.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Shadi El Hajj 3 | description: Tangent-Bitangent-Normal Matrix 4 | use: mat3 tbn(vec3 t, vec3 b, vec3 n) 5 | license: MIT License (MIT) Copyright (c) 2024 Shadi El Hajj 6 | */ 7 | 8 | #ifndef FNC_TBN 9 | #define FNC_TBN 10 | 11 | mat3 tbn(vec3 t, vec3 b, vec3 n) { 12 | return mat3(t, b, n); 13 | } 14 | 15 | mat3 tbn(vec3 n, vec3 up) { 16 | vec3 t = normalize(cross(up, n)); 17 | vec3 b = cross(n, t); 18 | return tbn(t, b, n); 19 | } 20 | 21 | #endif -------------------------------------------------------------------------------- /space/translate.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Shadi El Hajj 3 | description: Add a translation component to a transform matrix 4 | use: translate(in matrix, in tranaslation) 5 | license: MIT License (MIT) Copyright (c) 2024 Shadi EL Hajj 6 | */ 7 | 8 | #ifndef FNC_TRANSLATE 9 | #define FNC_TRANSLATE 10 | 11 | mat4 translate(mat3 m, vec3 translation) { 12 | return mat4( 13 | vec4(m[0], 0.0), 14 | vec4(m[1], 0.0), 15 | vec4(m[2], 0.0), 16 | vec4(translation, 1.0) 17 | ); 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /space/unratio.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: unFix the aspect ratio 4 | use: ratio(vec2 st, vec2 st_size) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_UNRATIO 11 | #define FNC_UNRATIO 12 | vec2 unratio (in vec2 st, in vec2 s) { return vec2(st.x, st.y*(s.x/s.y)+(s.y*.5-s.x*.5)/s.y); } 13 | #endif -------------------------------------------------------------------------------- /space/unratio.msl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: unFix the aspect ratio 4 | use: ratio(float2 st, float2 st_size) 5 | license: 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 7 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 8 | */ 9 | 10 | #ifndef FNC_UNRATIO 11 | #define FNC_UNRATIO 12 | float2 unratio (float2 st, float2 s) { return float2(st.x, st.y*(s.x/s.y)+(s.y*.5-s.x*.5)/s.y); } 13 | #endif -------------------------------------------------------------------------------- /version.wesl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: LYGIA version number 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | const LYGIA_VERSION_MAJOR: u32 = 1u; 9 | const LYGIA_VERSION_MINOR: u32 = 3u; 10 | const LYGIA_VERSION_PATCH: u32 = 3u; -------------------------------------------------------------------------------- /version.wgsl: -------------------------------------------------------------------------------- 1 | /* 2 | contributors: Patricio Gonzalez Vivo 3 | description: LYGIA version number 4 | license: 5 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0 6 | - Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license 7 | */ 8 | const LYGIA_VERSION_MAJOR: u32 = 1u; 9 | const LYGIA_VERSION_MINOR: u32 = 3u; 10 | const LYGIA_VERSION_PATCH: u32 = 3u; --------------------------------------------------------------------------------