着色器 - 简单的SSS照明问题

时间:2015-05-08 08:47:06

标签: opengl directx glsl shader hlsl

我正在尝试使用着色器创建一个简单的次表面散射效果,但我面临一个小问题。

查看这些截图。这三个图像代表三种照明状态(表面上方,非常接近表面,次表面),具有各种照明颜色(红色和蓝色),并且始终具有相同的次表面颜色(红色)。

enter image description here

正如您可能会注意到,当光线在表面上方并且非常接近该表面时,其影响似乎最小化了预期的行为。但问题是对于地下部分的行为是相同的,根据我的着色器代码这是正常的,但在我看来,当接近表面时,地下光的影响应该更高。我建议你查看预期结果的截图。

我该怎么做?

这是简化的着色器代码。

half ndotl = max(0.0f, dot(normalWorld, lightDir));
half inversendotl = max(0.0f, dot(normalWorld, -lightDir));
half3 lightColor = _LightColor0.rgb * ndotl; // This is the normal light color calculation
half3 subsurfacecolor = translucencyColor.rgb * inversendotl; // This is the subsurface color
half3 topsubsurfacecolor = translucencyColor.rgb; // This is used for adding subsurface color to top surface
final = subsurfacescolor + lerp(lightColor, topsubsurfacecolor * 0.5, 1 - ndotl - inversendotl);

0 个答案:

没有答案