PDA

View Full Version : How to texture a RGB image in grayscale?



Klynn
12-08-2003, 01:20 PM
I've been using OpenGL for a couple of weeks now (e.g. I'm a newbie) and I was trying to figure out how to display a texture in black & white, using luminescence values (G=59%, R=30%, B=11%). After some searching, I've discovered I could use either the ARB_fragment_shader or NV_fragment_shader extensions along with a simple fragment-program example to try out. However, I didn't get very far.

First, I can't seem to find a video card that supports these features. I have some old ATI cards and some relatively new nVidia cards but they only support vertex_shader programs and not fragment_shader ones. Does anyone know which versions of either ATI or nVidia cards began supporting the fragment shaders in GPU? I have a GeForce4 MX420 sitting here and was surprised it's not supported on that, as I thought that was a relatively new card.

Second, my target is more for compatibility and was wondering what the most efficient way is to grayscale an existing texture on the screen without a fragment shader present, with the mindset of using large 256x256 RGBA textures. Even a simple RGB average would be great (as opposed to luminescence)!

Third, assuming I have no access to a fragment shader... If I wanted to perform color blending on top of a RGBA texture, such as overlay a 50% Solid Color over only the visible (Alpha > 0.0) parts of the texture, is there an easy way to perform this without having to send two separate textures to the video card?

Thanks!!

AdrianD
12-08-2003, 01:46 PM
conversion RGB->grayscale

c1 = color RGB
c2 = (0.3,0.59,0.11)

grayscale = dot(c1,c2)

you can do it without fp's. ARB_texture_env_combine can do this job as well.

Klynn
12-09-2003, 01:10 PM
Thanks for your help!