diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-02-21 02:52:47 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-02-21 03:33:56 +0300 |
commit | d0959924ad057077cf71a1d401ec05ee011ee29e (patch) | |
tree | 318733f4ed1dc6da8e23aa28aaf459553aaf1441 /source/blender/draw | |
parent | 1d51cb6be24e3097de2a20f490ef0dd535240f5b (diff) |
Cleanup: EEVEE: Use P for world position instead of W
This removes the last places where this was not the case.
We follow cycles convention of P being for Postion.
Diffstat (limited to 'source/blender/draw')
3 files changed, 34 insertions, 34 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl index 724e63eaba8..737ef7dc509 100644 --- a/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/effect_translucency_frag.glsl @@ -81,7 +81,7 @@ float shadow_cube_radial_depth(vec3 cubevec, float tex_id, int shadow_id) return depth; } -vec3 light_translucent(LightData ld, vec3 W, vec3 N, vec4 l_vector, vec2 rand, float sss_scale) +vec3 light_translucent(LightData ld, vec3 P, vec3 N, vec4 l_vector, vec2 rand, float sss_scale) { int shadow_id = int(ld.l_shadowid); @@ -98,7 +98,7 @@ vec3 light_translucent(LightData ld, vec3 W, vec3 N, vec4 l_vector, vec2 rand, f float d, dist; int data_id = int(sd(shadow_id).sh_data_index); if (ld.l_type == SUN) { - vec4 view_z = vec4(dot(W - cameraPos, cameraForward)); + vec4 view_z = vec4(dot(P - cameraPos, cameraForward)); vec4 weights = step(scascade(data_id).split_end_distances, view_z); float id = abs(4.0 - dot(weights, weights)); @@ -109,7 +109,7 @@ vec3 light_translucent(LightData ld, vec3 W, vec3 N, vec4 l_vector, vec2 rand, f /* Same factor as in get_cascade_world_distance(). */ float range = abs(sd(shadow_id).sh_far - sd(shadow_id).sh_near); - vec4 shpos = scascade(data_id).shadowmat[int(id)] * vec4(W, 1.0); + vec4 shpos = scascade(data_id).shadowmat[int(id)] * vec4(P, 1.0); dist = shpos.z * range; if (shpos.z > 1.0 || shpos.z < 0.0) { @@ -149,7 +149,7 @@ vec3 light_translucent(LightData ld, vec3 W, vec3 N, vec4 l_vector, vec2 rand, f else { float ofs = 1.0 / float(textureSize(sssShadowCubes, 0).x); - vec3 cubevec = transform_point(scube(data_id).shadowmat, W); + vec3 cubevec = transform_point(scube(data_id).shadowmat, P); dist = length(cubevec); cubevec /= dist; /* tex_id == data_id for cube shadowmap */ @@ -187,8 +187,8 @@ void main(void) { vec2 uvs = uvcoordsvar.xy; float sss_scale = texture(sssRadius, uvs).r; - vec3 W = get_world_space_from_depth(uvs, texture(depthBuffer, uvs).r); - vec3 N = normalize(cross(dFdx(W), dFdy(W))); + vec3 P = get_world_space_from_depth(uvs, texture(depthBuffer, uvs).r); + vec3 N = normalize(cross(dFdx(P), dFdy(P))); vec3 rand = texelfetch_noise_tex(gl_FragCoord.xy).zwy; rand.xy *= fast_sqrt(rand.z); @@ -203,7 +203,7 @@ void main(void) } vec4 l_vector; /* Non-Normalized Light Vector with length in last component. */ - l_vector.xyz = ld.l_position - W; + l_vector.xyz = ld.l_position - P; l_vector.w = length(l_vector.xyz); float att = light_attenuation(ld, l_vector); @@ -211,7 +211,7 @@ void main(void) continue; } - accum += att * ld.l_color * light_translucent(ld, W, -N, l_vector, rand.xy, sss_scale); + accum += att * ld.l_color * light_translucent(ld, P, -N, l_vector, rand.xy, sss_scale); } FragColor = vec4(accum, 1.0); diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl index 6507534ce67..c1c0138e002 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl @@ -99,9 +99,9 @@ layout(std140) uniform planar_block /* ----------- Functions --------- */ -float probe_attenuation_cube(int pd_id, vec3 W) +float probe_attenuation_cube(int pd_id, vec3 P) { - vec3 localpos = transform_point(probes_data[pd_id].influencemat, W); + vec3 localpos = transform_point(probes_data[pd_id].influencemat, P); float probe_atten_fac = probes_data[pd_id].p_atten_fac; float fac; @@ -116,15 +116,15 @@ float probe_attenuation_cube(int pd_id, vec3 W) return fac; } -float probe_attenuation_planar(PlanarData pd, vec3 W) +float probe_attenuation_planar(PlanarData pd, vec3 P) { /* Distance from plane */ - float fac = saturate(abs(dot(pd.pl_plane_eq, vec4(W, 1.0))) * pd.pl_fade_scale + + float fac = saturate(abs(dot(pd.pl_plane_eq, vec4(P, 1.0))) * pd.pl_fade_scale + pd.pl_fade_bias); /* Fancy fast clipping calculation */ vec2 dist_to_clip; - dist_to_clip.x = dot(pd.pl_clip_pos_x, W); - dist_to_clip.y = dot(pd.pl_clip_pos_y, W); + dist_to_clip.x = dot(pd.pl_clip_pos_x, P); + dist_to_clip.y = dot(pd.pl_clip_pos_y, P); /* compare and add all tests */ fac *= step(2.0, dot(step(pd.pl_clip_edges, dist_to_clip.xxyy), vec2(-1.0, 1.0).xyxy)); return fac; @@ -138,18 +138,18 @@ float probe_attenuation_planar_normal_roughness(PlanarData pd, vec3 N, float rou return fac * saturate(1.0 - roughness * 10.0); } -float probe_attenuation_grid(GridData gd, vec3 W, out vec3 localpos) +float probe_attenuation_grid(GridData gd, vec3 P, out vec3 localpos) { - localpos = transform_point(gd.localmat, W); + localpos = transform_point(gd.localmat, P); vec3 pos_to_edge = max(vec3(0.0), abs(localpos) - 1.0); float fade = length(pos_to_edge); return saturate(-fade * gd.g_atten_scale + gd.g_atten_bias); } -vec3 probe_evaluate_cube(int pd_id, vec3 W, vec3 R, float roughness) +vec3 probe_evaluate_cube(int pd_id, vec3 P, vec3 R, float roughness) { /* Correct reflection ray using parallax volume intersection. */ - vec3 localpos = transform_point(probes_data[pd_id].parallaxmat, W); + vec3 localpos = transform_point(probes_data[pd_id].parallaxmat, P); vec3 localray = transform_direction(probes_data[pd_id].parallaxmat, R); float dist; @@ -161,7 +161,7 @@ vec3 probe_evaluate_cube(int pd_id, vec3 W, vec3 R, float roughness) } /* Use Distance in WS directly to recover intersection */ - vec3 intersection = W + R * dist - probes_data[pd_id].p_position; + vec3 intersection = P + R * dist - probes_data[pd_id].p_position; /* From Frostbite PBR Course * Distance based roughness @@ -186,10 +186,10 @@ vec3 probe_evaluate_world_spec(vec3 R, float roughness) return textureLod_cubemapArray(probeCubes, vec4(R, 0.0), lod).rgb; } -vec3 probe_evaluate_planar(int id, PlanarData pd, vec3 W, vec3 N, vec3 V, float roughness) +vec3 probe_evaluate_planar(int id, PlanarData pd, vec3 P, vec3 N, vec3 V, float roughness) { /* Find view vector / reflection plane intersection. */ - vec3 point_on_plane = line_plane_intersect(W, V, pd.pl_plane_eq); + vec3 point_on_plane = line_plane_intersect(P, V, pd.pl_plane_eq); /* How far the pixel is from the plane. */ float ref_depth = 1.0; /* TODO parameter */ @@ -245,7 +245,7 @@ void fallback_cubemap(vec3 N, } } -vec3 probe_evaluate_grid(GridData gd, vec3 W, vec3 N, vec3 localpos) +vec3 probe_evaluate_grid(GridData gd, vec3 P, vec3 N, vec3 localpos) { localpos = localpos * 0.5 + 0.5; localpos = localpos * vec3(gd.g_resolution) - 0.5; @@ -274,7 +274,7 @@ vec3 probe_evaluate_grid(GridData gd, vec3 W, vec3 N, vec3 localpos) (gd.g_increment_x * cell_cos.x + gd.g_increment_y * cell_cos.y + gd.g_increment_z * cell_cos.z); - vec3 ws_point_to_cell = ws_cell_location - W; + vec3 ws_point_to_cell = ws_cell_location - P; float ws_dist_point_to_cell = length(ws_point_to_cell); vec3 ws_light = ws_point_to_cell / ws_dist_point_to_cell; diff --git a/source/blender/draw/engines/eevee/shaders/lights_lib.glsl b/source/blender/draw/engines/eevee/shaders/lights_lib.glsl index b0845057a43..04ad53eabb7 100644 --- a/source/blender/draw/engines/eevee/shaders/lights_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/lights_lib.glsl @@ -164,10 +164,10 @@ vec4 sample_cascade(sampler2DArray tex, vec2 co, float cascade_id) #define scube(x) shadows_cube_data[x] #define scascade(x) shadows_cascade_data[x] -float sample_cube_shadow(int shadow_id, vec3 W) +float sample_cube_shadow(int shadow_id, vec3 P) { int data_id = int(sd(shadow_id).sh_data_index); - vec3 cubevec = transform_point(scube(data_id).shadowmat, W); + vec3 cubevec = transform_point(scube(data_id).shadowmat, P); float dist = max(sd(shadow_id).sh_near, max_v3(abs(cubevec)) - sd(shadow_id).sh_bias); dist = buffer_depth(true, dist, sd(shadow_id).sh_far, sd(shadow_id).sh_near); /* Manual Shadow Cube Layer indexing. */ @@ -179,11 +179,11 @@ float sample_cube_shadow(int shadow_id, vec3 W) return texture(shadowCubeTexture, vec4(coord, tex_id * 6.0 + face, dist)); } -float sample_cascade_shadow(int shadow_id, vec3 W) +float sample_cascade_shadow(int shadow_id, vec3 P) { int data_id = int(sd(shadow_id).sh_data_index); float tex_id = scascade(data_id).sh_tex_index; - vec4 view_z = vec4(dot(W - cameraPos, cameraForward)); + vec4 view_z = vec4(dot(P - cameraPos, cameraForward)); vec4 weights = 1.0 - smoothstep(scascade(data_id).split_end_distances, scascade(data_id).split_start_distances.yzwx, view_z); @@ -194,13 +194,13 @@ float sample_cascade_shadow(int shadow_id, vec3 W) float vis = weights.w; vec4 coord, shpos; /* Main cascade. */ - shpos = scascade(data_id).shadowmat[cascade] * vec4(W, 1.0); + shpos = scascade(data_id).shadowmat[cascade] * vec4(P, 1.0); coord = vec4(shpos.xy, tex_id + float(cascade), shpos.z - sd(shadow_id).sh_bias); vis += texture(shadowCascadeTexture, coord) * (1.0 - blend); cascade = min(3, cascade + 1); /* Second cascade. */ - shpos = scascade(data_id).shadowmat[cascade] * vec4(W, 1.0); + shpos = scascade(data_id).shadowmat[cascade] * vec4(P, 1.0); coord = vec4(shpos.xy, tex_id + float(cascade), shpos.z - sd(shadow_id).sh_bias); vis += texture(shadowCascadeTexture, coord) * blend; @@ -252,15 +252,15 @@ float light_attenuation(LightData ld, vec4 l_vector) return vis; } -float light_shadowing(LightData ld, vec3 W, float vis) +float light_shadowing(LightData ld, vec3 P, float vis) { #if !defined(VOLUMETRICS) || defined(VOLUME_SHADOW) if (ld.l_shadowid >= 0.0 && vis > 0.001) { if (ld.l_type == SUN) { - vis *= sample_cascade_shadow(int(ld.l_shadowid), W); + vis *= sample_cascade_shadow(int(ld.l_shadowid), P); } else { - vis *= sample_cube_shadow(int(ld.l_shadowid), W); + vis *= sample_cube_shadow(int(ld.l_shadowid), P); } } #endif @@ -308,10 +308,10 @@ float light_contact_shadows( } #endif /* VOLUMETRICS */ -float light_visibility(LightData ld, vec3 W, vec4 l_vector) +float light_visibility(LightData ld, vec3 P, vec4 l_vector) { float l_atten = light_attenuation(ld, l_vector); - return light_shadowing(ld, W, l_atten); + return light_shadowing(ld, P, l_atten); } float light_diffuse(LightData ld, vec3 N, vec3 V, vec4 l_vector) |