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.


forward rendering idea


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
2 replies to this topic

#1 he3117   Members   -  Reputation: 374

Like
0Likes
Like

Posted 12 February 2013 - 01:17 AM

Hi

I want to start writing forward rendering pipeline for my deferred engine and I'm looking for efficient way to pass light information to shader.

I have an idea about it.I don't want to pass light info as constant or array so I'm thinking about sending them as textures.

for point lights I need:

 

struct PointLight

{

   COLOR LightColor;

   Vector3 LightPosition;

   float LightRadius;

}

 

It seems I can store this structure in 2 pixel of a texture:

RGB=LightColor;

alpha=LightRadius;

 

RGB=xyz of light position

 

struct SpotLight

{

   COLOR LightColor;

   Vector3 LightPosition;

   float LightRadius;

   float CosAngel;

}

RGB=LightColor;

alpha=LightRadius;

 

RGB=xyz of light position

alpha=CosAngel;

 

so with a texture 128*2 I can pass 128 point light to the shader.

But what is the best way to fill this texture?Should I make a vertex buffer with light info and pass it to a shader to writing in texture or use LockRect and fill the texture on CPU?

 

also I can pack all light info in one texture and use another texture to pass ligh Ids to shader



Sponsor:

#2 Schrompf   Prime Members   -  Reputation: 954

Like
1Likes
Like

Posted 13 February 2013 - 10:19 AM

Try standard passing by constant registers first. Textures can store a lot more data than constant registers, but access to textures is pretty slow, and updating them is even slower. In contrast: reading from constant registers is "free" by nearly any measurement, and updating constant registers is quite cheap in my experience. And with 4096 x float4 constant registers you can still store a lot of lights.


----------
Gonna try that "Indie" stuff I keep hearing about. Let's start with Splatter.

#3 Jason Z   Crossbones+   -  Reputation: 5282

Like
0Likes
Like

Posted 13 February 2013 - 12:58 PM

Try standard passing by constant registers first. Textures can store a lot more data than constant registers, but access to textures is pretty slow, and updating them is even slower. In contrast: reading from constant registers is "free" by nearly any measurement, and updating constant registers is quite cheap in my experience. And with 4096 x float4 constant registers you can still store a lot of lights.

 

I completely agree with this - you could try using a texture as an experiment, but you are nearly certain to switch back to using constants afterwards...






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