parallax.frag 471 B

1234567891011121314151617181920
  1. uniform sampler2D basetex;
  2. uniform sampler2D bumptex;
  3. varying vec3 eyeVec;
  4. void main()
  5. {
  6. vec2 texUV, srcUV = gl_TexCoord[0].xy;
  7. float height = texture2D(bumptex, srcUV).r;
  8. float v = height * 0.04 - 0.02;
  9. vec3 eye = normalize(eyeVec);
  10. texUV = srcUV + (eye.xy * v);
  11. vec3 rgb = texture2D(basetex, texUV).rgb;
  12. // output final color
  13. gl_FragColor = vec4(vec3(rgb), 1.0);
  14. // gl_FragColor = vec4(vec3(rgb)*height, 1.0);
  15. }