2013-04-20 55 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

我是个白痴。我的笔记错误地指出,当它实际上是总和时,强度应该是组件的乘积。