• Advertisement
Sign in to follow this  

Different blending functions for different active texture in multitexturing?

This topic is 3473 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 need to render hologram style transparencies with additive blending, i.e. glBlendFunc(GL_SRC_ALPHA, GL_ONE), that are overlayed with regular type blended logos, glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); How do I multitexture so that the base texture uses the first blending type and the overlaying logo texture uses the second? I realize that I can draw the object twice, but the performance hit is too great in my application. There's got to be some way to do this, maybe in GLSL or something, to get the right effect.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
How do I multitexture so that the base texture uses the first blending type and the overlaying logo texture uses the second?


It's not possible. Graphics cards are not able to do that.

Share this post


Link to post
Share on other sites
Quote:
Original post by trippytarka
You can perform your own blending math in the pixel shader...

As soon as the framebuffer is involved, you can't. Unless you want to ping-pong around like mad. Which is extremely slow.

Share this post


Link to post
Share on other sites
Quote:
Original post by Yann L
Quote:
Original post by trippytarka
You can perform your own blending math in the pixel shader...

As soon as the framebuffer is involved, you can't. Unless you want to ping-pong around like mad. Which is extremely slow.


Maybe I've missed something, but I thought you could access the colours of each texture and set the final pixel colour using any maths you like...

Share this post


Link to post
Share on other sites
Huh? glBlendFunc etc. refers to blending between overlapping transparent objects. This has nothing to do with blending textures. Graphics cards do the blending outside of shaders, since it depends on a calculation involving data read back from a framebuffer to which the card is still in the process of writing.

Share this post


Link to post
Share on other sites
Yeah, you're right, I was thinking it would be possible to combine the textures in the pixel shader in such a way to allow using just one blending state, but I'm very wrong... Should have thought harder before I spoke.

Share this post


Link to post
Share on other sites
Typically, the easiest way to handle textures independently( as I am a simpleton) is to put them on independent meshes (e.g. one model made of multiple meshes). That may help produce the effect you need without unnecessary multitexturing, but perhaps this is not suitable for you application(e.g. the modeller in you workflow, if there is one, can't make multi-mesh models for some reason?)

But also...maybe could result in the same amount of 'performance hit'
as rendering object twice( that you mention)?

[Edited by - steven katic on July 11, 2008 5:07:19 PM]

Share this post


Link to post
Share on other sites
How about using premultiplied alpha (by multiplying the RGB colors by the alpha in the fragment shader) together with glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
Thus now if the outputted alpha is the same as the premultiplying alpha, then the blending should be equivalent to traditional a,1-a blending; if it's 1, then you have additive blending; if it's in between, the blending should be in between. Or am I wrong?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement