#70267 Retopology Overlay #104599

Merged
Clément Foucault merged 30 commits from bonj/blender:retopology-overlay into main 2023-03-03 00:35:56 +01:00
1 changed files with 4 additions and 4 deletions
Showing only changes of commit 3a90751a0b - Show all commits

View File

@ -257,18 +257,18 @@ vec3 point_world_to_view(vec3 p)
return (ViewMatrix * vec4(p, 1.0)).xyz;
}
/* View Z is used to adjust for perspective projection.
/* Viewspace Z is used to adjust for perspective projection.
* Homogenous W is used to convert from NDC to homogenous space.
bonj marked this conversation as resolved

My bad. The equation is actually comming from page 24.

My bad. The equation is actually comming from page 24.
Review

I thought you picked 18 because it's the start of the section about depth modification. I think it makes sense to point to the whole range of pages (18-26).

I thought you picked 18 because it's the start of the section about depth modification. I think it makes sense to point to the whole range of pages (18-26).

Yes, but here it is the reference to a specific formula. I also think this reference should be inside the function. Comment on top of function is only for documentation of the function usage.

Yes, but here it is the reference to a specific formula. I also think this reference should be inside the function. Comment on top of function is only for documentation of the function usage.
Review

Done.

Done.
* Offset is in viewspace, so positive values are closer to the camera. */
float get_homogenous_z_offset(float vs_z, float hs_w, float offset)
float get_homogenous_z_offset(float vs_z, float hs_w, float vs_offset)
{
if (ProjectionMatrix[3][3] == 0.0) {
bonj marked this conversation as resolved

Maybe also add a note that offset is in viewspace. So positive values are closer to camera.

Maybe also add a note that offset is in viewspace. So positive values are closer to camera.
Review

Done, now each parameter has an explanation.

Done, now each parameter has an explanation.
/* From "Projection Matrix Tricks" by Eric Lengyel:
* http://www.terathon.com/gdc07_lengyel.pdf (p. 24 Depth Modification) */
return ProjectionMatrix[3][2] * (offset / (vs_z * (vs_z + offset))) * hs_w;
return ProjectionMatrix[3][2] * (vs_offset / (vs_z * (vs_z + vs_offset))) * hs_w;
bonj marked this conversation as resolved

Remove the negative sign here and everywhere get_homogenous_z_offset is called.
The negative sign in the equation from the slide is inside ProjectionMatrix[3][2].

Remove the negative sign here and everywhere `get_homogenous_z_offset` is called. The negative sign in the equation from the slide is inside `ProjectionMatrix[3][2]`.
Review

Done and done.
I negated it because then you can subtract from the Z, which is what other offsets in the shader do, but yeah it was unnecessary so now they just use += for this.

Done and done. I negated it because then you can subtract from the Z, which is what other offsets in the shader do, but yeah it was unnecessary so now they just use += for this.
}
else {
return ProjectionMatrix[2][2] * offset * hs_w;
return ProjectionMatrix[2][2] * vs_offset * hs_w;
}
}