#Sampler2D in GLSL struct?

9 messages · Page 1 of 1 (latest)

strange raptor
#

Is it best practice to keep sampler types inside or outside of GLSL structs? I have read online that some drivers might have issues with this but all posts were fairly old. Is this something worth taking into account now a days?
Thank you!

terse vector
#

I have always kept them outside. Texture and buffer bindings are descriptor / bind group like stuff, so they are different from other stuff

#

I would reorder members to match the layout rules - groups of 4 components, so vec3 should always start at multiple of 4 components, and be followed by one component, dummy padding if nothing else exists.

strange raptor
#

by dummy padding do you mean like a fundamental type that's never called?

terse vector
#

vec3 cameraPosition; float dummy;

strange raptor
#

perfect, thank you for the advice! Its great to know

terse vector
#

Note that using sampler array consumes multiple texture units. You could use array texture instead - that way it consumes only one texture unit.

strange raptor
#

Great to know as well, I did not know about array textures.

runic vortex
#

you can only put them in structs if your structs are part of a regular uniform. you cannot use structs containing opaque types in buffer backed interface blocks unless you are using bindless, which I'm assuming you probably aren't