2
0
Эх сурвалжийг харах

SSAO: pick different sample/step count based on quality level

BearishSun 8 жил өмнө
parent
commit
2779f6cc40

+ 35 - 14
Data/Raw/Engine/Shaders/PPSSAO.bsl

@@ -32,21 +32,42 @@ technique PPSSAO
 		SamplerState gRandomSamp;
 		Texture2D gRandomTex;
 		
-		// TODO - Allow these to be controlled by a quality level
-		#define SAMPLE_COUNT 6
-		#define SAMPLE_STEPS 3
+		#if QUALITY < 3
+			#define SAMPLE_STEPS 1
+		#else
+			#define SAMPLE_STEPS 3
+		#endif
 		
-		static const float2 SAMPLES[6] =
-		{
-			// Points within a disc, at equally separated angles from 0 to 2PI.
-			// Each point is also placed further away from the disc center, up to unit disc radius.
-			float2( 0.000f,  0.166f),
-			float2( 0.288f,  0.166f),
-			float2( 0.433f, -0.250f),
-			float2( 0.000f, -0.666f),
-			float2(-0.721f, -0.416f),
-			float2(-0.866,   0.500f)
-		};
+		#if QUALITY < 4
+			#define SAMPLE_SET 0
+		#else
+			#define SAMPLE_SET 1
+		#endif
+		
+		// Points within a disc, at equally separated angles from 0 to 2PI.
+		// Each point is also placed further away from the disc center, up to unit disc radius.
+		// f[x_, s_] := {((x + 1)/(s + 1))*Cos[(x/s)*2 Pi], (x + 1)/(s + 1)*Sin[(x/s)*2 Pi]}
+		#if SAMPLE_SET == 0
+			#define SAMPLE_COUNT 3
+			static const float2 SAMPLES[3] =
+			{
+				float2( 0.250f,  0.000f),
+				float2(-0.250f,  0.433f),
+				float2(-0.375f, -0.649f)
+			};
+		#else
+			#define SAMPLE_COUNT 6
+			static const float2 SAMPLES[6] =
+			{
+
+				float2( 0.142f,  0.000f),
+				float2( 0.142f,  0.247f),
+				float2(-0.214f,  0.371f),
+				float2(-0.571f,  0.000f),
+				float2(-0.357f, -0.618f),
+				float2( 0.428f, -0.742f)
+			};		
+		#endif
 		
 		float2 ndcToDepthUV(float2 ndc)
 		{

+ 2 - 0
Source/RenderBeast/Source/BsPostProcessing.cpp

@@ -1510,6 +1510,8 @@ namespace bs { namespace ct
 		}
 
 		// Blur the output
+		// Note: If I implement temporal AA then this can probably be avoided. I can instead jitter the sample offsets
+		// each frame, and averaging them out should yield blurred AO.
 		if(quality > 1) // On level 0 we don't blur at all, on level 1 we use the ad-hoc blur in shader
 		{
 			const RenderTargetProperties& rtProps = destination->getProperties();