Skip to main content
GameDev.net gamedev.net
🔒 Locked

an alpha Q

Started by AndyIC3 Feb 24, 2005 at 5:50 PM 2 replies 800+ views
Original Post
AndyIC3
AndyIC3
I know you're supposed to render all your opaque triangles, then do your blended triangles back to front. i'm working on a height map based demo/minigame that has a height map, then "water" that is just a single giant quad with an alpha blended texture. Because this quad is so large, and is the size of the whole map, when should i draw it, before or after? i'm having a hard time getting it to blend for some reason. have been reading tutorials and books and experimenting with no success. how do i post source code on here? maybe someone can take a look
JohnBolton
JohnBolton
You are doing it the right way. Draw all the opaque geometry (the terrain), and then draw all the alpha-blended triangles (the single water quad) back to front. The size of the quad is not important.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
AndyIC3
AndyIC3
Well, here's a strange thing... when i draw the water before the terrain, i can see it, but when i render it after the terrain, it doesnt show at all. any ideas?

also, what should i be using for my blend func? here's what i'm using to set up blending:

glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable( GL_BLEND );

[edit] although it shows when i draw it before the terrain, it is not blended (or it is blended with the clear color.. i can't relaly tell [/edit]
AndyIC3
AndyIC3
i got it!

here's what i did (basically)

init RC with blending off

game loop
{
draw map
turn on & set blending settings
draw water
turn off blending
}

before, i was trying to set all the blending settings when i set up the RC. hope this helps someone

-andy

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.