general question - greying out RGB textures?

Member
Posts: 321
Joined: 2004.10
Post: #1
I've got a game with colored units (textures mapped into
rectangles) which move one a game board. The user selects
them with a mouse and moves it to a new game square.

I want to create an effect where the moving unit is greyed out
over the game board squares (and maybe even fades out the
its movement points are expended.

Can anybody suggest a very general approach to such an
effect? I'd like to avoid creating another texture map for
each unit as there are quite alot of these guys.

Thannk!
Quote this message in a reply
Simon Schoelly
Unregistered
 
Post: #2
hope this is correct:
Code:
glTextureEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTextureEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB); /* or GL_DOT3RGBA if you want to use color and alpha values for the calculation */
/* the next two lines are not in every case necesary */
glTextureEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTextureEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
Then you can use glColor4f to set how much of every color channel should be used in the calcuation and to set the brightnes of your texture.

source: the red book p. 438
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #3
Define "grey out"... do you mean lowering the contrast of the image towards neutral grey? If so you can do this just by mixing the texture with 0x7f7f7fff with texture_combine.

If you mean converting the RGB texture into a luminance value ("Grayscale" in Photoshop), then you either need a fragment program or another texture. If you keep the client copy of the texture data then you can reupload it as a luminance texture, fiddling with the glPixelTransfer RGB scale to get a balanced grayscale image. Of course this is slow and eats more texture ram.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  General Questions About Old Or Limited Graphics Cards Oddity007 5 4,019 Mar 3, 2009 01:39 AM
Last Post: arekkusu
  Quick question, will glCopyTexSubImage2D with with RECT textures? TomorrowPlusX 28 9,040 Jun 8, 2006 07:04 PM
Last Post: akb825
  Question about how textures are applied to quads which are scaled unevenly TomorrowPlusX 9 3,940 Feb 9, 2006 12:12 PM
Last Post: Chris Ball
  General Texture Question.... WhatMeWorry 5 4,137 Aug 5, 2005 09:38 PM
Last Post: WhatMeWorry
  A general OpenGL Newbie question dmbyer 1 2,691 Oct 6, 2002 03:13 PM
Last Post: henryj