__shdBulbKawaseDownWithThreshold.fsh 769 B

1234567891011121314151617181920
  1. varying vec2 v_vTexcoord;
  2. uniform vec2 u_vThreshold;
  3. uniform vec2 u_vTexel;
  4. float Luminance(vec3 color)
  5. {
  6. return dot(color, vec3(0.2126, 0.7152, 0.0722));
  7. }
  8. void main()
  9. {
  10. gl_FragColor = (4.0*texture2D(gm_BaseTexture, v_vTexcoord )
  11. + texture2D(gm_BaseTexture, v_vTexcoord + vec2( u_vTexel.x, 0.0))
  12. + texture2D(gm_BaseTexture, v_vTexcoord + vec2(-u_vTexel.x, 0.0))
  13. + texture2D(gm_BaseTexture, v_vTexcoord + vec2( 0.0, u_vTexel.y))
  14. + texture2D(gm_BaseTexture, v_vTexcoord + vec2( 0.0, -u_vTexel.y))) / 8.0;
  15. gl_FragColor.rgb *= smoothstep(u_vThreshold.x, u_vThreshold.y, Luminance(gl_FragColor.rgb));
  16. }