Fix #127590: EEVEE: Wrong background motion vectors
Add the missing view matrix multiplication and use the view forward vector instead of the incident vector. Pull Request: https://projects.blender.org/blender/blender/pulls/127718
This commit is contained in:
@@ -24,7 +24,8 @@ vec4 velocity_unpack(vec4 data)
|
||||
*/
|
||||
vec4 velocity_surface(vec3 P_prv, vec3 P, vec3 P_nxt)
|
||||
{
|
||||
/* NOTE: We don't use the drw_view.persmat to avoid adding the TAA jitter to the velocity. */
|
||||
/* NOTE: We use CameraData matrices instead of drw_view.persmat to avoid adding the TAA jitter to
|
||||
* the velocity. */
|
||||
vec2 prev_uv = project_point(camera_prev.persmat, P_prv).xy;
|
||||
vec2 curr_uv = project_point(camera_curr.persmat, P).xy;
|
||||
vec2 next_uv = project_point(camera_next.persmat, P_nxt).xy;
|
||||
@@ -51,12 +52,12 @@ vec4 velocity_surface(vec3 P_prv, vec3 P, vec3 P_nxt)
|
||||
*/
|
||||
vec4 velocity_background(vec3 vV)
|
||||
{
|
||||
/* Only transform direction to avoid losing precision. */
|
||||
vec3 V = transform_direction(camera_curr.viewinv, vV);
|
||||
/* NOTE: We don't use the drw_view.winmat to avoid adding the TAA jitter to the velocity. */
|
||||
vec2 prev_uv = project_point(camera_prev.winmat, V).xy;
|
||||
vec2 curr_uv = project_point(camera_curr.winmat, V).xy;
|
||||
vec2 next_uv = project_point(camera_next.winmat, V).xy;
|
||||
/* NOTE: We use CameraData matrices instead of drw_view.winmat to avoid adding the TAA jitter to
|
||||
* the velocity. */
|
||||
vec2 prev_uv = project_point(camera_prev.winmat, transform_direction(camera_prev.viewmat, V)).xy;
|
||||
vec2 curr_uv = project_point(camera_curr.winmat, transform_direction(camera_curr.viewmat, V)).xy;
|
||||
vec2 next_uv = project_point(camera_next.winmat, transform_direction(camera_next.viewmat, V)).xy;
|
||||
/* NOTE: We output both vectors in the same direction so we can reuse the same vector
|
||||
* with RGRG swizzle in viewport. */
|
||||
vec4 motion = vec4(prev_uv - curr_uv, curr_uv - next_uv);
|
||||
@@ -71,8 +72,8 @@ vec4 velocity_resolve(vec4 vector, vec2 uv, float depth)
|
||||
if (vector.x == VELOCITY_INVALID) {
|
||||
bool is_background = (depth == 1.0);
|
||||
if (is_background) {
|
||||
/* NOTE: Use viewCameraVec to avoid imprecision if camera is far from origin. */
|
||||
vec3 vV = drw_view_incident_vector(drw_point_screen_to_view(vec3(uv, 1.0)));
|
||||
/* NOTE: Use view vector to avoid imprecision if camera is far from origin. */
|
||||
vec3 vV = -drw_view_incident_vector(drw_point_screen_to_view(vec3(uv, 1.0)));
|
||||
return velocity_background(vV);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user