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 two shading models ShadingModelStandard
which should be what most people would use and ShadingModelCustom
as a base for custom shading models to be developed from, they will handle things like atmospherics and debug visualizations for you without a fuzz.
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.
Usage
Example ShadingModel
Here's an example of doing a simple Toon shader from the structure you get from lights