[Solved ^_^] Help: 3D Model Texture Transparency turns to Black.

Heya ^^;

My problem is the same as the title: the transparencies for 3D rendering come back as black pixels.

Here’s an image of my problem: http://imgur.com/YR83kR3

My current setup is:
model and texture made through an XNA content project, then brought over to a Monogame Windows Project.

I’m using a custom shader, but the problem persists even when using the most generic bassicEffect draw method.

I get a partial fix using the following before drawing my model:
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
GraphicsDevice.BlendState = BlendState.Additive;

However, this has worse problems in how it renders the parts of the model that shouldn’t be seen at certain viewpoints.

More information:

Also, I tried the following in regards to handling the texture and alphas:

  1. Used various blend states.
  2. tried pure blank colors and magic pink in the texture files ( <0,0,0,0> and <1,0,1,0> and <1,0,1,1>) respectively.
  3. Tried using regular png files rather then converted .xnb files.
  4. Tried to tell my shader to ignore the pixels or send back <0,0,0,0> if there is an alpha of 0.

More Info 2:

Played around with the shader and blend states. Got the black to disappear.

Now the transparencies show the background color, but parts of the model that should be shown through the transparency aren’t appearing.

Picture of changes/New Problem.

try BlendState.AlphaBlend

Thanks for replying ^^

The BlendState “does not contain a definition for Alpha”.

I had also tried the AlphaBlend value, which doesn’t help =/

Post code on how you are drawing this.

tried the following setups: (Sorry if the code is sloppy looking >.<)

With the shader-

protected override void Draw(GameTime gameTime)


            foreach (ModelMesh mesh in models[i].Meshes)
                foreach (ModelMeshPart part in mesh.MeshParts)
                    worldInverseTransposeMatrix = Matrix.Transpose(Matrix.Invert(mesh.ParentBone.Transform * world));
specialEffects.Parameters["World"].SetValue(world);                   specialEffects.Parameters["DiffuseColor"].SetValue(Color.White.ToVector4());                    specialEffects.Parameters["DiffuseLightDirection"].SetValue(new Vector3(0,0,-1));
specialEffects.CurrentTechnique = specialEffects.Techniques["TextureNormalDiffuse"];
part.Effect = specialEffects;

Without shader:

protected override void Draw(GameTime gameTime)
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;
            GraphicsDevice.BlendState = BlendState.AlphaBlend;           

            foreach (ModelMesh mesh in models[0].Meshes)
                foreach (BasicEffect effect in mesh.Effects)
                  effect.World = world;
                  effect.View = view;
                  effect.Projection = projection;
                  effect.TextureEnabled = true;
                  effect.Texture = textures[0];

Solved. A single line added to the shader solves everything. It runs perfectly now~ :slight_smile:

Apparently my problem was that the alpha’d pixels were still drawing, even if they were transparent. Read that alphatesting would fix this, but is no longer supported for DirectX 10. Found the shader clip() function, which I assume works for DX 10, and am using that to solve my problem.

Sorry for my noobishness XD