소스 검색

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.);