diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-06-03 14:35:15 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-06-03 17:18:50 +0300 |
commit | 91cc1f38aefdac70c2de2e19cec0d349329aa925 (patch) | |
tree | 4b5bc27e524128113b204717434b1a1f180948ef /source/blender/nodes | |
parent | 866e067d65c1691941865ee426bc0dac5c9e3f95 (diff) |
GPUMaterial: Add support for different sampler state per image sampler
This bridge between the new sampler state support from GPUTexture and
draw material handling.
The Sampler State is just the one from the texture for now. No change in
logic.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_tex_environment.c | 9 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_tex_image.c | 42 |
2 files changed, 36 insertions, 15 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index fd4efb1b7ec..a62c2ee22b2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -56,6 +56,7 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node_original = node->original ? node->original : node; NodeTexImage *tex_original = node_original->storage; ImageUser *iuser = &tex_original->iuser; + eGPUSamplerState sampler_state = GPU_SAMPLER_MAX; GPUNodeLink *outalpha; @@ -78,7 +79,7 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, "node_tex_environment_equirectangular", in[0].link, GPU_constant(&clamp_size), - GPU_image(mat, ima, iuser), + GPU_image(mat, ima, iuser, sampler_state), &in[0].link); } else { @@ -93,7 +94,7 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, GPU_link(mat, "node_tex_image_linear_no_mip", in[0].link, - GPU_image(mat, ima, iuser), + GPU_image(mat, ima, iuser, sampler_state), &out[0].link, &outalpha); break; @@ -101,7 +102,7 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, GPU_link(mat, "node_tex_image_nearest", in[0].link, - GPU_image(mat, ima, iuser), + GPU_image(mat, ima, iuser, sampler_state), &out[0].link, &outalpha); break; @@ -109,7 +110,7 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, GPU_link(mat, "node_tex_image_cubic", in[0].link, - GPU_image(mat, ima, iuser), + GPU_image(mat, ima, iuser, sampler_state), &out[0].link, &outalpha); break; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index bfef9341913..87114fe23b5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -118,6 +118,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, node_shader_gpu_tex_mapping(mat, node, in, out); + eGPUSamplerState sampler_state = GPU_SAMPLER_MAX; + if (ima->source == IMA_SRC_TILED) { /* UDIM tiles needs a samper2DArray and sampler1DArray for tile mapping. */ GPU_stack_link(mat, @@ -125,7 +127,7 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, names_tiled[tex->interpolation], in, out, - GPU_image_tiled(mat, ima, iuser), + GPU_image_tiled(mat, ima, iuser, sampler_state), GPU_image_tiled_mapping(mat, ima, iuser)); } else { @@ -141,16 +143,18 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, GPU_link(mat, "set_rgb", *texco, &input_coords); } if (do_texco_extend) { - GPU_link(mat, "point_texco_clamp", *texco, GPU_image(mat, ima, iuser), texco); + GPU_link( + mat, "point_texco_clamp", *texco, GPU_image(mat, ima, iuser, sampler_state), texco); } - GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(mat, ima, iuser)); + GPU_stack_link( + mat, node, gpu_node_name, in, out, GPU_image(mat, ima, iuser, sampler_state)); break; case SHD_PROJ_BOX: vnor = GPU_builtin(GPU_WORLD_NORMAL); ob_mat = GPU_builtin(GPU_OBJECT_MATRIX); blend = GPU_uniform(&tex->projection_blend); - gpu_image = GPU_image(mat, ima, iuser); + gpu_image = GPU_image(mat, ima, iuser, sampler_state); /* equivalent to normal_world_to_object */ GPU_link(mat, "normal_transform_transposed_m4v3", vnor, ob_mat, &norm); @@ -160,8 +164,14 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, GPU_link(mat, "set_rgb", *texco, &input_coords); in[0].link = input_coords; } - GPU_link( - mat, gpu_node_name, *texco, norm, GPU_image(mat, ima, iuser), &col1, &col2, &col3); + GPU_link(mat, + gpu_node_name, + *texco, + norm, + GPU_image(mat, ima, iuser, sampler_state), + &col1, + &col2, + &col3); GPU_stack_link( mat, node, "node_tex_image_box", in, out, norm, col1, col2, col3, gpu_image, blend); break; @@ -175,9 +185,11 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, GPU_link(mat, "set_rgb", *texco, &input_coords); } if (do_texco_extend) { - GPU_link(mat, "point_texco_clamp", *texco, GPU_image(mat, ima, iuser), texco); + GPU_link( + mat, "point_texco_clamp", *texco, GPU_image(mat, ima, iuser, sampler_state), texco); } - GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(mat, ima, iuser)); + GPU_stack_link( + mat, node, gpu_node_name, in, out, GPU_image(mat, ima, iuser, sampler_state)); break; case SHD_PROJ_TUBE: @@ -189,9 +201,11 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, GPU_link(mat, "set_rgb", *texco, &input_coords); } if (do_texco_extend) { - GPU_link(mat, "point_texco_clamp", *texco, GPU_image(mat, ima, iuser), texco); + GPU_link( + mat, "point_texco_clamp", *texco, GPU_image(mat, ima, iuser, sampler_state), texco); } - GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(mat, ima, iuser)); + GPU_stack_link( + mat, node, gpu_node_name, in, out, GPU_image(mat, ima, iuser, sampler_state)); break; } @@ -199,7 +213,13 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, if (do_texco_clip) { gpu_node_name = names_clip[tex->interpolation]; in[0].link = input_coords; - GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(mat, ima, iuser), out[0].link); + GPU_stack_link(mat, + node, + gpu_node_name, + in, + out, + GPU_image(mat, ima, iuser, sampler_state), + out[0].link); } } } |