Shaders
From Esenthel
In Esenthel Engine there are following rules in shader creation:
- All shader parameters are automatically shared between all shader files
Therefore having 2 shaders:
Shader "A.shader.cpp":
Flt parameter; ... vertex shader code pixel shader code
Shader "B.shader.cpp":
Flt parameter; ... vertex shader code pixel shader code
Changing "Flt parameter" from the application level will change the value in both shaders.
This greatly simplifies managing shader parameters across many shaders, hovewer it also implies the following restriction, you must make sure that when defining a parameter in many shaders, it will be of the same type in all shaders.
For example you cannot define in one shader a "Flt parameter" and in other shader "Vec parameter". When doing that the application will exit and return an error that the same parameter name has been defined in many shaders with different types.
- Global parameters of "Bool" and "Int" type are not supported (only float based are supported - "Flt", "Vec2", "Vec", ...), just replace your "Bool" and "Int" parameters to float type, you'll achieve the same effect
- In order to access a Shader Parameter or Shader Image, they must be created by the engine first.
Parameters and Images are created by the engine when a Shader is loaded which defines a Parameter or Image.
So in order to access the Parameter or Image you must first load at least one Shader which defines them.
- Vertex Input in Vertex Shaders should always be handled only by the VtxInput struct usage.
- Global parameters in shaders should be groupped into constant buffers:
BUFFER(BufferName) Flt parameter1; Vec2 parameter2; BUFFER_END vertex shader code pixel shader code
