Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 120
- varying vec4 color;
- varying vec4 texcoord;
- varying vec4 lmcoord;
- attribute vec4 mc_Entity;
- uniform float frameTimeCounter;
- vec4 newpos(in vec4 orig){
- //Uniform random direction using equal-area projection
- float noisep = clamp(fract(sin(dot(orig ,vec4(12.9898f,78.233f,16.5f,0.0f))) * 43758.5453f),0.0f,1.0f)*6.2831853f;
- 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;
- float k = sqrt(1-noisez*noisez);
- vec4 dir = vec4(k*cos(noisep), k*sin(noisep), noisez, 0.0f);
- //Box-Muller method to generate normal variates
- float noise3 = clamp(fract(sin(dot(orig, vec4(12.9898f,16.5f, 78.233f,0.0f))) * 43758.5453f),0.0f,1.0f);
- float noise4 = clamp(fract(sin(dot(orig, vec4(16.6f, 16.6f,16.6f,0.0f))) * 43758.5453f),0.0f,1.0f);
- float normv = sqrt(-2.0f * log(noise3)) * sin(6.2831853f*noise4);
- float scale = clamp(normv*0.33f,-1.0f,1.0f)*1.0; //increase last number for greater effect
- return dir*scale;
- }
- void main() {
- texcoord = gl_TextureMatrix[0] * gl_MultiTexCoord0;
- vec4 fg = floor(gl_Vertex);
- vec4 ff = fract(gl_Vertex);
- float ffl = ff.x+ff.y+ff.z;
- //Trilinear filtering from nearest integer coordinates
- vec4 p1,p2,p3,p4,p5,p6,p7,p8,p12,p34,p56,p78,p1234,p5678,p12345678;
- p1 = newpos(fg);
- p2 = newpos(fg + vec4(1.0f, 0.0f, 0.0f, 0.0f));
- p3 = newpos(fg + vec4(0.0f, 1.0f, 0.0f, 0.0f));
- p4 = newpos(fg + vec4(1.0f, 1.0f, 0.0f, 0.0f));
- p5 = newpos(fg + vec4(0.0f, 0.0f, 1.0f, 0.0f));
- p6 = newpos(fg + vec4(1.0f, 0.0f, 1.0f, 0.0f));
- p7 = newpos(fg + vec4(0.0f, 1.0f, 1.0f, 0.0f));
- p8 = newpos(fg + vec4(1.0f, 1.0f, 1.0f, 0.0f));
- p12 = p1 * (1.0f-ff.x) + p2 * (ff.x);
- p34 = p3 * (1.0f-ff.x) + p4 * (ff.x);
- p56 = p5 * (1.0f-ff.x) + p6 * (ff.x);
- p78 = p7 * (1.0f-ff.x) + p8 * (ff.x);
- p1234 = p12 * (1.0f-ff.y) + p34 * (ff.y);
- p5678 = p56 * (1.0f-ff.y) + p78 * (ff.y);
- p12345678 = p1234 * (1.0f-ff.z) + p5678*(ff.z);
- vec4 position = gl_ModelViewMatrix * (gl_Vertex + p12345678);
- gl_Position = gl_ProjectionMatrix * position; //Update position of matrix
- color = gl_Color;
- lmcoord = gl_TextureMatrix[1] * gl_MultiTexCoord1;
- gl_FogFragCoord = gl_Position.z;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement