Trouble with uniform parameters in fragment programs
Posted: Wed Feb 02, 2005 11:04 pm
For some reason I cannot get any of my CG fragment programs to accept uniform parameters that are not of type "float4". For instance consider the following material script excerpt:
with accompanying CG code for the frament program:
This code operates correctly and displays the object as solid red. Now consider the following material excerpt and fragment program. These are intended to accomplish the same effect only using float3's instead of float4's:
and the fragment program...
Unlike the first example, this second method does not work at all. The object is displayed as solid black indicating that the GPU did not recieve the correct values for "constColor".
Furthermore the same odd effect occurs when passing the fragment program a "float2"--the data is all zeroed out. Even worse, if you pass the fragment program a simple "float", the application will crash somewhere inside the CG parser. Does anyone know what is going on here?
Thanks!
Code: Select all
fragment_program_ref main_fp
{
param_named constColor float4 1 0 0 1
}
Code: Select all
void main_fp(out float4 oColor : COLOR,
uniform float4 constColor)
{
oColor = constColor;
}
Code: Select all
fragment_program_ref main_fp
{
param_named constColor float3 1 0 0
}
Code: Select all
void main_fp(out float4 oColor : COLOR,
uniform float3 constColor)
{
oColor.xyz = constColor;
oColor.w = 1;
}
Furthermore the same odd effect occurs when passing the fragment program a "float2"--the data is all zeroed out. Even worse, if you pass the fragment program a simple "float", the application will crash somewhere inside the CG parser. Does anyone know what is going on here?
Thanks!