View Full Version : help with depth peeling

01-28-2015, 06:12 AM
I'm trying to figure out a demo of cass everitt on depth peeling.
I find this fragment shader code.

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


const char nopeel_fp[] =
"MOV result.color, fragment.color.primary;\n"

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


02-01-2015, 08:58 AM
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.