Tomas Moller (tompa++at++clarus.se)
Mon, 25 Mar 1996 12:12:35 +0100
I have been trying to do the following for a time now without much success:
First I am drawing some primitives in one color in a pfChannel (128x128
pixels),
then I want to use this image as a texture map for a rectangle.
I want the texture map to be an intensity-alpha-map and I want bilinear
interpolation since the resolution of the texture is small.
So I have tried a few ways of doing this:
1) My first approach was to read the framebuffer with GL and then
download the texture into the texture memory. I downloaded the pfTexture
with
tex->setImage(texturemap,2,texturesize,texturesize,1);
This worked, but when I turned on multisampling, bilinear interpolation
disappears. Also, when drawing the primitives in certain colors
the texture disappears when multisampling is on, while the texture looked
fine with multisampling off.
To sum up, it worked as I wanted to when multisampling was off, but
with multisampling enabled nothing worked as expected.
Any ideas of what I am doing wrong or why I get different results?
Since this was a bit slow, I tried another approach.
2) I set up my pfTexture with:
tex->setFormat(PFTEX_INTERNAL_FORMAT,PFTEX_IA_8);
tex->setFormat(PFTEX_SUBLOAD_FORMAT,1);
tex->setLoadImage(texturemap);
tex->setLoadMode(PFTEX_LOAD_SOURCE,PFTEX_SOURCE_IMAGE);
After reading the framebuffer with the one-colored primitives, I called
tex->load() in order to load the new texture into the frambuffer.
This was a bit faster, but still generated the same erraneous results as
above.
3) So I abandoned GL and tried to use only Performer routines.
My pfTexEnv is set to:
tev->setComponent(PFTE_IA_GETS_RG);
in order to use the red and green components as intensity and alpha.
And then I tried reading the framebuffer directly into the texture memory
with:
tex->setFormat(PFTEX_INTERNAL_FORMAT,PFTEX_IA_8);
tex->setFormat(PFTEX_SUBLOAD_FORMAT,1);
tex->setLoadImage(texturemap);
tex->setLoadMode(PFTEX_LOAD_SOURCE,PFTEX_SOURCE_FRAMEBUFFER);
and using tex->load(); when the primitives had been rendered into the
framebuffer to load the texture into the texture memory.
This gave the correct shape of the texture but with wrong intensity
and alpha. I looped through the different combinations of Intensity and
Alpha
and I did not see any correlation between the IA on the primitives and
on the texturemap. Also when turning on multisampling I get even more
weird results: sometimes bilinear interpolation seems to be on, but it
generates wrong results. For instance when it should interpolate from a grey
value to a black, it interpolates to white in some areas.
I believe that the last approach should be the best one concerning performance,
and I really hope that someone can help me with this problem.
Thanks!
/Tomas
Bilinear interpolation disappears when multisampling.
--
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:34 PDT