36 lines
1.0 KiB
GLSL
36 lines
1.0 KiB
GLSL
|
#version 400 core
|
|||
|
|
|||
|
in vec2 pass_textureCoordinates;
|
|||
|
in vec3 surfaceNormal;
|
|||
|
in vec3 toLightVector;
|
|||
|
in vec3 toCameraVector;
|
|||
|
|
|||
|
out vec4 out_Color;
|
|||
|
|
|||
|
uniform sampler2D modelTexture;
|
|||
|
|
|||
|
uniform float shineDamper;
|
|||
|
uniform float reflectivity;
|
|||
|
|
|||
|
void main(void){
|
|||
|
|
|||
|
vec3 unitNormal = normalize(surfaceNormal);
|
|||
|
vec3 unitLightVector = normalize(toLightVector);
|
|||
|
|
|||
|
float nDotl = dot(unitNormal,unitLightVector);
|
|||
|
float brightness = max(nDotl,0.2);
|
|||
|
vec3 diffuse = brightness * vec3(1.0, 1.0, 1.0); //Tu by<62>a zmiana
|
|||
|
|
|||
|
vec3 unitVectorToCamera = normalize(toCameraVector);
|
|||
|
vec3 lightDirection = -unitLightVector;
|
|||
|
vec3 reflectedLightDirection = reflect(lightDirection,unitNormal);
|
|||
|
|
|||
|
float specularFactor = dot(reflectedLightDirection , unitVectorToCamera);
|
|||
|
specularFactor = max(specularFactor,0.0);
|
|||
|
float dampedFactor = pow(specularFactor,shineDamper);
|
|||
|
vec3 finalSpecular = dampedFactor * reflectivity * vec3(1.0, 1.0, 1.0); //Tu by<62>a zmiana
|
|||
|
|
|||
|
|
|||
|
out_Color = vec4(diffuse,1.0) * texture(modelTexture,pass_textureCoordinates) + vec4(finalSpecular,1.0);
|
|||
|
|
|||
|
}
|