Grafika_2024/projekt_grk/shaders/shader_5_1_tex_copy.frag

31 lines
675 B
GLSL
Raw Permalink Normal View History

2024-01-29 22:05:00 +01:00
#version 430 core
float AMBIENT = 0.1;
uniform vec3 color;
uniform vec3 lightPos;
uniform sampler2D colorTexture;
uniform sampler2D normalSampler;
in vec2 vecTex;
in vec3 viewDirTS;
in vec3 lightDirTS;
out vec4 outColor;
void main()
{
vec3 normalTS = vec3(0, 0, 1);
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
vec3 N = texture2D(normalSampler, vecTex).xyz;
N = normalize((N * 2.0) - 1.0);
// Normalizujemy wektory w przestrzeni stycznej
vec3 lightDir = normalize(lightDirTS);
vec3 viewDir = normalize(viewDirTS);
float diffuse=max(0,dot(N,lightDir));
outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0);
//outColor = vec4(N, 1.0);
}