3D Model w/ Transparent Textures

I am trying to display a 3D Model that has transparent parts but I am having issues. The transparent bits are instead black. I have tried using AlphaBlend BlendState but that doesn’t help since it just make the transparent bits actually transparent but it prevents anything behind them from being drawn.

Apparently it has something to do with the order of how things are being drawn but I don’t have much control over that since I am using a model. Any suggestions?

private void DrawModel(Model model, Matrix world, Matrix view, Matrix projection)
{
    foreach (ModelMesh mesh in model.Meshes)
    {
        foreach (BasicEffect effect in mesh.Effects)
        {
            effect.World = world;
            effect.View = view;
            effect.Projection = projection;
        }

        mesh.Draw();
    }
}

Yes, order of rendering is important here. Everything being in the one model makes that difficult.

The usual way this would happen is that each model part that has alpha transparency would be a separate model. All of the instances of this model would be sorted from furthest to nearest (back to front) so the instances furthest from you are drawn first and the instances closest to you are drawn last. This overcomes the problem you found of some of them obscuring others. Even though parts of the texture are transparent, they still get added to the depth buffer. This prevents some parts of models behind it to be drawn because they fail the depth test. Therefore you need to draw the models from back to front.

The opposite can be true for models that are fully opaque. They can be optimised by rendering from front to back, using the fact that the depth test can fail and therefore it doesn’t need to run the pixel shader because that pixel is not seen.

Take a look at this http://xbox.create.msdn.com/education/catalog/tutorial/particle_xml
Tip: When you use additive particles (like flames) you don’t need to sort them.

Would it be possible to use AlphaTestEffect? From what I understand it doesn’t draw Alpha Pixels and makes it easier to draw transparent textures. I switched my model to use it as the Default Effect but then MonoGame doesn’t render anything. Tried to look-up how to use it and couldn’t find anything.

@7H3LaughingMan You could use BasicEffect or write your own shader. You might even be able get away with using billboards, sprites that are essentially texture mapped 3D facets that always have their surface normal facing into the camera.

Does AlphaTestEffect no longer work? I don’t have much experience with shades so not sure how to gorder about doing it. I can’t really use a billboard method as my models are actually 3D Models with Depth and Height.

Alphatest works of course. (i mean in your own shader, i don’t use “base” effects like basiceffect skinnedeffect etc in my engine, they are too limited for it)

clip(currenttexmapvalue.a - alphatesttreshold)
In your effect should do the trick.

Well are there any tutorials on writings shades and using them on a 3D Model? Not sure how to go about doing any of this using MonoGame. Use to using Unity so you didn’t have to do all of this

You can start here: http://rbwhitaker.wikidot.com/xna-tutorials
There is a monogame section too

Hey, I know it’s a bit off topic (please delete if against rules), but I also used to use Unity and made the change to MonoGame. Out of curiosity, what was your reason for doing so?

Alright, I was able to write my own Shader to use that would clip out the transparent pixels. I was able to load it an apply it to my model at Runtime and it does function somewhat, but it isn’t clipping out the transparent pixels. What am I doing wrong here?

http://pastebin.com/vU8YMhj1

http://pastebin.com/1EEGcJSq

Edit: Nevermind, I figured it out and I feel stupid. Inside my RemapModel I wasn’t setting meshPart.Effect to the temporary one that I made. Made that change and it started to work properly. However, does anyone know a better way to apply a Custom Effect to a Model?

Use a custom ModelProcessor to apply effects at build time. But it seems to be very complicated to get it work with the content pipeline builder… it is my main problem while porting my engine from XNA to this version of monogame…
It ran smooth 60fps with instancing, deferred rendering, DOF, dirt lensflare, lit particles, ssao…
And i can’t add an effect on the model processor with monogame 3.5. Maybe 3.4 ?

http://community.monogame.net/t/external-reference-in-model-processor/7381

http://community.monogame.net/t/custom-model-processor/2367

http://community.monogame.net/t/mesh-effect-field/7462