You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12_texture_to_screen.lolfx 756 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. [vert.glsl]
  2. #version 130
  3. in vec2 in_position;
  4. out vec2 pass_position;
  5. void main()
  6. {
  7. pass_position = in_position;
  8. gl_Position = vec4(in_position, 0.0, 1.0);
  9. }
  10. [frag.glsl]
  11. #version 130
  12. #if defined GL_ES
  13. precision highp float;
  14. #endif
  15. in vec2 pass_position;
  16. uniform sampler2D u_texture;
  17. vec3 rand_color(float t)
  18. {
  19. return vec3(0.5 + 0.5 * sin(t * 19.0 + 17.0),
  20. 0.5 + 0.5 * sin(t * 24.0 + 23.0),
  21. 0.5 + 0.5 * sin(t * 37.0 + 12.0));
  22. }
  23. void main(void)
  24. {
  25. vec2 texcoords = pass_position * 0.5 + vec2(0.5, 0.5);
  26. vec4 src_color = texture2D(u_texture, texcoords);
  27. float newg = src_color.z;
  28. float newb = 0.0;
  29. if (newg > 0.0)
  30. newb = 1.0;
  31. gl_FragColor = vec4(rand_color(newg), 1.0);
  32. }