Advertisement
Guest User

Untitled

a guest
Apr 1st, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. varying vec4 color;
  2. varying vec4 texcoord;
  3. varying vec4 lmcoord;
  4.  
  5. attribute vec4 mc_Entity;
  6.  
  7. //Calculate three normally distributed values for random vector using Box-Muller method
  8. vec4 newpos(in vec4 orig){
  9. float distortionScale = 0.35f; //change this when needed -- 0.0f - 1.0f is the sensible range
  10. float n1, n2, n3;
  11. vec4 noise = fract(sin(mat4(2.0f, 3.0f, 5.0f, 7.0f, 11.0f, 13.0f, 17.0f, 19.0f, 23.0f, 29.0f, 31.0f, 37.0f, 41.0f, 43.0f, 47.0f, 53.0f)*orig)*43758.5453f);
  12. n1 = sqrt(-2.0f * log(noise.x)) * sin(6.2831853f*noise.y);
  13. n2 = sqrt(-2.0f * log(noise.x)) * cos(6.2831853f*noise.y);
  14. n3 = sqrt(-2.0f * log(noise.z)) * sin(6.2831853f*noise.w);
  15. return clamp(0.16666666f*vec4(n1, n2, n3, 0.0f),-0.5f, 0.5f)*distortionScale;
  16. }
  17.  
  18. void main() {
  19.  
  20. //Calculate offset with trilinear interpolation from full block corners.
  21. vec4 fg,ff,p1,p2,p3,p4,p5,p6,p7,p8,p12,p34,p56,p78,p1234,p5678,offset;
  22. if (mc_Entity.x == 0.0) offset = vec4(0.0f); //Don't offset chests
  23. else {
  24. fg = floor(gl_Vertex);
  25. ff = fract(gl_Vertex);
  26. p1 = newpos(fg);
  27. p2 = newpos(fg + vec4(1.0f, 0.0f, 0.0f, 0.0f));
  28. p3 = newpos(fg + vec4(0.0f, 1.0f, 0.0f, 0.0f));
  29. p4 = newpos(fg + vec4(1.0f, 1.0f, 0.0f, 0.0f));
  30. p5 = newpos(fg + vec4(0.0f, 0.0f, 1.0f, 0.0f));
  31. p6 = newpos(fg + vec4(1.0f, 0.0f, 1.0f, 0.0f));
  32. p7 = newpos(fg + vec4(0.0f, 1.0f, 1.0f, 0.0f));
  33. p8 = newpos(fg + vec4(1.0f, 1.0f, 1.0f, 0.0f));
  34. p12 = p1 + (p2-p1) * ff.x;
  35. p34 = p3 + (p4-p3) * ff.x;
  36. p56 = p5 + (p6-p5) * ff.x;
  37. p78 = p7 + (p8-p7) * ff.x;
  38. p1234 = p12 + (p34-p12) * ff.y;
  39. p5678 = p56 + (p78-p56) * ff.y;
  40. offset = p1234 + (p5678-p1234) * ff.z;
  41. }
  42. vec4 position = gl_ModelViewMatrix * (gl_Vertex + offset);
  43. gl_Position = gl_ProjectionMatrix * position; //Update position of matrix
  44.  
  45. texcoord = gl_TextureMatrix[0] * gl_MultiTexCoord0;
  46. color = gl_Color;
  47. lmcoord = gl_TextureMatrix[1] * gl_MultiTexCoord1;
  48. gl_FogFragCoord = gl_Position.z;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement