Advertisement
Guest User

normal-mapper.jxs

a guest
Jun 26th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. <jittershader name="normalmapper">
  2.     <param name="tex0" type="int" default="0" />
  3.     <param name="size" type="vec2" default="1.0 0.0" />
  4.     <language name="glsl" version="1.50">
  5.         <bind param="scale" program="fp" />
  6.         <bind param="tex0" program="fp" />
  7.         <bind param="size" program="fp" />
  8.         <program name="vp" type="vertex" source="sh.passthrudim.vp.glsl" />
  9.         <program name="fp" type="fragment" >
  10. <![CDATA[
  11. uniform sampler2D tex0;
  12. uniform vec2 size;
  13.  
  14. varying vec2 texcoord0;
  15.  
  16. const ivec3 off = ivec3(-1,0,1);
  17.  
  18. void main(void)
  19. {
  20.     vec4 wave = texture2D(tex0,texcoord0);
  21.  
  22.     float s11 = wave.x;
  23.     float s01 = textureOffset(tex0, texcoord0, off.xy).x;
  24.     float s21 = textureOffset(tex0, texcoord0, off.zy).x;
  25.     float s10 = textureOffset(tex0, texcoord0, off.yx).x;
  26.     float s12 = textureOffset(tex0, texcoord0, off.yz).x;
  27.     vec3  va  = normalize(vec3(size.xy,s21-s01));
  28.     vec3  vb  = normalize(vec3(size.yx,s12-s10));
  29.     vec4 bump = vec4(cross(va,vb), s11);
  30.  
  31.     gl_FragColor = bump;
  32. }
  33.  
  34. ]]>
  35.         </program>
  36.     </language>
  37. </jittershader>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement