Re: Performer & color_matrix_SGI

New Message Reply Date view Thread view Subject view Author view

Ran Yakir (rany++at++rtset.co.il)
Wed, 29 Jan 1997 13:49:25 +0000


On Jan 29, 2:00pm, Harri Kaimio wrote:
> Subject: Performer & color_matrix_SGI

> I am working on a project in which I need to change the color saturation
> (perhaps also hue) of part of the scene graph over time. The way I have
> planned to do it is by using the color matrix OpenGL extension. My
> source code looks like this:
>
>
> int
> bwPreDraw( pfTraverser * )
> {
> // draw callback to turn on color matrix stuff
> float colorMat[16];
>
> // set up the color matrix
> ...
>
> // Store current matrix mode
> int mmode[1];
> glGetIntegerv( GL_MATRIX_MODE, mmode );
>
> glMatrixMode( GL_COLOR );
> glLoadMatrixf( colorMat );
> glMatrixMode( mmode[0] );
> return PFTRAV_CONT;
> }
>
> int
> bwPostDraw( pfTraverser * )
> {
> // Turn off color matrixes
> int mmode[1];
> glGetIntegerv( GL_MATRIX_MODE, mmode );
> glMatrixMode( GL_COLOR );
>
> glLoadIdentity();
> glMatrixMode( mmode[0] );
> return PFTRAV_CONT;
> }
>
> ...
>
> // Set color matrix callbacks for a node
> node->setTravFuncs( PFTRAV_DRAW, bwPreDraw, bwPostDraw )
>
> ...
>
> OK, this kind of works - I can specify different color matrix for
> different nodes and the results look correct, BUT I CANNOT ANIMATE THE
> COLOR MATRIXES. If I change the color matrix used for a certain object
> between frames, it makes no visible difference in the rendered picture -
> it is always rendered using the color matrices specified in the first
> frame of simulation. I have checked that my callbacks are really called
> and correct color matrixes have been loaded for each frame.

Color matrix is not applied to glColor as it is sent to the pipe. Also, it is
not applied to texture fragements after the filtering. It is only applied to
texture pixels, as they are being loaded to the texture memory, using
glTexImage, glCopyTexSubImage, etc, and to pixels drawn with glDrawPixels and
glCopyPixels.

In your case, when you draw the frame for the first time, the textures are
being loaded when they are first applied, so they are transformed by the color
matrix.

To do realtime modifications of colors you have several choices :

1. Use a pfColortable, that will allow you to change the vertex colors on the
fly. On iR, it will propobaly hurt your performance.

2. Use the GL_POST_TEXTURE_FILTER_SCALE_SGIX and
GL_POST_TEXTURE_FILTER_BIAS_SGIX texture parameters. Those allow you to set a
scale and bias for texture fragements after filtering. You will have to call
them in the GeoState callback functions, after the texture is bound
(glBindTextureEXT).

Ran

-- 
 __                                  | Ran Yakir
 /_)  _  __   \  / _   / o __        | RT-SET Ltd.
/ )_ (_(_) )   \/ (_(_/<_(_)(        | 
              _/                     |   
-------------------------------------+--------------------------------
Phone :                              | E-mail : rany++at++rtset.co.il
  Work : 972-9-9552236               |          rany++at++netvision.net.il
  Res. : 972-9-7489974               |
Fax    : 972-9-9552239               |
=======================================================================
List Archives, FAQ, FTP:  http://www.sgi.com/Technology/Performer/
            Submissions:  info-performer++at++sgi.com
        Admin. requests:  info-performer-request++at++sgi.com

New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:54:29 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.