Garry's Mod Wiki
Render Hook Order
This is the call order for client rendering hooks. The lower a hook is on the list, the higher priority it has for drawing. This list is only to be used as a reference - in real time while rendering a frame, the engine might call certain groups of hooks multiple times to achieve reflective properties, draw render targets, and react to render.RenderView and render.RenderHUD calls.
Hook | Render context | Notes |
---|---|---|
WEAPON:RenderScreen | None | Call condition: Weapon is scripted. Context must be setup with cam to draw |
GM:RenderScene | None | Context must be setup with cam to draw. Returning true in this hook will skip all the way down to GM:PostRender |
GM:DrawMonitors | None | Context must be setup with cam to draw |
GM:PreDrawSkyBox | 3D | Call condition: r_3dsky is enabled and EyePos is in world bounds |
GM:SetupSkyboxFog | 3D | Call condition: r_3dsky is enabled and EyePos is in world bounds |
WEAPON:TranslateFOV | 3D | Call condition: Weapon is scripted |
GM:PostDraw2DSkyBox | 3D | Call condition: r_skybox, r_drawopaqueworld, and r_drawworld are enabled, and EyePos is in world bounds |
DrawOpaqueRenderables (false, r_skybox is enabled) | 3D | Call condition: r_3dsky, r_drawentities, and r_drawopaquerenderables are enabled and EyePos is in world bounds. For opaque entities in the skybox |
DrawTranslucentRenderables (false, r_skybox is enabled) | 3D | Call condition: r_3dsky is enabled and EyePos is in world bounds. For translucent entities in the skybox |
GM:PostDrawSkyBox | 3D | Call condition: r_3dsky is enabled and EyePos is in world bounds |
DrawWaterReflections | 3D | Call condition: r_WaterDrawReflection and r_drawworld is enabled and reflective water is visible |
DrawWorld | 3D | |
GM:GetMotionBlurValues | 3D | |
GM:PreDrawViewModels | 3D | |
ENTITY:Draw | 3D | For animated scripted entities with rendergroup RENDERGROUP_VIEWMODEL |
ENTITY:RenderOverride | 3D | For non-viewmodel entities or viewmodels not linked to a weapon with rendergroup RENDERGROUP_VIEWMODEL |
GM:PreDrawViewModel | 3D | For engine "viewmodel" and "predicted_viewmodel" entities linked to a weapon |
WEAPON:PreDrawViewModel | 3D | Dependent on gamemode implementation |
ENTITY:RenderOverride | 3D | For engine "viewmodel" and "predicted_viewmodel" entities linked to a weapon |
WEAPON:ViewModelDrawn | 3D | For engine "viewmodel" and "predicted_viewmodel" entities linked to a weapon |
GM:PostDrawViewModel | 3D | For engine "viewmodel" and "predicted_viewmodel" entities linked to a weapon |
WEAPON:PostDrawViewModel | 3D | Dependent on gamemode implementation |
GM:PreDrawPlayerHands | 3D | Dependent on gamemode implementation |
ENTITY:RenderOverride | 3D | Dependent on gamemode implementation |
GM:PostDrawPlayerHands | 3D | Dependent on gamemode implementation |
ENTITY:DrawTranslucent | 3D | For animated scripted entities with rendergroup RENDERGROUP_VIEWMODEL_TRANSLUCENT |
ENTITY:RenderOverride | 3D | For entities with rendergroup RENDERGROUP_VIEWMODEL_TRANSLUCENT |
GM:PreDrawEffects | 3D | |
GM:RenderScreenspaceEffects | 2D | |
GM:PostDrawEffects | 2D | |
GM:PreDrawHalos | 2D | Hook called from Lua, which means more GM:PostDrawEffects hooks can be called afterward |
GM:PreDrawHUD | 2D | |
DrawActiveHUD | 2D | Call condition: r_drawvgui is enabled and game is not paused |
GM:PostDrawHUD | 2D | |
GM:HUDShouldDraw | 2D | Call condition: r_drawvgui is enabled. For NetGraph |
GM:DrawOverlay | 2D | Call condition: r_drawvgui is enabled |
GM:PostRenderVGUI | 2D | |
GM:PostRender | None | Context must be setup with cam to draw |
Hook Blocks
For simplicity, "blocks" of hooks will be defined to reduce the repetitive listing of the same functions. These blocks can also relate to groups of methods in the Source renderer that are called multiple times.
DrawWaterReflections
Hook | Notes |
---|---|
GM:SetupWorldFog | |
GM:PostDraw2DSkyBox | Call condition: r_drawopaqueworld and r_drawworld are enabled |
DrawOpaqueRenderables(false, true) | Call condition: r_drawopaquerenderables is enabled. Draws reflections for opaque entities in the world not completely submerged in reflective water |
DrawTranslucentRenderables(false, false) | Draws reflections for translucent entities in the world not completely submerged in reflective water |
WEAPON:TranslateFOV | Call condition: Weapon is scripted |
DrawOpaqueRenderables(false, false) | Call condition: r_drawopaquerenderables is enabled. Draws refractions for opaque entities in reflective water |
DrawTranslucentRenderables(false, false) | Draws refractions for translucent entities in reflective water |
DrawWorld
Hook | Notes |
---|---|
GM:NeedsDepthPass | |
GM:SetupWorldFog | |
DrawOpaqueRenderables(false, false) | Call condition: r_drawentities and r_drawopaquerenderables are enabled. For opaque entities in the world not completely submerged in reflective water |
DrawTranslucentRenderables(false, false) | For translucent entities in the world not completely submerged in reflective water |
DrawOpaqueRenderables
This block specifies two boolean arguments that point to what PreDrawRenderables and PostDrawRenderables will be called with. The first arg is true if the rendering is writing to the depth buffer, and the second is true if the rendering is being done for skybox objects.
GM:PrePlayerDraw and GM:PostPlayerDraw will be called for every visible, opaque player, just as ENTITY:RenderOverride will be for every visible, opaque entity. The order in which entities are drawn is based on their distance from the viewport in the world, and thus the entity type hook pairings can be called in any order. In other words, the entity hooks can be called before the player hooks depending on the object render order. With that, the only guarenteed hook orderings are:
- (GM:ShouldDrawLocalPlayer is checked first if the player entity being drawn is the local player) -> ENTITY:RenderOverride -> GM:PrePlayerDraw -> GM:PostPlayerDraw for players
- (ENTITY:Draw if the entity is scripted and animated) -> ENTITY:RenderOverride for entities
- (WEAPON:DrawWorldModel if the weapon is scripted) -> ENTITY:RenderOverride for weapons
Opaque rendergroups include RENDERGROUP_OPAQUE_HUGE, RENDERGROUP_OPAQUE, RENDERGROUP_BOTH, and RENDERGROUP_OPAQUE_BRUSH.
Hook | Notes |
---|---|
GM:ShouldDrawLocalPlayer | Called if the local player is opaque, the thirdperson concommand is not active, and GM:CalcView did not return a table with key "drawviewer" set to true. The return will be cached for all other relevant Draw*Renderables blocks so that it is only called once per frame |
ENTITY:RenderOverride | For opaque players |
GM:PrePlayerDraw | For opaque players |
GM:PostPlayerDraw | For opaque players |
ENTITY:Draw | For opaque, animated scriped entities |
ENTITY:RenderOverride | For opaque entities |
WEAPON:DrawWorldModel | For opaque scriped weapons |
ENTITY:RenderOverride | For opaque weapons |
GM:PostDrawOpaqueRenderables (isDrawingDepth, isDrawingSkybox) |
DrawTranslucentRenderables
All of the prior logic from DrawOpaqueRenderables applies here.
Translucent rendergroups include RENDERGROUP_TRANSLUCENT and RENDERGROUP_BOTH.
Hook | Notes |
---|---|
GM:ShouldDrawLocalPlayer | Called if the local player is translucent, the thirdperson concommand is not active, and GM:CalcView did not return a table with key "drawviewer" set to true. The return will be cached for all other relevant Draw*Renderables blocks so that it is only called once per frame |
ENTITY:RenderOverride | For translucent players |
GM:PrePlayerDraw | For translucent players |
GM:PostPlayerDraw | For translucent players |
ENTITY:Draw | For translucent, animated scriped entities |
ENTITY:RenderOverride | For translucent entities |
WEAPON:DrawWorldModelTranslucent | For translucent scriped weapons |
ENTITY:RenderOverride | For translucent weapons |
GM:DrawPhysgunBeam | For engine physgun_beam entities |
GM:PostDrawTranslucentRenderables (isDrawingDepth, isDrawingSkybox) |
DrawActiveHUD
Hook | Notes |
---|---|
WEAPON:DrawHUDBackground | Call condition: Weapon is scripted |
GM:HUDPaint | |
GM:HUDDrawTargetID | |
GM:HUDDrawPickupHistory | |
GM:DrawDeathNotice | |
WEAPON:DrawHUD | |
GM:HUDDrawScoreBoard | |
WEAPON:TranslateFOV | Call condition: Weapon is scripted |
WEAPON:DoDrawCrosshair | Call condition: Weapon is scripted and has SWEP.DrawCrosshair set to true |
GM:HUDShouldDraw | For CHudWeaponSelection |
This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.
Page content is automatically updated twice a day. Edits and history are not available.
Last Parsed: Loading...