Advertisement Jump to content
Sign in to follow this  
StanIAm

Deffered rendering : store all lightsdata

This topic is 1880 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

Hey guys I have a little question to you.I've got my deffered renderer working with support for all lightsources with the local light model and want to to do that more userfriendly. In my postprocessing shader I just have hardcoded light position/color... but now I want to control that from my code.

The question is how can I overgive this informations to the shader with the cbuffers..I mean I could make an array of float3 for position ( for example) but I have no idea in the shader how much lights I have.

 

Is it possible to create an integer in the cbuffer with the num of lights and give the following arrays for position,color...this size ??

 

Something like that:

cbuffer Lights
{
     int m_numLights;
     float3 m_position[m_numLights];
};
Edited by StanIAm

Share this post


Link to post
Share on other sites
Advertisement


Something like that:

cbuffer Lights
{
int m_numLights;
float3 m_position[m_numLights];
};

 

Well you can't have an array of arbitrary size in the cbuffer, based on the m_numLights-variable, but you could always hardcode the size of the array, like

const int MAX_LIGHTS = 256;
cbuffer Lights
{
int m_numLights;
float3 m_position[MAX_LIGHTS];
};

And you just set the m_numLights variable accordingly, and use it for processing the correct amounts of light.

Share this post


Link to post
Share on other sites

For deferred renderer it is common to do it like this - foreach light draw a bounding sphere/bounding screen-aligned quad/bounding cone (it depends on type of light and your preference), send info to shader about your light (position, color etc.) and blend it.

Share this post


Link to post
Share on other sites

For deferred renderer it is common to do it like this - foreach light draw a bounding sphere/bounding screen-aligned quad/bounding cone (it depends on type of light and your preference), send info to shader about your light (position, color etc.) and blend it.

Exactly; this mean that you'll be only be doing lighting calculations for the pixels affected by each light.

Share this post


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

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!