diff options
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_material.glsl')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 291 |
1 files changed, 0 insertions, 291 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 24fef4f05d8..57061ad1628 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1167,235 +1167,6 @@ float integer_noise(int n) return 0.5 * (float(nn) / 1073741824.0); } -/* ***** Jenkins Lookup3 Hash Functions ***** */ - -/* Source: http://burtleburtle.net/bob/c/lookup3.c */ - -#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k)))) - -#define mix(a, b, c) \ - { \ - a -= c; \ - a ^= rot(c, 4); \ - c += b; \ - b -= a; \ - b ^= rot(a, 6); \ - a += c; \ - c -= b; \ - c ^= rot(b, 8); \ - b += a; \ - a -= c; \ - a ^= rot(c, 16); \ - c += b; \ - b -= a; \ - b ^= rot(a, 19); \ - a += c; \ - c -= b; \ - c ^= rot(b, 4); \ - b += a; \ - } - -#define final(a, b, c) \ - { \ - c ^= b; \ - c -= rot(b, 14); \ - a ^= c; \ - a -= rot(c, 11); \ - b ^= a; \ - b -= rot(a, 25); \ - c ^= b; \ - c -= rot(b, 16); \ - a ^= c; \ - a -= rot(c, 4); \ - b ^= a; \ - b -= rot(a, 14); \ - c ^= b; \ - c -= rot(b, 24); \ - } - -uint hash_uint(uint kx) -{ - uint a, b, c; - a = b = c = 0xdeadbeefu + (1u << 2u) + 13u; - - a += kx; - final(a, b, c); - - return c; -} - -uint hash_uint2(uint kx, uint ky) -{ - uint a, b, c; - a = b = c = 0xdeadbeefu + (2u << 2u) + 13u; - - b += ky; - a += kx; - final(a, b, c); - - return c; -} - -uint hash_uint3(uint kx, uint ky, uint kz) -{ - uint a, b, c; - a = b = c = 0xdeadbeefu + (3u << 2u) + 13u; - - c += kz; - b += ky; - a += kx; - final(a, b, c); - - return c; -} - -uint hash_uint4(uint kx, uint ky, uint kz, uint kw) -{ - uint a, b, c; - a = b = c = 0xdeadbeefu + (4u << 2u) + 13u; - - a += kx; - b += ky; - c += kz; - mix(a, b, c); - - a += kw; - final(a, b, c); - - return c; -} - -#undef rot -#undef final -#undef mix - -uint hash_int(int kx) -{ - return hash_uint(uint(kx)); -} - -uint hash_int2(int kx, int ky) -{ - return hash_uint2(uint(kx), uint(ky)); -} - -uint hash_int3(int kx, int ky, int kz) -{ - return hash_uint3(uint(kx), uint(ky), uint(kz)); -} - -uint hash_int4(int kx, int ky, int kz, int kw) -{ - return hash_uint4(uint(kx), uint(ky), uint(kz), uint(kw)); -} - -/* Hashing uint or uint[234] into a float in the range [0, 1]. */ - -float hash_uint_to_float(uint kx) -{ - return float(hash_uint(kx)) / float(0xFFFFFFFFu); -} - -float hash_uint2_to_float(uint kx, uint ky) -{ - return float(hash_uint2(kx, ky)) / float(0xFFFFFFFFu); -} - -float hash_uint3_to_float(uint kx, uint ky, uint kz) -{ - return float(hash_uint3(kx, ky, kz)) / float(0xFFFFFFFFu); -} - -float hash_uint4_to_float(uint kx, uint ky, uint kz, uint kw) -{ - return float(hash_uint4(kx, ky, kz, kw)) / float(0xFFFFFFFFu); -} - -/* Hashing float or vec[234] into a float in the range [0, 1]. */ - -float hash_float_to_float(float k) -{ - return hash_uint_to_float(floatBitsToUint(k)); -} - -float hash_vec2_to_float(vec2 k) -{ - return hash_uint2_to_float(floatBitsToUint(k.x), floatBitsToUint(k.y)); -} - -float hash_vec3_to_float(vec3 k) -{ - return hash_uint3_to_float(floatBitsToUint(k.x), floatBitsToUint(k.y), floatBitsToUint(k.z)); -} - -float hash_vec4_to_float(vec4 k) -{ - return hash_uint4_to_float( - floatBitsToUint(k.x), floatBitsToUint(k.y), floatBitsToUint(k.z), floatBitsToUint(k.w)); -} - -/* Hashing vec[234] into vec[234] of components in the range [0, 1]. */ - -vec2 hash_vec2_to_vec2(vec2 k) -{ - return vec2(hash_vec2_to_float(k), hash_vec3_to_float(vec3(k, 1.0))); -} - -vec3 hash_vec3_to_vec3(vec3 k) -{ - return vec3( - hash_vec3_to_float(k), hash_vec4_to_float(vec4(k, 1.0)), hash_vec4_to_float(vec4(k, 2.0))); -} - -vec4 hash_vec4_to_vec4(vec4 k) -{ - return vec4(hash_vec4_to_float(k.xyzw), - hash_vec4_to_float(k.wxyz), - hash_vec4_to_float(k.zwxy), - hash_vec4_to_float(k.yzwx)); -} - -/* Hashing float or vec[234] into vec3 of components in range [0, 1]. */ - -vec3 hash_float_to_vec3(float k) -{ - return vec3( - hash_float_to_float(k), hash_vec2_to_float(vec2(k, 1.0)), hash_vec2_to_float(vec2(k, 2.0))); -} - -vec3 hash_vec2_to_vec3(vec2 k) -{ - return vec3( - hash_vec2_to_float(k), hash_vec3_to_float(vec3(k, 1.0)), hash_vec3_to_float(vec3(k, 2.0))); -} - -vec3 hash_vec4_to_vec3(vec4 k) -{ - return vec3(hash_vec4_to_float(k.xyzw), hash_vec4_to_float(k.zxwy), hash_vec4_to_float(k.wzyx)); -} - -/* White Noise */ - -void node_white_noise_1d(vec3 vector, float w, out float value) -{ - value = hash_float_to_float(w); -} - -void node_white_noise_2d(vec3 vector, float w, out float value) -{ - value = hash_vec2_to_float(vector.xy); -} - -void node_white_noise_3d(vec3 vector, float w, out float value) -{ - value = hash_vec3_to_float(vector); -} - -void node_white_noise_4d(vec3 vector, float w, out float value) -{ - value = hash_vec4_to_float(vec4(vector, w)); -} - /* Cell Noise */ float bits_to_01(uint bits) @@ -3022,68 +2793,6 @@ void node_tex_image_empty(vec3 co, out vec4 color, out float alpha) alpha = 0.0; } -void node_tex_magic( - vec3 co, float scale, float distortion, float depth, out vec4 color, out float fac) -{ - vec3 p = co * scale; - float x = sin((p.x + p.y + p.z) * 5.0); - float y = cos((-p.x + p.y - p.z) * 5.0); - float z = -cos((-p.x - p.y + p.z) * 5.0); - - if (depth > 0) { - x *= distortion; - y *= distortion; - z *= distortion; - y = -cos(x - y + z); - y *= distortion; - if (depth > 1) { - x = cos(x - y - z); - x *= distortion; - if (depth > 2) { - z = sin(-x - y - z); - z *= distortion; - if (depth > 3) { - x = -cos(-x + y - z); - x *= distortion; - if (depth > 4) { - y = -sin(-x + y + z); - y *= distortion; - if (depth > 5) { - y = -cos(-x + y + z); - y *= distortion; - if (depth > 6) { - x = cos(x + y + z); - x *= distortion; - if (depth > 7) { - z = sin(x + y - z); - z *= distortion; - if (depth > 8) { - x = -cos(-x - y + z); - x *= distortion; - if (depth > 9) { - y = -sin(x - y + z); - y *= distortion; - } - } - } - } - } - } - } - } - } - } - if (distortion != 0.0) { - distortion *= 2.0; - x /= distortion; - y /= distortion; - z /= distortion; - } - - color = vec4(0.5 - x, 0.5 - y, 0.5 - z, 1.0); - fac = (color.x + color.y + color.z) / 3.0; -} - float noise_fade(float t) { return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); |