瀏覽代碼

bloom bug hunting

Samuel Skiff 3 年之前
父節點
當前提交
820e1972b0

+ 36 - 37
Templates/BaseGame/game/core/postFX/scripts/Bloom/BloomPostFX.tscript

@@ -30,15 +30,15 @@ singleton ShaderData( PFX_Bloom_Shader )
 	 pixVersion = 3.0;
 };
 
-singleton ShaderData( PFX_BloomDownSample_Shader )
-{
-   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
-	 DXPixelShaderFile  = "./downSampleP.hlsl";
-	 
-	 samplerNames[0] = "$inputTex";
-	 
-	 pixVersion = 3.0;
-};
+//singleton ShaderData( PFX_BloomDownSample_Shader )
+//{
+//   DXVertexShaderFile = $Core::CommonShaderPath @ "/postFX/postFxV.hlsl";
+//	 DXPixelShaderFile  = "./downSampleP.hlsl";
+//	 
+//	 samplerNames[0] = "$inputTex";
+//	 
+//	 pixVersion = 3.0;
+//};
 
 singleton GFXStateBlockData( BloomPostFX_SampleStateBlock : PFX_DefaultStateBlock )
 {
@@ -46,13 +46,13 @@ singleton GFXStateBlockData( BloomPostFX_SampleStateBlock : PFX_DefaultStateBloc
    samplerStates[0] = SamplerClampLinear;
 };
 
-function BloomPostFX::setShaderConsts( %this )
-{
-}
-
-function BloomPostFX::preProcess( %this )
-{
-}
+//function BloomPostFX::setShaderConsts( %this )
+//{
+//}
+//
+//function BloomPostFX::preProcess( %this )
+//{
+//}
 
 function BloomPostFX::onAdd(%this)
 {
@@ -120,34 +120,33 @@ singleton PostEffect( BloomPostFX )
    stateBlock = BloomPostFX_SampleStateBlock;
    texture[0] = "$backBuffer";
    target = "$outTex";
-	 targetFormat = "GFXFormatR16G16B16A16F";
 	 
-	 new PostEffect()
-	 {
-		allowReflectPass = false;
-		shader = PFX_BloomDownSample_Shader;
-		stateBlock = BloomPostFX_SampleStateBlock;
-		texture[0] = "$inTex";
-		target = "#bloom0";
-		targetScale = "0.5 0.5";
-	 };
-	 
-	 new PostEffect()
-	 {
-		allowReflectPass = false;
-		shader = PFX_BloomDownSample_Shader;
-		stateBlock = BloomPostFX_SampleStateBlock;
-		texture[0] = "#bloom0";
-		target = "#bloom1";
-		targetScale = "0.25 0.25";
-	 };
+	// new PostEffect()
+	// {
+	//	allowReflectPass = false;
+	//	shader = PFX_BloomDownSample_Shader;
+	//	stateBlock = BloomPostFX_SampleStateBlock;
+	//	texture[0] = "$inTex";
+	//	target = "#bloom0";
+	//	targetScale = "0.5 0.5";
+	// };
+	// 
+	// new PostEffect()
+	// {
+	//	allowReflectPass = false;
+	//	shader = PFX_BloomDownSample_Shader;
+	//	stateBlock = BloomPostFX_SampleStateBlock;
+	//	texture[0] = "#bloom0";
+	//	target = "#bloom1";
+	//	targetScale = "0.25 0.25";
+	// };
 	 
 	 new PostEffect()
 	 {
 		allowReflectPass = false;
 		shader = PFX_PassthruShader;
 		stateBlock = BloomPostFX_SampleStateBlock;
-		texture[0] = "#bloom1";
+		texture[0] = "$inTex";
 		target = "$backBuffer";
 	 };
 };

+ 3 - 3
Templates/BaseGame/game/core/postFX/scripts/Bloom/bloomP.hlsl

@@ -26,7 +26,7 @@ TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
 
 float4 main(PFXVertToPix IN) : TORQUE_TARGET0
 {
-	float4 color = TORQUE_TEX2D(inputTex, IN.uv0);
-	float brightness = max(color.r, max(color.g, color.b));
-	return float4(color.rgb * pow(brightness, 8.0f), color.a);
+	float4 screenColor = TORQUE_TEX2D(inputTex, IN.uv0);
+	float brightness = max(screenColor.r, max(screenColor.g, screenColor.b));
+	return float4(screenColor.rgb * saturate(pow(brightness, 8.0f)), screenColor.a);
 }

+ 3 - 4
Templates/BaseGame/game/core/postFX/scripts/Bloom/downSampleP.hlsl

@@ -27,16 +27,15 @@
 //-----------------------------------------------------------------------------
 
 TORQUE_UNIFORM_SAMPLER2D(inputTex, 0);
-//uniform float2 targetSize;
+//uniform float2 oneOverTargetSize;
  
 //-----------------------------------------------------------------------------
 // Main
 //-----------------------------------------------------------------------------
 float4 main(PFXVertToPix IN) : TORQUE_TARGET0
 {
-	float2 texSize = 1.0f / float2(1024.0f, 1024.0f);
-	float x = texSize.x;
-	float y = texSize.y;
+	float x = 0.01f;
+	float y = 0.01f;
 	float4 a = TORQUE_TEX2D( inputTex, IN.uv0 + float2(-x*2.0f, y*2.0f));
 	float4 b = TORQUE_TEX2D( inputTex, IN.uv0 + float2( 0.0f  , y*2.0f));
 	float4 c = TORQUE_TEX2D( inputTex, IN.uv0 + float2( x*2.0f, y*2.0f));

+ 3 - 3
Templates/BaseGame/game/core/postFX/scripts/Bloom/upSampleP.hlsl

@@ -30,12 +30,12 @@ struct Conn
 
 TORQUE_UNIFORM_SAMPLER2D(inputTex0, 0);
 TORQUE_UNIFORM_SAMPLER2D(inputTex1, 1);
-uniform float filterRadius;
+//uniform float filterRadius;
 
 float4 main( Conn V_IN ) : TORQUE_TARGET0
 {
-	float x = filterRadius;
-	float y = filterRadius;
+	float x = 1.0f;
+	float y = 1.0f;
 	
 	float4 a = TORQUE_TEX2D( inputTex0, V_IN.texCoord + float2(-x, y));
 	float4 b = TORQUE_TEX2D( inputTex0, V_IN.texCoord + float2( 0, y));

+ 1 - 1
Templates/BaseGame/game/core/postFX/scripts/default.postfxpreset.tscript

@@ -1 +1 @@
-
+$PostFX::BloomPostFX::Enabled = "1";