diff --git a/cw 7/shaders/shader_5_tex.frag b/cw 7/shaders/shader_5_tex.frag index 1c2f19d..cb24da1 100644 --- a/cw 7/shaders/shader_5_tex.frag +++ b/cw 7/shaders/shader_5_tex.frag @@ -1,9 +1,9 @@ #version 430 core -float AMBIENT = 0.6; +float AMBIENT = 0.4; float roughness; float metalic; - +float MAX_DISTANCE = 12.0; uniform vec3 color; uniform sampler2D colorTexture; @@ -17,7 +17,7 @@ in vec2 vecTex; in vec3 viewDirTS; in vec3 lightDirTS; - +in float distanceToCamera; out vec4 outColor; void main() @@ -57,7 +57,10 @@ void main() vec3 BRDF = kD*(textureColor/3.1458493) + specular; - + if (distanceToCamera > MAX_DISTANCE) + { + discard; + } diff --git a/cw 7/shaders/shader_5_tex.vert b/cw 7/shaders/shader_5_tex.vert index fbd4e0e..21618d3 100644 --- a/cw 7/shaders/shader_5_tex.vert +++ b/cw 7/shaders/shader_5_tex.vert @@ -17,7 +17,7 @@ uniform vec3 cameraPos; out vec3 viewDirTS; out vec3 lightDirTS; - +out float distanceToCamera; mat3 TBN; @@ -42,6 +42,6 @@ void main() vecTex = vertexTexCoord; vecTex.y = 1.0 - vecTex.y; - + distanceToCamera = length(worldPos - cameraPos); gl_Position = transformation * vec4(vertexPosition, 1.0); }