-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfragment.glsl
38 lines (28 loc) · 1.01 KB
/
fragment.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#version 330 core
in vec3 FragPos; //--- 위치값
in vec3 Normal; //--- 버텍스 세이더에서 받은 노멀값
out vec4 FragColor; //--- 색상 출력
uniform vec3 inputColor;
//uniform vec3 texCoord;
uniform vec3 lightPos; //--- 조명의 위치
uniform vec3 lightColor; //--- 조명의 색
uniform vec3 viewPos;
void main(void)
{
float ambientLight = 0.7;
vec3 ambient = ambientLight * lightColor;
vec3 norm = normalize(Normal);
vec3 lightDir = normalize(lightPos - FragPos);
float diffuseLight = max(dot(Normal, lightDir), 0.0);
float d = 0.05f;
vec3 diffuse = d * diffuseLight * lightColor;
int shininess = 36;
vec3 viewDir = normalize(viewPos - FragPos);
vec3 reflectDir = reflect(-lightDir, norm);
float specularLight = max(dot(viewDir, reflectDir), 0.0);
specularLight = pow(specularLight, shininess);
vec3 specular = specularLight * lightColor;
vec3 result = (ambient + diffuse + specular) * inputColor;
//vec3 result = (ambient + specular ) * inputColor;
FragColor = vec4(result, 1.0f);
}