fs_shadowmaps_packdepth_vsm.sc 447 B

1234567891011121314151617181920
  1. $input v_position
  2. /*
  3. * Copyright 2013-2014 Dario Manesku. All rights reserved.
  4. * License: http://www.opensource.org/licenses/BSD-2-Clause
  5. */
  6. #include "../common/common.sh"
  7. void main()
  8. {
  9. float depth = v_position.z/v_position.w * 0.5 + 0.5;
  10. float depthSq = depth*depth;
  11. //TODO: try this.
  12. //vec2 dxy = vec2(dFdx(depth), dFdy(depth));
  13. //depthSq += 0.25*dot(dxy, dxy);
  14. gl_FragColor = vec4(packHalfFloat(depth), packHalfFloat(depthSq));
  15. }