Garry's Mod Wiki

Revision Difference

render_rendertargets#561260

<cat>Don'tListMePlease Dev</cat> <title>Render Reference - Render Targets</title> # Render Library References These pages seek to provide helpful insight into the groups of functions provided by the <page text="Render Library">render</page>. The major function groups are: * <page text="Beams">Beam_Rendering</page> * <page text="Minification and Magnification Texture Filters">render_min_mag_filters</page> * **Render Targets** ⤶ # Render Targets⤶ ## A Note on Layout⤶ This page is laid out with the intention of first building understanding of the concepts, then only once that understanding exists do we introduce the code side. Feel free to read the page in whatever way helps you understand the contents best.⤶ # What are Render Targets? **A Render Target is a special kind of image** that is created during gameplay via the game's code, rather than a pre-existing image that is loaded from the game's files.⤶ ⤶ ## Some Basic Facts⤶ ⤶ Render Targets, because they are fundamentally just images, have a fixed resolution, measured in pixels, that is defined when they are first created. ⤶ Unless your specific use-case has a reason not to, it's recommended to use the game's render resolution (Obtained via <page text="ScrW">Global.ScrW</page> and <page text="ScrH">Global.ScrH</page>.)⤶ ⤶ Each Render Target is comprised of three (3) parts:⤶ 1. The Color Channel⤶ 2. The Depth Buffer⤶ 3. The Stencil Buffer⤶ ⤶ ## The Color Channel⤶ The Color Channel (or simply "Color") is what is visible on the Render Target. Very simply, this is what you would see if you drew the Render Target onto the screen.⤶ ⤶ ## The Depth Buffer⤶ ⤶ ## The Stencil Buffer⤶ ⤶ ⤶ ## How Render Targets are Used to Draw Frames⤶ Render Targets are used for anything that needs to be drawn dynamically, including the view you see while playing the game. Internally, the engine creates two two Render Targets (Called "Frame Buffers") when the game starts. At any given time, one of these two Render Targets is considered "in front" and the other is considered "in back". ⤶ ⤶ When your monitor asks for a frame to draw, the game sends it whatever is in the Front Render Target. Meanwhile, the game renders the next frame to the Back Render Target where it won't be seen by the player. When the next frame is finished, the two Render Targets are swapped (Called "Spinning") and the game starts sending the new Front Render Target to the monitor.⤶ ⤶