Shader Creation

From Wolfire Games Wiki
Revision as of 19:28, 26 January 2018 by Edoantonioco (talk | contribs) (Creation of your custom shader)
Jump to: navigation, search


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:

  1. Copy the Envobject.* files and paste them on Data/GLSL folder inside your mod.
  2. Rename the envobject files to another name so it wont conflict with those from the game (we will use EnvobjectEx.* on this guide).
  3. Set the name of your shader. On this case our name will be CUSTOM_SHADER
  4. 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

  1. 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.