25 lines
608 B
GLSL
25 lines
608 B
GLSL
|
#version 430 core
|
||
|
|
||
|
float AMBIENT = 0.1;
|
||
|
|
||
|
uniform vec3 color;
|
||
|
uniform vec3 lightPos;
|
||
|
uniform sampler2D colorTexture;
|
||
|
uniform sampler2D normal0;
|
||
|
|
||
|
in vec3 vecNormal;
|
||
|
in vec3 worldPos;
|
||
|
in vec2 vecTex;
|
||
|
|
||
|
out vec4 outColor;
|
||
|
void main()
|
||
|
{
|
||
|
vec3 lightDir = normalize(lightPos);
|
||
|
vec3 normal = normalize(vecNormal);
|
||
|
vec3 normals = normalize(texture2D(normal0, vecTex).xyz * 2.0f - 1.0f);
|
||
|
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
|
||
|
float diffuse=max(dot(normal,lightDir), 0.0f);
|
||
|
float diffuses=max(dot(normals,lightDir), 0.0f);
|
||
|
outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0) * diffuses;
|
||
|
}
|