Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

#ActualNik02

Posted 19 July 2012 - 05:06 AM

Enable the stencil write render state, render your mask texture and discard those pixels that you don't want to write in the stencil buffer by using the clip() pixel shader function. The pixel shader logic specifies the "area of masking".

In your case, you'd sample the mask texture, and feed its luminance - 0.5f (where 0.5 is the gray treshold) to the clip function as a parameter. The clip function discards the currently processed pixel if its parameter is less than zero, and effectively prevents it from being written to color targets, depth buffer or the stencil buffer.

Alternatively (in case you don't want to use pixel shader), enable alpha testing and set the alpha test treshold to 0.5. Then output the texture luminance (or alpha, if you have an actual alpha channel in the texture) as alpha in the texture stage cascade. Alpha test rejection effectively establishes the same thing as the clip() function.

#4Nik02

Posted 19 July 2012 - 05:05 AM

Enable the stencil write render state, and discard those pixels that you don't want to write in the stencil buffer by using the clip() pixel shader function. The pixel shader logic specifies the "area of masking".

In your case, you'd sample the mask texture, and feed its luminance - 0.5f (where 0.5 is the gray treshold) to the clip function as a parameter. The clip function discards the currently processed pixel if its parameter is less than zero, and effectively prevents it from being written to color targets, depth buffer or the stencil buffer.

Alternatively (in case you don't want to use pixel shader), enable alpha testing and set the alpha test treshold to 0.5. Then output the texture luminance (or alpha, if you have an actual alpha channel in the texture) as alpha in the texture stage cascade. Alpha test rejection effectively establishes the same thing as the clip() function.

#3Nik02

Posted 19 July 2012 - 05:04 AM

Enable the stencil write render state, and discard those pixels that you don't want to write in the stencil buffer by using the clip() pixel shader function. The pixel shader logic specifies the "area of masking".

In your case, you'd sample the mask texture, and feed its luminance - 0.5f (where 0.5 is the gray treshold) to the clip function as a parameter. The clip function discards the currently processed pixel if its parameter is less than zero, and effectively prevents it from being written to color targets, depth buffer or the stencil buffer.

Alternatively (in case you don't want to use pixel shader), enable alpha testing and set the alpha test treshold to 0.5. Then output the texture luminance (or alpha, if you have an actual alpha channel in the texture) as alpha in the texture stage cascade.

#2Nik02

Posted 19 July 2012 - 04:47 AM

Enable the stencil write render state, and discard those pixels that you don't want to write in the stencil buffer by using the clip() pixel shader function. The pixel shader logic specifies the "area of masking".

In your case, you'd sample the mask texture, and feed its luminance - 0.5f (where 0.5 is the gray treshold) to the clip function as a parameter. The clip function discards the currently processed pixel if its parameter is less than zero, and effectively prevents it from being written to color targets, depth buffer or the stencil buffer.

#1Nik02

Posted 19 July 2012 - 04:45 AM

Enable the stencil write render state, and discard those pixels that you don't want to write in the stencil buffer by using the clip() pixel shader function. The pixel shader logic specifies the "area of masking". In your case, you'd sample the mask texture, and feed its luminance - 0.5f (where 0.5 is the gray treshold) to the clip function as a parameter.

PARTNERS