You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#version 430
|
|
|
|
layout (binding=0) uniform sampler2D samp;
|
|
|
|
in vec2 uv;
|
|
|
|
in vec3 varyingNormal;
|
|
|
|
in vec3 varyingLightDir;
|
|
|
|
in vec3 varyingVertPos;
|
|
|
|
in vec3 varyingHalfVector;
|
|
|
|
out vec4 color;
|
|
|
|
|
|
|
|
struct PositionalLight
|
|
|
|
{ vec4 ambient;
|
|
|
|
vec4 diffuse;
|
|
|
|
vec4 specular;
|
|
|
|
vec3 position;
|
|
|
|
};
|
|
|
|
struct Material
|
|
|
|
{ vec4 ambient;
|
|
|
|
vec4 diffuse;
|
|
|
|
vec4 specular;
|
|
|
|
float shininess;
|
|
|
|
};
|
|
|
|
uniform vec4 globalAmbient;
|
|
|
|
uniform PositionalLight light;
|
|
|
|
uniform Material material;
|
|
|
|
|
|
|
|
void main(void)
|
|
|
|
{
|
|
|
|
vec3 Normal=normalize(varyingNormal);
|
|
|
|
vec3 Light=normalize(varyingLightDir);
|
|
|
|
|
|
|
|
vec3 ViewVec=normalize(-varyingVertPos);
|
|
|
|
vec3 H=normalize(varyingHalfVector);
|
|
|
|
|
|
|
|
float cosTheta=dot(Light,Normal);
|
|
|
|
float cosPhi=dot(Normal,H);
|
|
|
|
|
|
|
|
vec3 ambient=((globalAmbient * material.ambient) + (light.ambient * material.ambient)).xyz;
|
|
|
|
vec3 diffuse=light.diffuse.xyz * material.diffuse.xyz * max(cosTheta, 0.0);
|
|
|
|
vec3 specular=material.specular.xyz * light.specular.xyz * pow(max(cosPhi, 0.0f), material.shininess*3.0);
|
|
|
|
|
|
|
|
color=vec4(ambient+diffuse+specular,material.diffuse.w);
|
|
|
|
}
|