From 54d30bbd0524e5a30c2df85c7f2f9dfef1e0101b Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Thu, 14 Apr 2022 14:43:14 +0200 Subject: [PATCH] Skip hands + view weapons for motion vectors --- neo/renderer/RenderBackend.cpp | 30 ++++++++------------- neo/shaders/builtin/post/motionBlur.ps.hlsl | 4 +-- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/neo/renderer/RenderBackend.cpp b/neo/renderer/RenderBackend.cpp index 81573157..50fb6509 100644 --- a/neo/renderer/RenderBackend.cpp +++ b/neo/renderer/RenderBackend.cpp @@ -5435,8 +5435,6 @@ void idRenderBackend::CalculateAutomaticExposure() { idLib::Printf( "HDR luminance avg = %f, max = %f, key = %f\n", hdrAverageLuminance, hdrMaxLuminance, hdrKey ); } - - //GL_CheckErrors(); } void idRenderBackend::DrawMotionVectors() @@ -5467,18 +5465,22 @@ void idRenderBackend::DrawMotionVectors() // clear the alpha buffer and draw only the hands + weapon into it so // we can avoid blurring them GL_State( GLS_COLORMASK | GLS_DEPTHMASK ); + GL_Color( 0, 0, 0, 1 ); + renderProgManager.BindShader_Color(); + + currentSpace = &viewDef->worldSpace; + RB_SetMVP( viewDef->worldSpace.mvp ); + + DrawElementsWithCounters( &unitSquareSurface ); + + // draw the hands + weapon with alpha 0 GL_Color( 0, 0, 0, 0 ); + GL_SelectTexture( 0 ); globalImages->blackImage->Bind(); currentSpace = NULL; -#if 0 - - TODO mask out the view weapon + hands using the stencil buffer - - commandList->clearTextureFloat( globalImages->currentHDRImage->GetTextureHandle(), nvrhi::AllSubresources, nvrhi::Color( 0.f ) ); - drawSurf_t** drawSurfs = ( drawSurf_t** )&viewDef->drawSurfs[0]; for( int surfNum = 0; surfNum < viewDef->numDrawSurfs; surfNum++ ) { @@ -5517,17 +5519,11 @@ void idRenderBackend::DrawMotionVectors() // draw it solid DrawElementsWithCounters( surf ); } -#endif globalFramebuffers.taaMotionVectorsFBO->Bind(); commandList->clearTextureFloat( globalImages->taaMotionVectorsImage->GetTextureHandle(), nvrhi::AllSubresources, nvrhi::Color( 0.f ) ); - // copy off the color buffer and the depth buffer for the motion blur prog - // we use the viewport dimensions for copying the buffers in case resolution scaling is enabled. - //const idScreenRect& viewport = viewDef->viewport; - //globalImages->currentRenderImage->CopyFramebuffer( viewport.x1, viewport.y1, viewport.GetWidth(), viewport.GetHeight() ); - // in stereo rendering, each eye needs to get a separate previous frame mvp int mvpIndex = ( viewDef->renderView.viewEyeBuffer == 1 ) ? 1 : 0; @@ -5546,10 +5542,6 @@ void idRenderBackend::DrawMotionVectors() renderProgManager.BindShader_MotionVectors(); - // let the fragment program know how many samples we are going to use - idVec4 samples( ( float )( 1 << 4 ) ); ///r_motionBlur.GetInteger() ) ); - SetFragmentParm( RENDERPARM_OVERBRIGHT, samples.ToFloatPtr() ); - GL_SelectTexture( 0 ); globalImages->currentRenderHDRImage->Bind(); @@ -6944,7 +6936,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste //------------------------------------------------- // resolve of HDR target using temporal anti aliasing before any tonemapping and post processing // - // use this to eat all stochastic noise like from volumetric light sampling, + // use this to eat all stochastic noise like from volumetric light sampling or SSAO // runs at full resolution //------------------------------------------------- TemporalAAPass( _viewDef ); diff --git a/neo/shaders/builtin/post/motionBlur.ps.hlsl b/neo/shaders/builtin/post/motionBlur.ps.hlsl index e5e20a33..f50cf154 100644 --- a/neo/shaders/builtin/post/motionBlur.ps.hlsl +++ b/neo/shaders/builtin/post/motionBlur.ps.hlsl @@ -61,14 +61,12 @@ void main( PS_IN fragment, out PS_OUT result ) } #endif -#if 0 //!VECTORS_ONLY // don't motion blur the hands, which were drawn with alpha = 0 - if( t_ViewColor.Sample( LinearSampler, fragment.texcoord0 ).w == 0.0 ) + if( t_ViewColor.Sample( LinearSampler, fragment.texcoord0 ).a == 0.0 ) { discard; return; } -#endif // derive clip space from the depth buffer and screen position float windowZ = t_ViewDepth.Sample( LinearSampler, fragment.texcoord0 ).x;