#### Archived

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

# 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.

## 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 on other sites
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 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 on other sites
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 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 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

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632631
• Total Posts
3007532
• ### Who's Online (See full list)

There are no registered users currently online

×