From 507a331f0182dd5458e823f705de644613a890b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Mon, 27 Jan 2020 19:48:31 +0100 Subject: Fix T67552 EEVEE: Vector Curves node clamps maximum input value at 1.0 --- .../nodes/shader/nodes/node_shader_curves.c | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'source/blender/nodes') diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 6292d7b5062..d20b919a7fb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -64,10 +64,44 @@ static int gpu_shader_curve_vec(GPUMaterial *mat, float *array, layer; int size; - BKE_curvemapping_table_RGBA(node->storage, &array, &size); + CurveMapping *cumap = node->storage; + + BKE_curvemapping_table_RGBA(cumap, &array, &size); GPUNodeLink *tex = GPU_color_band(mat, size, array, &layer); - return GPU_stack_link(mat, node, "curves_vec", in, out, tex, GPU_constant(&layer)); + float ext_xyz[3][4]; + float range_xyz[3]; + + for (int a = 0; a < 3; a++) { + const CurveMap *cm = &cumap->cm[a]; + ext_xyz[a][0] = cm->mintable; + ext_xyz[a][2] = cm->maxtable; + range_xyz[a] = 1.0f / max_ff(1e-8f, cm->maxtable - cm->mintable); + /* Compute extrapolation gradients. */ + if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE) != 0) { + ext_xyz[a][1] = (cm->ext_in[0] != 0.0f) ? (cm->ext_in[1] / (cm->ext_in[0] * range_xyz[a])) : + 1e8f; + ext_xyz[a][3] = (cm->ext_out[0] != 0.0f) ? + (cm->ext_out[1] / (cm->ext_out[0] * range_xyz[a])) : + 1e8f; + } + else { + ext_xyz[a][1] = 0.0f; + ext_xyz[a][3] = 0.0f; + } + } + + return GPU_stack_link(mat, + node, + "curves_vec", + in, + out, + tex, + GPU_constant(&layer), + GPU_uniform(range_xyz), + GPU_uniform(ext_xyz[0]), + GPU_uniform(ext_xyz[1]), + GPU_uniform(ext_xyz[2])); } void register_node_type_sh_curve_vec(void) -- cgit v1.2.3