Jump to content
  • Advertisement

Archived

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

trager

blending

This topic is 5219 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I meant that black would be completely transparent and white would be completely solid and the transparency of colours in between would depend on the brightness of the colour.

I''m now using GL_SRC_COLOR, GL_SRC_ALPHA it is very close to what I want but not perfect.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!