Garry's Mod Wiki

Revision Difference

render.GetResolvedFullFrameDepth#565448

<function name="GetResolvedFullFrameDepth" parent="render" type="libraryfunc"> <description>Returns the `_rt_ResolvedFullFrameDepth` texture for SSAO depth. It will only be updated if <page>GM:NeedsDepthPass</page> returns true.</description> <description>Returns the `_rt_ResolvedFullFrameDepth` texture for SSAO depth. It will only be updated if <page>GM:NeedsDepthPass</page> returns true. Depth is written using the <page>Shaders/DepthWrite</page>.</description> <realm>Client</realm> <rets> <ret name="" type="ITexture">The depth texture.</ret> </rets> </function> <example> <description>Render the depth pass to the screen.</description> <code> 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 ) </code> <output><upload src="ab571/8dc388e4e483f90.png" size="146994" name="depth_example.png" /></output> </example> <example name="Depth buffer upgrade"> <description> This method allows you to increase the bit depth of the depth buffer. IMAGE_FORMAT_R32F does not work on Linux (dx 92). Also, 32-bit image formats do not work on Windows without D3D9EX. </description> <code> D3D9EX = !GetConVar("mat_disable_d3d9ex"):GetBool() cvars.AddChangeCallback("mat_disable_d3d9ex", function(convar_name, value_old, value_new) D3D9EX = !tobool(value_new) end) IMAGE_FORMAT_R32F = 27 // Single-channel 32-bit floating point IMAGE_FORMAT_RGBA32323232F = 29 GetRenderTargetEx("_rt_resolvedfullframedepth", ScrW(), ScrH(), RT_SIZE_FULL_FRAME_BUFFER, MATERIAL_RT_DEPTH_SHARED, bit.bor(4, 8, 256, 512, 65536), 0, render.GetDXLevel() == 92 and IMAGE_FORMAT_RGBA32323232F or (D3D9EX and IMAGE_FORMAT_R32F or IMAGE_FORMAT_RGBA16161616F) ) hook.Add("NeedsDepthPass", "32BitDepth", function() return true end) </code> </example>