mirror of
https://github.com/seigler/webgl-threejs-hello
synced 2025-07-28 02:06:13 +00:00
⚡ Fast moving clouds with transparency and shadows
This commit is contained in:
parent
9dc521e39a
commit
8721b90d84
11 changed files with 88 additions and 111 deletions
16
app/js/shaders/depthShader-frag.glsl
Normal file
16
app/js/shaders/depthShader-frag.glsl
Normal file
|
@ -0,0 +1,16 @@
|
|||
uniform sampler2D texture;
|
||||
varying vec2 vUV;
|
||||
|
||||
vec4 pack_depth(const in 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);
|
||||
vec4 res = fract(depth * bit_shift);
|
||||
res -= res.xxyz * bit_mask;
|
||||
return res;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 pixel = texture2D(texture, vUV);
|
||||
if (pixel.a < 0.5) discard;
|
||||
gl_FragData[0] = pack_depth(gl_FragCoord.z);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue