Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //vertex fragment
- #ifdef GL_ES
- precision mediump float;
- #endif
- uniform float invFar; // actually this is inverse of distance from camera to frustum corner
- const vec4 bitShift = vec4( 256.0, 1.0, 256.0, 1.0);
- const vec4 bitMask = vec4(0.0, 1.0 / 256.0, 0.0, 1.0 / 256.0);
- varying vec3 pos;
- void main() {
- float depth = length(pos) * invFar;
- float moment2 = depth * depth;
- vec4 comp = fract(vec4depth, depth, moment2, moment2) * bitShift);
- gl_FragColor = comp - comp.xxzz * bitMask; //this give more precission
- }
- //vertex
- attribute vec4 a_position;
- uniform mat4 u_projectionViewMatrix;
- uniform vec3 lightPos;
- varying vec3 pos;
- void main()
- {
- pos = (a_position.rgb - lightPos);
- gl_Position = u_projectionViewMatrix * a_position;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement