Stencil mask from texture

I have a functioning stencil mask in my project based on the 3D Magic Card sample.

This is working great, but I’m running into issues because sometimes I need to make a non-square hole, for example to match this archway:

I’m aware I could just replace the plane mesh with a specialized one, but ideally I would want to define the shape of the hole with a texture mask like this:

Is there any official way to do this without making a custom shader? Is there a custom shader in existence that can do this?

Hi @Quincy,

Not sure if that’s possible without a custom shader or shader chunk.

@mvaligursky do you have a point of view?

1 Like

I’m not sure … but it could work with setting a stencil on material, and using alpha test to reject pixels based on the texture?

I’ve actually discovered that this functionality is built into the stencil mask code already. This project demonstrates how to do it properly, it basically just requires the material to have its opacity map set up in a particular way.


All better


Looks good, thanks for sharing!