Garry's Mod Wiki

render

The render library is a powerful set of functions that let you control how the world and its contents are rendered. It can also be used to draw some 3D clientside effects such as beams, boxes and spheres.

Methods

render.AddBeam( Vector startPos, number width, number textureEnd, table color )
Adds a beam segment to the beam started by render.StartBeam.
render.BlurRenderTarget( ITexture rendertarget, number blurx, number blury, number passes )
Blurs the render target ( or a given texture )
render.BrushMaterialOverride( IMaterial mat = nil )
This function is broken and does absolutely nothing
string render.Capture( table captureData )
Captures a part of the current render target and returns the data as a binary string in the given format. Since the pixel buffer clears itself every frame, this will return a black screen outside of . To capture the user's final view, use GM:PostRender. This will not capture the Steam overlay or third-party injections (such as the Discord overlay, Overwolf, and advanced cheats) on the user's screen. This sets the alpha channel incorrectly in PNG mode, causing the foreground to be rendered almost completel..
render.CapturePixels()
Dumps the current render target and allows the pixels to be accessed by render.ReadPixel.
render.Clear( number r, number g, number b, number a, boolean clearDepth = false, boolean clearStencil = false )
Clears the current render target and the specified buffers. This sets the alpha incorrectly for surface draw calls for render targets.
render.ClearBuffersObeyStencil( number r, number g, number b, number a, boolean depth )
Clears the current rendertarget for obeying the current stencil buffer conditions.
render.ClearDepth()
Resets the depth buffer. This function also clears the stencil buffer. Use render.Clear in the meantime.
render.ClearRenderTarget( ITexture texture, table color )
Clears a render target It uses render.Clear then render.SetRenderTarget on the modified render target.
render.ClearStencil()
Resets all values in the stencil buffer to zero.
render.ClearStencilBufferRectangle( number originX, number originY, number endX, number endY, number stencilValue )
Sets the stencil value in a specified rect. This is not affected by render.SetStencilWriteMask
Vector render.ComputeDynamicLighting( Vector position, Vector normal )
Calculates the lighting caused by dynamic lights for the specified surface.
Vector render.ComputeLighting( Vector position, Vector normal )
Calculates the light color of a certain surface.
render.CopyRenderTargetToTexture( ITexture Target )
Copies the currently active Render Target to the specified texture.
render.CopyTexture( ITexture texture_from, ITexture texture_to )
Copies the contents of one texture to another. Only works with rendertargets.
render.CullMode( number cullMode )
Changes the cull mode.
render.DepthRange( number depthmin, number depthmax )
Set's the depth range of the upcoming render.
render.DrawBeam( Vector startPos, Vector endPos, number width, number textureStart, number textureEnd, table color = Color( 255, 255, 255 ) )
Draws textured beam. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
render.DrawBox( Vector position, Angle angles, Vector mins, Vector maxs, table color = Color( 255, 255, 255 ) )
Draws a box in 3D space. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
render.DrawLine( Vector startPos, Vector endPos, table color = Color( 255, 255, 255 ), boolean writeZ = false )
Draws a line in 3D space. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
render.DrawQuad( Vector vert1, Vector vert2, Vector vert3, Vector vert4, table color = Color( 255, 255, 255 ) )
Draws 2 connected triangles. Expects material to be set by render.SetMaterial. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
render.DrawQuadEasy( Vector position, Vector normal, number width, number height, table color, number rotation = 0 )
Draws a quad. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
render.DrawScreenQuad()
Draws the current material set by render.SetMaterial to the whole screen. The color cannot be customized. See also render.DrawScreenQuadEx. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
render.DrawScreenQuadEx( number startX, number startY, number width, number height )
Draws the the current material set by render.SetMaterial to the area specified. Color cannot be customized. See also render.DrawScreenQuad. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
render.DrawSphere( Vector position, number radius, number longitudeSteps, number latitudeSteps, table color = Color( 255, 255, 255 ) )
Draws a sphere in 3D space. The material previously set with render.SetMaterial will be applied the sphere's surface. See also render.DrawWireframeSphere for a wireframe equivalent. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
render.DrawSprite( Vector position, number width, number height, table color = Color( 255, 255, 255 ) )
Draws a sprite in 3D space. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
render.DrawTextureToScreen( ITexture tex )
Draws a texture over the whole screen. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
render.DrawTextureToScreenRect( ITexture tex, number x, number y, number width, number height )
Draws a textured rectangle. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
render.DrawWireframeBox( Vector position, Angle angle, Vector mins, Vector maxs, table color = Color( 255, 255, 255 ), boolean writeZ = false )
Draws a wireframe box in 3D space. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
render.DrawWireframeSphere( Vector position, number radius, number longitudeSteps, number latitudeSteps, table color = Color( 255, 255, 255 ), boolean writeZ = false )
Draws a wireframe sphere in 3d space. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
boolean render.EnableClipping( boolean state )
Sets the status of the clip renderer, returning previous state. To prevent unintended rendering behavior of other mods/the game, you must reset the clipping state to its previous value.Reloading the map does not reset the previous value of this function.
render.EndBeam()
Ends the beam mesh of a beam started with render.StartBeam.
render.FogColor( number red, number green, number blue )
Sets the color of the fog.
render.FogEnd( number distance )
Sets the at which the fog reaches its max density.
render.FogMaxDensity( number maxDensity )
Sets the maximum density of the fog.
render.FogMode( number fogMode )
Sets the mode of fog.
render.FogStart( number fogStart )
Sets the distance at which the fog starts showing up.
Vector render.GetAmbientLightColor()
Returns the ambient color of the map.
number render.GetBlend()
Returns the current alpha blending.
number render.GetColorModulation()
Returns the current color modulation values as normals.
number render.GetDXLevel()
Returns the maximum available directX version.
number, number, number render.GetFogColor()
Returns the current fog color.
number, number, number render.GetFogDistances()
Returns the fog start and end distance.
number render.GetFogMode()
Returns the fog mode.
ITexture render.GetFullScreenDepthTexture()
Returns the _rt_FullFrameDepth texture. Alias of _rt_PowerOfTwoFB
Vector render.GetLightColor( Vector position )
Gets the light exposure on the specified position.
ITexture render.GetPowerOfTwoTexture()
Returns the render target's power of two texture.
ITexture render.GetRefractTexture()
Alias of render.GetPowerOfTwoTexture.
ITexture render.GetRenderTarget()
Returns the currently active render target. Instead of saving the current render target using this function and restoring to it later, it is generally better practice to use render.PushRenderTarget and render.PopRenderTarget.
ITexture render.GetResolvedFullFrameDepth()
Returns the _rt_ResolvedFullFrameDepth texture for SSAO depth.
ITexture render.GetScreenEffectTexture( number textureIndex = 0 )
Obtain an ITexture of the screen. You must call render.UpdateScreenEffectTexture in order to update this texture with the currently rendered scene. This texture is mainly used within GM:RenderScreenspaceEffects
ITexture render.GetSuperFPTex()
Returns a floating point texture the same resolution as the screen. The gmodscreenspace doesn't behave as expected when drawing a floating-point texture to an integer texture (e.g. the default render target). Use an UnlitGeneric material instead
ITexture render.GetSuperFPTex2()
See render.GetSuperFPTex
Vector render.GetSurfaceColor( Vector startPos, Vector endPos )
Performs a render trace and returns the color of the surface hit, this uses a low res version of the texture.
Vector render.GetToneMappingScaleLinear()
Returns a vector representing linear tone mapping scale.
render.MaterialOverride( IMaterial material )
Sets the render material override for all next calls of Entity:DrawModel. Also overrides render.MaterialOverrideByIndex.
render.MaterialOverrideByIndex( number index, IMaterial material )
Similar to render.MaterialOverride, but overrides the materials per index. render.MaterialOverride overrides effects of this function.
number render.MaxTextureHeight()
Returns the maximum texture height the renderer can handle.
number render.MaxTextureWidth()
Returns the maximum texture width the renderer can handle.
render.Model( table settings, CSEnt ent = nil )
Creates a new ClientsideModel, renders it at the specified pos/ang, and removes it. Can also be given an existing CSEnt to reuse instead. This function is only meant to be used in a single render pass kind of scenario, if you need to render a model continuously, use a cached ClientsideModel and provide it as a second argument.Using this with a map model (game.GetWorld():GetModel()) crashes the game.
render.ModelMaterialOverride( IMaterial material )
Sets a material to override a model's default material. Similar to Entity:SetMaterial except it uses an IMaterial argument and it can be used to change materials on models which are part of the world geometry.
render.OverrideAlphaWriteEnable( boolean enable, boolean shouldWrite )
Overrides the write behaviour of all next rendering operations towards the alpha channel of the current render target. See also render.OverrideBlend. Doing surface draw calls with alpha set to 0 is a no-op and will never have any effect.
render.OverrideBlend( boolean enabled, number srcBlend, number destBlend, number blendFunc, number srcBlendAlpha = none, number destBlendAlpha = none, number blendFuncAlpha = none )
Overrides the internal graphical functions used to determine the final color and alpha of a rendered texture. See also render.OverrideAlphaWriteEnable. Doing surface draw calls with alpha set to 0 is a no-op and won't have an effect.
render.OverrideBlendFunc( boolean enabled, number srcBlend, number destBlend, number srcBlendAlpha = nil, number destBlendAlpha = nil )
We advise against using this. It may be changed or removed in a future update. Use render.OverrideBlend instead. Overrides the internal graphical functions used to determine the final color and alpha of a rendered texture. See also render.OverrideAlphaWriteEnable. Doing surface draw calls with alpha set to 0 is a no-op and will never have any effect.
render.OverrideColorWriteEnable( boolean enable, boolean shouldWrite )
Overrides the write behaviour of all next rendering operations towards the color channel of the current render target.
render.OverrideDepthEnable( boolean enable, boolean shouldWrite )
Overrides the write behaviour of all next rendering operations towards the depth buffer.
render.PopCustomClipPlane()
Removes the current active clipping plane from the clip plane stack.
render.PopFilterMag()
Pops the current texture magnification filter from the filter stack. See render.PushFilterMag
render.PopFilterMin()
Pops the current texture minification filter from the filter stack. See render.PushFilterMin
render.PopFlashlightMode()
Pops the current flashlight mode from the flashlight mode stack.
render.PopRenderTarget()
Pops the last render target and viewport from the RT stack and sets them as the current render target and viewport. This is should be called to restore the previous render target and viewport after a call to render.PushRenderTarget.
render.PushCustomClipPlane( Vector normal, number distance )
Pushes a new clipping plane of the clip plane stack and sets it as active. A max of 2 clip planes are supported on Linux/POSIX, and 6 on Windows.
render.PushFilterMag( number texFilterType )
Pushes a texture filter onto the magnification texture filter stack.
render.PushFilterMin( number texFilterType )
Pushes a texture filter onto the minification texture filter stack.
render.PushFlashlightMode( boolean enable = false )
Enables the flashlight projection for the upcoming rendering. This will leave models lit under specific conditions.
render.PushRenderTarget( ITexture texture, number x = 0, number y = 0, number w = texture:Width(), number h = texture:Height() )
Pushes the current render target and viewport to the RT stack then sets a new current render target and viewport. If the viewport is not specified, the dimensions of the render target are used instead. This is similar to a call to render.SetRenderTarget and render.SetViewPort where the current render target and viewport have been saved beforehand, except the viewport isn't clipped to screen bounds. See also render.PopRenderTarget. If you want to render to the render target in 2d mode and it is not the sam..
number, number, number render.ReadPixel( number x, number y )
Reads the color of the specified pixel from the RenderTarget sent by render.CapturePixels
render.RedownloadAllLightmaps( boolean DoStaticProps = false )
This applies the changes made to map lighting using engine.LightStyle.
render.RenderHUD( number x, number y, number w, number h )
Renders the HUD on the screen.
render.RenderView( table view = nil )
Renders the scene with the specified viewData to the current active render target. Static props and LODs are rendered improperly due to incorrectly perceived distance.
render.ResetModelLighting( number r, number g, number b )
Resets the model lighting to the specified color. Calls render.SetModelLighting for every direction with given color.
render.ResetToneMappingScale( number scale )
Resets the HDR tone multiplier to the specified value. This will only work on HDR maps, and the value will automatically fade to what it was ( or whatever render.SetGoalToneMappingScale is ) if called only once.
render.SetAmbientLight( number r, number g, number b )
Sets the ambient lighting for any upcoming render operation.
render.SetBlend( number blending )
Sets the alpha blending for every upcoming render operation. This does not affect non-model render.Draw* functions.
render.SetColorMaterial()
Sets the current drawing material to "color". The material is defined as: "UnlitGeneric" { "$basetexture" "color/white" "$model" 1 "$translucent" 1 "$vertexalpha" 1 "$vertexcolor" 1 }
render.SetColorMaterialIgnoreZ()
Sets the current drawing material to "color_ignorez". The material is defined as: "UnlitGeneric" { "$basetexture" "color/white" "$model" 1 "$translucent" 1 "$vertexalpha" 1 "$vertexcolor" 1 "$ignorez" 1 }
render.SetColorModulation( number r, number g, number b )
Sets the color modulation.
render.SetFogZ( number fogZ )
If the fog mode is set to MATERIAL_FOG_LINEAR_BELOW_FOG_Z, the fog will only be rendered below the specified height.
render.SetGoalToneMappingScale( number scale )
Sets the goal HDR tone mapping scale. Use this in a rendering/think hook as it is reset every frame.
render.SetLightingMode( number Mode )
Sets lighting mode when rendering something. Do not forget to restore the default value to avoid unexpected behavior, like the world and the HUD/UI being affected
render.SetLightingOrigin( Vector lightingOrigin )
Sets the lighting origin. This does not work for prop_physics.
render.SetLightmapTexture( ITexture tex )
Sets the texture to be used as the lightmap in upcoming rendering operations. This is required when rendering meshes using a material with a lightmapped shader such as LightmappedGeneric. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
render.SetLocalModelLights( table lights = {} )
Sets up the local lighting for any upcoming render operation. Up to 4 local lights can be defined, with one of three different types (point, directional, spot). Disables all local lights if called with no arguments.
render.SetMaterial( IMaterial mat )
Sets the material to be used in any upcoming render operation using the render. Not to be confused with surface.SetMaterial. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
render.SetModelLighting( number lightDirection, number red, number green, number blue )
Sets up the ambient lighting for any upcoming render operation. Ambient lighting can be seen as a cube enclosing the object to be drawn, each of its faces representing a directional light source that shines towards the object. Thus, there is a total of six different light sources that can be configured separately. Light color components are not restricted to a specific range (i.e. 0-255), instead, higher values will result in a brighter light.
render.SetRenderTarget( ITexture texture )
Sets the render target to the specified rt.
render.SetRenderTargetEx( number rtIndex, ITexture texture )
Sets the render target with the specified index to the specified rt.
render.SetScissorRect( number startX, number startY, number endX, number endY, boolean enable )
Sets a scissoring rect which limits the drawing area.
render.SetShadowColor( number red, number green, number blue )
Sets the shadow color.
render.SetShadowDirection( Vector shadowDirections )
Sets the shadow projection direction.
render.SetShadowDistance( number shadowDistance )
Sets the maximum shadow projection range.
render.SetShadowsDisabled( boolean newState )
Sets whether any future render operations will ignore shadow drawing.
render.SetStencilCompareFunction( number compareFunction )
Sets the compare function of the stencil. Pixels which fail the stencil comparison function are not written to the render target. The operation to be performed on the stencil buffer values for these pixels can be set using render.SetStencilFailOperation. Pixels which pass the stencil comparison function are written to the render target unless they fail the depth buffer test (where applicable). The operation to perform on the stencil buffer values for these pixels can be set using render.SetStencilPassOper..
render.SetStencilEnable( boolean newState )
Sets whether stencil tests are carried out for each rendered pixel. Only pixels passing the stencil test are written to the render target.
render.SetStencilFailOperation( number failOperation )
Sets the operation to be performed on the stencil buffer values if the compare function was not successful. Note that this takes place before depth testing.
render.SetStencilPassOperation( number passOperation )
Sets the operation to be performed on the stencil buffer values if the compare function was successful.
render.SetStencilReferenceValue( number referenceValue )
Sets the reference value which will be used for all stencil operations. This is an unsigned integer.
render.SetStencilTestMask( number mask )
Sets the unsigned 8-bit test bitflag mask to be used for any stencil testing.
render.SetStencilWriteMask( number mask )
Sets the unsigned 8-bit write bitflag mask to be used for any writes to the stencil buffer.
render.SetStencilZFailOperation( number zFailOperation )
Sets the operation to be performed on the stencil buffer values if the stencil test is passed but the depth buffer test fails.
render.SetViewPort( number x, number y, number w, number h )
Changes the view port position and size. The values will be clamped to the game's screen resolution. If you are looking to render something to a texture (render target), you should use render.PushRenderTarget. This function will override values of ScrW and ScrH with the ones you set.
render.SetWriteDepthToDestAlpha( boolean enable )
Sets the internal parameter INT_RENDERPARM_WRITE_DEPTH_TO_DESTALPHA
render.Spin()
Swaps the frame buffers/cycles the frame. In other words, this updates the screen. If you take a really long time during a single frame render, it is a good idea to use this and let the user know that the game isn't stuck.
render.StartBeam( number segmentCount )
Start a new beam draw operation. This is a rendering function that requires a 3d rendering context. This means that it will only work in 3d Rendering Hooks.
boolean render.SupportsHDR()
Returns whether the game supports HDR, i.e. if the DirectX level is higher than or equal to 8.
boolean render.SupportsPixelShaders_1_4()
Returns if the current settings and the system allow the usage of pixel shaders 1.4.
boolean render.SupportsPixelShaders_2_0()
Returns if the current settings and the system allow the usage of pixel shaders 2.0.
boolean render.SupportsVertexShaders_2_0()
Returns if the current settings and the system allow the usage of vertex shaders 2.0.
render.SuppressEngineLighting( boolean suppressLighting )
Suppresses or enables any engine lighting for any upcoming render operation. This does not affect IMeshes.
render.TurnOnToneMapping()
Enables HDR tone mapping which influences the brightness.
render.UpdateFullScreenDepthTexture()
Updates the texture returned by render.GetFullScreenDepthTexture. Silently fails if render.SupportsPixelShaders_2_0 returns false.
ITexture render.UpdatePowerOfTwoTexture()
Updates the power of two texture.
render.UpdateRefractTexture()
Pretty much alias of render.UpdatePowerOfTwoTexture but does not return the texture.
render.UpdateScreenEffectTexture()
Copies the entire screen to the screen effect texture, which can be acquired via render.GetScreenEffectTexture. This function is mainly intended to be used in GM:RenderScreenspaceEffects

Page Links


Special Pages


Wikis

?

Render Time: 24ms

Session 0
DB GetPage 3
Generate Html 4
SaveChanges 8
Render Body 0
Render Sidebar 6