Advertisement
thecplusplusguy

GLSL tutorial 3 - vertex and fragment shader

Jul 31st, 2012
1,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. //http://www.youtube.com/user/thecplusplusguy
  2. //vertexshader, create a file for it as vertex.vs
  3. #version 120
  4. uniform vec3 color;
  5. varying vec3 color2;    //out
  6. attribute vec3 atr; //in
  7. varying vec2 texcoord;
  8.  
  9. void main()
  10. {
  11.     gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex;
  12.     color2=atr;
  13.     texcoord=gl_MultiTexCoord0.xy;
  14. }
  15.  
  16. //fragment shader, create a file for it named fragment.frag
  17. #version 120
  18. uniform sampler2D img;
  19. uniform sampler2D img2;
  20. uniform vec3 color;
  21. varying vec3 color2;    //in
  22. varying vec2 texcoord;
  23.  
  24. void main()
  25. {
  26.     vec4 texcolor=texture2D(img,texcoord);
  27.     vec4 texcolor2=texture2D(img2,texcoord);
  28.     gl_FragColor=texcolor2*0.5 + texcolor*0.5;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement