Jump to content

  • Log In with Google      Sign In   
  • Create Account

Best practice for storing more complex data in textures


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
1 reply to this topic

#1 Wh0p   Members   -  Reputation: 340

Like
0Likes
Like

Posted 30 November 2013 - 03:54 PM

Hi,

I am simply looking for some best practices on how to store more complex data types in textures and how to access them in glsl.

For example if I would want to store parameters for pointlights I might have a struct like this:

struct PointLight
{
  vec3 Ambient;
  vec3 Diffuse;
  vec3 Specular;
  vec3 Position;
  float Radius;
};

Obviously texture access via samplers only allow me to retrieve vec4's at a time.

Basically I'm most interested in how you efficiently setup the layout of the texture (or textures). Thing like use a single texture for each component or pack them together or how to pack the components together, what kind of textures to use etc.

 

I dont want specific answers to THIS example struct.. I am looking for a general truth smile.png

Like do things that change often (maybe the positions) in a seperat texture while compose the other components together in one texture. (just an assumption however)

 

I hope you can give me a direction here,

Wh0p.



Sponsor:

#2 Samith   Members   -  Reputation: 2326

Like
0Likes
Like

Posted 30 November 2013 - 04:02 PM

This is highly, highly dependent on what exactly you want to store in the texture, how much data there's going to be total and its access patterns (ie, is it small enough and accessed linearly, could it be put in a constant buffer more efficiently?) how much precision you want in the data, whether texture compression is going to be acceptable (and if so, what kinds of texture compression work best for your specific data), whether you want to take advantage of hardware filtering on reads, etc.

 

EDIT: Also, if you're interested in having complicated structs inside textures where texture filtering and compression aren't necessary (or even wanted), you might look into using texture buffers.


Edited by Samith, 30 November 2013 - 04:21 PM.





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