I’m texturing a list of meshes via DrawMeshShaded() like this:
public override void DrawViewportMeshes(IGH_PreviewArgs args)
{
for (int i = 0; i < mesh.Count; i++)
{
mesh[i].SetTextureCoordinates(textureMapping[i], Transform.Identity, true);
args.Display.DrawMeshShaded(mesh[i], new Rhino.Display.DisplayMaterial(material[i]));
}
}
Switching to Rendered makes my custom meshes transparent if they visually intersect with an existing Rhino object (white box). This only happens if shadows are on, though. While this is true for Rhino geometry, custom meshes remain opaque while visually intersecting with other custom objects (violet box). Also, custom objects don’t cast shadows, while existing Rhino geometry does.
I think it’s not so much a problem of transparency, as the fact that the shadows get drawn on top of your geometry, but without taking into account your geometry.
@andy designed the various render and display pipelines that are involved here and he’ll be able to tell you which ones are ideal for drawing your shapes in. The custom render mesh pipeline is tricky to use from within Grasshopper because I believe it involves registration from the plugin Load event, which you don’t have as a Grasshopper plugin. But again Andy will be able to tell you what, if any, workarounds are available here.
There are a few posts on the forums asking similar questions but none provides a clear solution. It has to be doable from within Grasshopper, because the Custom Preview component doesn’t suffer from this issue. You mentioned it adds meshes to the rendering rather than the display pipeline. Could you elaborate on how this is done, maybe?
Like I said, that component relies on the Grasshopper plugin registering a custom render mesh provider. You don’t have an RHP associated with your code so you’ll need to solve your issue in some other way.
Don’t want to rush anyone, but could you please look into this topic @andy? Are there any methods to properly display GH meshes in rendered viewports? Or is this just a lost cause, and we always need to use the Custom Preview component?