Fix precision issue in SSAO shader

This commit is contained in:
Magnus Norddahl 2016-09-01 07:15:40 +02:00
parent 723eb746f6
commit a6fdaca633
2 changed files with 7 additions and 4 deletions

View file

@ -104,11 +104,11 @@ CVAR(Float, gl_ssao_strength, 0.7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, gl_ssao_debug, false, 0) CVAR(Bool, gl_ssao_debug, false, 0)
CVAR(Float, gl_ssao_bias, 0.5f, 0) CVAR(Float, gl_ssao_bias, 0.5f, 0)
CVAR(Float, gl_ssao_radius, 100.0f, 0) CVAR(Float, gl_ssao_radius, 100.0f, 0)
CUSTOM_CVAR(Float, gl_ssao_blur_amount, 6.0f, 0) CUSTOM_CVAR(Float, gl_ssao_blur_amount, 4.0f, 0)
{ {
if (self < 0.1f) self = 0.1f; if (self < 0.1f) self = 0.1f;
} }
CUSTOM_CVAR(Int, gl_ssao_blur_samples, 9, 0) CUSTOM_CVAR(Int, gl_ssao_blur_samples, 5, 0)
{ {
if (self < 3 || self > 15 || self % 2 == 0) if (self < 3 || self > 15 || self % 2 == 0)
self = 9; self = 9;
@ -158,8 +158,8 @@ void FGLRenderer::AmbientOccludeScene()
float aoStrength = gl_ssao_strength; float aoStrength = gl_ssao_strength;
//float tanHalfFovy = tan(fovy * (M_PI / 360.0f)); //float tanHalfFovy = tan(fovy * (M_PI / 360.0f));
float tanHalfFovy = 1.0f / 1.33333302f; //gl_RenderState.mProjectionMatrix.get()[5]; float tanHalfFovy = 1.0f / 1.33333302f; // 1.0f / gl_RenderState.mProjectionMatrix.get()[5];
float invFocalLenX = tanHalfFovy * (mBuffers->AmbientWidth / (float)mBuffers->AmbientHeight); float invFocalLenX = tanHalfFovy * (mBuffers->GetSceneWidth() / (float)mBuffers->GetSceneHeight());
float invFocalLenY = tanHalfFovy; float invFocalLenY = tanHalfFovy;
float nDotVBias = clamp(bias, 0.0f, 1.0f); float nDotVBias = clamp(bias, 0.0f, 1.0f);
float r2 = aoRadius * aoRadius; float r2 = aoRadius * aoRadius;

View file

@ -70,6 +70,9 @@ public:
int GetWidth() const { return mWidth; } int GetWidth() const { return mWidth; }
int GetHeight() const { return mHeight; } int GetHeight() const { return mHeight; }
int GetSceneWidth() const { return mSceneWidth; }
int GetSceneHeight() const { return mSceneHeight; }
private: private:
void ClearScene(); void ClearScene();
void ClearPipeline(); void ClearPipeline();