From 37aa8e0c99254601220159d652ecbab558f68a77 Mon Sep 17 00:00:00 2001 From: mxsgd Date: Thu, 8 Feb 2024 09:24:56 +0100 Subject: [PATCH] =?UTF-8?q?p=C5=82ynne=20przejscie=20planetoid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cw 7/shaders/shader_5_tex.frag | 11 +++++++---- cw 7/shaders/shader_5_tex.vert | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) 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); }