• Advertisement
Sign in to follow this  

Best practice for storing more complex data in textures

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

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.

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


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

  • Advertisement