#70267 Retopology Overlay #104599
|
@ -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
|
||||
* 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
Clément Foucault
commented
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.
Jorijn de Graaf
commented
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
Clément Foucault
commented
Remove the negative sign here and everywhere 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]`.
Jorijn de Graaf
commented
Done and done. 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
My bad. The equation is actually comming from page 24.
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.
Done.