Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Vertex shader
- ...
- float dist = distance( vPos, uLightPos ) / 30.0;
- // Encode float over multiply bytes for higher accuracy
- gl_FragColor = vec4( dist, fract( dist * 100.0 ), fract( dist * 10000.0 ), 1.0 );
- ...
- // Fragment shader
- ...
- // Decode multiple byte float
- float lightDist = 0.0;
- lightDist += floor( lightSample.x * 100.0 ) / 100.0;
- lightDist += floor( lightSample.y * 100.0 ) / 10000.0;
- lightDist += floor( lightSample.z * 100.0 ) / 1000000.0;
- lightDist *= 30.0;
- ...
Add Comment
Please, Sign In to add comment