3delight and useBackground
为什么3delight使用maya的useBackground材质渲出来的阴影怪的不行,后来发现它使用的阴影计算方法有点不一样。
原因就在shading_utils.h文件里头定义的computeShadowValue函数,把这个函数修改成下边的方法才好使一点。
float computeShadowValue(normal i_N)
{
float shadowValue = 0;
varying float totalLightIntensity = 0;
normal unitN=normalize(i_N);
normal Nn= ShadingNormal(unitN);
extern varying point P;
illuminance(P,Nn,PI/2)
{
float Cl_shd=0;
color Cl_noshd=0;
float k = Nn.normalize(L);
lightsource("__3dfm_shadowing", Cl_shd);
lightsource("__3dfm_unshadowed_cl", Cl_noshd);
float unshadowed_intensity = luminance(Cl_noshd);
shadowValue += k * Cl_shd * unshadowed_intensity;
totalLightIntensity += k *unshadowed_intensity;
}
shadowValue /= totalLightIntensity;
return shadowValue;
}