2013-04-20 5 views
0

Phong 조명 모델에 대한 기본 쉐이더 코드가 있습니다. 확산, 주위 및 반사 조명을 테스트했으며 정확한 결과를 산출하고 있습니다. 마지막 라인에서 구성 할 때 주변 조명과 같은 효과를 계속 얻습니다. 누가 그걸 잘못 알고 있니?ADS (Phong/Gourang) 구성 요소 구성하기

//translate the normals to be in sync with any tranlations applied to the model 
vec3 tnormal = normalize(vec3(viewMatrix * modelMatrix * vec4(normal,0.0)));  
vec3 tVertex = vec3(viewMatrix * modelMatrix * vec4(position, 1.0)); 

// Ambient = La * Ka 
vec3 ambience = La * theMaterial.ka; 

//Diffuse = Ld * Kd * dot(s, n) 
vec3 s = normalize(vec3(myLight.position - tVertex)); 
vec3 diffuse = myLight.Ld * theMaterial.kd * max(dot(s, tnormal), 0.0); 

//Specular = Ls * ks * dot(r,n)^f 
//r is the reflection of -lightposition, r = -s + 2 * dot(s,n) * n 
vec3 r = normalize(reflect(-myLight.position, tnormal)); 
vec3 v = normalize(-tVertex.xyz); 
vec3 specularity = myLight.Ls * theMaterial.ks * pow(dot(v, r), theMaterial.f); 


//(ABS) Intensity = Ia * Id * Is 
LightIntensity = ambience * diffuse * specularity; 

답변

0

나는 바보입니다. 내 노트는 실제 합계 일 때 상태 강도가 구성 요소의 곱이어야합니다.