Blended textures and the evil outlines.

Started by
10 comments, last by Xero-X2 21 years, 5 months ago
I was messing with some stuff and I tested the following things, 1. I made a background 2. I made a forground. 3. I made a routine to create a RGBA texture by replaceing the mask color so then I ran it well most of it is gone but the very edge is still visible at about 50% alpha but the whole idea was to have either 1 or 0 not .5! It also outlines the very edge of the texture for some odd reason so I have the transparent area outlined by bright purple lines, I whanted to see if it was the image so I made it change the transparent areas to black and suddently the outlines where black.. why do I have these outlines I tried it with both GL_NEAREST and GL_LINEAR filtering here are all of my opengl state changes no other changes exist. opengl setup { glClearColor (0.0f, 0.0f, 0.0f, 0.5f); glEnable(GL_TEXTURE_2D); glShadeModel(GL_FLAT); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Create Textues } per Frame setup { glClear(GL_COLOR_BUFFER_BIT); glLoadIdentity(); glEnable(GL_BLEND); glColor4f(1,1,1,1); //draw background plane //draw foreground plane /swap buffers } thanks
"I seek knowledge and to help those who also seek it"
Advertisement
hi!
i think i have a similar problem with blending..

i am using blending to draw some particles:

here is my result with glDisable(GL_DEPTH_TEST);
http://hosting.xlnet.net/internet/uniqwas/good.jpg

here is my result with glEnable(GL_DEPTH_TEST);
http://hosting.xlnet.net/internet/uniqwas/bad.jpg

does anybody know how i get the same "cool" looking particles, but still have the DEPTH_TEST enable?

nope, thats not the same what you need is glDepthMask(0); use that when you draw your particals use it with depth test on then just use glDepthMask(1); and finish drawing for what ever.

That allows you to stop writing to the depth buffer when you draw shapes, which allows you particals to blend together correctly. this allows them to be behind a car under the floor and such without being seen throught it.
"I seek knowledge and to help those who also seek it"
Ok I came up with a picture that will show you exactly what is going on.

here It is
"I seek knowledge and to help those who also seek it"
first of all, its not happening during your rendering routine.
its happening during texture generation, so post some of your
texture generation code so we can see what you''re doing.


-eldee
;another space monkey;
[ Forced Evolution Studios ]

::evolve::

''In C we had to code our own bugs. In C++ we can inherit them.''

-eldee;another space monkey;[ Forced Evolution Studios ]
big big thx !!!

that is the solution
ok here you are my texture generation function

INT2d CreateTexture(UINT *textureArray, LPSTR strFileName, int Filter){INT2d me;me.x=0; me.y=0; //Return Varible	AUX_RGBImageRec *pBitmap = NULL;	if(!strFileName)		return me;        // Load	pBitmap = auxDIBImageLoad(strFileName);	if(pBitmap == NULL)                return me;                          // Make new copy of image with 4 BPP        GLubyte *data; //create pointer to memory        data = new GLubyte[pBitmap->sizeX*pBitmap->sizeY*4]; // Bitmap is x*y*4 bits/pixel        for (int c=0; csizeX*pBitmap->sizeY ;c++)        {        // Copy color data unchanged        data[c*4]=pBitmap->data[c*3];        data[(c*4) +1]=pBitmap->data[(c*3) +1];        data[(c*4) +2]=pBitmap->data[(c*3) +2];        // Determine alpha        if (data[c*4]==255&&data[c*4+1]==0&&data[c*4+2]==255)        data[(c*4)+3]=0;   // If its not Visible        else        data[(c*4)+3]=255; //if it is visible        }	glGenTextures(1, textureArray);	glPixelStorei (GL_UNPACK_ALIGNMENT, 1);	glBindTexture(GL_TEXTURE_2D, *textureArray);        gluBuild2DMipmaps(GL_TEXTURE_2D, 4, pBitmap->sizeX, pBitmap->sizeY, GL_RGBA, GL_UNSIGNED_BYTE, data);        //Save Sizeof Image        me.x=pBitmap->sizeX; me.y=pBitmap->sizeY;        //Set filters	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,Filter );	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,Filter );        //Clean memory	if (pBitmap)	{		if (pBitmap->data)                free(pBitmap->data);        free(pBitmap);	}        //Return Size        return me;}  



FIX: I accedently added a rouge ' into the code

[edited by - Xero-X2 on October 20, 2002 1:37:08 PM]
"I seek knowledge and to help those who also seek it"
i''m almost positive it''s going to be the fault of mipmapping...
try doing a normal glTexImage2D() and see if that changes things.
also, use GL_NEAREST as your min and mag filters.. that should
fix it.. im pretty sure that when GL creates the mipmapped textures
it does a little blending of its own (which would blur the lines
around your sprite, thus creating your ''halo'')

-eldee
;another space monkey;
[ Forced Evolution Studios ]

::evolve::

''In C we had to code our own bugs. In C++ we can inherit them.''

-eldee;another space monkey;[ Forced Evolution Studios ]
Another thing that may or may not be relevant: When you create your image in photoshop, I hope the anti-aliasing settings are OFF, otherwise you''ll be blending your image with that pink background...

2DNow - Specializing in yesterday''s technology today!
It was Glu build Mips it was bluring the purple into the near pixels when resizing the images to powers of two. I found a solution I am just going to make the transparent pixels equal the average of the VISIBLE pixels next to it that way it isn''t black and it isn''t puple. thanks for helping me figure out what the problem was.
"I seek knowledge and to help those who also seek it"

This topic is closed to new replies.

Advertisement