Browse Source

No need to output 4 flots from SSAO shader

BearishSun 8 years ago
parent
commit
02e18de5ba

+ 7 - 7
Data/Raw/Engine/Shaders/PPSSAO.bsl

@@ -105,7 +105,7 @@ technique PPSSAO
 			return weightedSum / weightSum;
 		}
 		
-		float4 fsmain(VStoFS input, float4 pixelPos : SV_Position) : SV_Target0
+		float fsmain(VStoFS input, float4 pixelPos : SV_Position) : SV_Target0
 		{
 			// TODO - Support MSAA (most likely don't require all samples)
 		
@@ -208,16 +208,16 @@ technique PPSSAO
 				accumulator += float2(weightedValue.x + weightedValue.y, 2.0f * stepAccum.z);
 			}
 			
-			float4 output = 0;
+			float output = 0;
 			
 			// Divide by total weight to get the weighted average
-			output.r = accumulator.x / accumulator.y;
+			output = accumulator.x / accumulator.y;
 			
 			#if MIX_WITH_UPSAMPLED
 			float upsampledAO = getUpsampledAO(input.uv0, sceneDepth, worldNormal);
 			
 			// Note: 0.6f just an arbitrary constant that looks good. Make this adjustable externally?
-			output.r = lerp(output.r, upsampledAO, 0.6f);
+			output = lerp(output, upsampledAO, 0.6f);
 			#endif
 			
 			#if FINAL_AO
@@ -229,7 +229,7 @@ technique PPSSAO
 			// Note: Ideally the blur would be 4x4 since the pattern is 4x4
 			
 			// TODO - Don't blur on minimal quality level
-			float4 myVal = float4(output.r, viewNormal);
+			float4 myVal = float4(output, viewNormal);
 			float4 dX = ddx_fine(myVal);
 			float4 dY = ddy_fine(myVal);
 			
@@ -248,9 +248,9 @@ technique PPSSAO
 			weightHorz *= invWeight;
 			weightVert *= invWeight;
 			
-			output.r = output.r * myWeight + horzVal.r * weightHorz + vertVal.r * weightVert;
+			output = output * myWeight + horzVal.r * weightHorz + vertVal.r * weightVert;
 			
-			return output; // TODO - No need to output 4 values
+			return output;
 		}	
 	};
 };

+ 4 - 1
Source/RenderBeast/Source/BsPostProcessing.cpp

@@ -1308,7 +1308,10 @@ namespace bs { namespace ct
 		// TODO - Resolve normals if MSAA
 		// TODO - When downsampling, consider using previous pass as input instead of always sampling gbuffer data
 
-		UINT32 numDownsampleLevels = 1; // TODO - Make it a property, ranging [0, 2]
+		// Multiple downsampled AO levels are used to minimize cache trashing. Downsampled AO targets use larger radius,
+		// whose contents are then blended with the higher level.
+
+		UINT32 numDownsampleLevels = 2; // TODO - Make it a property, ranging [0, 2]
 		UINT32 quality = 1; // TODO - Make it a property
 
 		SPtr<PooledRenderTexture> setupTex0;