uploading textures with only certain components using glTexImage2D

Started by
12 comments, last by Majestik_666 17 years, 1 month ago
well it does and it does not ...
let's say i have an image with Red and Blue Channel
and a fragment shader doing :
R = R + G;
B = R + B;
B = B;

with this shader I just cannot swap channels etc ...

my main concern is that i don't "choose" the shaders, they're user
provided, so my texture should reflect exactly the data provided from
the main memory ...

hope it makes sense :)
Advertisement
just reviving this thread ...
anyone has any idea about this problem ?

Thanks a lot !
OK, first of all:
Quote:
I think you are answering your own question. Keep it in one format in system memory, and another in video memory. Just simply fill in the missing components when uploading to the card.

Do NOT do this. Every GPU since the Voodoo has native support for single channel texture formats, and will not expand these to RGBA. And only really old cards will expand dual channel formats to RGBA (GeForce2, and similar). From the GF 7x00 series onwards, RGB24 tri-channel formats are not expanded to 32bit anymore, since those GPUs can access 24bit aligned data internally.

My suggestions:

* For single channel formats, use the luminance8 format
* For dual channel formats, the luminance8-alpha8 format is ideal
* For three component formats, RGB8 will not be expanded to RGBA8 on anything equal or above the NV44.

You can easily use simple component swizzling in a pixel shader (basically this operation is free) to get the channels back into the correct order.

For very specific purposes, Nvidia created a few new compressed high precision bi-component formats on the GF 8800 series (eg. GL_COMPRESSED_RED_GREEN_RGTC2_EXT), which are specifically designed for two-component normal map representation.
thx Yann,
that was my first idea , I guess i'll just have to make some small common code
to use in the shaders to get the correct channels.

This topic is closed to new replies.

Advertisement