I use a texture as a palette, used in turn by a fragment shader. The texture
is generated procedurally as 256x1 bitmap. The wrap parameter is set to
clamp - both on U and V axis. Strangely, when texture coordinates' reaches
0.0 or 1.0 on the U axis, color becomes way darker than it is originally on
the texture.
I've done a small test: changed all colors in a palette texture to white and
textured a square - you can see results at
www.spook.freshsite.pl/Temporary/texwtf.png . Why exteriors of center square
are darker than interior? Why clamping is done inconsistently on the U and V
axis?
Best regards -- Spook.
> I've done a small test: changed all colors in a palette texture to white
> and textured a square - you can see results at
> www.spook.freshsite.pl/Temporary/texwtf.png . Why exteriors of center
> square are darker than interior? Why clamping is done inconsistently on
> the U and V axis?
I suspect you specified a texture border (at least as glTexImage parameter).
Since a 1D texture has borders in only the U direction, one sees the border
only there.
Try setting the border width to 0
Also remember, that the texture texels matching coordinates go from
0.5/width ... width / (width + 1/width)
Wolfgang
Not strange, OpenGL clamping will sample 50% texture and
50% border color at when a coordinate goes outside the
range 0 to 1;
To fix this, use GL_CLAMP_TO_EDGE instead of GL_CLAMP.
See: http://www.opengl.org/registry/specs/SGIS/texture_edge_clamp.txt
nb. That page is out of date, the extension is
now EXT_texture_edge_clamp and the value is
GL_CLAMP_TO_EDGE
--
<\___/>
/ O O \
\_____/ FTB.
http://www.topaz3d.com/ - New 3D editor for real time simulation