devDept home page
Home
| Support | Purchase | Company
 
 
Tickets
Submit a Ticket
View your Tickets
License Profile
Resources
Documentation
Knowledge Base
FAQ
Change Log
Other
Contact Support
Fast Inaccurate Transparency

 

  Info & Tags
 
Article #: 1
Created: 2009-12-14
Modified: 2010-06-03
Tags: eyeshot3, transparency

Accurate transparency can be too slow for huge semi-transparent meshes or when thousands of simple semi-transparent entities come into play. If this is your case, give a try to the following approach.

 

  1. Set display mode as Rendered
  2. Entities are drawn in the same order they are added, therefore keep the semi-transparent ones at the end of the Viewport.Entities collection and on the same layer
  3. Never set the material Diffuse.A less than 255 otherwise the accurate transparency algorithm will process the entity
  4. Subclass the necessary entity types (Mesh, StlModel, etc.) and override the Render() method
  5. Add the following function body:
C#
Material mat = new Material("Glass", Color.FromArgb(100, Color.Cyan));

public override void Render(float screenToWorld, 
        float[] pattern, Dictionary‹char, CharData› charDefs)
{

    gl.Enable(gl.BLEND);

    Viewport.SetColorRendered(this, mat, Selected);

    byte cullingEnabled = gl.IsEnabled(gl.CULL_FACE);

    if (cullingEnabled == 0)

       gl.Enable(gl.CULL_FACE);
 
    gl.FrontFace(gl.CW);
    
    base.Render();
    
    gl.FrontFace(gl.CCW);
    
    base.Render(); 

    if (cullingEnabled == 0)

       gl.Disable(gl.CULL_FACE);

    gl.Disable(gl.BLEND);
    
}

Visual Basic
Dim mat As New Material("Glass", Color.FromArgb(100, Color.Cyan))
                        
Public Overridable Sub Render(ByVal screenToWorld As Single, _
        ByVal pattern As Single(), _ 
        ByVal charDefs As Dictionary(Of Char, CharData))
    
    gl.Enable(gl.BLEND)
    
    Viewport.SetColorRendered(Me, mat, Selected)
    
    Dim cullingEnabled As Byte = gl.IsEnabled(gl.CULL_FACE)
    
    If cullingEnabled = 0 Then
        
        gl.Enable(gl.CULL_FACE)
        
    End If
    
    gl.FrontFace(gl.CW)
    
    MyBase.Render()
    
    gl.FrontFace(gl.CCW)
    
    MyBase.Render()
    
    If cullingEnabled = 0 Then
        
        gl.Disable(gl.CULL_FACE)
        
    End If
            
    gl.Disable(gl.BLEND)
    
End Sub

 

This method will draw the entity twice: the first time back-facing triangles only while the second front-facing only. This is the fastest - inaccurate - way to draw a semi-transparent entity in Eyeshot 3.x.

 
Copyright © 2009 devDept Software. All rights reserved.