diff options
Diffstat (limited to 'source/blender/draw/engines/eevee')
10 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl index c9af2753baa..1c32a5975be 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_cube_display_vert.glsl @@ -39,6 +39,6 @@ void main() vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y; ws_location += screen_pos * sphere_size; - gl_Position = ViewProjectionMatrix * vec4(ws_location, 1.0); + gl_Position = ProjectionMatrix * (ViewMatrix * vec4(ws_location, 1.0)); gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */ } diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl index 6fefe1319bd..c296d901880 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl @@ -42,6 +42,6 @@ void main() vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * quadCoord.y; ws_cell_location += screen_pos * sphere_size; - gl_Position = ViewProjectionMatrix * vec4(ws_cell_location, 1.0); + gl_Position = ProjectionMatrix * (ViewMatrix * vec4(ws_cell_location, 1.0)); gl_Position.z += 0.0001; /* Small bias to let the icon draw without zfighting */ } diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl index e1035af37be..6c1a95bba49 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_lib.glsl @@ -203,7 +203,7 @@ vec3 probe_evaluate_planar(int id, PlanarData pd, vec3 P, vec3 N, vec3 V, float vec3 ref_pos = point_on_plane + proj_ref; /* Reproject to find texture coords. */ - vec4 refco = ViewProjectionMatrix * vec4(ref_pos, 1.0); + vec4 refco = ProjectionMatrix * (ViewMatrix * vec4(ref_pos, 1.0)); refco.xy /= refco.w; /* TODO: If we support non-ssr planar reflection, we should blur them with gaussian diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl index 0a53abcb04a..fff3209bb8a 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_frag.glsl @@ -10,7 +10,7 @@ out vec4 FragColor; void main() { - vec4 refco = ViewProjectionMatrix * vec4(worldPosition, 1.0); + vec4 refco = ProjectionMatrix * (ViewMatrix * vec4(worldPosition, 1.0)); refco.xy /= refco.w; FragColor = vec4( textureLod(probePlanars, vec3(refco.xy * vec2(-0.5, 0.5) + 0.5, float(probeIdx)), 0.0).rgb, diff --git a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl index 6759c060259..9c79fd4c939 100644 --- a/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/lightprobe_planar_display_vert.glsl @@ -12,6 +12,6 @@ flat out int probeIdx; void main() { worldPosition = (probe_mat * vec4(-pos.x, pos.y, 0.0, 1.0)).xyz; - gl_Position = ViewProjectionMatrix * vec4(worldPosition, 1.0); + gl_Position = ProjectionMatrix * (ViewMatrix * vec4(worldPosition, 1.0)); probeIdx = probe_id; } diff --git a/source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl b/source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl index ef96bcbaedb..9dab04006a8 100644 --- a/source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/object_motion_vert.glsl @@ -52,8 +52,8 @@ void main() /* Use jittered projmatrix to be able to match exact sample depth (depth equal test). * Note that currModelMatrix needs to also be equal to ModelMatrix for the samples to match. */ #ifndef HAIR - gl_Position = ViewProjectionMatrix * vec4(currWorldPos, 1.0); + gl_Position = ProjectionMatrix * (ViewMatrix * vec4(currWorldPos, 1.0)); #else - gl_Position = ViewProjectionMatrix * vec4(wpos, 1.0); + gl_Position = ProjectionMatrix * (ViewMatrix * vec4(wpos, 1.0)); #endif } diff --git a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl index 69762027643..ac7519195c0 100644 --- a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl @@ -181,7 +181,7 @@ vec3 coordinate_screen(vec3 P) window.xy = window.xy * CameraTexCoFactors.xy + CameraTexCoFactors.zw; #else /* MESH */ - window.xy = project_point(ViewProjectionMatrix, P).xy * 0.5 + 0.5; + window.xy = project_point(ProjectionMatrix, transform_point(ViewMatrix, P)).xy * 0.5 + 0.5; window.xy = window.xy * CameraTexCoFactors.xy + CameraTexCoFactors.zw; #endif return window; diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl index 9ed21fc0bf5..eebcf56de28 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_frag.glsl @@ -52,7 +52,7 @@ vec3 coordinate_camera(vec3 P) vec3 coordinate_screen(vec3 P) { vec3 window = vec3(0.0); - window.xy = project_point(ViewProjectionMatrix, P).xy * 0.5 + 0.5; + window.xy = project_point(ProjectionMatrix, transform_point(ViewMatrix, P)).xy * 0.5 + 0.5; window.xy = window.xy * CameraTexCoFactors.xy + CameraTexCoFactors.zw; return window; } diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl index 777e48fde34..07b817d1713 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl @@ -117,7 +117,7 @@ vec3 light_volume_light_vector(LightData ld, vec3 P) vec3 participating_media_extinction(vec3 wpos, sampler3D volume_extinction) { /* Waiting for proper volume shadowmaps and out of frustum shadow map. */ - vec3 ndc = project_point(ViewProjectionMatrix, wpos); + vec3 ndc = project_point(ProjectionMatrix, transform_point(ViewMatrix, wpos)); vec3 volume_co = ndc_to_volume(ndc * 0.5 + 0.5); /* Let the texture be clamped to edge. This reduce visual glitches. */ @@ -147,12 +147,15 @@ vec3 light_volume_shadow(LightData ld, vec3 ray_wpos, vec4 l_vector, sampler3D v if (ld.l_type == SUN) { /* For sun light we scan the whole frustum. So we need to get the correct endpoints. */ - vec3 ndcP = project_point(ViewProjectionMatrix, ray_wpos); - vec3 ndcL = project_point(ViewProjectionMatrix, ray_wpos + l_vector.xyz) - ndcP; + vec3 ndcP = project_point(ProjectionMatrix, transform_point(ViewMatrix, ray_wpos)); + vec3 ndcL = project_point(ProjectionMatrix, + transform_point(ViewMatrix, ray_wpos + l_vector.xyz)) - + ndcP; vec3 frustum_isect = ndcP + ndcL * line_unit_box_intersect_dist_safe(ndcP, ndcL); - L = project_point(ViewProjectionMatrixInverse, frustum_isect) - ray_wpos; + vec4 L_hom = ViewMatrixInverse * (ProjectionMatrixInverse * vec4(frustum_isect, 1.0)); + L = (L_hom.xyz / L_hom.w) - ray_wpos; L /= volShadowSteps; dd = length(L); } diff --git a/source/blender/draw/engines/eevee/shaders/world_vert.glsl b/source/blender/draw/engines/eevee/shaders/world_vert.glsl index 29892a7ffb4..837dca4ad08 100644 --- a/source/blender/draw/engines/eevee/shaders/world_vert.glsl +++ b/source/blender/draw/engines/eevee/shaders/world_vert.glsl @@ -17,7 +17,7 @@ void main() gl_Position = vec4(pos, 1.0, 1.0); viewPosition = project_point(ProjectionMatrixInverse, vec3(pos, 0.0)); - worldPosition = project_point(ViewProjectionMatrixInverse, vec3(pos, 0.0)); + worldPosition = transform_point(ViewMatrixInverse, viewPosition); /* Not usable. */ viewNormal = vec3(0.0); worldNormal = vec3(0.0); |