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-11-07 21:40:24 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-08 00:16:13 +0300
commite0edac4cb27ddacc22bcbf7a628d58bb0eb9e9bf (patch)
treea3cf814cc7c51bb0c8b16423490d8c38a1f77fdb /source/blender/nodes
parent0b837a49861c4d4a413ba282124ecd8a6a2efd79 (diff)
Eevee: Support for extension type in the Node Image Texture
This does not work with the box projection mode. Implementing for box projection mode would be difficult, slow, and produce a lot of code duplication. Also i'm not sure this is worth it, as it's not a common use case.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c42
1 files changed, 41 insertions, 1 deletions
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 9782df2638f..24ad28289c1 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -67,6 +67,12 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
"tex_box_sample_cubic",
"tex_box_sample_smart"
};
+ static const char *names_clip[] = {
+ "tex_clip_linear",
+ "tex_clip_nearest",
+ "tex_clip_cubic",
+ "tex_clip_smart"
+ };
Image *ima = (Image *)node->id;
ImageUser *iuser = NULL;
@@ -75,8 +81,18 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
? names_box[tex->interpolation]
: names[tex->interpolation];
bool do_color_correction = false;
+ bool do_texco_extend = (tex->extension != SHD_IMAGE_EXTENSION_REPEAT);
+ const bool do_texco_clip = (tex->extension == SHD_IMAGE_EXTENSION_CLIP);
+
+ if (do_texco_extend && (tex->projection != SHD_PROJ_BOX) &&
+ ELEM(tex->interpolation, SHD_INTERP_CUBIC, SHD_INTERP_SMART))
+ {
+ gpu_node_name = "node_tex_image_cubic_extend";
+ /* We do it inside the sampling function */
+ do_texco_extend = false;
+ }
- GPUNodeLink *norm, *col1, *col2, *col3;
+ GPUNodeLink *norm, *col1, *col2, *col3, *input_coords;
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
float blend = tex->projection_blend;
@@ -100,6 +116,12 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
switch (tex->projection) {
case SHD_PROJ_FLAT:
+ if (do_texco_clip) {
+ GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ }
+ if (do_texco_extend) {
+ GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ }
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
case SHD_PROJ_BOX:
@@ -131,15 +153,33 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, bNodeExecDat
case SHD_PROJ_SPHERE:
GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
GPU_link(mat, "point_map_to_sphere", in[0].link, &in[0].link);
+ if (do_texco_clip) {
+ GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ }
+ if (do_texco_extend) {
+ GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ }
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
case SHD_PROJ_TUBE:
GPU_link(mat, "point_texco_remap_square", in[0].link, &in[0].link);
GPU_link(mat, "point_map_to_tube", in[0].link, &in[0].link);
+ if (do_texco_clip) {
+ GPU_link(mat, "set_rgb", in[0].link, &input_coords);
+ }
+ if (do_texco_extend) {
+ GPU_link(mat, "point_texco_clamp", in[0].link, GPU_image(ima, iuser, isdata), &in[0].link);
+ }
GPU_stack_link(mat, node, gpu_node_name, in, out, GPU_image(ima, iuser, isdata));
break;
}
+ if (do_texco_clip && (tex->projection != SHD_PROJ_BOX)) {
+ GPU_link(mat, names_clip[tex->interpolation],
+ input_coords, GPU_image(ima, iuser, isdata), out[0].link,
+ &out[0].link, &out[1].link);
+ }
+
if (do_color_correction && (tex->projection != SHD_PROJ_BOX)) {
GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link);
}