浏览代码

Add clamp to custom light function example (#3752)

Without this clamp, negative lighting will be applied to the back side of the object.
bmolyneaux 5 年之前
父节点
当前提交
f48162e9cc
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      tutorials/shading/shading_reference/spatial_shader.rst

+ 1 - 1
tutorials/shading/shading_reference/spatial_shader.rst

@@ -293,7 +293,7 @@ Below is an example of a custom light function using a Lambertian lighting model
 .. code-block:: glsl
 .. code-block:: glsl
 
 
     void light() {
     void light() {
-        DIFFUSE_LIGHT += dot(NORMAL, LIGHT) * ATTENUATION * ALBEDO;
+        DIFFUSE_LIGHT += clamp(dot(NORMAL, LIGHT), 0.0, 1.0) * ATTENUATION * ALBEDO;
     }
     }
 
 
 If you want the lights to add together, add the light contribution to ``DIFFUSE_LIGHT`` using ``+=``, rather than overwriting it.
 If you want the lights to add together, add the light contribution to ``DIFFUSE_LIGHT`` using ``+=``, rather than overwriting it.