Blending texture edges
Hello all,
A situation has arisen where I wish to add an effect to my game engine.
It's a 2D sprite engine which uses OpenGL as the workhorse.
Currently what I'm doing at texture-loading time is:
- load PNGs using SDL_Image (IMG_Load) into an SDL_Surface
- iterate pixel by pixel through the SDL surface to add alpha=0 to color-keyed pixels, or alpha=255 for opaque pixels
- load this into an OpenGL texture as a 32 bit RGBA texture
What I want to try doing is giving 50% alpha to pixels which border both opaque and transparent pixels. I figure this will give a smooth look to the game engine, but who knows, it might totally suck, I just want to see what the end result will look like. :)
Immediately I thought of performing a 2nd pass in the loading code, check surrounding pixels, and setting alpha that way. But to render textured polys with the desired effect, what renderstates do I need to set?
Right now I use these to discard colorkeyed pixels:
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_NOTEQUAL, 0.0f);
Do I additionally need to add this to render pixels based on values contained in the alpha channel?
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
Thanks in advance,
- m³
umm i'm not sure i have understanded what you want to do but...
Tga and PNG format got an option to add a channel
and so they wont show anything in that channel
take a look at nehe lesson 32
hope i helped
mc
Tga and PNG format got an option to add a channel
and so they wont show anything in that channel
take a look at nehe lesson 32
hope i helped
mc
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement