Skip to content

Add _rt_FullFrameDepth as IMAGE_FORMAT_NV_INTZ#1914

Open
Akabenko wants to merge 12 commits into
ValveSoftware:masterfrom
Akabenko:patch-1
Open

Add _rt_FullFrameDepth as IMAGE_FORMAT_NV_INTZ#1914
Akabenko wants to merge 12 commits into
ValveSoftware:masterfrom
Akabenko:patch-1

Conversation

@Akabenko
Copy link
Copy Markdown

@Akabenko Akabenko commented May 5, 2026

Description

INTZ colored hardware depth can be as analogue of Resolved Depth buffer from SSAO_DepthPass for moders. Without extra rendering of scene.
We can see scene on our screen.
Image
And hardware colored INTZ depth on _rt_FullFrameDepth render target.
Image

Explanation of code

  • PushRenderTargetAndViewport allow to write Hardware depth as second arg, but we need to input both args. First as colored rendertarget and second depth render target. We can't skip first argument.

  • When we run PushRenderTargetAndViewport with colored and depth args, scene will gone from screen. So we need to return that, and we call pRenderContext->CopyTextureToRenderTargetEx(0, pColor, NULL, NULL); to write image to BackBuffer from colored texture.

@Akabenko
Copy link
Copy Markdown
Author

Akabenko commented May 5, 2026

But there is still a problem.

No 3D skybox
image

Activated 3D skybox
image

@Akabenko
Copy link
Copy Markdown
Author

Akabenko commented May 5, 2026

This code helps, but I think there must be a more elegant solution.

if (g_CurrentViewID == VIEW_MAIN) {
	pRTColor = GetFullscreenTexture();
	pRTDepth = GetFullFrameDepthTexture();
}

viewrender.cpp#L4994

void CSkyboxView::Draw()
{
	VPROF_BUDGET( "CViewRender::Draw3dSkyboxworld", "3D Skybox" );

	ITexture *pRTColor = NULL;
	ITexture *pRTDepth = NULL;

	if (g_CurrentViewID == VIEW_MAIN) { // extra code
		pRTColor = GetFullscreenTexture();
		pRTDepth = GetFullFrameDepthTexture();
	}

	if( m_eStereoEye != STEREO_EYE_MONO )
	{
		pRTColor = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(m_eStereoEye-1), ISourceVirtualReality::RT_Color );
		pRTDepth = g_pSourceVR->GetRenderTarget( (ISourceVirtualReality::VREye)(m_eStereoEye-1), ISourceVirtualReality::RT_Depth );
	}

	DrawInternal(VIEW_3DSKY, true, pRTColor, pRTDepth );
}
Desktop.2026.05.05.-.06.13.45.02.mp4

@Akabenko
Copy link
Copy Markdown
Author

Akabenko commented May 5, 2026

Seems INTZ kill MSAA

@HyperionCoding
Copy link
Copy Markdown

What's the motivation for this?

@Akabenko
Copy link
Copy Markdown
Author

Akabenko commented May 7, 2026

What's the motivation for this?

This allow to get depth buffer without second render of scene like as do Resolved Depth Buffer in SSAO_DepthPass function. This can be useful for modders on Source SDK 2013 for deferred renderer. Thats why INTZ kill MSAA.

https://www.dmitrex.com/publications/Enhancing%20the%20looks%20of%20Source%20Engine%20in%20Military%20Conflict%20Vietnam.pdf
image

@neobenedict
Copy link
Copy Markdown

Just change the pyrovision check instead so SSAO_DepthPass always runs if there's something in the scene that needs it. Instead of hardcoding to only have pyrovision on?

@Akabenko
Copy link
Copy Markdown
Author

Akabenko commented May 22, 2026

But its not a SSAO_DepthPass. INTZ depth is cheaper to get, than Resolved Depth.

@neobenedict
Copy link
Copy Markdown

neobenedict commented May 22, 2026

I know, I was suggesting since the feature's already implemented, it could be made more "available", which is potentially a lower bar to clear than this.

Also it's only 8-bit in the red buffer, other channels should be used to encode more data...

@Akabenko
Copy link
Copy Markdown
Author

Akabenko commented May 23, 2026

@neobenedict you can run GetRenderTargetEx in view.cpp void CViewRender::Init( void ) for _rt_ResolvedFullFrameDepth with IMAGE_FORMAT_R32F. And then your depth will be as 32 bit. Then use it as depth * 4000 = projPosW in shaders. or as 1/depth/4000 as depth in range 0...1

@Akabenko
Copy link
Copy Markdown
Author

Akabenko commented May 23, 2026

We can modify DepthWrite to writes WorldNormals in other channels, but here no Normals info in meshes in Brushes. Its as optimization of render of shadow maps and ssao depth pass. U can get Normals of props and reconstruct Normals for World.
533283244-bf424ad7-28bd-4f43-ab3b-a6a31ea5bfac

So you can get normals from Models and make 3Tap reconstruction for world.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants