Sfoglia il codice sorgente

[RENDERER] Fill MRT empty slots with named variables, custom1 and custom2.

clandrin 4 anni fa
parent
commit
0d999525b8

+ 1 - 1
h3d/scene/pbr/Renderer.hx

@@ -101,7 +101,7 @@ class Renderer extends h3d.scene.Renderer {
 		Vec4([Swiz(Value("output.color"),[X,Y,Z]), Value("output.albedoStrength",1)]),
 		Vec4([Value("output.normal",3), Value("output.normalStrength",1)]),
 		Vec4([Value("output.metalness"), Value("output.roughness"), Value("output.occlusion"), Value("output.pbrStrength")]),
-		Vec4([Value("output.emissive"), Const(0), Const(0), Value("output.emissiveStrength")])
+		Vec4([Value("output.emissive"), Value("output.custom1"), Value("output.custom2"), Value("output.emissiveStrength")])
 	]);
 
 	public function new(?env) {

+ 2 - 0
h3d/shader/pbr/PropsDefinition.hx

@@ -10,6 +10,8 @@ class PropsDefinition extends hxsl.Shader {
 		var roughness : Float;
 		var occlusion : Float;
 		var emissive : Float;
+		var custom1 : Float;
+		var custom2 : Float;
 		var pbrSpecularColor : Vec3;
 		var transformedPosition : Vec3;
 

+ 4 - 0
h3d/shader/pbr/PropsImport.hx

@@ -20,6 +20,8 @@ class PropsImport extends hxsl.Shader {
 		var roughness : Float;
 		var occlusion : Float;
 		var emissive : Float;
+		var custom1 : Float;
+		var custom2 : Float;
 		var calculatedUV : Vec2;
 		var transformedPosition : Vec3;
 		var pbrSpecularColor : Vec3;
@@ -38,6 +40,8 @@ class PropsImport extends hxsl.Shader {
 
 			var other = otherTex.get(uv);
 			emissive = other.r;
+			custom1 = other.g;
+			custom2 = other.b;
 			depth = depthTex.get(uv).r;
 
 			pbrSpecularColor = mix(vec3(0.04),albedo,metalness);

+ 10 - 0
h3d/shader/pbr/PropsTexture.hx

@@ -5,18 +5,24 @@ class PropsTexture extends hxsl.Shader {
 
 		@param var texture : Sampler2D;
 		@param var emissiveValue : Float;
+		@param var custom1Value : Float;
+		@param var custom2Value : Float;
 
 		var output : {
 			metalness : Float,
 			roughness : Float,
 			occlusion : Float,
 			emissive : Float,
+			custom1 : Float,
+			custom2 : Float,
 		};
 
 		var metalness : Float;
 		var roughness : Float;
 		var occlusion : Float;
 		var emissive : Float;
+		var custom1 : Float;
+		var custom2 : Float;
 
 		var calculatedUV : Vec2;
 
@@ -27,6 +33,8 @@ class PropsTexture extends hxsl.Shader {
 				roughness = 1 - v.g * v.g;
 				occlusion = v.b;
 				emissive = emissiveValue * v.a;
+				custom1 = custom1Value * v.a;
+				custom2 = custom2Value * v.a;
 			}
 		}
 
@@ -35,6 +43,8 @@ class PropsTexture extends hxsl.Shader {
 			output.roughness = roughness;
 			output.occlusion = occlusion;
 			output.emissive = emissive;
+			output.custom1 = custom1;
+			output.custom2 = custom2;
 		}
 
 	}

+ 13 - 1
h3d/shader/pbr/PropsValues.hx

@@ -9,23 +9,31 @@ class PropsValues extends hxsl.Shader {
 			roughness : Float,
 			occlusion : Float,
 			emissive : Float,
+			custom1 : Float,
+			custom2 : Float,
 		};
 
 		@param var metalnessValue : Float;
 		@param var roughnessValue : Float;
 		@param var occlusionValue : Float;
 		@param var emissiveValue : Float;
+		@param var custom1Value : Float;
+		@param var custom2Value : Float;
 
 		var metalness : Float;
 		var roughness : Float;
 		var occlusion : Float;
 		var emissive : Float;
+		var custom1 : Float;
+		var custom2 : Float;
 
 		function __init__() {
 			metalness = metalnessValue;
 			roughness = roughnessValue;
 			occlusion = occlusionValue;
 			emissive = emissiveValue;
+			custom1 = custom1Value;
+			custom2 = custom2Value;
 		}
 
 		function fragment() {
@@ -33,16 +41,20 @@ class PropsValues extends hxsl.Shader {
 			output.roughness = roughness;
 			output.occlusion = occlusion;
 			output.emissive = emissive;
+			output.custom1 = custom1;
+			output.custom2 = custom2;
 		}
 
 	};
 
-	public function new(metalness=0.,roughness=1.,occlusion=1.,emissive=0.) {
+	public function new(metalness=0.,roughness=1.,occlusion=1.,emissive=0.,custom1=0.,custom2=0.) {
 		super();
 		this.metalnessValue = metalness;
 		this.roughnessValue = roughness;
 		this.occlusionValue = occlusion;
 		this.emissiveValue = emissive;
+		this.custom1Value = custom1;
+		this.custom2Value = custom2;
 	}
 
 }