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:
Diffstat (limited to 'source/blender/nodes/shader/nodes/node_shader_tex_environment.c')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c56
1 files changed, 27 insertions, 29 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..0cf4b51f307 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -19,6 +19,8 @@
#include "../node_shader_util.h"
+#include "GPU_draw.h"
+
/* **************** OUTPUT ******************** */
static bNodeSocketTemplate sh_node_tex_environment_in[] = {
@@ -56,6 +58,10 @@ 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 = GPU_SAMPLER_REPEAT | GPU_SAMPLER_ANISO | GPU_SAMPLER_FILTER;
+ if (GPU_get_mipmap()) {
+ sampler |= GPU_SAMPLER_MIPMAP;
+ }
GPUNodeLink *outalpha;
@@ -72,49 +78,41 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat,
/* Compute texture coordinate. */
if (tex->projection == SHD_PROJ_EQUIRECTANGULAR) {
- /* To fix pole issue we clamp the v coordinate. The clamp value depends on the filter size. */
- float clamp_size = (ELEM(tex->interpolation, SHD_INTERP_CUBIC, SHD_INTERP_SMART)) ? 1.5 : 0.5;
- GPU_link(mat,
- "node_tex_environment_equirectangular",
- in[0].link,
- GPU_constant(&clamp_size),
- GPU_image(mat, ima, iuser),
- &in[0].link);
+ GPU_link(mat, "node_tex_environment_equirectangular", in[0].link, &in[0].link);
+ /* To fix pole issue we clamp the v coordinate. */
+ sampler &= ~GPU_SAMPLER_REPEAT_T;
+ /* Force the highest mipmap and don't do anisotropic filtering.
+ * This is to fix the artifact caused by derivatives discontinuity. */
+ sampler &= ~(GPU_SAMPLER_MIPMAP | GPU_SAMPLER_ANISO);
}
else {
GPU_link(mat, "node_tex_environment_mirror_ball", in[0].link, &in[0].link);
+ /* Fix pole issue. */
+ sampler &= ~GPU_SAMPLER_REPEAT;
}
- /* Sample texture with correct interpolation. */
+ const char *gpufunc;
+ static const char *names[] = {
+ "node_tex_image_linear",
+ "node_tex_image_cubic",
+ };
+
switch (tex->interpolation) {
case SHD_INTERP_LINEAR:
- /* Force the highest mipmap and don't do anisotropic filtering.
- * This is to fix the artifact caused by derivatives discontinuity. */
- GPU_link(mat,
- "node_tex_image_linear_no_mip",
- in[0].link,
- GPU_image(mat, ima, iuser),
- &out[0].link,
- &outalpha);
+ gpufunc = names[0];
break;
case SHD_INTERP_CLOSEST:
- GPU_link(mat,
- "node_tex_image_nearest",
- in[0].link,
- GPU_image(mat, ima, iuser),
- &out[0].link,
- &outalpha);
+ sampler &= ~(GPU_SAMPLER_FILTER | GPU_SAMPLER_MIPMAP);
+ gpufunc = names[0];
break;
default:
- GPU_link(mat,
- "node_tex_image_cubic",
- in[0].link,
- GPU_image(mat, ima, iuser),
- &out[0].link,
- &outalpha);
+ gpufunc = names[1];
break;
}
+ /* Sample texture with correct interpolation. */
+ GPU_link(mat, gpufunc, in[0].link, GPU_image(mat, ima, iuser, sampler), &out[0].link, &outalpha);
+
if (out[0].hasoutput) {
if (ELEM(ima->alpha_mode, IMA_ALPHA_IGNORE, IMA_ALPHA_CHANNEL_PACKED) ||
IMB_colormanagement_space_name_is_data(ima->colorspace_settings.name)) {