Resolve multisampling depth in shader
This commit is contained in:
parent
b1c1e6aae7
commit
902097d6da
6 changed files with 211 additions and 84 deletions
|
|
@ -136,8 +136,8 @@ void FGLRenderer::RenderScreenQuad()
|
|||
|
||||
void FGLRenderer::PostProcessScene()
|
||||
{
|
||||
mBuffers->BlitSceneToTexture();
|
||||
AmbientOccludeScene();
|
||||
mBuffers->BlitSceneToTexture();
|
||||
BloomScene();
|
||||
TonemapScene();
|
||||
ColormapScene();
|
||||
|
|
@ -165,6 +165,7 @@ void FGLRenderer::AmbientOccludeScene()
|
|||
const float blurAmount = gl_ssao_blur_amount;
|
||||
int blurSampleCount = gl_ssao_blur_samples;
|
||||
float aoStrength = gl_ssao_strength;
|
||||
bool multisample = gl_multisample > 1;
|
||||
|
||||
//float tanHalfFovy = tan(fovy * (M_PI / 360.0f));
|
||||
float tanHalfFovy = 1.0f / 1.33333302f; // 1.0f / gl_RenderState.mProjectionMatrix.get()[5];
|
||||
|
|
@ -177,12 +178,15 @@ void FGLRenderer::AmbientOccludeScene()
|
|||
glBindFramebuffer(GL_FRAMEBUFFER, mBuffers->AmbientFB0);
|
||||
glViewport(0, 0, mBuffers->AmbientWidth, mBuffers->AmbientHeight);
|
||||
mBuffers->BindSceneDepthTexture(0);
|
||||
mLinearDepthShader->Bind();
|
||||
mLinearDepthShader->DepthTexture.Set(0);
|
||||
mLinearDepthShader->LinearizeDepthA.Set(1.0f / GetZFar() - 1.0f / GetZNear());
|
||||
mLinearDepthShader->LinearizeDepthB.Set(MAX(1.0f / GetZNear(), 1.e-8f));
|
||||
mLinearDepthShader->InverseDepthRangeA.Set(1.0f);
|
||||
mLinearDepthShader->InverseDepthRangeB.Set(0.0f);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
mLinearDepthShader->Bind(multisample);
|
||||
mLinearDepthShader->DepthTexture[multisample].Set(0);
|
||||
if (multisample) mLinearDepthShader->SampleCount[multisample].Set(gl_multisample);
|
||||
mLinearDepthShader->LinearizeDepthA[multisample].Set(1.0f / GetZFar() - 1.0f / GetZNear());
|
||||
mLinearDepthShader->LinearizeDepthB[multisample].Set(MAX(1.0f / GetZNear(), 1.e-8f));
|
||||
mLinearDepthShader->InverseDepthRangeA[multisample].Set(1.0f);
|
||||
mLinearDepthShader->InverseDepthRangeB[multisample].Set(0.0f);
|
||||
RenderScreenQuad();
|
||||
|
||||
// Apply ambient occlusion
|
||||
|
|
@ -227,7 +231,7 @@ void FGLRenderer::AmbientOccludeScene()
|
|||
RenderScreenQuad();
|
||||
|
||||
// Add SSAO back to scene texture:
|
||||
mBuffers->BindCurrentFB();
|
||||
mBuffers->BindSceneFB();
|
||||
glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue