Rendering Both IM Canvas and other elements in the same scene
I realise in the documentation it warns against rendering multiple shapes in different places and mentions that you should try to render everything from one location.
However, I've come across a particular issue. I'm using ImmediateModeShapeDrawer to render Polylines in my scene and ImmediateModeCanvas to render lines in my UI.
I'm having issues on IOS where the 3D polylines are always visible through the Canvas lines.
I've tried fiddling with Depth testing, rendering the scene polylines as opaque, and UI as transparent, but nothing seems to work.
Though, in the editor it works fine, when it comes to IOS it always looks the same.
Any recommendations would be greatly appreciated.
3D Scene Drawing code:
private void DrawPolyline(Camera actualCamera)
{
if(!selected && actualCamera == selectionCamera) return;
using(Draw.Command(actualCamera))
{
if (_linePaths == null) return;
Draw.ResetAllDrawStates();
Draw.ZTest = CompareFunction.LessEqual;
Draw.BlendMode = ShapesBlendMode.Transparent;
Draw.PolylineGeometry = PolylineGeometry.Billboard;
Draw.ThicknessSpace = ThicknessSpace.Meters;
Draw.Thickness = 0.0002f;
Draw.Color = selected ? selectionColor : new Color(0.7f, 0.7f, 0.7f, 0.8f);
Draw.Matrix = transform.localToWorldMatrix;
foreach (var linePath in _linePaths)
{
Draw.Polyline(linePath, false, PolylineJoins.Simple);
}
}
}
Canvas Code
public override void DrawPanelShapes( Rect rect )
{
if( Lines == null )
return;
foreach (var polyline in Lines.Where(polyline => polyline.PolylinePath.Count > 1))
{
// draw set up
Draw.ZTest = CompareFunction.Always;
Draw.BlendMode = ShapesBlendMode.Transparent;
Draw.PolylineGeometry = PolylineGeometry.Billboard;
Draw.DiscGeometry = DiscGeometry.Billboard;
Draw.ThicknessSpace = ThicknessSpace.Pixels;
// line
Draw.Polyline(polyline.PolylinePath, false, polyline.Thickness, PolylineJoins.Round, polyline.Color);
}
}
Oh great, thanks for the update!
I can't actually remember if I solved this problem or not, so I will let you know if I solve it.