Shading Model
What is a Shading Model
Shading Models determines how a surface will interact with light.
They dictate how the Material's input data is utilized to produce the final visual output.
Not only can you use one of these pre-defined shading models, but you can also create your own shading model to shade your surface the way you want.
S&box currently ships with one shading model ShadingModelStandard
which should be what most people would use.
Using built-in shading models
Creating a shading model
Structure
Light Structure
We provide the following light types to be used from shader code:
DynamicLight
StaticLight
EnvironmentMapLight
AmbientLight
All can be created with Light::From()
and all but AmbientLight
can be iterated with Light::Count()
,
Light types already handle everything from tiled rendering to shadowing seamlessly, for example:
Each light structure gives you the following data to be consumed:
Note that ambient lights skip some of this data.
Applying Fog
You can apply fog to shaders by using DoAtmospherics()
Usage
Example ShadingModel
Here's an example of doing a simple Toon shader from the structure you get from lights