Game Development Community

Procedural shaders?

by Lukasz Smaga · in Torque Game Engine Advanced · 04/05/2007 (4:28 am) · 4 replies

Hi
First of all, I'm a complete noob :P
How can I generate procedural shaders?
cheers, lucas

#1
04/05/2007 (6:58 pm)
They are generated automatically when you create a materials.cs file. For example in the demo in the data/shapes/spaceorc/materials.cs directory you see this:

new Material(OrcEye)
{
baseTex[0] = "~/data/shapes/spaceOrc/orc_ID6_eye";
emissive[0] = true;
glow[0] = true;
};

new Material(SpaceOrc)
{
baseTex[0] = "~/data/shapes/SpaceOrc/Orc_Material";
bumpTex[0] = "~/data/shapes/SpaceOrc/Orc_Material_normal";
cubemap = WChrome;
pixelSpecular[0] = true;
specular[0] = "0.5 0.5 0.5 0.5";
specularPower[0] = 8.0;
};

Those materails will generate the shaders automatically. For example in the add this line into the SpaceOrc material definition:

glow[0] = true;

and you now have a glowing spaceorc. You can find the full details on what all you can do with the procedural shaders on TDN.
#2
04/06/2007 (3:45 am)
Thank you for answer :P

PS. I can't go to TDN because I have downloaded the demo of TGEA. :)

Cheers, Lucas
#3
04/06/2007 (6:41 am)
Oh oops, just noticed this was in the public forum. You should be able to figure out most of the procedurals by looking at the materials.cs files in the various areas in the data directory. Basically every folder in your data gets scanned at start up for materials.cs files and it uses those to generate the procedural shaders. The [0] in the brackets indicate the pass.

So for example you could do multiple passes by doing further declarations with a [1] instead of a 0. For example if you had a texture which featured a light... and you wanted to make the lighted area to glow but only that area, you could make a second transparent texture (png or dds) which was transparent except for the area that you wanted to glow, and was colored with the light color. You could then use a material like this...

new Material(LightedPanel)
{
baseTex[0] = "~/data/textures/paneltexture";
baseTex[0] = "~/data/textures/panelexture_normalmap";
baseTex[1] = "~/data/textures/panelglowtexture";
emissive[1] = true;
glow[1] = true;
};

And it would draw the panel with its normal map, and then on the second pass (panelglowtexture) it would make the second pass glow and emit light.
#4
04/06/2007 (12:31 pm)
Fantastic :) thank you for the help :)