Hi everyone.
I’m trying to learn how to write shaders from Ben’s HLSL dvd 1 and the cg tutorial. I wrote a VERY simple shader to start and I have a question.
I wrote an “AplhaIn” float attribute to control the final Pixel program color output’s alpha. So that I could control the object transparency.
The shader works just fine, but when I move the alpha slider, nothing happens.
Any help is super welcomed
here’s the shader:
// hello world shader.
/************************************
************* Tweakables ************
************************************/
float3 ColorIn : Diffuse
<
string UIName = “Color”;
string UIWidget = “Color”;
> = {0f, .5f, 1f};
float AlphaIn
<
string UIWidget = “slider”;
float UIMin = 0;
float UIMax = 1;
string UIName = “Alpha”;
> = .5;
/************************************
************* Matrices **************
************************************/
float4x4 WorldViewProjection : WorldViewProjection < string UIWidget = “None”; >;
/************************************
************** Structs **************
************************************/
struct maya
{
float3 position : POSITION;
};
struct v_out
{
float4 position : POSITION;
};
struct f_out
{
float4 color : COLOR;
};
/************************************
*********** Vertex Program **********
************************************/
v_out v_p(maya IN)
{
v_out OUT;
float4 pos = float4(IN.position, 1);
OUT.position = mul(WorldViewProjection, pos);
return OUT;
}
/************************************
********* Fragment Program **********
************************************/
f_out f_p() : COLOR
{
f_out result;
result.color = float4(ColorIn, AlphaIn);
return result;
}
/************************************
************ Technique **************
************************************/
technique ONE
{
pass one
{
CullFace = Back;
DepthTestEnable=true;
DepthFunc = LEqual;
VertexProgram = compile arbvp1 v_p();
FragmentProgram = compile arbfp1 f_p();
}
}