Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualfrench_hustler

Posted 09 August 2012 - 11:47 AM

As Hodgman mentioned, your C++ code light structs should mirror your shader light structs (making sure you have the right padding).

If you do want to have an arbitrary amount of lights to be defined by your C++ code, there a couple ways of doing so (without deferred rendering):

1: have different shaders with different light #'s. This way is a bit sketchy though since you are still restricted to a certain number of lights depending on which shader you run.

2: if your hardware allows it, you could use dynamic branching. You could define a constant in your shader (gNumLights) that specifies the amount of lights you'll be sending over to the gpu. You will still have a MAX_POINT_LIGHTS, but you'll be able to define in C++ how many lights you have in your scene in the range of [0, MAX_POINT_LIGHTS]. Then when you do your lighting, you just iterate through your light array from 0 to gNumLights.

#1french_hustler

Posted 09 August 2012 - 11:47 AM

As Hodgman mentioned, your C++ code light structs should mirror your shader light structs.

If you do want to have an arbitrary amount of lights to be defined by your C++ code, there a couple ways of doing so (without deferred rendering):

1: have different shaders with different light #'s. This way is a bit sketchy though since you are still restricted to a certain number of lights depending on which shader you run.

2: if your hardware allows it, you could use dynamic branching. You could define a constant in your shader (gNumLights) that specifies the amount of lights you'll be sending over to the gpu. You will still have a MAX_POINT_LIGHTS, but you'll be able to define in C++ how many lights you have in your scene in the range of [0, MAX_POINT_LIGHTS]. Then when you do your lighting, you just iterate through your light array from 0 to gNumLights.

PARTNERS