Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strange texture behavior

1 view
Skip to first unread message

Wojciech "Spook" Sura

unread,
Nov 20, 2009, 2:53:39 AM11/20/09
to
Hi!

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.


Wolfgang Draxinger

unread,
Nov 20, 2009, 6:48:37 AM11/20/09
to
Wojciech "Spook" Sura wrote:

> 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


fungus

unread,
Nov 20, 2009, 7:29:03 AM11/20/09
to
On Nov 20, 8:53 am, "Wojciech \"Spook\" Sura" <wojciech.sura...@spam-

poczta.medi.com.pl> wrote:
> Hi!
>
> 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.
>

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

0 new messages