Hi all,
I am having issues with transparent material for a CustomBrepObject, hope anyone could point me a direction. So here is a screenshot for illustration:
-
The original geometries (looks all fine with transparent objects).
-
Copied from above original geometries (gumball + drag + Alt). The top brep is seeing through all objects below as if there’s nothing behind.
-
Copied from above original geometries, and moved. The top brep is not showing correctly with the color of below objects.
Here is what I did for OnDraw in my CustomBrepObject:
protected override void OnDraw(DrawEventArgs e)
{
if (e.Display.DrawingSurfaces)
{
var material = new DisplayMaterial(Color.FromArgb(120, 75, 190), 0.2);
var mesh = RH.Mesh.CreateFromBrep(this.BrepGeometry, RH.MeshingParameters.Default);
e.Display.DrawMeshShaded(mesh, material);
}
else
{
base.OnDraw(e);
}
}
(note: code above is simplified for illustrating the problem)
I tried to set the material IsTwoSided to true, or set mesh.VertexColors with the color with alpha value, but they doesn’t improve anything.
material.IsTwoSided = true;
material.BackDiffuse = material.Diffuse;
material.BackTransparency = material.Transparency;
There are a several posts mentioned about EnableDepthTesting and EnableDepthWriting, etc, I couldn’t get them work.
I also tried to create custom DisplayConduit, it only works fine if I reorder the objects based on their distance from the camera. But this is very intensive, and Rhino’s view gets very slow when I have about 200 breps.
Hope this provides you enough information to understand this issue.
Thanks so much in advance.