Advertisement
Guest User

Untitled

a guest
Mar 31st, 2014
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #version 120
  2.  
  3. varying vec4 color;
  4. varying vec4 texcoord;
  5. varying vec4 lmcoord;
  6.  
  7. attribute vec4 mc_Entity;
  8.  
  9. uniform float frameTimeCounter;
  10.  
  11. vec4 newpos(in vec4 orig){
  12. //Uniform random direction using equal-area projection
  13. float noisep = clamp(fract(sin(dot(orig ,vec4(12.9898f,78.233f,16.5f,0.0f))) * 43758.5453f),0.0f,1.0f)*6.2831853f;
  14. float noisez = clamp(fract(sin(dot(orig, vec4(16.5f, 12.9898f,78.233f,0.0f))) * 43758.5453f),0.0f,1.0f)*2.0f-1.0f;
  15. float k = sqrt(1-noisez*noisez);
  16. vec4 dir = vec4(k*cos(noisep), k*sin(noisep), noisez, 0.0f);
  17.  
  18. //Box-Muller method to generate normal variates
  19. float noise3 = clamp(fract(sin(dot(orig, vec4(12.9898f,16.5f, 78.233f,0.0f))) * 43758.5453f),0.0f,1.0f);
  20. float noise4 = clamp(fract(sin(dot(orig, vec4(16.6f, 16.6f,16.6f,0.0f))) * 43758.5453f),0.0f,1.0f);
  21. float normv = sqrt(-2.0f * log(noise3)) * sin(6.2831853f*noise4);
  22. float scale = clamp(normv*0.33f,-1.0f,1.0f)*1.0; //increase last number for greater effect
  23. return dir*scale;
  24. }
  25.  
  26. void main() {
  27.  
  28. texcoord = gl_TextureMatrix[0] * gl_MultiTexCoord0;
  29.  
  30. vec4 fg = floor(gl_Vertex);
  31. vec4 ff = fract(gl_Vertex);
  32. float ffl = ff.x+ff.y+ff.z;
  33.  
  34. //Trilinear filtering from nearest integer coordinates
  35. vec4 p1,p2,p3,p4,p5,p6,p7,p8,p12,p34,p56,p78,p1234,p5678,p12345678;
  36. p1 = newpos(fg);
  37. p2 = newpos(fg + vec4(1.0f, 0.0f, 0.0f, 0.0f));
  38. p3 = newpos(fg + vec4(0.0f, 1.0f, 0.0f, 0.0f));
  39. p4 = newpos(fg + vec4(1.0f, 1.0f, 0.0f, 0.0f));
  40. p5 = newpos(fg + vec4(0.0f, 0.0f, 1.0f, 0.0f));
  41. p6 = newpos(fg + vec4(1.0f, 0.0f, 1.0f, 0.0f));
  42. p7 = newpos(fg + vec4(0.0f, 1.0f, 1.0f, 0.0f));
  43. p8 = newpos(fg + vec4(1.0f, 1.0f, 1.0f, 0.0f));
  44. p12 = p1 * (1.0f-ff.x) + p2 * (ff.x);
  45. p34 = p3 * (1.0f-ff.x) + p4 * (ff.x);
  46. p56 = p5 * (1.0f-ff.x) + p6 * (ff.x);
  47. p78 = p7 * (1.0f-ff.x) + p8 * (ff.x);
  48. p1234 = p12 * (1.0f-ff.y) + p34 * (ff.y);
  49. p5678 = p56 * (1.0f-ff.y) + p78 * (ff.y);
  50. p12345678 = p1234 * (1.0f-ff.z) + p5678*(ff.z);
  51.  
  52. vec4 position = gl_ModelViewMatrix * (gl_Vertex + p12345678);
  53.  
  54. gl_Position = gl_ProjectionMatrix * position; //Update position of matrix
  55.  
  56. color = gl_Color;
  57.  
  58. lmcoord = gl_TextureMatrix[1] * gl_MultiTexCoord1;
  59.  
  60. gl_FogFragCoord = gl_Position.z;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement