فهرست منبع

MRT_low allocates RGB10A2 textures instead of RGB16F/RG11B10UF

clementlandrin 2 سال پیش
والد
کامیت
a5575566f2
3فایلهای تغییر یافته به همراه8 افزوده شده و 5 حذف شده
  1. 4 4
      h3d/scene/pbr/Renderer.hx
  2. 1 1
      h3d/shader/BaseMesh.hx
  3. 3 0
      h3d/shader/pbr/PropsImport.hx

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

@@ -285,7 +285,7 @@ class Renderer extends h3d.scene.Renderer {
 		draw(pbrLightPass.name);
 
 		if ( displayMode == Performance ) {
-			var perf = allocTarget("performance", #if MRT_low RG11B10UF #else RGBA16F #end);
+			var perf = allocTarget("performance", #if MRT_low RGB10A2 #else RGBA16F #end);
 			h3d.pass.Copy.run(textures.hdr, perf);
 			performance.shader.hdrMap = perf;
 		}
@@ -311,7 +311,7 @@ class Renderer extends h3d.scene.Renderer {
 		}
 
 		// Probe Rendering & Blending
-		var probeOutput = allocTarget("probeOutput", true, 1.0, #if MRT_low RG11B10UF #else RGBA16F #end);
+		var probeOutput = allocTarget("probeOutput", true, 1.0, #if MRT_low RGB10A2 #else RGBA16F #end);
 		ctx.engine.pushTarget(probeOutput);
 		clear(0);
 
@@ -395,13 +395,13 @@ class Renderer extends h3d.scene.Renderer {
 
 	function initTextures() {
 		textures.albedo = allocTarget("albedo", true, 1.);
-		textures.normal = allocTarget("normal", true, 1., RGBA16F);
+		textures.normal = allocTarget("normal", true, 1., RGB10A2);
 		textures.pbr = allocTarget("pbr", true, 1.);
 		#if !MRT_low
 		textures.other = allocTarget("other", true, 1.);
 		#end
 		textures.depth = allocTarget("depth", true, 1., R32F);
-		textures.hdr = allocTarget("hdrOutput", true, 1, #if MRT_low RG11B10UF #else RGBA16F #end);
+		textures.hdr = allocTarget("hdrOutput", true, 1, #if MRT_low RGB10A2 #else RGBA16F #end);
 		textures.ldr = allocTarget("ldrOutput");
 	}
 

+ 1 - 1
h3d/shader/BaseMesh.hx

@@ -86,7 +86,7 @@ class BaseMesh extends hxsl.Shader {
 		function fragment() {
 			output.color = pixelColor;
 			output.depth = depth;
-			output.normal = transformedNormal;
+			output.normal = #if MRT_low packNormal(transformedNormal).rgb #else transformedNormal #end;
 			output.worldDist = worldDist;
 		}
 

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

@@ -35,6 +35,9 @@ class PropsImport extends hxsl.Shader {
 			albedo *= albedo; // gamma correct
 
 			normal = normalTex.get(uv).xyz;
+			#if MRT_low
+			normal = unpackNormal(vec4(normal, 1.0));
+			#end
 			var pbr = pbrTex.get(uv);
 			metalness = pbr.r;
 			roughness = pbr.g;