How to send a custom variable into the pixel shader?
by Dave Calabrese · in Torque Game Engine Advanced · 07/28/2008 (12:03 pm) · 3 replies
I have a new pixel shader that I wish to use to allow the user to modify the color of something from within the game's GUI system. It seems simple enough to pass in a custom variable, however I'm hitting a snag somewhere.
I see a few possibilities, such as utilizing the register at PC_USERDEF1. The process looks like it should be simple enough. There is a float4 value sent into the HLSL from the script, just like the way we currently send in the specular color. So I would want to have the following:
All I need is the ability to pass that 'customColor' variable into the HLSL script. Anyone think they can give me a shove in the right direction on how to pass in custom variables?
Thanks in advance!
-Dave Calabrese
Gaslight Studios
I see a few possibilities, such as utilizing the register at PC_USERDEF1. The process looks like it should be simple enough. There is a float4 value sent into the HLSL from the script, just like the way we currently send in the specular color. So I would want to have the following:
new CustomMaterial(redWood)
{
mapTo = "redWood_d";
shader = StandardShader;
version = 2.0;
texture[0] = "redWood_d.jpg"; //Diffuse Map
texture[1] = "redWood_n.png"; //Bump Map
specularPower[0] = 10;
specular[0] = "0.6 0.6 0.6 1";
customColor = "0.4 0.2 0.6"; //<--------- Custom Color Definition Variable
};All I need is the ability to pass that 'customColor' variable into the HLSL script. Anyone think they can give me a shove in the right direction on how to pass in custom variables?
Thanks in advance!
-Dave Calabrese
Gaslight Studios
About the author
Associate Dave Calabrese
Cerulean Games
-Dave Calabrese
Gaslight Studios