Jump to content


depth peeling program


1 reply to this topic

#1 abc9804

    New Member

  • Members
  • PipPip
  • 14 posts

Posted 14 March 2008 - 02:09 PM

Hello,everyone
I get the depth peeling code from NV demos (C. Everitt).I'm not familier with shader programming. Can you please try to interpret this fragment code?

char _fp_peel[] =
"!!ARBfp1.0\n"
"OPTION ARB_fragment_program_shadow;\n"
"TEMP R0;\n"
"TEX R0.x, fragment.position, texture[0], SHADOWRECT;\n"
"ADD R0.x, R0.x, -0.5;\n"
"KIL R0.x;\n"
"MOV result.color, fragment.color;\n"
"END\n";

Also,I have three problem:how to understand TEX sentence? if fragment.position changes into fragment.texcoord[0],is there any differences? The last one,why R0.x need subtract 0.5?
Many thanks,

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 14 March 2008 - 04:32 PM

fragment.position is a built-in variable that represents the fragment's x, y coordinates on the screen. fragment.texcoord[0] isn't necessarily the same although you could set up your geometry with appropriate texcoords so that it would be the same.

As for the subtraction of 0.5, look at the next line: KIL R0.x. This instruction discards (kills) the fragment if R0.x is less than zero. So the subtraction right before means that the fragment gets killed if the returned value from the texture is less than 0.5, i.e. if the fragment is more than 50% shadowed.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users