sprite_local_uv.fp 762 B

1234567891011121314151617181920212223242526272829
  1. #version 140
  2. // from sprite_local_uv.vp
  3. in mediump vec2 var_texcoord0;
  4. in highp vec2 var_position_local;
  5. out vec4 out_fragColor;
  6. uniform mediump sampler2D texture_sampler;
  7. uniform fs_uniforms
  8. {
  9. mediump vec4 tint;
  10. };
  11. void main()
  12. {
  13. // Pre-multiply alpha since all runtime textures already are
  14. mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w);
  15. // sample color from sprite texture
  16. vec4 color = texture(texture_sampler, var_texcoord0.xy) * tint_pm;
  17. // mix local position with red and green color of sprite to
  18. // create a gradient across the entire sprite
  19. out_fragColor.rg = mix(color.rg, var_position_local.xy, 0.3);
  20. // use blue and alpha from the sprite
  21. out_fragColor.b = color.b;
  22. out_fragColor.a = color.a;
  23. }