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

blending

Started by trager Jun 7, 2004 at 6:07 AM 4 replies 1.9k views
Original Post
trager
trager
I''m looking for a blending technique which blends dark colours, not nessecarily black, more than light colours. Does anyone here know how to do this? Thanks
Krohm
Krohm
No, unless you tell me how you compute your alpha.
Well, in fact I have an idea which is to use ping-pong rendering and fragment programs but it''s quite unfocused and it won''t be too fast.
Previously "Krohm"
Enigma
Enigma
What do you mean by 'blends dark colours more than light colours'? Do mean so that if you blend a dark colour over a light colour you will get a dark colour and if you blend a light colour over a dark colour you will also get a dark colour? If so then try:
glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_SRC_COLOR)  

or
glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_DST_COLOR)  

Note that these both require the GL_NV_blend_square extension. I thought there was another extension that also supported these blending modes, but I can't find it at the moment.

Enigma

EDIT: Typo

[edited by - Enigma on June 8, 2004 11:48:59 AM]
Enigma
Enigma
Ah, OK. In that case you probably want the complete opposite of what I suggested:
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) 

or
glBlendFunc(GL_SRC_COLOR, GL_DST_COLOR) 


May I ask why you''re using GL_SRC_ALPHA as your destination blend factor? Does your image have an alpha channel? If not then it''s probably the same as using GL_ONE, and probably slower.

Enigma
trager
trager
Thanks Enigma

glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) yeilds exactly the results I was orignaly after.

The only issue is that for this particular application I prefer the results I got from GL_SRC_COLOR, GL_SRC_ALPHA. The blend is being used on a sprite of a star so the brightness you get with this method is a nice touch.

Again thanks for the tip that it will run quicker with GL_SRC_COLOR, GL_ONE there is no alpha channel so I have changed that line.

I was only using GL_SRC_COLOR, GL_SRC_ALPHA because despite how many times I read the red book I dont understand the mathematics behind blending and I just experimented with values until I found something suitable. Perhaps I should look into blending a bit more.

Again thanks

Trager

Topic Locked

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

Sign in to reply to this topic.