diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-02-21 03:01:15 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-02-21 03:33:56 +0300 |
commit | 33b4a03ca98997a074783599b816768e7f90dd2b (patch) | |
tree | b2e27c709bb5eebbd7492bdf08f21c7d5bf8df67 /source/blender/draw | |
parent | d0959924ad057077cf71a1d401ec05ee011ee29e (diff) |
Cleanup: EEVEE: Use P and vP instead of worldPosition and viewPosition
... for local variables.
Diffstat (limited to 'source/blender/draw')
3 files changed, 18 insertions, 28 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl index 71aead9155d..1b7c535379e 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl @@ -42,15 +42,8 @@ uniform sampler2D specroughBuffer; layout(location = 0) out ivec2 hitData; layout(location = 1) out float pdfData; -void do_planar_ssr(int index, - vec3 V, - vec3 N, - vec3 T, - vec3 B, - vec3 planeNormal, - vec3 viewPosition, - float a2, - vec4 rand) +void do_planar_ssr( + int index, vec3 V, vec3 N, vec3 T, vec3 B, vec3 planeNormal, vec3 vP, float a2, vec4 rand) { float NH; vec3 H = sample_ggx(rand.xzw, a2, N, T, B, NH); /* Microfacet normal */ @@ -75,12 +68,12 @@ void do_planar_ssr(int index, * below the reflection plane). This way it's garanted that the hit will * be in front of the camera. That let us tag the bad rays with a negative * sign in the Z component. */ - vec3 hit_pos = raycast(index, viewPosition, R * 1e16, 1e16, rand.y, ssrQuality, a2, false); + vec3 hit_pos = raycast(index, vP, R * 1e16, 1e16, rand.y, ssrQuality, a2, false); hitData = encode_hit_data(hit_pos.xy, (hit_pos.z > 0.0), true); } -void do_ssr(vec3 V, vec3 N, vec3 T, vec3 B, vec3 viewPosition, float a2, vec4 rand) +void do_ssr(vec3 V, vec3 N, vec3 T, vec3 B, vec3 vP, float a2, vec4 rand) { float NH; /* Microfacet normal */ @@ -112,7 +105,7 @@ void do_ssr(vec3 V, vec3 N, vec3 T, vec3 B, vec3 viewPosition, float a2, vec4 ra pdfData = min(1024e32, pdf_ggx_reflect(NH, a2)); /* Theoretical limit of 16bit float */ - vec3 hit_pos = raycast(-1, viewPosition, R * 1e16, ssrThickness, rand.y, ssrQuality, a2, true); + vec3 hit_pos = raycast(-1, vP, R * 1e16, ssrThickness, rand.y, ssrQuality, a2, true); hitData = encode_hit_data(hit_pos.xy, (hit_pos.z > 0.0), false); } diff --git a/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl index 19eecdb5b79..c48828b7b8d 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl @@ -36,22 +36,21 @@ void main() /* Convert to view Z. */ tracing_depth = get_view_z_from_depth(tracing_depth); - vec3 viewPosition = get_view_space_from_depth(uvs, depth); - vec3 worldPosition = transform_point(ViewMatrixInverse, viewPosition); + vec3 vP = get_view_space_from_depth(uvs, depth); + vec3 P = transform_point(ViewMatrixInverse, vP); - vec3 true_normal = safe_normalize(cross(dFdx(viewPosition), dFdy(viewPosition))); + vec3 vNg = safe_normalize(cross(dFdx(vP), dFdy(vP))); for (int i = 0; i < MAX_LIGHT && i < laNumLight; i++) { LightData ld = lights_data[i]; vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */ - l_vector.xyz = ld.l_position - worldPosition; + l_vector.xyz = ld.l_position - P; l_vector.w = length(l_vector.xyz); - float l_vis = light_shadowing(ld, worldPosition, 1.0); + float l_vis = light_shadowing(ld, P, 1.0); - l_vis *= light_contact_shadows( - ld, worldPosition, viewPosition, tracing_depth, true_normal, rand.x, 1.0); + l_vis *= light_contact_shadows(ld, P, vP, tracing_depth, vNg, rand.x, 1.0); accum_light += l_vis; } diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl index 13287eab82b..e72bf8b9150 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_scatter_frag.glsl @@ -29,15 +29,14 @@ void main() outTransmittance = texelFetch(volumeExtinction, volume_cell, 0); vec3 s_scattering = texelFetch(volumeScattering, volume_cell, 0).rgb; vec3 volume_ndc = volume_to_ndc((vec3(volume_cell) + volJitter.xyz) * volInvTexSize.xyz); - vec3 worldPosition = get_world_space_from_depth(volume_ndc.xy, volume_ndc.z); - vec3 wdir = cameraVec(worldPosition); + vec3 P = get_world_space_from_depth(volume_ndc.xy, volume_ndc.z); + vec3 V = cameraVec(P); vec2 phase = texelFetch(volumePhase, volume_cell, 0).rg; float s_anisotropy = phase.x / max(1.0, phase.y); /* Environment : Average color. */ - outScattering.rgb += irradiance_volumetric(worldPosition) * s_scattering * - phase_function_isotropic(); + outScattering.rgb += irradiance_volumetric(P) * s_scattering * phase_function_isotropic(); #ifdef VOLUME_LIGHTING /* Lights */ for (int i = 0; i < MAX_LIGHT && i < laNumLight; i++) { @@ -45,16 +44,15 @@ void main() LightData ld = lights_data[i]; vec4 l_vector; - l_vector.xyz = (ld.l_type == SUN) ? -ld.l_forward : ld.l_position - worldPosition; + l_vector.xyz = (ld.l_type == SUN) ? -ld.l_forward : ld.l_position - P; l_vector.w = length(l_vector.xyz); - float Vis = light_visibility(ld, worldPosition, l_vector); + float Vis = light_visibility(ld, P, l_vector); - vec3 Li = light_volume(ld, l_vector) * - light_volume_shadow(ld, worldPosition, l_vector, volumeExtinction); + vec3 Li = light_volume(ld, l_vector) * light_volume_shadow(ld, P, l_vector, volumeExtinction); outScattering.rgb += Li * Vis * s_scattering * - phase_function(-wdir, l_vector.xyz / l_vector.w, s_anisotropy); + phase_function(-V, l_vector.xyz / l_vector.w, s_anisotropy); } #endif |