diff options
Diffstat (limited to 'mesh_snap_utilities_line/snap_context_l/shaders')
-rw-r--r-- | mesh_snap_utilities_line/snap_context_l/shaders/ID_color_frag.glsl | 24 | ||||
-rw-r--r-- | mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl | 25 |
2 files changed, 49 insertions, 0 deletions
diff --git a/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_frag.glsl b/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_frag.glsl new file mode 100644 index 00000000..3e01f7b0 --- /dev/null +++ b/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_frag.glsl @@ -0,0 +1,24 @@ +uniform int offset; + +#ifdef USE_CLIP_PLANES +uniform bool use_clip_planes; +in vec4 clip_distance; +#endif + +out uint FragColor; + +void main() +{ +#ifdef USE_CLIP_PLANES + if (use_clip_planes && + ((clip_distance[0] < 0) || + (clip_distance[1] < 0) || + (clip_distance[2] < 0) || + (clip_distance[3] < 0))) + { + discard; + } +#endif + + FragColor = uint(gl_PrimitiveID + offset); +} diff --git a/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl b/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl new file mode 100644 index 00000000..fa0afec6 --- /dev/null +++ b/mesh_snap_utilities_line/snap_context_l/shaders/ID_color_vert.glsl @@ -0,0 +1,25 @@ +uniform mat4 ModelViewProjectionMatrix; + +#ifdef USE_CLIP_PLANES +uniform mat4 ModelViewMatrix; +uniform bool use_clip_planes; +uniform vec4 clip_plane[4]; +out vec4 clip_distance; +#endif + +in vec3 pos; + +void main() +{ +#ifdef USE_CLIP_PLANES + if (use_clip_planes) { + vec4 g_pos = ModelViewMatrix * vec4(pos, 1.0); + + for (int i = 0; i != 4; i++) { + clip_distance[i] = dot(clip_plane[i], g_pos); + } + } +#endif + + gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); +} |