simple_texturing.glsl 852 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma anki vert_shader_begins
  2. attribute vec3 position;
  3. attribute vec3 normal;
  4. attribute vec2 tex_coords;
  5. varying vec2 tex_coords_v2f;
  6. varying vec3 normal_v2f;
  7. void main()
  8. {
  9. tex_coords_v2f = tex_coords;
  10. normal_v2f = gl_NormalMatrix * normal;
  11. gl_Position = gl_ModelViewProjectionMatrix * vec4(position, 1.0);
  12. }
  13. #pragma anki frag_shader_begins
  14. #pragma anki include "shaders/pack.glsl"
  15. uniform sampler2D diffuse_map, noise_map;
  16. varying vec2 tex_coords_v2f;
  17. varying vec3 normal_v2f;
  18. void main()
  19. {
  20. /*vec3 _noise = DecodeNormal( texture2D( noise_map, gl_FragCoord.xy*vec2( 1.0/R_W, 1.0/R_H ) ).rg ).rgb;
  21. _noise = _noise * 2 - 1;
  22. _noise *= 7.0;*/
  23. vec4 _texel = texture2D( diffuse_map, (gl_FragCoord.xy+(normal_v2f.xy*2))*vec2( 1.0/R_W, 1.0/R_H ) );
  24. //vec4 _texel = texture2D( diffuse_map, tex_coords_v2f ) / 2;
  25. gl_FragData[0] = _texel;
  26. }