diff options
Diffstat (limited to 'source')
9 files changed, 21 insertions, 8 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 7b4748056a7..e24cf8da989 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1749,6 +1749,19 @@ void node_geometry( pointiness = 0.5; } +void generated_texco(vec3 I, vec3 attr_orco, out vec3 generated) +{ + vec4 v = (ProjectionMatrix[3][3] == 0.0) ? vec4(I, 1.0) : vec4(0.0, 0.0, 1.0, 1.0); + vec4 co_homogenous = (ProjectionMatrixInverse * v); + vec4 co = vec4(co_homogenous.xyz / co_homogenous.w, 0.0); + co.xyz = normalize(co.xyz); +#if defined(WORLD_BACKGROUND) || defined(PROBE_CAPTURE) + generated = (ViewMatrixInverse * co).xyz; +#else + generated_from_orco(attr_orco, generated); +#endif +} + void node_tex_coord( vec3 I, vec3 N, mat4 viewinvmat, mat4 obinvmat, vec4 camerafac, vec3 attr_orco, vec3 attr_uv, diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c index 2002e3c14c9..4f488025a99 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c @@ -73,7 +73,7 @@ static int node_shader_gpu_tex_brick(GPUMaterial *mat, bNode *node, bNodeExecDat { if (!in[0].link) { in[0].link = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "generated_from_orco", in[0].link, &in[0].link); + GPU_link(mat, "generated_texco", GPU_builtin(GPU_VIEW_POSITION), in[0].link, &in[0].link); } node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c index 4e065ffde23..52aa33c033e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c @@ -56,7 +56,7 @@ static int node_shader_gpu_tex_checker(GPUMaterial *mat, bNode *node, bNodeExecD { if (!in[0].link) { in[0].link = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "generated_from_orco", in[0].link, &in[0].link); + GPU_link(mat, "generated_texco", GPU_builtin(GPU_VIEW_POSITION), in[0].link, &in[0].link); } node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c index 750ce60e84d..404463a8fbe 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c @@ -54,7 +54,7 @@ static int node_shader_gpu_tex_gradient(GPUMaterial *mat, bNode *node, bNodeExec { if (!in[0].link) { in[0].link = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "generated_from_orco", in[0].link, &in[0].link); + GPU_link(mat, "generated_texco", GPU_builtin(GPU_VIEW_POSITION), in[0].link, &in[0].link); } node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c index fb3012e1d2b..e24ef04bc57 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c @@ -59,7 +59,7 @@ static int node_shader_gpu_tex_magic(GPUMaterial *mat, bNode *node, bNodeExecDat if (!in[0].link) { in[0].link = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "generated_from_orco", in[0].link, &in[0].link); + GPU_link(mat, "generated_texco", GPU_builtin(GPU_VIEW_POSITION), in[0].link, &in[0].link); } node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c index 30171eea9e2..5d4f6b7c578 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c @@ -60,7 +60,7 @@ static int node_shader_gpu_tex_musgrave(GPUMaterial *mat, bNode *node, bNodeExec { if (!in[0].link) { in[0].link = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "generated_from_orco", in[0].link, &in[0].link); + GPU_link(mat, "generated_texco", GPU_builtin(GPU_VIEW_POSITION), in[0].link, &in[0].link); } node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c index e2879528a5f..310e82d2d6b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c @@ -56,7 +56,7 @@ static int node_shader_gpu_tex_noise(GPUMaterial *mat, bNode *node, bNodeExecDat { if (!in[0].link) { in[0].link = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "generated_from_orco", in[0].link, &in[0].link); + GPU_link(mat, "generated_texco", GPU_builtin(GPU_VIEW_POSITION), in[0].link, &in[0].link); } node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c index a4145a350d2..059d6348473 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c @@ -58,7 +58,7 @@ static int node_shader_gpu_tex_voronoi(GPUMaterial *mat, bNode *node, bNodeExecD { if (!in[0].link) { in[0].link = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "generated_from_orco", in[0].link, &in[0].link); + GPU_link(mat, "generated_texco", GPU_builtin(GPU_VIEW_POSITION), in[0].link, &in[0].link); } node_shader_gpu_tex_mapping(mat, node, in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c index ac955b29808..db33be2bcb7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c @@ -58,7 +58,7 @@ static int node_shader_gpu_tex_wave(GPUMaterial *mat, bNode *node, bNodeExecData { if (!in[0].link) { in[0].link = GPU_attribute(CD_ORCO, ""); - GPU_link(mat, "generated_from_orco", in[0].link, &in[0].link); + GPU_link(mat, "generated_texco", GPU_builtin(GPU_VIEW_POSITION), in[0].link, &in[0].link); } node_shader_gpu_tex_mapping(mat, node, in, out); |