UNPKG

@animech-public/playcanvas

Version:
16 lines (13 loc) 580 B
var packDepthPS = /* glsl */` // Packing a float in GLSL with multiplication and mod // http://blog.gradientstudios.com/2012/08/23/shadow-map-improvement vec4 packFloat(float depth) { const vec4 bit_shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0); const vec4 bit_mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); // combination of mod and multiplication and division works better vec4 res = mod(depth * bit_shift * vec4(255), vec4(256) ) / vec4(255); res -= res.xxyz * bit_mask; return res; } `; export { packDepthPS as default };