Copy data from RGBA texture to luminance

vinartrulz

Newcomer
hello..

I have a 128 X 256 RGBA texture, which is the o/p of an algorithm. I want to copy these 128 X 256 X 4 values to a single channel texture of size 512 X 256. I tried glTexSubImage2D but it skips three channels and copies single channel to the first 128 entries of my destination texture. This is not the behavior i want. Please suggest a solution.
Thanks in advance
 
Do you mean you want a single grayscale channel as output?


[edit] If that is what you are wanting to do then as Colourless has already said, use a shader to do the conversion. A formula along the lines of
Y = 0.299*R + 0.587*G + 0.114*B

There are all kinds of different factors you can take into account doing this conversion (different standards, different input/output ranges) but this should get you off the ground.


CC
 
Given that his dest texture is 4x the width of original texture he seams to want just a "type cast".

Why would you need that though?
 
thanks for the replies..
I need a typecast like operation.
I am doing some morphological operations on 8 bit luminance volume data. For optimization purpose i pack 4 luminance value in to one RGBA texture. After i have finished different levels of shader operation currently i have the result in an RGBA texture. Now i need to unpack it to single channel luminance texture for display purpose.
 
Read the texture and write to an L8/R8 buffer of the appropriate size. You'll have to figure out which component to write per pixel, but by using the screen coords that shouldn't be too hard.
 
Back
Top