projekt_grafika/cw 2/shaders/shader_tex.vert
2022-02-13 01:51:44 +01:00

31 lines
693 B
GLSL

#version 410 core
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec2 vertexTexCoord;
layout(location = 2) in vec3 vertexNormal;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelMatrix;
uniform vec3 cameraPos;
out vec3 interpNormal;
out vec2 interpTexCoord;
out float visibility;
const float density = 0.0050;
const float gradient = 2.0;
void main()
{
gl_Position = modelViewProjectionMatrix * vec4(vertexPosition, 1.0);
interpNormal = (modelMatrix * vec4(vertexNormal, 0.0)).xyz;
interpTexCoord = vertexTexCoord;
float distance = length(gl_Position);
visibility = exp(-pow((distance*density),gradient));
visibility = clamp(visibility,0.0,1.0);
}