Jump to content
  • Advertisement
Sign in to follow this  
andrew1b

Unsized uniform arrays in Cg?

This topic is 3020 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anybody know any example that shows the use of unsized uniform arrays in Cg? My program is compiling but it doesnt work. Here is my program:


void light_particle( float3 position : POSITION,
float2 texCoord : TEXCOORD0,
out float4 oPosition : POSITION,
out float4 oColor : COLOR0,
out float2 oTexCoord0 : TEXCOORD0,
uniform float4 ambientLight,
uniform float3 lightPos[],
uniform float3 lightColor[],
uniform float lightRange[])
{
float4 outPos = transformSprite(position);
oPosition = outPos;
float2 coord = transformCoord(texCoord);
oTexCoord0 = coord;

float4 outColor = ambientLight;
for (int t=0; t<lightPos.length; t++)
{
float3 diff = outPos.xyz-lightPos[t];
float squaredDist = dot(diff,diff);
float squaredRange = lightRange[t]*lightRange[t];
squaredRange = max(squaredDist, squaredRange);
float attenBias = 1-(squaredDist/squaredRange);
outColor += float4(lightColor[t],0)*attenBias;
}

oColor = color0*outColor;
}


The loop ins't running even once, I don't know if I'm sending the data correctly.

This is what I do:

D3DXVECTOR3 pos[nLights];
...
cgD3D9SetUniformArray(lightPosParam, 0, nLights, pParam);

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!