Login  Register

Re: Porting a depth peeling example to modern OpenGL

Posted by elect on Oct 11, 2013; 3:49pm
URL: https://forum.jogamp.org/Porting-a-depth-peeling-example-to-modern-OpenGL-tp4030224p4030240.html

I cant see any layer behind...

I guess there are some problems with the alpha value..

I tried to debug it and in the

   private void renderDepthPeeling(GL2 gl2) {

confronting between the GL2 and GL3 program version the the first and the last passage (1 and 3) looks correct, so the problem lies in the 2

I modified the for cicle in order to get only a cicle

for (int layer = 1; layer < 2; layer++) {

and

//            gl2.glBindFramebuffer(GL2.GL_FRAMEBUFFER, fboId[currentId]);
            gl2.glBindFramebuffer(GL2.GL_FRAMEBUFFER, 0);

In order to see visually the intermediate result

Well, in the GL2 I get



while in the GL3



My dpPeel program is based on dpPeel_VS

#version 330

layout (location = 0) in vec4 position;

layout(std140) uniform mvpMatrixes  {

    mat4 projectionMatrix;
    mat4 cameraMatrix;
};

void main(void)
{
        gl_Position = projectionMatrix * cameraMatrix * position;
}


And dpPeel_FS plus shade_FS

#version 330

uniform samplerRect DepthTex;

vec4 ShadeFragment();

out vec4 outputColor;

void main(void)
{
        // Bit-exact comparison between FP32 z-buffer and fragment depth
        float frontDepth = texture(DepthTex, gl_FragCoord.xy).r;
        if (gl_FragCoord.z <= frontDepth) {
                discard;
        }
       
        // Shade all the fragments behind the z-buffer
        vec4 color = ShadeFragment();
        outputColor = vec4(color.rgb * color.a, color.a);
}



#version 330

uniform float Alpha;

vec4 ShadeFragment()
{
        vec4 color;
        color.rgb = vec3(.4,.85,.0);
        color.a = Alpha;
        return color;
}


Where am I wrong? You can find all the code here https://github.com/elect86/modern-jogl-examples/tree/master/modern-jogl-examples/src/depthPeeling