EEVEE: Color Ramp Ease Optimisation

This patch provides an optimisation for Ease (Smoothstep) setting in the color ramp node.
This optimisation exists already for Constant and Linear modes.

Reviewed By: fclem

Differential Revision: https://developer.blender.org/D6880
This commit is contained in:
Charlie Jolly 2020-02-19 02:03:43 +01:00 committed by Clément Foucault
parent e82827bf6e
commit eef5b506d5
2 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,15 @@ void valtorgb_opti_linear(
outalpha = outcol.a;
}
void valtorgb_opti_ease(
float fac, vec2 mulbias, vec4 color1, vec4 color2, out vec4 outcol, out float outalpha)
{
fac = clamp(fac * mulbias.x + mulbias.y, 0.0, 1.0);
fac = fac * fac * (3.0 - 2.0 * fac);
outcol = mix(color1, color2, fac);
outalpha = outcol.a;
}
void valtorgb(float fac, sampler1DArray colormap, float layer, out vec4 outcol, out float outalpha)
{
outcol = texture(colormap, vec2(fac, layer));

View File

@ -94,6 +94,17 @@ static int gpu_shader_valtorgb(GPUMaterial *mat,
GPU_uniform(&mul_bias[1]),
GPU_uniform(&coba->data[0].r),
GPU_uniform(&coba->data[1].r));
case COLBAND_INTERP_EASE:
mul_bias[0] = 1.0f / (coba->data[1].pos - coba->data[0].pos);
mul_bias[1] = -mul_bias[0] * coba->data[0].pos;
return GPU_stack_link(mat,
node,
"valtorgb_opti_ease",
in,
out,
GPU_uniform(mul_bias),
GPU_uniform(&coba->data[0].r),
GPU_uniform(&coba->data[1].r));
default:
break;
}