Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Scene Lighting : Passing structs of arrays of structs via cbuffer


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Chris_J_H   Members   -  Reputation: 256

Like
0Likes
Like

Posted 05 April 2013 - 08:39 AM

Hi, I have a variable number of spotlights in my scene and would like to pass in all my lighting info via a single cbuffer update. Ideally something that would look like this:

 

// hlsl --------------------------------------------------

struct DirectionalLight
{
    float4         ambient;
    //...
};

struct SpotLight
{
    float3        pos;
    //...
};

 

cbuffer LightingBuffer            : register (b0)
{
    DirectionalLight   gDirectionalLight;

    SpotLight           gSpotLight[4];
    int                     gNumActiveSpotLights;
};

 

// c++ -----------------------------------------------------

struct DirectionalLight
{
    XMFLOAT4         ambient;
    //...
};

struct SpotLight
{
    XMFLOAT3        pos;
    //...
};

 

struct LightingBuffer

{

   DirectionalLight    directionalLight;

   SpotLight            spotLight[4];

   int                      gNumActiveSpotLights;

};

 

Does the system tolerate the nested structs and struct arrays? - if so, could you give me guidelines to ensure that the packing will match? (4 is the maximum number of active spotLights allowed). Is there a better way of doing this? Thanks.



Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS