Fix T95984: Use consistent shifting for persp and ortho cam.
Now always properly shifting camera for ortho and perspective.
This commit is contained in:
parent
0781c22cee
commit
60af7a3496
@ -1404,21 +1404,20 @@ static void lineart_main_perspective_division(LineartRenderBuffer *rb)
|
||||
LineartVert *vt;
|
||||
int i;
|
||||
|
||||
if (!rb->cam_is_persp) {
|
||||
return;
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (LineartElementLinkNode *, eln, &rb->vertex_buffer_pointers) {
|
||||
vt = eln->pointer;
|
||||
for (i = 0; i < eln->element_count; i++) {
|
||||
/* Do not divide Z, we use Z to back transform cut points in later chaining process. */
|
||||
vt[i].fbcoord[0] /= vt[i].fbcoord[3];
|
||||
vt[i].fbcoord[1] /= vt[i].fbcoord[3];
|
||||
/* Re-map z into (0-1) range, because we no longer need NDC (Normalized Device Coordinates)
|
||||
* at the moment.
|
||||
* The algorithm currently doesn't need Z for operation, we use W instead. If Z is needed in
|
||||
* the future, the line below correctly transforms it to view space coordinates. */
|
||||
// `vt[i].fbcoord[2] = -2 * vt[i].fbcoord[2] / (far - near) - (far + near) / (far - near);
|
||||
if (rb->cam_is_persp) {
|
||||
/* Do not divide Z, we use Z to back transform cut points in later chaining process. */
|
||||
vt[i].fbcoord[0] /= vt[i].fbcoord[3];
|
||||
vt[i].fbcoord[1] /= vt[i].fbcoord[3];
|
||||
/* Re-map z into (0-1) range, because we no longer need NDC (Normalized Device Coordinates)
|
||||
* at the moment.
|
||||
* The algorithm currently doesn't need Z for operation, we use W instead. If Z is needed
|
||||
* in the future, the line below correctly transforms it to view space coordinates. */
|
||||
// `vt[i].fbcoord[2] = -2 * vt[i].fbcoord[2] / (far - near) - (far + near) / (far - near);
|
||||
}
|
||||
/* Shifting is always needed. */
|
||||
vt[i].fbcoord[0] -= rb->shift_x * 2;
|
||||
vt[i].fbcoord[1] -= rb->shift_y * 2;
|
||||
}
|
||||
@ -2518,19 +2517,16 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
|
||||
interp_v3_v3v3_db(gloc, e->v1->gloc, e->v2->gloc, cut);
|
||||
mul_v4_m4v3_db(trans, vp, gloc);
|
||||
mul_v3db_db(trans, (1 / trans[3]));
|
||||
}
|
||||
else {
|
||||
interp_v3_v3v3_db(trans, e->v1->fbcoord, e->v2->fbcoord, cut);
|
||||
}
|
||||
trans[0] -= cam_shift_x * 2;
|
||||
trans[1] -= cam_shift_y * 2;
|
||||
|
||||
/* To accommodate `k=0` and `k=inf` (vertical) lines. here the cut is in image space. */
|
||||
if (fabs(e->v1->fbcoord[0] - e->v2->fbcoord[0]) > fabs(e->v1->fbcoord[1] - e->v2->fbcoord[1])) {
|
||||
cut = ratiod(e->v1->fbcoord[0], e->v2->fbcoord[0], trans[0]);
|
||||
}
|
||||
else {
|
||||
cut = ratiod(e->v1->fbcoord[1], e->v2->fbcoord[1], trans[1]);
|
||||
trans[0] -= cam_shift_x * 2;
|
||||
trans[1] -= cam_shift_y * 2;
|
||||
/* To accommodate `k=0` and `k=inf` (vertical) lines. here the cut is in image space. */
|
||||
if (fabs(e->v1->fbcoord[0] - e->v2->fbcoord[0]) >
|
||||
fabs(e->v1->fbcoord[1] - e->v2->fbcoord[1])) {
|
||||
cut = ratiod(e->v1->fbcoord[0], e->v2->fbcoord[0], trans[0]);
|
||||
}
|
||||
else {
|
||||
cut = ratiod(e->v1->fbcoord[1], e->v2->fbcoord[1], trans[1]);
|
||||
}
|
||||
}
|
||||
|
||||
#define LRT_GUARD_NOT_FOUND \
|
||||
@ -2956,9 +2952,10 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
|
||||
* them as well. */
|
||||
mul_v4_m4v3_db(v1->fbcoord, rb->view_projection, v1->gloc);
|
||||
mul_v4_m4v3_db(v2->fbcoord, rb->view_projection, v2->gloc);
|
||||
mul_v3db_db(v1->fbcoord, (1 / v1->fbcoord[3]));
|
||||
mul_v3db_db(v2->fbcoord, (1 / v2->fbcoord[3]));
|
||||
|
||||
if (rb->cam_is_persp) {
|
||||
mul_v3db_db(v1->fbcoord, (1 / v1->fbcoord[3]));
|
||||
mul_v3db_db(v2->fbcoord, (1 / v2->fbcoord[3]));
|
||||
}
|
||||
v1->fbcoord[0] -= rb->shift_x * 2;
|
||||
v1->fbcoord[1] -= rb->shift_y * 2;
|
||||
v2->fbcoord[0] -= rb->shift_x * 2;
|
||||
|
Loading…
Reference in New Issue
Block a user