Archived

This topic is now archived and is closed to further replies.

Do00d

Help with blending 2 objects and not have one shine through the other

Recommended Posts

Do00d    122
well ive been doing some stuff with opengl for some time now noting really special considering im also new to c++ but ye ive finnaly got around to making a game where blending will be a bit of a problem im making a top down shooter, editor first, and well later on ill need this anyway, but my objects seem to love to shine through one-another when they intersect however if i disable blending then i get the black square that remains around the image im using bmps still and i was wondering if u can do proper blending so that one object can be drawn over another without the one behind it shining through it ive taken a look at tut #33 and ive come to the conculsion that either i need to use tga's coz of the alpha channel or im doing something wrong oh yes and this is all done in ortho view so i cant do much with sorting... or can I? any ideas any help would be greatly appreciated Edited by - Do00d on July 1, 2001 3:32:34 AM

Share this post


Link to post
Share on other sites
Wavarian    850
Not sure if this is what you wanted but anyways..

try:

glEnable(GL_BLEND);
glDepthMask(0);

Draw_transparent_object_1

glDepthMask(1);
glDisable(GL_BLEND);

glEnable(GL_BLEND);
glDepthMask(0);

Draw_transparent_object_2

glDepthMask(1);
glDisable(GL_BLEND);


"You are just as irritating to me as an irrational term that accidentially creeps into your equation and cannot be factorized out."

Share this post


Link to post
Share on other sites
Do00d    122
thanx for ure help but it didnt work
what i need is this
i have a lil space ship somewhere on my screen
now to get the object to blend into the scene i need to do some blending otherwise ull see the blackoutline of the poly
now if i had a black background and just simply added polys to it witout any of em ever going over each other then its all fine
but if i were to have a background image then the lil ship gets birghter as it is totally blended in with the scene
and if 2 olys go over one-another then they both shine
anwyasy ive looked at tutorial 33 and that seems to have the solution except it doesnt use bmp files and im inclined to believe that the alpha mask of the targa files are whats making the object not blend with the rest of the image
as even if i delete wats in the image, for examplke i turn the whole font image to white the program can still show the text
anyways ye is there a way to do proper blending with the bmp format?

Share this post


Link to post
Share on other sites
mckracken    122
Hello... May be you have to draw the polys in order from farest to nearest... Have you tried to order all the polys in Z before you draw them?? May be that''s the problem...

C u soon..

Share this post


Link to post
Share on other sites
Do00d    122
hehe
yes i have seen lesson 20 and well im wondering is there another way?
but ye if noone knows ill go either with targas or with masking

and well as for the order of the way i draw
well thats useless as this is done in ortho, no z axis
hehehe
so i take it masking is the way to go unless i want another image type

but also what makes me wonder is that ive seen a similar game done in VB using directdraw i think and well they use gifs and jpeg images and no masks
what happens is the objects do tend to intersect with each other yet they dont shine, or blend, together
so is it a feature of directdraw that lets em blend in the image with the scene and make it fully opauqe yet leave the, pink around the image,dunno why that color, out
anyone know?

Share this post


Link to post
Share on other sites
Wavarian    850
Whoa, hang on.. you mean to say that you''re not masking nor making use of alpha values? You can''t leave out certain colours of an image just by enabling ogl blending, because obviously this blends the whole object. You either need to mask, use alpha values, or create your own function to leave out certain colour values in a texture just before loading them.

As some advice, try the use of targa files first.

"You are just as irritating to me as an irrational term that accidentially creeps into your equation and cannot be factorized out."

Share this post


Link to post
Share on other sites
Do00d    122
hehe
ye ive read up some stuff
and it seems that ill have to go with masking or targa
with targa being better
but what still intrigues me is the directdraw vb sample
which uses gifs for gfx
anyways thanx guys
its back to coding for me

Share this post


Link to post
Share on other sites