🔳 CosterGraphics Systems OutlineSystem Shaders Overview
🌍 Outline System Shaders Overview
This OutlineSystem uses three types of shaders:
Mask Shaders
The mask shaders are used by the renderer feature during the mask render passes to create different types of masks of the outline objects that are stored to be used later each frame by the Composite shaders that draw the final outlines to the camera texture.Intermediate Buffer Shaders Intermediate buffer shaders are only used by the Pro tier outline shaders during render passes in between the regular mask passes and the final composite passes. To create the Jump Flood Algorithm distance field textures that are required by the JFA Composite shaders, the JFA Seeds Texture Mask created during the JFA Seed Mask pass is first copied to an intermediate texture that is then written to several times in a loop for as many render passes that are required to generate the field (which depends on the size of the screen). To create the JFA distance field outlines the system uses separate vertical and horizontal jump passes that both require a different intermediate material/shader. After the jump passes are done the final JFA UV field is stored in a JFA UV jump render texture which is used by the Composite JFA shaders via the _OutlineJFAUVJumpTextureMask property to calculate distance fields and signed distance fields with of the ouline geometry. The JFA seeds texture from which the UV field texture is originally created is also stored in a render texture for later use in the Composite shaders via the _OutlineJFAUVSeedTexture property. What is stored in the JFA UV seed textures during the mask passes are only the screen space UV positions of the masked outline objects and what is stored in the final JFA Jump texture after the intermediate horizontal and vertical jump passes are the distances from each pixel to the closes edges of the masked outline objects.
Final Composite Shaders To explain this in terms of cooking in a restaurant kitchen, the outline composite shaders are where the outline ingredients that are created during the masking render and shader passes are used to cook the final outline dishes with. Each composite shader uses one or more different kinds of ingredients to create the different types of outlines with. In regular terms, the composite shaders uses the render texture masks, (of which most are drawn using unlit or lit shaders via command buffers in the renderer feature that render only the selected outline objects to the special render texture masks), to the scene view and game view cameras color textures via full-screen Shader Graph shaders. This setup makes it extremely easy to start creating your own outline shaders for this system because any Full-Screen Shader Graph shader used for the composite pass of the outline systems renderer feature has access to all the ingredients via the properties listed below. To keep things optimized and efficient the renderer feature will only execute the passes and create the mask textures if the composite actually has the right property for it!
The Composite Shader Graph Mask Texture Properties (The Ingredients List)
These are the property names of the mask textures that are available to the full-screen Composite shaders.
Basic Advanced Pro Hyper
Texture2D _OutlineColorTextureMask ✔️ ✔️ ✔️ ✔️
Texture2D _OutlineColorTextureMaskDepthTested ✔️ ✔️ ✔️ ✔️
Texture2D _OutlineDepthTextureMask ✔️ ✔️ ✔️ ✔️
Texture2D _OutlineNormalsTextureMask ✔️ ✔️ ✔️ ✔️
Texture2D _OutlineObjectIDTextureMask ✔️ ✔️ ✔️
Texture2D _OutlineJFAUVSeedsTextureMask ✔️ ✔️
Texture2D _OutlineJFAUVJumpTextureMask ✔️ ✔️