glowMapGeneration.fragment.fx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifdef DIFFUSE
  2. varying vec2 vUVDiffuse;
  3. uniform sampler2D diffuseSampler;
  4. #endif
  5. #ifdef OPACITY
  6. varying vec2 vUVOpacity;
  7. uniform sampler2D opacitySampler;
  8. uniform float opacityIntensity;
  9. #endif
  10. #ifdef EMISSIVE
  11. varying vec2 vUVEmissive;
  12. uniform sampler2D emissiveSampler;
  13. #endif
  14. #ifdef VERTEXALPHA
  15. varying vec4 vColor;
  16. #endif
  17. uniform vec4 glowColor;
  18. void main(void)
  19. {
  20. vec4 finalColor = glowColor;
  21. // _____________________________ Alpha Information _______________________________
  22. #ifdef DIFFUSE
  23. vec4 albedoTexture = texture2D(diffuseSampler, vUVDiffuse);
  24. #ifdef GLOW
  25. // In glow mode a is used to dim the opacity
  26. finalColor.a *= albedoTexture.a;
  27. #endif
  28. #ifdef HIGHLIGHT
  29. // While in highlight mode we only use the 3 colors
  30. finalColor.a = albedoTexture.a;
  31. #endif
  32. #endif
  33. #ifdef OPACITY
  34. vec4 opacityMap = texture2D(opacitySampler, vUVOpacity);
  35. #ifdef OPACITYRGB
  36. finalColor.a *= getLuminance(opacityMap.rgb);
  37. #else
  38. finalColor.a *= opacityMap.a;
  39. #endif
  40. finalColor.a *= opacityIntensity;
  41. #endif
  42. #ifdef VERTEXALPHA
  43. finalColor.a *= vColor.a;
  44. #endif
  45. #ifdef ALPHATEST
  46. if (finalColor.a < ALPHATESTVALUE)
  47. discard;
  48. #endif
  49. #ifdef EMISSIVE
  50. gl_FragColor = texture2D(emissiveSampler, vUVEmissive) * finalColor;
  51. #else
  52. gl_FragColor = finalColor;
  53. #endif
  54. #ifdef HIGHLIGHT
  55. // a should stay untouched from the setup in highlight mode.
  56. gl_FragColor.a = glowColor.a;
  57. #endif
  58. }