diff options
Diffstat (limited to 'source/blender/gpu/shaders')
9 files changed, 17 insertions, 12 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl index 4721b9f0132..0231aeca04b 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_ambient_occlusion.glsl @@ -10,7 +10,7 @@ void node_ambient_occlusion(vec4 color, vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy); OcclusionData data = occlusion_search(viewPosition, maxzBuffer, dist, inverted, 8.0); - vec3 V = cameraVec; + vec3 V = cameraVec(worldPosition); vec3 N = normalize(normal); vec3 Ng = safe_normalize(cross(dFdx(worldPosition), dFdy(worldPosition))); diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl index 429c4ed41ac..d5623c890e4 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_eevee_specular.glsl @@ -32,6 +32,8 @@ void node_eevee_specular(vec4 diffuse, result = CLOSURE_DEFAULT; + vec3 V = cameraVec(worldPosition); + { /* Diffuse. */ out_Diffuse_0.radiance = render_pass_diffuse_mask(vec3(1), out_Diffuse_0.radiance); @@ -40,7 +42,7 @@ void node_eevee_specular(vec4 diffuse, } { /* Glossy. */ - float NV = dot(in_Glossy_1.N, cameraVec); + float NV = dot(in_Glossy_1.N, V); vec2 split_sum = brdf_lut(NV, in_Glossy_1.roughness); vec3 brdf = F_brdf_single_scatter(specular.rgb, vec3(1.0), split_sum); @@ -52,7 +54,7 @@ void node_eevee_specular(vec4 diffuse, } { /* Clearcoat. */ - float NV = dot(in_Glossy_2.N, cameraVec); + float NV = dot(in_Glossy_2.N, V); vec2 split_sum = brdf_lut(NV, in_Glossy_2.roughness); vec3 brdf = F_brdf_single_scatter(vec3(0.04), vec3(1.0), split_sum); diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_emission.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_emission.glsl index 502bc7f92d6..f2de7c2da39 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_emission.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_emission.glsl @@ -3,7 +3,7 @@ void node_emission(vec4 color, float strength, vec3 vN, out Closure result) result = CLOSURE_DEFAULT; #ifndef VOLUMETRICS result.radiance = render_pass_emission_mask(color.rgb) * strength; - result.ssr_normal = normal_encode(vN, viewCameraVec); + result.ssr_normal = normal_encode(vN, viewCameraVec(viewPosition)); #else result.emission = color.rgb * strength; #endif diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl index 6788b34c938..aa0a8873596 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_glass.glsl @@ -23,7 +23,7 @@ void node_bsdf_glass(vec4 color, result = CLOSURE_DEFAULT; - float NV = dot(in_Refraction_1.N, cameraVec); + float NV = dot(in_Refraction_1.N, cameraVec(worldPosition)); float fresnel = (do_multiscatter != 0.0) ? btdf_lut(NV, in_Refraction_1.roughness, in_Refraction_1.ior).y : diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_glossy.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_glossy.glsl index ca7c3749597..fa83bfb6c7a 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_glossy.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_glossy.glsl @@ -16,7 +16,7 @@ void node_bsdf_glossy( result = CLOSURE_DEFAULT; - vec2 split_sum = brdf_lut(dot(in_Glossy_0.N, cameraVec), in_Glossy_0.roughness); + vec2 split_sum = brdf_lut(dot(in_Glossy_0.N, cameraVec(worldPosition)), in_Glossy_0.roughness); vec3 brdf = (use_multiscatter != 0.0) ? F_brdf_multi_scatter(vec3(1.0), vec3(1.0), split_sum) : F_brdf_single_scatter(vec3(1.0), vec3(1.0), split_sum); out_Glossy_0.radiance = closure_mask_ssr_radiance(out_Glossy_0.radiance, ssr_id); diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl index 139dcb33222..40fe83a3616 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_principled.glsl @@ -86,8 +86,10 @@ void node_bsdf_principled(vec4 base_color, out_Refraction_3.radiance = vec3(0); } + vec3 V = cameraVec(worldPosition); + /* Glossy_1 will always be evaluated. */ - float NV = dot(in_Glossy_1.N, cameraVec); + float NV = dot(in_Glossy_1.N, V); vec3 base_color_tint = tint_from_color(base_color.rgb); @@ -172,7 +174,7 @@ void node_bsdf_principled(vec4 base_color, } if (clearcoat > 1e-5) { - float NV = dot(in_Glossy_2.N, cameraVec); + float NV = dot(in_Glossy_2.N, V); vec2 split_sum = brdf_lut(NV, in_Glossy_2.roughness); vec3 brdf = F_brdf_single_scatter(vec3(0.04), vec3(1.0), split_sum); diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_refraction.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_refraction.glsl index db820efa42e..7cbc7218f5c 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_refraction.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_refraction.glsl @@ -22,7 +22,8 @@ void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Cl result.radiance = out_Refraction_0.radiance; /* TODO(fclem) Try to not use this. */ - result.ssr_normal = normal_encode(mat3(ViewMatrix) * in_Refraction_0.N, viewCameraVec); + result.ssr_normal = normal_encode(mat3(ViewMatrix) * in_Refraction_0.N, + viewCameraVec(viewPosition)); } #else diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_shader_to_rgba.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_shader_to_rgba.glsl index f495157f6e1..a5fdc7a2337 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_shader_to_rgba.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_shader_to_rgba.glsl @@ -3,8 +3,8 @@ void node_shader_to_rgba(Closure cl, out vec4 outcol, out float outalpha) { vec4 spec_accum = vec4(0.0); if (ssrToggle && FLAG_TEST(cl.flag, CLOSURE_SSR_FLAG)) { - vec3 V = cameraVec; - vec3 vN = normal_decode(cl.ssr_normal, viewCameraVec); + vec3 V = cameraVec(worldPosition); + vec3 vN = normal_decode(cl.ssr_normal, viewCameraVec(viewPosition)); vec3 N = transform_direction(ViewMatrixInverse, vN); float roughness = cl.ssr_data.a; float roughnessSquared = max(1e-3, roughness * roughness); diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_texture_coordinates.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_texture_coordinates.glsl index 24276156d55..08d566224bf 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_texture_coordinates.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_texture_coordinates.glsl @@ -50,7 +50,7 @@ void node_tex_coord(vec3 I, camera = vec3(I.xy, -I.z); vec4 projvec = ProjectionMatrix * vec4(I, 1.0); window = vec3(mtex_2d_mapping(projvec.xyz / projvec.w).xy * camerafac.xy + camerafac.zw, 0.0); - reflection = -reflect(cameraVec, normalize(wN)); + reflection = -reflect(cameraVec(worldPosition), normalize(wN)); } void node_tex_coord_background(vec3 I, |