Scratch Card / Scratcher effect

Hi,

I need to implement scratch card type effect.

Anyone know how to implement it?

I am trying with setPixels and getPiexels.

Although not able to get exactly the same effect.

Any reference link / Code will be appreciated.

Thanks.

Hey there,

What you are trying to do you should not use setPixels, that function is super slow. You will need to write a custom shader. You can write to the stencil buffer for your scratch area. Then draw only parts of the images based on that buffer. As for implementation there are some resources online but if you are not familiar with shader this might be a difficult task. I don’t know of any direct references but at least you now know what you are looking for.

The easiest way would be to have a monochromatic texture you use as a direct replacement for the scratch texture alpha so the shader can just read this value directly and you would not be plagued with alpha channel render texture issues.

hi guys, thanks for rpls,

In mean time I am done creating same effect with setPixel, but for efficiency will look for stencil buffers.

Digging in Stencil buffers.Hoping for best.

@hippocoder may I know if you too mean to point me towards stencil buffer or its something differently done?