Browse Source

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

clementlandrin 1 year ago
parent
commit
69e2241ad8
1 changed files with 6 additions and 1 deletions
  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.);