3DS Glass is not See-Thru

Started by
2 comments, last by remigius 15 years, 10 months ago
I've had this problem with 3DS glass meterial objects I export to XNA, Seems there not see-thru at all, I can't get them to display correctly, they look solid. Has anyone else ran into this, I figure I'm just doing something wrong:( Oh I'm exporting to .3DS then exporting from Deep Exploration to a .x file. Thanks, MajSlayer
Advertisement
3DS materials aren't exported when you export a mesh. For those effects you'd need to export the mesh and then do transparency with shaders and XNA.
Unless you're referring to HLSL in 3DS Max which I'm not sure about. That may depend on the exporter.
How does one go about doing that? do I apply commands to the object in question(via its name)?
Kinda new and I need to get this window working, I'll study up in the mean time. Thanks I had no idea why it wasn't working,

MajSlayer

Transparent materials are typically rendered using alpha blending, you can set that up with the code below.

GraphicsDevice.RenderState.AlphaBlendEnable = true;GraphicsDevice.RenderState.SourceBlend = Blend.SourceAlpha;GraphicsDevice.RenderState.DestinationBlend = Blend.InverseSourceAlpha;// render transparent meshpart hereGraphicsDevice.RenderState.AlphaBlendEnable = false;


However, rendering transparent materials isn't quite as straightforward as you might think. Because of depth buffering, if you render your transparent material before you render the stuff that's behind it, it won't be there. The device doesn't care if an object is transparent (with alphablending, alphatesting is another matter), so it'll mark the pixels as 'taken' in the depth buffer and discard any pixels rendered behind it. A bit of googling should provide you with more in depth info.

There are basically two ways around this, sorting materials so you render the transparent ones last or disabling zbuffer writes when rendering transparent materials. Disabling the zbuffer writes is only useful if you don't care the transparent material gets overwritten (common with grass and foilage), so I'm afraid you're going to have to do some sorting. For a single mesh though, this is just a matter of figuring out the MeshPart index which uses the transparent material and rendering that after you've looped over the opaque parts.

There you go, I hope this makes some sense [smile]
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement