PDA

View Full Version : Texture swizzle in sampler?



Groovounet
03-26-2010, 07:05 AM
This isn't possible in OpenGL 3.3:
glSamplerParameteri(Sampler, GL_TEXTURE_SWIZZLE_R, GL_ONE);
glSamplerParameteri(Sampler, GL_TEXTURE_SWIZZLE_G, GL_ONE);
glSamplerParameteri(Sampler, GL_TEXTURE_SWIZZLE_B, GL_ONE);
glSamplerParameteri(Sampler, GL_TEXTURE_SWIZZLE_A, GL_RED);

I thought it was at first but I made a mistake.
Question: why not?

Imagine, I'm going nut! I decide to interleave 2 kind of data in 1 texture, like diffuse color (RGB) and specular map (A) or normalmap (RGB) and heightmap (A). It could be something completely different but following the same idea.

I could use 2 samplers to read both kind of data and interpret these data with different ways using texture swizzle.

I might be completely inefficient, limited by the hardware or actually useless. Let me know what you think!

sqrt[-1]
03-26-2010, 08:19 AM
Not sure if it is a hardware limitation or not - on the consoles from ATi and Nvidia the texture swizzles are associated with the texture itself. (and not a sampler state)

However, on consoles you are free to create as many textures as you want that point to the same memory - so in a way you can do this.

Groovounet
04-19-2010, 12:07 PM
In other word:
http://www.opengl.org/registry/specs/EXT/shader_image_load_store.txt

Even if actually this extension also let you write!