Garry's Mod Wiki

render.GetResolvedFullFrameDepth

  ITexture render.GetResolvedFullFrameDepth()

Description

Returns the _rt_ResolvedFullFrameDepth texture for SSAO depth. It will only be updated if GM:NeedsDepthPass returns true. Depth is written using the Shaders/DepthWrite.

Returns

1 ITexture
The depth texture.

Example

Render the depth pass to the screen.

local function MyNeedsDepthPass() return true end -- Add hook so that the _rt_ResolvedFullFrameDepth texture is updated hook.Add( "NeedsDepthPass", "MyNeedsDepthPass", MyNeedsDepthPass ) local function RenderSSAOdepth() -- call render.GetResolvedFullFrameDepth() and draw the resulting itexture to the screen local texture = render.GetResolvedFullFrameDepth() render.DrawTextureToScreen( texture ) end -- Add hook to render pass to screen hook.Add( "RenderScreenspaceEffects", "RenderSSAOdepth", RenderSSAOdepth )
Output:
depth_example.png

Example: Depth buffer upgrade

This method allows you to increase the bit depth of the depth buffer.

IMAGE_FORMAT_R32F = 27 // Single-channel 32-bit floating point GetRenderTargetEx("_rt_resolvedfullframedepth", ScrW(), ScrH(), RT_SIZE_FULL_FRAME_BUFFER, MATERIAL_RT_DEPTH_SHARED, bit.bor(4, 8, 256, 512, 65536), 0, IMAGE_FORMAT_R32F )