Shader Creation
How a shader works
Usually, shaders are compound of 2 files: the .frag and the .vert. But most of the time, the relevant information is set on the .frag file.
Overgrowth doesnt support this approach anymore, all the existing shaders on Overgrowth are stored on "Data/GLSL/Envobject.*".
How Overgrowth currently handle Shaders
Right now The engine automatically substitutes certain shader strings with a different/expanded string with extra options in place.
This means, even if seems to be that an object is using one of the shaders set inside Data/GLSL, the truth is that the engine is replacing it with another path making a reference to the shader created on envobject. For example:
"cubemap" -> "envobject #TANGENT"
"cubemapobj" or "cubemapobjchar" or "cubemapobjitem" -> "envobject"
"cubemapalpha" -> "envobject #TANGENT #ALPHA"
"plant" or "plant_less_movement" -> "envobject #TANGENT #ALPHA #PLANT"
"plant_foliage" -> "envobject #TANGENT #ALPHA #PLANT #NO_DECALS"
"detailmap4" -> "envobject #DETAILMAP4 #TANGENT"
"detailmap4tangent" -> "envobject #DETAILMAP4 #TANGENT #BASE_TANGENT"
"MagmaFloor" -> "envobject #MAGMA_FLOOR"
"MagmaFlow" -> "envobject #MAGMA_FLOW"
Creation of your custom shader
To create or modify an existing shader:
- Copy the Envobject.* files and paste them on Data/GLSL folder inside your mod.
- Rename the envobject files to another name so it wont conflict with those from the game (we will use EnvobjectEx.* on this guide).
- Set the name of your shader. On this case our name will be
CUSTOM_SHADER
- Write somewhere on the file your shader code by setting it inside an "if" statement.
For example: #ifdef CUSTOM_SHADER
and then close it with #endif
- Now, you can easily put your shader to work on any object very easily. Just go to your object .XML file, and inside the ShaderName tags, set something like this
<ShaderName>EnvobjectEx #CUSTOM_SHADER</ShaderName> And now your shader will be used on that object.