Is it possible to render two scenes (same scene with different setups) without any alpha, and after that is done just overlay the result from the second render on top of the first layer with a static transparency?

And how do I do it? I want it fast so the transparency should not be implemented during rendering, only on the final overlay process.

Basically I am asking for an efficient OpenGL post-processing method to combine the two different renders when drawing to screen.

  • 2
    \$\begingroup\$ I'm not an expert. But sources tell me you're asking "I want to know what happens if I take one and then add another one, but I don't want 1 + 1 = 2" \$\endgroup\$
    – Almo
    Apr 14, 2014 at 14:24
  • \$\begingroup\$ I'm confused too. What is this mysterious "final overlay process" and why isn't it part of the rendering if it's... rendering? \$\endgroup\$
    – Anko
    Apr 14, 2014 at 14:35
  • \$\begingroup\$ Not exactly. I want a result where 75% of the objects is rendered normally while the other 25% (close to camera) is transparent. I want to do it in two separate renders (without any transparency). The method I am asking for is a cpu/gpu efficient way adding the second result on top of the first. \$\endgroup\$ Apr 14, 2014 at 14:39
  • \$\begingroup\$ Question is unclear, but regardless there's no efficient pure "post-processing" solution. You seem to be asking for some kind of multiple pass depth or stencil buffer algorithm. \$\endgroup\$
    – MickLH
    Apr 14, 2014 at 14:40
  • \$\begingroup\$ Okay, well if I knew the correct wording for what I am searching for I would have googled it. I am looking for what in say Photoshop is two layers: background is 100%, and second layer is 50% transparent, but I dont want to do it "manually" before I switch buffer. If there is no builtin functions for this, then there isn't, I will code my own then, thanks anyway \$\endgroup\$ Apr 14, 2014 at 14:53

1 Answer 1


Yes it seems you do want a post processing effect.

First Render your scene normally. Then sample this texture in your next Render technique but use a set alpha.

something along the lines of:

in vec2 Texcoord;
out vec4 outColour;
uniform sampler2D tex;

void main()
   outColour = texture( tex, Texcoord );
   outColour += vec4( outcolour.rgb, 0.5f );

This is not tested and I'm only guessing that this is the effect you will want. The 0.5 in the second line of main can be cahnged for whichever alpha value you would like.

As an added note, you could do this in your original render pass, as soon as you know what the final color for the pixel will be, then you can just do that that last line of the shader with your own predefined alpha value.

  • \$\begingroup\$ Perfect! Not exactly what I wanted but it broke a logical barrier for me, so now I know how to reach my goal! \$\endgroup\$ Apr 14, 2014 at 15:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .