Help with depth peeling

I’m trying to figure out a demo of cass everitt on depth peeling.
I find this fragment shader code.


const char peel_fp[] = 
    "!!ARBfp1.0
"
    "OPTION ARB_fragment_program_shadow;
"
    "PARAM offset = program.env[0];
"
    "TEMP R0;
"
    "MOV R0, fragment.position;
"
    "ADD R0.x, R0.x, -offset;
"
    "TEX R0.x, R0, texture[0], SHADOWRECT;
" 
    "ADD R0.x, R0.x, -0.5;
"           
    "KIL R0.x;
"                       
    "MOV result.color, fragment.color;
"
    "END
";

    fp_peel.bind();
    fp_peel.load(peel_fp);
    GL_ERRORS;

    const char nopeel_fp[] = 
    "!!ARBfp1.0
"
    "MOV result.color, fragment.color.primary;
"
    "END
";


I do not understand what it does. Someone can explain this code. Can it be translated into a shader GLSL?

Thanks.

I suggest ignoring that code and looking for a description of depth peeling which uses GLSL.

The basic concept is to render in multiple passes, with depth tests and writes enabled and blending disabled. The depth buffer at the end of each pass is used as an input in the next pass. Only fragments which are farther away than the fragment from the previous pass are rendered. So the first pass ends up rendering the closest fragment, the second pass the second-closest fragment, and so on. The results of the individual passes are composited with blending to obtain the final image.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.