mustardplus

Shader - Noise

Feb 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. //
  2. // Simple passthrough fragment shader
  3. //
  4. varying vec2 v_vTexcoord;
  5. varying vec4 v_vColour;
  6. varying vec2 v_vPosition;
  7. uniform float u_time;
  8.  
  9. float rand (vec2 p){
  10. return fract(cos(dot(p, vec2(5.237, 6.378)))*8463.648);
  11. }
  12.  
  13. void main()
  14. {
  15. gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
  16. gl_FragColor *= vec4(vec3(rand(v_vPosition*u_time)), 1.0);
  17. }
  18.  
  19.  
  20.  
  21. //
  22. // Simple passthrough vertex shader
  23. //
  24. attribute vec3 in_Position; // (x,y,z)
  25. //attribute vec3 in_Normal; // (x,y,z) unused in this shader.
  26. attribute vec4 in_Colour; // (r,g,b,a)
  27. attribute vec2 in_TextureCoord; // (u,v)
  28.  
  29. varying vec2 v_vTexcoord;
  30. varying vec4 v_vColour;
  31. varying vec2 v_vPosition;
  32.  
  33. void main()
  34. {
  35. vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
  36. gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
  37.  
  38. v_vColour = in_Colour;
  39. v_vTexcoord = in_TextureCoord;
  40. v_vPosition = in_Position.xy;
  41. }
  42.  
  43.  
  44. // DRAW CODE
  45.  
  46. var uTime = shader_get_uniform(shdNoise, "u_time");
  47. shader_set(shdNoise);
  48. shader_set_uniform(uTime, current_time/5000);
  49. //drawstuff();
  50. shader_reset();
Add Comment
Please, Sign In to add comment