Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualmv348

Posted 15 September 2012 - 11:23 PM

Thanks for all the input guys! I just got shadow-mapping workingwith a single light, for a single model. So now I am moving towards multiple lights, and multiple models.

To avoid excessive extra-rendering, I am planning on enclosing each lamp in a bounding volume (i.e. an Axis Aligned Bounding Box) and checking for intersections with each models bounding volume. I admit I haven't read up much on this just yet, there's something called 'Cascaded Shadows' that I need to look into, but I wanted to get your input on the algorithm I came up with today.

Here's the psuedo-code. Should be pretty self explanatory:


Algorithm:

PositionModels()
PositionsLights()
/////////////////
// SHADOW PASS //
/////////////////



for  light in AllLights
{
   // determine which models are hit by the light
   for model in AllModels:
   {
	 if (collision(light.volume, model.volume)
	 {
		 light.modelsInView.add(model);
		// give model access to light data, including its shadow map
		model.shadowCasters.add(light);
	  }
   }  

  // if any models were hit by the light
  if (light.modelsInView.Count > 0)
  {
	 prepareShadowRender(light);
			  
	 // render all models in this light's view to the light's shadowmap
	 for model in light.modelsInView
	 {
		model.render();
	 }
	  
  }

}

//////////////////
// FINAL RENDER //
//////////////////

for model in models:
{
   for light in model.shadowCasters:
   {
	  shaderSetupShadowMap(light)
   }
   model.render();
  
}



Obviously the relevant lists need to be cleared after each rendered. Further optimizations can obviously be made, such as caching shadows for stable objects. But I think the general structure is captured here, wouldn't you say?

Any input/feedback would be appreciated.

#4mv348

Posted 15 September 2012 - 11:22 PM

Thanks for all the input guys! I just got shadow-mapping workingwith a single light, for a single model. So now I am moving towards multiple lights, and multiple models.

To avoid excessive extra-rendering, I am planning on enclosing each lamp in a bounding volume (i.e. an Axis Aligned Bounding Box) and checking for intersections with each models bounding volume. I admit I haven't read up much on this just yet, there's something called 'Cascaded Shadows' that I need to look into, but I wanted to get your input on the algorithm I came up with today.

Here's the psuedo-code. Should be pretty self explanatory:


Algorithm:

PositionModels()
PositionsLights()
/////////////////
// SHADOW PASS //
////////////////////////////////



for  light in AllLights
{
   // determine which models are hit by the light
   for model in AllModels:
   {
	 if (collision(light.volume, model.volume)
	 {
		 light.modelsInView.add(model);
		// give model access to light data, including its shadow map
		model.shadowCasters.add(light);
	  }
   }  

  // if any models were hit by the light
  if (light.modelsInView.Count > 0)
  {
     prepareShadowRender(light);
			  
     // render all models in this light's view to the light's shadowmap
     for model in light.modelsInView
     {
        model.render(); 
     }
	  
  }

}

//////////////////
// FINAL RENDER //
//////////////////

for model in models:
{
   for light in model.shadowCasters:
   {
	  shaderSetupShadowMap(light)
   }
   model.render();
  
}



Obviously the relevant lists need to be cleared after each rendered. Further optimizations can obviously be made, such as caching shadows for stable objects. But I think the general structure is captured here, wouldn't you say?

Any input/feedback would be appreciated.

#3mv348

Posted 15 September 2012 - 11:17 PM

Thanks for all the input guys! I just got shadow-mapping workingwith a single light, for a single model. So now I am moving towards multiple lights, and multiple models.

To avoid excessive extra-rendering, I am planning on enclosing each lamp in a bounding volume (i.e. an Axis Aligned Bounding Box) and checking for intersections with each models bounding volume. I admit I haven't read up much on this just yet, there's something called 'Cascaded Shadows' that I need to look into, but I wanted to get your input on the algorithm I came up with today.

Here's the psuedo-code. Should be pretty self explanatory:


Algorithm:

PositionModels()
PositionsLights()
/////////////////
// SHADOW PASS //
////////////////
for  light in AllLights
{
   // determine which models are hit by the light
   for model in AllModels:
   {
	 if (collision(light.volume, model.volume)
	 {
		 light.modelsInView.add(model);
		// give model access to light data, including its shadow map
		model.shadowCasters.add(light);
	  }
   }
}  

// if any models were hit by a light
if (light.modelsInView.Count > 0)
{
   prepareShadowRender(light);
			  
   // render all models in this light's view to the light's shadowmap
   for model in light.modelsInView
   {
	  model.render();  
  
   }
	  
}

//////////////////
// FINAL RENDER //
//////////////////

for model in models:
{
   for light in model.shadowCasters:
   {
      shaderSetupShadowMap(light)
   }
   model.render();
  
}



Obviously the relevant lists need to be cleared after each rendered. Further optimizations can obviously be made, such as caching shadows for stable objects. But I think the general structure is captured here, wouldn't you say?

Any input/feedback would be appreciated.

#2mv348

Posted 15 September 2012 - 11:15 PM

Thanks for all the input guys! I just got shadow-mapping workingwith a single light, for a single model. So now I am moving towards multiple lights, and multiple models.

To avoid excessive extra-rendering, I am planning on enclosing each lamp in a bounding volume (i.e. an Axis Aligned Bounding Box) and checking for intersections with each models bounding volume. I admit I haven't read up much on this just yet, there's something called 'Cascaded Shadows' that I need to look into, but I wanted to get your input on the algorithm I came up with today.

Here's the psuedo-code. Should be pretty self explanatory:


Algorithm:

PositionModels()
PositionsLights()
/////////////////
// SHADOW PASS //
////////////////
for  light in AllLights
{
   // determine which models are hit by the light
   for model in AllModels:
   {
     if (collision(light.volume, model.volume)
     {
         light.modelsInView.add(model);
        // give model access to light data, including its shadow map
        model.shadowCasters.add(light);
      }
   }
}  

// if any models were hit
if (light.modelsInView.Count > 0)
{
   prepareShadowRender(light);
			  
   // render all models in this light's view to the light's shadowmap
   for model in light.modelsInView
   {
      model.render();  
  
   }
	  
}

//////////////////
// FINAL RENDER //
//////////////////

for model in models:
{
   for light in model.shadowCasters:
   {
shaderSetupShadowMap(light)
   }
   model.render();
  
}


Further optimizations can obviously be made, such as caching shadows for stable objects. But I think the general structure is captured here, wouldn't you say?

Any input/feedback would be appreciated.

#1mv348

Posted 15 September 2012 - 11:12 PM

Thanks for all the input guys! I just got shadow-mapping workingwith a single light, for a single model. So now I am moving towards multiple lights, and multiple models.

To avoid excessive extra-rendering, I am planning on enclosing each lamp in a bounding volume (i.e. an Axis Aligned Bounding Box) and checking for intersections with each models bounding volume. I admit I haven't read up much on this just yet, there's something called 'Cascaded Shadows' that I need to look into, but I wanted to get your input on the algorithm I came up with today.

Here's the psuedo-code. Should be pretty self explanatory:


Algorithm:

PositionModels()
PositionsLights()
/////////////////
// SHADOW PASS //
////////////////
for  light in AllLights
{
// determine which models are hit by the light
for model in AllModels:
{
  if (collision(light.volume, model.volume)
  {
   light.modelsInView.add(model);
   // give model access to light data, including its shadow map
   model.shadowCasters.add(light);
  }
}
  

// if any models were hit
if (light.modelsInView.Count > 0)
{
			    prepareShadowRender(light);
			   
  // render all models in this light's view to the light's shadowmap
  for model in light.modelsInView
  {
   model.render();  
  
  }
	  
}
}
//////////////////
// FINAL RENDER //
//////////////////

for model in models:
{
   for light in model.shadowCasters:
   {
shaderSetupShadowMap(light)
   }
   model.render();
  
}



Further optimizations can obviously be made, such as caching shadows for stable objects. But I think the general structure is captured here, wouldn't you say?

Any input/feedback would be appreciated.

PARTNERS