class Shader
A shader is a piece of code that runs on the GPU, and determines how model data gets transformed into pixels on screen! It’s more likely that you’ll work more directly with Materials, which shaders are a subset of.
With this particular class, you can mostly just look at it. It doesn’t do a whole lot. Maybe you can swap out the shader code or something sometimes!
Instance Fields and Properties
string Id | Gets or sets the unique identifier of this asset resource! This can be helpful for debugging, managine your assets, or finding them later on! |
string Name | The name of the shader, provided in the shader file itself. Not the filename or id. |
Static Fields and Properties
Shader Default | This is a fast, general purpose shader. It uses a texture for ‘diffuse’, a ‘color’ property for tinting the material, and a ‘tex_scale’ for scaling the UV coordinates. For lighting, it just uses a lookup from the current cubemap. |
Shader PBR | A physically based shader. |
Shader PBRClip | Same as ShaderPBR, but with a discard clip for transparency. |
Shader UI | A shader for UI or interactable elements, this’ll be the same as the Shader, but with an additional finger ‘shadow’ and distance circle effect that helps indicate finger distance from the surface of the object. |
Shader UIBox | A shader for indicating interaction volumes! It renders a border around the edges of the UV coordinates that will ‘grow’ on proximity to the user’s finger. It will discard pixels outside of that border, but will also show the finger shadow. This is meant to be an opaque shader, so it works well for depth LSR. This shader works best on cube-like meshes where each face has UV coordinates from 0-1. Shader Parameters: color - color border_size - meters border_size_grow - meters border_affect_radius - meters |
Shader Unlit | Sometimes lighting just gets in the way! This is an extremely simple and fast shader that uses a ‘diffuse’ texture and a ‘color’ tint property to draw a model without any lighting at all! |
Shader UnlitClip | Sometimes lighting just gets in the way! This is an extremely simple and fast shader that uses a ‘diffuse’ texture and a ‘color’ tint property to draw a model without any lighting at all! This shader will also discard pixels with an alpha of zero. |
Static Methods
Find | Looks for a Shader asset that’s already loaded, matching the given id! Unless the id has been set manually, the id will be the same as the shader’s name provided in the metadata. |
FromFile | Loads a shader from a precompiled StereoKit Shader (.sks) file! HLSL files can be compiled using the skshaderc tool included in the NuGet package. This should be taken care of by MsBuild automatically, but you may need to ensure your HLSL file is a |
FromMemory | Creates a shader asset from a precompiled StereoKit Shader file stored as bytes! |
Found an issue with these docs, or have some additional questions? Create an Issue on Github!