I have created a number of semi-transparent objects in my model inside blender. I have created them in 2 different ways, some using UV mapped textures with an alpha component (these work fine, I think), and some with just an object color and alpha value set in blender. The objects that I created without using textures, I did the following:- set material color & alpha in Blender- programmatically assign the blend mode during loading to SIO2_MATERIAL_COLOR for the materials used for the objects (since I could not do this in blender)

The problen I have is that the transparency works correctly only in alphabetical order. (i.e. if object Cube is in front of object Wall, wall is not visible through the cube. If object 'Wall' is in front of 'Cube', then it appears to render correctly - you can see the Cube through the Wall because I'm guessing Wall is rendered last.I stepped through my code, and it appears that the _SIO2object->dst is being updated properly.What is funny is that objects that I created using transparent textures with alpha layers all set up in Blender always get the ordering correct. (the transparent objects without textures render correctly both in front and behind an object with created with texture.

Anyone else have this problem or have some suggestions? I think I am going to have to create a dummy texture for these objects in blender and do it that way. >> working on it now...

I had trouble with transparency too. I left it to get back to so I'm interested to hear what you learn. Sio2 recommended using translucency in Blender instead. I'm a little concerned about the amount of computation required for transparency too.

I ended up creating a 'default' texture that is basically a 2x2 tga file that is all white and alpha layer that is 1.0. I set this image as texture layer 0 on my objects' material and set the blend mode to COLOR. This appeared to work even with multiple objects (solid/transparent) stacked in front of each other. The alpha set in blender now sets the material's alpha, and I can adjust this on the fly with _SIO2material->alpha = 0.2 for example.

**EDIT** > The following is a tricky problem, and my solution, as it turns out, is not better.. I'm going back to the original code.

After looking into it a bit more, there was still a subtle problem with ordering. The transparency is correct for the most part, except when you bring objects of different sizes close to each other. The _SIO2object->dst property was not quite being updated properly. if a large object was just in front of a small object, then sometimes the small object would completely disappear instead of being visible through the large object. The dst property is set during culling, using the object's bounding sphere radius. The result is what I described, so I modified the sio2ResourceCull to cull (set dst to 0.0) using the bounding sphere, but not to set the distance this way (rather set it using a sphere radius of 0). This can still have trouble with irregular (concave) objects close to each other, I think, like when one object is inside of another. The code I came up with is below.

What I understood about the translucency setting is that it uses a sort of threshold to determine what gets rendered. I wanted to try to stay away from that and render transparency as accurately as I can.

Rendering:

Code:

// proper distances are updated for the objects based on the frustrum of the camera // this routine applies a more accurate dst based on the centers only sio2ResourceCullDst( sio2->_SIO2resource, sio2->_SIO2camera ); sio2ResourceRender( sio2->_SIO2resource, sio2->_SIO2window, sio2->_SIO2camera, SIO2_RENDER_SOLID_OBJECT | SIO2_RENDER_TRANSPARENT_OBJECT ); // sio2MaterialReset();

Made a new sio2ResourceCull that looks like this:

Code:

// routine to correctly calculate dst.// This improves z-ordering by using a radius of 0 for calculating dst// rad is still used for culling (sets dst = 0.0)// still does not work well for irregularly shaped objectsvoid sio2ResourceCullDst( SIO2resource *_SIO2resource, SIO2camera *_SIO2camera ){ unsigned int i = 0;

Okay, I'm going to have to think about the irregular shaped objects thing a bit more... The center of the object is the only thing determining z-order (dst), which is causing problems.sio2CameraRectangleDistInFrustum for some shapes possibly...

Well with the original sio2 code, using the bounding sphere to calculate dst, it works fine except the case I mentioned before. Specifically this is when you have an object 'hiding' behind another larger object and the edge of its bounding sphere is not as far back as the larger object's bounding sphere. Confused? Me too. Moving on.

Sometimes. When it is, the rendering order is definitely screwed up. I think that the depth calculation in sio2 orders the objects by how far back the furthest point on the bounding sphere is for each object. (distance from frustum clip plane to center point + radius of bounding sphere = dst) Then renders back to front.

I ended up doing my own sorting. It works pretty well for objects somewhat close to each other.

Simply check the tutorial04 video... I explain there all the necessary technique for you to have transparency rendered properly. SIO2 have absolutely no problem handling transparent, semi-transparent and alpha leveled objects...

That tutorial got me a LONG way, so thanks for putting that together. I think where I went wrong is that I didn't set a non-0 tralu value in blender for materials that I was not using a texture. My object type was then left at SIO2_OBJECT_SOLID for objects that I had set an alpha value.

hmm. That explains the alphabetically ordered objects in my original post, I think, since solid objects are rendered that way.