Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#ActualMedo3337

Posted 17 July 2013 - 07:04 PM

I don't know have many lights will be used in the scene, so I'm looking for a way to be able to pass any number of lights.

 

I thought that I could create array with high number of lights in the shader and then tell the shader how many lights was passed for light calculation, for example:

// Shader
#define MAX_LIGHTS 8 // *** I don't know how many lights, so I will assume 1000 is the maximum possible ***
PointLight pointLights[MAX_LIGHTS];
DirectionalLight directionalLights[MAX_LIGHTS];
SpotLight spotLights[MAX_LIGHTS];

float numOfLights;

// Then loop in the shader
(for int i = 0; i < numOfLights; i++)
{
     // Code to calculate light here...
}

Is this way a good idea?


#7Medo3337

Posted 17 July 2013 - 07:04 PM

I don't know have many lights will be used in the scene, so I'm looking for a way to be able to pass any number of lights.

 

I thought that I could create array with high number of lights in the shader and then tell the shader how many lights was passed for light calculation, for example:

// Shader
#define MAX_LIGHTS 8; // *** I don't know how many lights, so I will assume 1000 is the maximum possible ***
PointLight pointLights[MAX_LIGHTS];
DirectionalLight directionalLights[MAX_LIGHTS];
SpotLight spotLights[MAX_LIGHTS];

float numOfLights;

// Then loop in the shader
(for int i = 0; i < numOfLights; i++)
{
     // Code to calculate light here...
}

Is this way a good idea?


#6Medo3337

Posted 17 July 2013 - 02:06 PM

I don't know have many lights will be used in the scene, so I'm looking for a way to be able to pass any number of lights.

 

I thought that I could create array with high number of lights in the shader and then tell the shader how many lights was passed for light calculation, for example:

// Shader
float MAX_LIGHTS = 1000; // *** I don't know how many lights, so I will assume 1000 is the maximum possible ***
PointLight pointLights[MAX_LIGHTS];
DirectionalLight directionalLights[MAX_LIGHTS];
SpotLight spotLights[MAX_LIGHTS];

float numOfLights;

// Then loop in the shader
(for int i = 0; i < numOfLights; i++)
{
     // Code to calculate light here...
}

Is this way a good idea?


#5Medo3337

Posted 17 July 2013 - 02:05 PM

I don't know have many lights will be used in the scene, so I'm looking for a way to be able to pass any number of lights.

 

I thought that I could create array with high number of lights in the shader and then tell the shader how many lights was passed for light calculation, for example:

// Shader
float MAX_LIGHTS = 1000; // *** I don't know how many lights, so I will assume 1000 is the maximum possible ***
PointLight pointLights[MAX_LIGHTS];
DirectionalLight directionalLights[MAX_LIGHTS];
SpotLight spotLights[MAX_LIGHTS];

float numOfLights;

// Then loop in the shader
(for int i = 0; i < numOfLights; i++)
{
     // Code to calculate additional light here...
}

Is this way a good idea?


#4Medo3337

Posted 17 July 2013 - 02:05 PM

I don't know have many lights will be used in the scene, so I'm looking for a way to be able to pass any number of lights.

 

I thought that I could create array with high number of lights in the shader and then tell the shader how many lights was passed for light calculation, for example:

// Shader
float MAX_LIGHTS = 1000; // *** I don't know how many lights, so I will assume 1000 is the maximum possible ***
PointLight pointLights[MAX_LIGHTS];
DirectionalLight directionalLights[MAX_LIGHTS];
SpotLight spotLights[MAX_LIGHTS];

float numOfLights

// Then loop in the shader
(for int i = 0; i < numOfLights; i++)
{
     // Code to calculate additional light here...
}

Is this way a good idea?


#3Medo3337

Posted 17 July 2013 - 02:04 PM

I don't know have many lights will be used in the scene, so I'm looking for a way to be able to pass any number of lights.

 

I thought that I could create array with high number of lights in the shader and then tell the shader how many lights was passed for light calculation, for example:

// Shader
float MAX_LIGHTS = 1000; // *** I don't know how many lights, so I will assume 1000 is the maximum possible ***
PointLight pointLights[MAX_LIGHTS];
DirectionalLight directionalLights[MAX_LIGHTS];
SpotLight spotLights[MAX_LIGHTS];

float numOfLights

// Then loop in the shader
(for int i = 0; i < numOfLights; i++)
{
     // Code to calculate additional light here...
}

Is this way a good idea?


PARTNERS