Prepass.frag 918 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "Uniforms.frag"
  2. #include "Samplers.frag"
  3. #ifdef HWDEPTH
  4. varying vec2 vTexCoord;
  5. #else
  6. varying vec3 vTexCoord;
  7. #endif
  8. varying vec3 vNormal;
  9. #ifdef NORMALMAP
  10. varying vec3 vTangent;
  11. varying vec3 vBitangent;
  12. #endif
  13. void main()
  14. {
  15. #ifdef ALPHAMASK
  16. vec4 diffInput = texture2D(sDiffMap, vTexCoord.xy);
  17. if (diffInput.a < 0.5)
  18. discard;
  19. #endif
  20. #ifdef NORMALMAP
  21. mat3 tbn = mat3(vTangent, vBitangent, vNormal);
  22. vec3 normal = tbn * DecodeNormal(texture2D(sNormalMap, vTexCoord.xy));
  23. #else
  24. vec3 normal = vNormal;
  25. #endif
  26. float specPower = cMatSpecColor.a / 255.0;
  27. #ifdef HWDEPTH
  28. gl_FragColor = vec4(normal * 0.5 + 0.5, specPower);
  29. #else
  30. gl_FragData[0] = vec4(normal * 0.5 + 0.5, specPower);
  31. gl_FragData[1] = vec4(EncodeDepth(vTexCoord.z), 0.0);
  32. #endif
  33. }