Shader mm_contour - Customizable offset to calculate the correction to avoid z-fighting (MESA driver needs bigger one)
This commit is contained in:
parent
0995cfc658
commit
a4435d214f
8 changed files with 21 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform float offset;
|
||||
|
||||
attribute vec3 v_position;
|
||||
|
||||
|
@ -9,6 +10,6 @@ void main()
|
|||
{
|
||||
// Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
|
||||
vec4 clip_position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
clip_position.z -= 0.00001 * abs(clip_position.w);
|
||||
clip_position.z -= offset * abs(clip_position.w);
|
||||
gl_Position = clip_position;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
uniform mat4 view_model_matrix;
|
||||
uniform mat4 projection_matrix;
|
||||
uniform float offset;
|
||||
|
||||
in vec3 v_position;
|
||||
|
||||
|
@ -9,6 +10,6 @@ void main()
|
|||
{
|
||||
// Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
|
||||
vec4 clip_position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
|
||||
clip_position.z -= 0.00001 * abs(clip_position.w);
|
||||
clip_position.z -= offset * abs(clip_position.w);
|
||||
gl_Position = clip_position;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#version 110
|
||||
|
||||
uniform float offset;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
|
||||
vec4 clip_position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
clip_position.z -= 0.00001 * abs(clip_position.w);
|
||||
clip_position.z -= offset * abs(clip_position.w);
|
||||
gl_Position = clip_position;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue