Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-08-10 16:13:39 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-08-10 17:16:35 +0300
commitbf6a22ed6f6bbe7db3e7796e83d32e071aae93cc (patch)
treeaefa8c3e594d9d9fd761e12c0a825f199853b596 /source/blender/nodes
parentc9bd61b37240ad000ae7ac4d49801e4afe3565b0 (diff)
GPUMaterial: Group all colorband texture together
This lower the use of texture samplers slots and let users use more real textures in their shaders. This patch also make the ramp texture 16 bit floating point. Meaning you can now use value greater than one in your color ramps. With the limit of 128 colorband per shader (a color band being either a color ramp, a wavelength node or a curve node (and maybe wavelength node in the future)). Only drawback with the current implementation is that it does not remove colorband from pruned GPUNodes but it shouldn't really matter in practice. This should fix T56010
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_blackbody.c7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_curves.c12
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_valToRgb.c5
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_volume_principled.c14
4 files changed, 23 insertions, 15 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.c b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
index 76291df41bc..e57f5e0d6cf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_blackbody.c
+++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.c
@@ -40,12 +40,15 @@ static bNodeSocketTemplate sh_node_blackbody_out[] = {
static int node_shader_gpu_blackbody(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- const int size = 256;
+ const int size = CM_TABLE + 1;
float *data = MEM_mallocN(sizeof(float) * size * 4, "blackbody texture");
blackbody_temperature_to_rgb_table(data, size, 965.0f, 12000.0f);
- return GPU_stack_link(mat, node, "node_blackbody", in, out, GPU_texture(size, data));
+ float layer;
+ GPUNodeLink *ramp_texture = GPU_texture_ramp(mat, size, data, &layer);
+
+ return GPU_stack_link(mat, node, "node_blackbody", in, out, ramp_texture, GPU_uniform(&layer));
}
/* node type definition */
diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c
index d5932ff233a..21bdc3cd0d8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_curves.c
+++ b/source/blender/nodes/shader/nodes/node_shader_curves.c
@@ -62,11 +62,13 @@ static void node_shader_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node)
static int gpu_shader_curve_vec(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- float *array;
+ float *array, layer;
int size;
curvemapping_table_RGBA(node->storage, &array, &size);
- return GPU_stack_link(mat, node, "curves_vec", in, out, GPU_texture(size, array));
+ GPUNodeLink *tex = GPU_texture_ramp(mat, size, array, &layer);
+
+ return GPU_stack_link(mat, node, "curves_vec", in, out, tex, GPU_uniform(&layer));
}
void register_node_type_sh_curve_vec(void)
@@ -119,12 +121,14 @@ static void node_shader_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node)
static int gpu_shader_curve_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- float *array;
+ float *array, layer;
int size;
curvemapping_initialize(node->storage);
curvemapping_table_RGBA(node->storage, &array, &size);
- return GPU_stack_link(mat, node, "curves_rgb", in, out, GPU_texture(size, array));
+ GPUNodeLink *tex = GPU_texture_ramp(mat, size, array, &layer);
+
+ return GPU_stack_link(mat, node, "curves_rgb", in, out, tex, GPU_uniform(&layer));
}
void register_node_type_sh_curve_rgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
index b6581cb18cb..00940b5acaf 100644
--- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c
@@ -65,11 +65,12 @@ static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node)
static int gpu_shader_valtorgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out)
{
- float *array;
+ float *array, layer;
int size;
BKE_colorband_evaluate_table_rgba(node->storage, &array, &size);
- return GPU_stack_link(mat, node, "valtorgb", in, out, GPU_texture(size, array));
+ GPUNodeLink *tex = GPU_texture_ramp(mat, size, array, &layer);
+ return GPU_stack_link(mat, node, "valtorgb", in, out, tex, GPU_uniform(&layer));
}
void register_node_type_sh_valtorgb(void)
diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
index a88a7ebb21a..c946c42f9af 100644
--- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.c
@@ -132,19 +132,19 @@ static int node_shader_gpu_volume_principled(GPUMaterial *mat, bNode *node, bNod
}
/* Create blackbody spectrum. */
- GPUNodeLink *spectrummap;
+ const int size = CM_TABLE + 1;
+ float *data, layer;
if (use_blackbody) {
- const int size = 256;
- float *data = MEM_mallocN(sizeof(float) * size * 4, "blackbody texture");
+ data = MEM_mallocN(sizeof(float) * size * 4, "blackbody texture");
blackbody_temperature_to_rgb_table(data, size, 965.0f, 12000.0f);
- spectrummap = GPU_texture(size, data);
}
else {
- float *data = MEM_callocN(sizeof(float) * 4, "blackbody black");
- spectrummap = GPU_texture(1, data);
+ data = MEM_callocN(sizeof(float) * size * 4, "blackbody black");
}
+ GPUNodeLink *spectrummap = GPU_texture_ramp(mat, size, data, &layer);
- return GPU_stack_link(mat, node, "node_volume_principled", in, out, density, color, temperature, spectrummap);
+ return GPU_stack_link(mat, node, "node_volume_principled", in, out, density, color, temperature, spectrummap,
+ GPU_uniform(&layer));
}
/* node type definition */