LWJGL
May 22, 2012, 15:57:44 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: "Darken only" Blending  (Read 1061 times)
CodeBunny
Nerdus Imperius
*****
Posts: 453



WWW
« on: May 17, 2011, 04:47:48 »

I can get the beginnings of an interesting blending function by using the following parameters:

Code:
GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA);

The result is that render results are bounded by the color they're being rendered to. This has some potentially useful effects in terms of shadows and other details.

However, the problem is that the above blending function doesn't allow the source image to effectively use transparency. It only works if I'm using full alpha.

Is there any way I can multiply the source pixels by both GL_DST_COLOR and GL_SRC_ALPHA? That would completely fix this effect and get it to where I'd like.
Logged
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #1 on: May 17, 2011, 06:59:11 »

Pre-multiplied alpha? Or just do it in the fragment shader, like:

Code:
gl_FragColor = vec4(color.rgb * color.a, color.a);

Where color == whatever you'd normally output from the shader.
Logged

CodeBunny
Nerdus Imperius
*****
Posts: 453



WWW
« Reply #2 on: May 17, 2011, 09:25:05 »

I was hoping to do it without shaders. Is there another way to do that?

Yeah, I've realized that premultiplied alpha will fix this, but I wanted to see if it could work with "normal" alpha images.
Logged
spasi
Nerdus Imperius
*****
Posts: 643



WWW
« Reply #3 on: May 17, 2011, 09:56:39 »

I haven't used the fixed-function texture environment shading in many years, but I think you should be able to do this with ARB_texture_env_combine (or OpenGL 1.3+). ATI_fragment_shader and NV_register_combiners are two other, vendor-specific, options.
Logged

CodeBunny
Nerdus Imperius
*****
Posts: 453



WWW
« Reply #4 on: May 17, 2011, 10:07:24 »

Thank you. Cheesy
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!