Skip to main content
gamedev.net
🔒 Locked

CG Lighting question

Started by Kincaid Sep 12, 2006 at 9:10 AM 5 replies 650+ views
Original Post
Kincaid
Kincaid
How can u support x number of light with per pixel lighting? I'm using CG and I can bind the lightdistance, normal, color of one light. but how can I pass the list off all my lights so the shader can work through all of em?? Ideally i'd like to pass a linked list, as it is. How would you usually go about in per pixel lighting many lights ?
leoptimus
leoptimus
Read the Cg Manual and the Nvidia examples.

You need to pass an uniform array with the info of all the lights.

There is a function for pass an array of parameters:

Quote:

void cgGLSetParameterArray4f( CGparameter param,
long offset,
long nelements,
const float * v );


your fragment shader function must receive an unsize array like this:
Quote:

float4 main(float4 myarray[])
{
// ...
}

And if you need, call cgSetArraySize for manually set the array size
"Technocracy Rules With Supremacy" visit: http://gimpact.sourceforge.net
leoptimus
leoptimus
Sorry! forget it. If your nvidia card doesn't support branching on the fragment shader, you can't pass unsized array data to the program.
You'd need a graphic card with shader model 3.0, Nvidia fx 7xxx family.
"Technocracy Rules With Supremacy" visit: http://gimpact.sourceforge.net
Kincaid
Kincaid
but how will interpolation take place ??
I need to pass the vertices of polygon minus a light position to the TEXCOORD0, so interpolation takes place which gives a good lighting effect.
Setting parameters straight away doesn't undergo this step

Kincaid
Kincaid
then how can we light a scene with more then one light?
Kincaid
Kincaid
by the way

does anybody know of a good CG forum ??
MARS_999
MARS_999
http://www.shadertech.com/cgi-bin/articles.cgi?filter=1

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.