浏览代码

Diffuse and specular can be computed from different directions for the same light.

clementlandrin 1 年之前
父节点
当前提交
69e2241ad8
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      h3d/shader/pbr/Lighting.hx

+ 6 - 1
h3d/shader/pbr/Lighting.hx

@@ -100,16 +100,21 @@ class Direct extends PropsDefinition {
 		@:import h3d.shader.pbr.BDRF;
 
 		var pbrLightDirection : Vec3;
+		var pbrSpecularLightDirection : Vec3;
 		var pbrLightColor : Vec3;
 		var pbrOcclusionFactor : Float;
 		@const var doDiscard : Bool = true;
 
+		function __init__fragment2() {
+			pbrSpecularLightDirection = pbrLightDirection;
+		}
+
 		function fragment() {
 
 			var NdL = normal.dot(pbrLightDirection).max(0.);
 			if( pbrLightColor.dot(pbrLightColor) > 0.0001 && NdL > 0 ) {
 
-				var half = (pbrLightDirection + view).normalize();
+				var half = (pbrSpecularLightDirection + view).normalize();
 				var NdH = normal.dot(half).max(0.);
 				var VdH = view.dot(half).max(0.);