This way it can't offset a vertex to behind the camera, and by keeping the ratio between Z and offset large enough, it avoids floating point precision errors.
The bias property is now called offset, not just in the UI but everywhere, because I like consistency.
get_homogenous_z_offset no longer negates its output, and has some more documentation.
The offset property is now of distance type, because it is a viewspace offset.
To make this more clear the soft max is increased to 10.
Because there's no point in arbitrarily limiting the values users can input, the hard max is FLT_MAX now.
I kept step the same, because it good the way it is.
The clip distances no longer need to be factored in on the C++ side, so that simplifies how bias is calculated.
I've added a new function to the common_view_lib, which uses math I found in a neat PDF for perspective, and math I came up with through a little trial and error for orthographic.
The shaders that use retopology bias now have an extra step to get the view position, but that was being calculated to get the homogenous position anyway so it's just an extra variable.
The offset is done at the start of the vertex shader now instead of the end; I think it makes sense because the offset it does is usually much larger than anything that comes after.
This is what happens when you copy paste without reading carefully.
This shader was sharing a variable with the regular overlay_depth_only shader, so whichever was used first during a session would be used for both.
Now it has its own variable, so the shaders don't interfere with each other anymore.
Oh boy, this is about to get confusing, so I recommend just looking at the PR's final changes instead.
overlay_uniform_color_vert.glsl is renamed back to overlay_depth_only.glsl, like it was originally.
overlay_uniform_color uses this vertex shader again.
overlay_depth_only no longer has retopologyBias.
For edit mesh I've added a new shader, overlay_edit_mesh_depth, with its own vertex shader, overlay_edit_mesh_depth_vert.glsl.
I've added the necessary function, OVERLAY_shader_edit_mesh_depth, in hopefully the right places.
It builds and runs fine at least.
Now the shader can tell whether the effect is enabled or not by comparing against zero.
No longer using negative values for that means that I can remove the max calls from vertex shaders.
Setting the value to 0.0 no longer disables the effect, so I removed that part of the tooltip.
Very large meshes require very large bias values, so I'm upping the hard maximum to 100000, and adding a soft maximum.
Since we're not changing the opacity by selection mode, this value was too opaque compared to selected / active / freestyle faces when in vertex select mode.
When in retopology mode, the depth pass now uses the edit cage mesh, and no longer does back face culling.
I've also removed the unnecessary DRW_shgroup_uniform_block line, which I previously added via careless copy pasting.
A value of 0 no longer disables the effect, and the face color code now checks for a value of -1 instead.
The shaders that use the bias for math have to clamp it to positive values.
After a few hours of trial and error, I managed to figure out the right way to calculate the bias value for orthographic view.
Also it turns out bias should divided by W instead of Z in the shaders; this fixes orthographic view, and some minor artifacts in perspective view.