Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

This is odd but when i enable lighting everything disapears, however Ambient is set to white?

Also i still cant get my engine to use Black as transparant.

d3d.Dev.RenderState.Lighting = true;

d3d.Dev.RenderState.Ambient = Color.White;

d3d.Dev.RenderState.CullMode = Cull.None;

d3d.Dev.RenderState.AlphaBlendEnable = true;

d3d.Dev.RenderState.AlphaTestEnable = true;

d3d.Dev.RenderState.ReferenceAlpha = Color.Black.ToArgb();

d3d.Dev.RenderState.AlphaFunction = Compare.NotEqual;

d3d.Dev.RenderState.AlphaSourceBlend = Blend.SourceAlpha;

d3d.Dev.RenderState.AlphaDestinationBlend = Blend.InvSourceAlpha;

d3d.Dev.RenderState.ColorVertex = true;

d3d.Dev.RenderState.AlphaBlendOperation = BlendOperation.Add;

Posted

I'm guessing here, but I think the problem is in one of the following lines:

 

d3d.Dev.RenderState.ReferenceAlpha = Color.Black.ToArgb();

d3d.Dev.RenderState.AlphaFunction = Compare.NotEqual;

d3d.Dev.RenderState.ColorVertex = true;

Posted (edited)
Alernatively your problem may be that you do not have 'normal' data for your object. DirectX then renders everything in black when lighting is turned on. Edited by Drak
Posted

I think you got it there

 

That sounds about right, Ill have to apply some normals when i get a chance, just the transparancy problem left to go and one more project effectively done! (with many debts owing to the people here).

Posted

Normals are easy, luckily

 

That sounds about right' date=' Ill have to apply some normals when i get a chance, just the transparancy problem left to go and one more project effectively done! (with many debts owing to the people here).[/quote']

 

If you've got a mesh, you can let DX itself calculate the normals throught the Mesh.ComputeNormals() method.

 

Be aware that if you re-use vertices DX will calculate the normals for those vertices as an average of all the surfaces which leads to 'roundish' results (at least it did for my meshes), which are not always what you want.

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...