Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Not all meshes are applying transparency correctly

$
0
0

@LeonardoLimaAlmeida wrote:

Hello everyone!

I have a model of a ship, where the flags and ropes have textures with transparency.
My model has 5 meshes (body of the ship, set of flags, another set of flags, cannons and ropes).
Transparency works fine on everything except on one of the set of flag.

The green arrows indicate the set of flags and the ropes, where transparency is being applied correctly.
The red ones point to where the problem is occurring.

Debugging, I realized that the BasicEffect of the Mesh where the problem occurs is with Alpha as 1 instead of 0 as the other two with transparency.
When I tried to "force" 0 for this Alpha, the texture disappeared and the Mesh site was filled with the background, hiding everything behind.

The textures used in the sets of flags are the same, implemented (in blender) in exactly the same way.
The output file is a fbx, and the textures are tga.

Follows a view of where the transparencies are and how it should appear.

And the code i'm using for draw:

    public override void Draw(GameTime gameTime)
    {
        GraphicsDevice.RasterizerState = RasterizerState.CullNone;
        GraphicsDevice.BlendState = BlendState.AlphaBlend;
        GraphicsDevice.DepthStencilState = DepthStencilState.Default;
        
        foreach (ModelMesh mesh in Model.Meshes)
        {
            foreach (BasicEffect effect in mesh.Effects)
            {
                effect.AmbientLightColor = new Vector3(1f, 0, 0);
                effect.View = ScreenManager.GameViewMatrix;
                effect.World = WorldMatrix;
                effect.Projection = ProjectionMatrix;
            }
            mesh.Draw();
        }
        base.Draw(gameTime);
    }

Has anyone ever experienced this or could point me to a way to search and solve the problem?

Posts: 6

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles