diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-08-01 20:37:18 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-08-01 23:08:36 +0300 |
commit | e8dd5e5cc6b7366c36f19035f94864a1b320cb83 (patch) | |
tree | 9d8eb3e799872aaccc69883c0b0a7b49e4cacafc /source/blender/nodes | |
parent | ad64cb63448d69ec1667bfa2e4941dfb996841dd (diff) |
GPUMaterial: Make Mapping node use UBO storage
This means tweaking parameter is now interactive and does not need to
recompile the shaders.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/shader/node_shader_util.c | 19 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_mapping.c | 19 |
2 files changed, 24 insertions, 14 deletions
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 9190f0d53cd..63c1cac566d 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -253,13 +253,18 @@ void node_shader_gpu_tex_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in float domax = (texmap->flag & TEXMAP_CLIP_MAX) != 0; if (domin || domax || !(texmap->flag & TEXMAP_UNIT_MATRIX)) { - GPUNodeLink *tmat = GPU_uniform((float *)texmap->mat); - GPUNodeLink *tmin = GPU_uniform(texmap->min); - GPUNodeLink *tmax = GPU_uniform(texmap->max); - GPUNodeLink *tdomin = GPU_uniform(&domin); - GPUNodeLink *tdomax = GPU_uniform(&domax); - - GPU_link(mat, "mapping", in[0].link, tmat, tmin, tmax, tdomin, tdomax, &in[0].link); + static float max[3] = { FLT_MAX, FLT_MAX, FLT_MAX}; + static float min[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX}; + GPUNodeLink *tmin, *tmax, *tmat0, *tmat1, *tmat2, *tmat3; + + tmin = GPU_uniform_buffer((domin) ? texmap->min : min, GPU_VEC3); + tmax = GPU_uniform_buffer((domax) ? texmap->max : max, GPU_VEC3); + tmat0 = GPU_uniform_buffer((float *)texmap->mat[0], GPU_VEC4); + tmat1 = GPU_uniform_buffer((float *)texmap->mat[1], GPU_VEC4); + tmat2 = GPU_uniform_buffer((float *)texmap->mat[2], GPU_VEC4); + tmat3 = GPU_uniform_buffer((float *)texmap->mat[3], GPU_VEC4); + + GPU_link(mat, "mapping", in[0].link, tmat0, tmat1, tmat2, tmat3, tmin, tmax, &in[0].link); if (texmap->type == TEXMAP_TYPE_NORMAL) GPU_link(mat, "texco_norm", in[0].link, &in[0].link); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index a84e88e9551..2541b3bc842 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -88,13 +88,18 @@ static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS TexMapping *texmap = node->storage; float domin = (texmap->flag & TEXMAP_CLIP_MIN) != 0; float domax = (texmap->flag & TEXMAP_CLIP_MAX) != 0; - GPUNodeLink *tmat = GPU_uniform((float *)texmap->mat); - GPUNodeLink *tmin = GPU_uniform(texmap->min); - GPUNodeLink *tmax = GPU_uniform(texmap->max); - GPUNodeLink *tdomin = GPU_uniform(&domin); - GPUNodeLink *tdomax = GPU_uniform(&domax); - - GPU_stack_link(mat, node, "mapping", in, out, tmat, tmin, tmax, tdomin, tdomax); + static float max[3] = { FLT_MAX, FLT_MAX, FLT_MAX, 0.0}; + static float min[3] = {-FLT_MAX, -FLT_MAX, -FLT_MAX, 0.0}; + GPUNodeLink *tmin, *tmax, *tmat0, *tmat1, *tmat2, *tmat3; + + tmin = GPU_uniform_buffer((domin) ? texmap->min : min, GPU_VEC3); + tmax = GPU_uniform_buffer((domax) ? texmap->max : max, GPU_VEC3); + tmat0 = GPU_uniform_buffer((float *)texmap->mat[0], GPU_VEC4); + tmat1 = GPU_uniform_buffer((float *)texmap->mat[1], GPU_VEC4); + tmat2 = GPU_uniform_buffer((float *)texmap->mat[2], GPU_VEC4); + tmat3 = GPU_uniform_buffer((float *)texmap->mat[3], GPU_VEC4); + + GPU_stack_link(mat, node, "mapping", in, out, tmat0, tmat1, tmat2, tmat3, tmin, tmax); if (texmap->type == TEXMAP_TYPE_NORMAL) GPU_link(mat, "texco_norm", out[0].link, &out[0].link); |