我正在尝试找出如何使用phong模型来缩放具有照明照明的颜色。例如,给定i= KaAx,其中ka是环境系数,Ax是环境照明强度,其中x可以是r,b或g,例如,我希望将其应用于纹理颜色为(1,0,1)的曲面。我试着将单个rgb值乘以I,(r*Ka*Ar.r,r*Kb*Ag,r*Kg*Ab)照明,但它可以完全改变颜色,这不是我想要的。
发布于 2014-01-15 05:57:34
好的,我看到了几件事:
对每种颜色(.r、.g、.b)和像太阳这样的平行光试试这个:
pixel_color.r=clamp_to_1 // clamp to <0.0,1.1>
(
texture_color.r*glColor.r // pixel color without lighting
*( // apply lighting
diffuse.r*((glNormal.xyz*NormalMatrix).light_dir.xyz) // diffuse * dot product of light source direction and normal vectors. If you need also consider distance just multiply by next term...
+ambient.r // ambient light is additive !!!
)
);PS。
原点设置为0.0,0.0,0.0
https://stackoverflow.com/questions/13503325
复制相似问题