Shaders Flashcards
3 Shader Categories
Graphics pipeline Shaders
Compute Shaders
Ray tracing Shaders
What is the Graphics pipeline Shader?
Most common shader.
Performs calculations that determine the color of the pixels on the screen.
Uses shader objects
What are Compute Shaders?
They perform calculations on the GPU outside of the regular graphics pipeline.
What are Ray tracing Shaders?
Perform calculations related to ray tracing
What are shader objects?
An instance of the shader class. A wrapper for shader programs and other information.
What is a Shader Lab?
A unity-specific language for writing Shaders
What is a Shader graph?
A tool for creating Shaders without writing code
What is a Shader Asset?
A file in your project that defines a Shader object.
What are Shaders?
Shaders are part of the Graphics pipeline. An instance of the shader class is called a Shader object.
What is a Shader Object?
Shader objects is a way of working with shader programs; it is a wrapper for shader programs and other information.
It let’s you define multiple shader programs in the same file and tell unity how to use them
What do shader objects contain?
A Shader object contains shader programs, instructions for changing settings on the GPU (collectively called render states), and information that tells unity how to use them.
What do you use shader objects for/with?
You can use shader objects with materials to determine the appearance of your scene
How do you create shader objects? (2 ways)
1) You can write code to create a Shader asset, which is a text file with the (.Shader) extension.
2) You can use a Shader graph to create a Shader graph asset.
An instance of the shader is called?
A Shader object
Inside a Shader object…
A Shader object has a nested structure.
It organizes information into structures called Subshaders and Passes.
It organizes shader programs into shader varients.
What does a Shader object contain?
1) Information about its self such as it’s name.
2) An optional fallback shader object, which unity uses if it can’t use the current one.
3) One or more Subshaders
What else can you do with shader objects?
You can also define additional information such as shared shader code, or whether to use a custom editor.
What is a SubShader?
Subshaders let you separate your shader object into parts that are compatible with different hardware, render pipelines, and runtime settings.
What does a SubShader contain?
1) Information about which hardware, render pipelines, and runtime settings this shader is compatible with
2) Subshader tags, which are key-value pairs that provide information about the Subshader
3) One or more passes
What else can you do with Subshaders?
You can also define information, such as render state that is common to all of its passes
Passes in Subshaders… What do they contain?
A Pass contains…
1) Pass tags. Which are key-value pairs that provide information about the pass.
2) Instructions for updating the render state before running its shader programs.
3) Shader programs, organized into one or more shader varients.
What are Shader Varients?
The Shader programs that a Pass contains are organized into shader varients.
Shader varients share common code, but have different functionality when a given keyword is enabled or disabled.
The number of shader variant in a Pass depends on how many keywords you define in your shader code, and the target platform
Each pass contains at least one variant.
Before unity uses a Shader object..
Unity creates a list of Subshaders for the shader object.
It adds all of the Subshaders defined in the shader object, and then adds all of the Subshaders in any fallback shader objects, in order.
When Unity first renders geometry using the Shader object, or when the shader LOD value or active render pipeline changes…
1) Unity iterates over the list of all the Subshaders and examines them to determine if they are: Compatible with the device hardware at all or below the current shader LOD value, and compatable with the active render pipeline.
2) If the list contains one or more Subshaders that meet these requirements, it selects the first one. This is the active Subshader.
3) If the list does not contain any Subshaders that meet all the requirements:
If the list contains one or more Subshaders that meet the hardware requirements (but do not meet the LOD or render pipeline requirements) Unity selects the first one to be the active Subshader.
If the list does not contain a u Subshaders that meet the hardware requirements, Unity displays the error Shader.