Techniques define shaders, shader-inputs and statemaps that are being used for your current pass. Always make sure that every constant you pass into your shader is actively being used within your shader and referenced by your material template
, otherwise your shader will fail to compile.
You can mix up Vertex- and PixelShaders as long as the VertexShader ouputs the information that the PixelShader needs. You could also use a stock Vertex- with a custom PixelShader if you so wish, but its somewhat impractical.
Multiple Shader-passes are also supported, but more on that later.
Lets have a look at a technique that is using 2 textures (referencing the dynamic material template that was shown here: Material Templates - In-depth)
Example:
1. Samplers
Samplers are defined in root\raw\shader_bin\shader_src\shader_vars.h and either mapped to constant registers or mapped dynamically.
Each sampler type uses different hard-coded sampler stats that define how it samples the given input image (eg. texture filtering or sampling technique).
I advice you to use a sampler that fits your input but you can obv. experiment with them if you want.
A list of availible samplers (not sure if every one of them works tho)
2. Code-Textures
Textures exposed by code are not always valid. They represent the different Rendertargets that the game uses to render
to off-screen “textures” and are mostly used for post-process effects but also for depth, shadows, lightmaps etc.
Most of them are only valid when the specific use-case (in code), that they are used for, is active.
Rendering to code-textures can only be done via engine modifications so these can only be read from.
A list of availible textures exposed by code:
The most useful textures exposed by code:
Can be used like:
3. Semantics / Code-Variables / Input
Like mentioned earlier, you pass material parameters into your shader by assigning them to pre-defined, global shader variables (defined in shader_vars.h).
The same applies to textures that you assign to samplers.
Example:
There are also variables exposed by code, that hold information about the current vertex within the pipeline.
Vertex-information that you need within your shader needs to be put into its intended [Semantic] defined at the bottom of your technique.
Example:
You only define the variables you really need and use in your shader or you’ll get errors when linking your shader.
Vertex information exposed by code assigned to their intended semantics (incomplete)