23 layout (local_size_x = 64) in;
53 r =
clamp(r, -1.0, 1.0);
55 return r * (1.875 - 1.25 * r2 + 0.375 * r2 * r2);
62 return (3.1415) * log(dot(q, q) + eps.
x);
69 float m = (2.0 * 3.1415) / (dot(q, q) +
eps.x);
111 vec3 v1 = vec3(dN.
y - dN.
z, dN.
z - dN.
x, dN.
x - dN.
y);
124 vec3
v = 0.2 * a1 * v1 + 0.14 * a2 *
v2;
152 const float SKEWFACTOR = 1.0/3.0;
153 const float UNSKEWFACTOR = 1.0/6.0;
154 const float SIMPLEX_CORNER_POS = 0.5;
155 const float SIMPLEX_PYRAMID_HEIGHT = 0.70710678118654752440084436210485;
157 P *= SIMPLEX_PYRAMID_HEIGHT;
160 Pi = floor( P + dot( P,
vec3( SKEWFACTOR) ) );
161 vec3 x0 = P - Pi + dot(Pi,
vec3( UNSKEWFACTOR ) );
162 vec3 g = step(x0.yzx, x0.xyz);
164 Pi_1 =
min( g.xyz, l.zxy );
165 Pi_2 =
max( g.xyz, l.zxy );
166 vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;
167 vec3 x2 = x0 - Pi_2 + SKEWFACTOR;
168 vec3 x3 = x0 - SIMPLEX_CORNER_POS;
171 v1234_x =
vec4( x0.
x, x1.
x, x2.
x, x3.
x );
172 v1234_y =
vec4( x0.
y, x1.
y, x2.
y, x3.
y );
173 v1234_z =
vec4( x0.
z, x1.
z, x2.
z, x3.
z );
187 const vec2 OFFSET =
vec2( 50.0, 161.0 );
188 const float DOMAIN = 69.0;
189 const vec3 SOMELARGEFLOATS =
vec3( 635.298681, 682.357502, 668.926525 );
190 const vec3 ZINC =
vec3( 48.500388, 65.294118, 63.934599 );
193 gridcell.xyz = gridcell.xyz - floor(gridcell.xyz * ( 1.0 / DOMAIN )) * DOMAIN;
194 vec3 gridcell_inc1 = step( gridcell,
vec3( DOMAIN - 1.5 ) ) * ( gridcell + 1.0 );
197 vec4 P =
vec4( gridcell.xy, gridcell_inc1.xy ) + OFFSET.xyxy;
199 vec4 V1xy_V2xy = mix( P.xyxy, P.zwzw,
vec4( v1_mask.xy, v2_mask.xy ) );
200 P =
vec4( P.
x, V1xy_V2xy.xz, P.
z ) *
vec4( P.
y, V1xy_V2xy.yw, P.
w );
203 vec3 lowz_mods =
vec3( 1.0 / ( SOMELARGEFLOATS.xyz + gridcell.zzz * ZINC.xyz ) );
204 vec3 highz_mods =
vec3( 1.0 / ( SOMELARGEFLOATS.xyz + gridcell_inc1.zzz * ZINC.xyz ) );
207 v1_mask = ( v1_mask.z < 0.5 ) ? lowz_mods : highz_mods;
208 v2_mask = ( v2_mask.z < 0.5 ) ? lowz_mods : highz_mods;
211 hash_0 = fract( P *
vec4( lowz_mods.
x, v1_mask.
x, v2_mask.
x, highz_mods.
x ) );
212 hash_1 = fract( P *
vec4( lowz_mods.
y, v1_mask.
y, v2_mask.
y, highz_mods.
y ) );
213 hash_2 = fract( P *
vec4( lowz_mods.
z, v1_mask.
z, v2_mask.
z, highz_mods.
z ) );
237 vec4 norm = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 );
243 vec4 grad_results = hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z;
246 vec4 m = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;
247 m =
max(0.5 - m, 0.0);
252 vec4 temp = -6.0 * m2 * grad_results;
253 float xderiv = dot( temp, v1234_x ) + dot( m3, hash_0 );
254 float yderiv = dot( temp, v1234_y ) + dot( m3, hash_1 );
255 float zderiv = dot( temp, v1234_z ) + dot( m3, hash_2 );
257 const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;
260 return vec3(xderiv, yderiv, zderiv) * FINAL_NORMALIZATION;
uniform float particleLifetime
void FAST32_hash_3D(vec3 gridcell, vec3 v2_mask, out vec4 hash_0, out vec4 hash_1, out vec4 hash_2)
float min(float x, float y)
void Simplex3D_GetCornerVectors(vec3 P, out vec3 Pi, out vec3 Pi_1, out vec3 Pi_2, out vec4 v1234_x, out vec4 v1234_y, out vec4 v1234_z)
float clamp(float x, float min, float max)
GLint GLfloat GLfloat GLfloat v2
layout(local_size_x=64) in
vec3 SimplexPerlin3D_Deriv(vec3 P)
GLfloat GLfloat GLfloat w
float max(float x, float y)
void uniform(string name, const mat4 &v)
GLint GLint GLint GLint GLint x
GLenum GLuint GLenum GLsizei length