Is there any way to force AlphaTestEffect on everything?


I’m trying to make a N64/PSX style game, and because of that, I’m trying to keep my poly count quite low, and am substituting a lot of detail with transparent textures. Here’s an example of what one of my models looks like in Blender (the orange outline shows the actual mesh vertices):

Now, when I import this model into my game, the parts of the mesh which are covered up by .png transparency are also transparent (I’ve highlighted the bad areas in red):

I know that AlphaTestEffect would fix this, but it lacks some of the lighting features that other effects have. On top of that, I’m using a custom processor for this model (SkinnedSample), and I have no idea how to apply AlphaTestEffect to it. So my question is: can I apply AlphaTestEffect’s alpha testing effect to every model in my game (as pretty 90% of them will need it), or if that’s not possible, how would I apply it to SkinnedSample?

Thank you very much in advance for any help!

If you need more lighting stuff in the effect you can write your own. The source of the built-in shaders should help you out :slight_smile:
You can set the effect in your processor, so it is automatically set for all your models. Check out this sample:

1 Like

Just to clarify - the problem is that the model which is partly transparent still covers the background and therefore the background is not rendered, right?

No it’s not that. The transparent part cuts into the model where it overlaps itself. As you can see in the jaw, there’s a large angular hole in the head you can see the background through which isn’t supposed to be there that’s caused by the .png transparency.

it looks like the entire side of the front jaw is not drawn, not only in the red part but alos the mouth below. Like the triangle faces the wrong direction. The bottom part seems to have the problem that the transparency of the front triangle covers the model in the background, even though it shouldn’t.

  • The transparent part cuts into the model where it overlaps itself.

Sorry i don’t understand.

Anyways, what lighting features is the default alpha testing effect missing?

Yeah, you’re right the inside of the mouth is also being affected by it (it’s not because of backfaces though, I’ve switched off culling).

Default alpha test effect seems to have more basic lighting abilities compared to the other effects that come with MonoGame. That’s not really the issue I have, as AlphaTest doesn’t have any Skinned Model support, so I’m going to have to use a custom implementation to fix the transparency.

Many things to take into account:
You need alpha test,
Many transparent textures [may] overlap
As you cannot sort your triangles by depth before drawing them, you certainly need to use a depthpeeling. You are in the case of particles where many transparents with opaques zones triangles overlap.