Better transparency

Don't use the proposed solution if MinimumFramerate is enabled.

By default Eyeshot has design.AccurateTransparency property set to false.

This allows to render transparent entities without the preprocessing step (design.ProcessSemiTransparent()) required by the AccurateTransparency algorithm (that can take some time depending on the scene complexity).

With this property set to false, the transparent entities are just drawn in the order they appear in the design.Entities list, simply enabling transparency.

This can cause visual problems because to correctly render transparent entities they must be drawn from the farthest one (from the viewer) to the nearest one.

See the image below, created with AccurateTransparency = false and this code:

var sp1 = Mesh.CreateSphere(10, 10, 10);
design1.Entities.Add(sp1, Color.FromArgb(127, Color.Red));
var sp2 = Mesh.CreateSphere(10, 10, 10);
sp2.Translate(0, 20, 0);
design1.Entities.Add(sp2, Color.FromArgb(127, Color.Blue));

Since the red sphere is added first, it is usually drawn before the blue one.

This causes the issue on the left viewport where the blue sphere, which is farther from the viewer, should be drawn first instead.

To improve the rendering of transparent entities (without turning on design.AccurateTransparency) you can derive the Design like this:

public class MyDesign : Design
    protected override void DrawViewport(DrawSceneParams myParams)
        myParams.Entities = SortEntitiesForTransparency(myParams.Viewport, myParams.Entities); 

The SortEntitiesForTransparency() method sorts the transparent entities from the farthest one to the nearest one so they are rendered in the correct order, no matter the view orientation.

See image below:

Of course this is just an improvement of the (less expensive) inaccurate transparency and works fine only with clearly separated entities like these ones. More complex and self-intersecting transparent entities will still have issues. To correctly render them the design.AccurateTransparency =  true is needed.

Previous versions of this article: Eyeshot 9, Eyeshot 10

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.