Cull vertices beyond cull distance
This commit is contained in:
parent
651ad69c26
commit
799257bfdb
@ -5,6 +5,7 @@ noperspective in vec2 UV;
|
||||
in vec3 AMBIENT;
|
||||
in vec3 DIFFUSE;
|
||||
in vec3 SPECULAR;
|
||||
flat in float kill;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
@ -38,4 +39,8 @@ void main() {
|
||||
if (material.cullBack && !gl_FrontFacing) {
|
||||
discard;
|
||||
}
|
||||
|
||||
if (kill == 1.0) {
|
||||
discard;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,10 @@ out vec3 AMBIENT;
|
||||
out vec3 DIFFUSE;
|
||||
out vec3 SPECULAR;
|
||||
|
||||
flat out float kill;
|
||||
|
||||
const float cullDistance = 100.0;
|
||||
|
||||
struct DirectionalLight {
|
||||
vec3 direction;
|
||||
vec3 color;
|
||||
@ -43,6 +47,11 @@ uniform Material material;
|
||||
void main() {
|
||||
vec4 vertex = PROJECTION * VIEW * MODEL * vec4(pos, 1.0);
|
||||
gl_Position = vertex;
|
||||
if (length(vertex) > cullDistance) {
|
||||
kill = 1.0;
|
||||
} else {
|
||||
kill = 0.0;
|
||||
}
|
||||
|
||||
UV = uv;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user