diff options
author | Charlie Jolly <charlie> | 2018-09-10 20:39:48 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-09-10 20:48:14 +0300 |
commit | 89295c7f6b47ff3c2837a884c2377f26c1f959d0 (patch) | |
tree | 197e23a74bd6e552da334e254a060a4a7c64a6fd /source/blender/gpu | |
parent | 86aa621f4b2751fc1eae2b0a4e6f31c99f5f9665 (diff) |
Eeevee: update to match recent voronoi GLSL features for Cycles.
Differential Revision: https://developer.blender.org/D3680
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 55 |
1 files changed, 51 insertions, 4 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index f3dea3afaf4..5ea888ca774 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2577,7 +2577,7 @@ void node_tex_sky(vec3 co, out vec4 color) color = vec4(1.0); } -void node_tex_voronoi(vec3 co, float scale, float exponent, float coloring, out vec4 color, out float fac) +void node_tex_voronoi(vec3 co, float scale, float exponent, float coloring, float metric, float feature, out vec4 color, out float fac) { vec3 p = co * scale; int xx, yy, zz, xi, yi, zi; @@ -2599,7 +2599,21 @@ void node_tex_voronoi(vec3 co, float scale, float exponent, float coloring, out vec3 ip = vec3(xx, yy, zz); vec3 vp = cellnoise_color(ip); vec3 pd = p - (vp + ip); - float d = dot(pd, pd); + + float d = 0.0; + if (metric == 0) { /* SHD_VORONOI_DISTANCE 0 */ + d = dot(pd, pd); + } + else if (metric == 1) { /* SHD_VORONOI_MANHATTAN 1 */ + d = abs(pd[0]) + abs(pd[1]) + abs(pd[2]); + } + else if (metric == 2) { /* SHD_VORONOI_CHEBYCHEV 2 */ + d = max(abs(pd[0]), max(abs(pd[1]), abs(pd[2]))); + } + else if (metric == 3) { /* SHD_VORONOI_MINKOWSKI 3 */ + d = pow(pow(abs(pd[0]), exponent) + pow(abs(pd[1]), exponent) + pow(abs(pd[2]), exponent), 1.0/exponent); + } + vp += vec3(xx, yy, zz); if (d < da[0]) { da[3] = da[2]; @@ -2636,11 +2650,44 @@ void node_tex_voronoi(vec3 co, float scale, float exponent, float coloring, out } if (coloring == 0.0) { - fac = abs(da[0]); + /* Intensity output */ + if (feature == 0) { /* F1 */ + fac = abs(da[0]); + } + else if (feature == 1) { /* F2 */ + fac = abs(da[1]); + } + else if (feature == 2) { /* F3 */ + fac = abs(da[2]); + } + else if (feature == 3) { /* F4 */ + fac = abs(da[3]); + } + else if (feature == 4) { /* F2F1 */ + fac = abs(da[1] - da[0]); + } color = vec4(fac, fac, fac, 1); } else { - color = vec4(cellnoise_color(pa[0]), 1); + /* Color output */ + vec3 col = vec3(fac, fac, fac); + if (feature == 0) { /* F1 */ + col = pa[0]; + } + else if (feature == 1) { /* F2 */ + col = pa[1]; + } + else if (feature == 2) { /* F3 */ + col = pa[2]; + } + else if (feature == 3) { /* F4 */ + col = pa[3]; + } + else if (feature == 4) { /* F2F1 */ + col = abs(pa[1] - pa[0]); + } + + color = vec4(cellnoise_color(col), 1); fac = (color.x + color.y + color.z) * (1.0 / 3.0); } } |