diff options
author | Patrick Bender <ichbinkeinreh> | 2020-02-06 04:53:53 +0300 |
---|---|---|
committer | mano-wii <germano.costa@ig.com.br> | 2020-02-06 04:57:38 +0300 |
commit | b4f8e3f01bc91c98cc8b37f9a6f4ab8378e807eb (patch) | |
tree | 4c0c5a60f48bc18ad3d737b18c53a71e9853e0db | |
parent | 092deb88b074848c5b252ba6b7bb2d9890c8a2cc (diff) |
Fix T69776: Error with complex Eevee noise texture in some drivers
Apparently the compiled shader bump into some register limit and
the compiler instead of giving an error, does something incorrectly.
Differential Revision: https://developer.blender.org/D6759
3 files changed, 25 insertions, 30 deletions
diff --git a/source/blender/gpu/intern/gpu_material_library.h b/source/blender/gpu/intern/gpu_material_library.h index 08c36e24920..0d697a31c35 100644 --- a/source/blender/gpu/intern/gpu_material_library.h +++ b/source/blender/gpu/intern/gpu_material_library.h @@ -139,9 +139,7 @@ static GPUMaterialLibrary gpu_shader_material_hash_library = { static GPUMaterialLibrary gpu_shader_material_noise_library = { .code = datatoc_gpu_shader_material_noise_glsl, - .dependencies = {&gpu_shader_material_math_util_library, - &gpu_shader_material_hash_library, - NULL}, + .dependencies = {&gpu_shader_material_hash_library, NULL}, }; static GPUMaterialLibrary gpu_shader_material_fractal_noise_library = { diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl index e8487fb5d42..5c1ee05f094 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_math_util.glsl @@ -48,13 +48,6 @@ int quick_floor(float x) return int(x) - ((x < 0) ? 1 : 0); } -float floorfrac(float x, out int i) -{ - float x_floor = floor(x); - i = int(x_floor); - return x - x_floor; -} - /* Vector Math */ vec2 safe_divide(vec2 a, vec2 b) diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl index c184c61c269..cc65b1eb57c 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_noise.glsl @@ -1,3 +1,7 @@ +/* clang-format off */ +#define FLOORFRAC(x, x_int, x_fract) { float x_floor = floor(x); x_int = int(x_floor); x_fract = x - x_floor; } +/* clang-format on */ + /* Bilinear Interpolation: * * v2 v3 @@ -124,7 +128,10 @@ float noise_grad(uint hash, float x, float y, float z, float w) float noise_perlin(float x) { int X; - float fx = floorfrac(x, X); + float fx; + + FLOORFRAC(x, X, fx); + float u = fade(fx); float r = mix(noise_grad(hash_int(X), fx), noise_grad(hash_int(X + 1), fx - 1.0), u); @@ -134,11 +141,11 @@ float noise_perlin(float x) float noise_perlin(vec2 vec) { - int X; - int Y; + int X, Y; + float fx, fy; - float fx = floorfrac(vec.x, X); - float fy = floorfrac(vec.y, Y); + FLOORFRAC(vec.x, X, fx); + FLOORFRAC(vec.y, Y, fy); float u = fade(fx); float v = fade(fy); @@ -155,13 +162,12 @@ float noise_perlin(vec2 vec) float noise_perlin(vec3 vec) { - int X; - int Y; - int Z; + int X, Y, Z; + float fx, fy, fz; - float fx = floorfrac(vec.x, X); - float fy = floorfrac(vec.y, Y); - float fz = floorfrac(vec.z, Z); + FLOORFRAC(vec.x, X, fx); + FLOORFRAC(vec.y, Y, fy); + FLOORFRAC(vec.z, Z, fz); float u = fade(fx); float v = fade(fy); @@ -184,15 +190,13 @@ float noise_perlin(vec3 vec) float noise_perlin(vec4 vec) { - int X; - int Y; - int Z; - int W; - - float fx = floorfrac(vec.x, X); - float fy = floorfrac(vec.y, Y); - float fz = floorfrac(vec.z, Z); - float fw = floorfrac(vec.w, W); + int X, Y, Z, W; + float fx, fy, fz, fw; + + FLOORFRAC(vec.x, X, fx); + FLOORFRAC(vec.y, Y, fy); + FLOORFRAC(vec.z, Z, fz); + FLOORFRAC(vec.w, W, fw); float u = fade(fx); float v = fade(fy); |