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 AMBIENT;
|
||||||
in vec3 DIFFUSE;
|
in vec3 DIFFUSE;
|
||||||
in vec3 SPECULAR;
|
in vec3 SPECULAR;
|
||||||
|
flat in float kill;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
@ -38,4 +39,8 @@ void main() {
|
|||||||
if (material.cullBack && !gl_FrontFacing) {
|
if (material.cullBack && !gl_FrontFacing) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kill == 1.0) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,10 @@ out vec3 AMBIENT;
|
|||||||
out vec3 DIFFUSE;
|
out vec3 DIFFUSE;
|
||||||
out vec3 SPECULAR;
|
out vec3 SPECULAR;
|
||||||
|
|
||||||
|
flat out float kill;
|
||||||
|
|
||||||
|
const float cullDistance = 100.0;
|
||||||
|
|
||||||
struct DirectionalLight {
|
struct DirectionalLight {
|
||||||
vec3 direction;
|
vec3 direction;
|
||||||
vec3 color;
|
vec3 color;
|
||||||
@ -43,6 +47,11 @@ uniform Material material;
|
|||||||
void main() {
|
void main() {
|
||||||
vec4 vertex = PROJECTION * VIEW * MODEL * vec4(pos, 1.0);
|
vec4 vertex = PROJECTION * VIEW * MODEL * vec4(pos, 1.0);
|
||||||
gl_Position = vertex;
|
gl_Position = vertex;
|
||||||
|
if (length(vertex) > cullDistance) {
|
||||||
|
kill = 1.0;
|
||||||
|
} else {
|
||||||
|
kill = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
UV = uv;
|
UV = uv;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user