Guest User

Untitled

a guest
Jun 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. // Vertex shader
  2.  
  3. ...
  4. float dist = distance( vPos, uLightPos ) / 30.0;
  5. // Encode float over multiply bytes for higher accuracy
  6. gl_FragColor = vec4( dist, fract( dist * 100.0  ), fract( dist * 10000.0 ), 1.0 );
  7. ...
  8.  
  9. // Fragment shader
  10.  
  11. ...
  12. // Decode multiple byte float
  13. float lightDist = 0.0;
  14. lightDist += floor( lightSample.x * 100.0 ) / 100.0;
  15. lightDist += floor( lightSample.y * 100.0 ) / 10000.0;
  16. lightDist += floor( lightSample.z * 100.0 ) / 1000000.0;
  17. lightDist *= 30.0;
  18. ...
Add Comment
Please, Sign In to add comment