Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

In the render method I use this:

 

device.RenderState.Lighting = true;
device.RenderState.Ambient = Color.FromArgb(100,100,100);
device.RenderState.ZBufferEnable = true;
device.RenderState.CullMode = Cull.CounterClockwise;
device.RenderState.ShadeMode = ShadeMode.Gouraud;
device.RenderState.FillMode = FillMode.Solid;

device.RenderState.AlphaBlendEnable = true;
device.RenderState.AlphaSourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
device.TextureState[0].ColorOperation = TextureOperation.Modulate;
device.TextureState[0].ColorArgument1 = TextureArgument.TextureColor;
device.TextureState[0].ColorArgument2 = TextureArgument.Diffuse;
device.TextureState[0].AlphaArgument1 = TextureArgument.Diffuse;
device.TextureState[0].AlphaArgument2 = TextureArgument.TextureColor;
device.TextureState[0].AlphaOperation = TextureOperation.BlendFactorAlpha;

device.Lights[0].Type = LightType.Directional;
device.Lights[0].Diffuse = Color.FromArgb(0,200,200,200);
device.Lights[0].Specular = Color.White;
device.Lights[0].Direction = new Vector3((float)Math.Cos((float)
device.Lights[0].Commit();//let d3d know about the light
device.Lights[0].Enabled = true;

 

Then I set the material color to argb(0,255,255,255) for one of the rendered meshes. I trun off alpha blending for all except one.

 

The question is: When I set the alpha channel to 0, I would expect the transparent mesh to dissapear completely. Why does it not ?

transparent.bmp

Posted (edited)

The simplest soulution is often the best. Very good point :)

 

You are quite right, but what if I want the mesh to be even more transparent than what you see on the snapshot, but not completely gone ?

 

I have tried to fiddle with different alpha settings, but this is the best I could come up with.

Edited by Reidar Lange
Posted (edited)

Not sure here (yes, i am a DX n00b. Just trying to find some logic in DX). I always thought that SourceBlend and DestinationBlend were linked, and AlphaSourceBlend and AlphaDestinationBlend were linked. But i see you use:

 

device.RenderState.AlphaSourceBlend = Blend.SourceAlpha;

device.RenderState.DestinationBlend = Blend.InvSourceAlpha;

 

Really not sure here, just something that popped up in my head while reading...

 

-- Loffen

Edited by Loffen
Erutangis a si tahw

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...