DrawMeshFalseColors v6 bug

,

@pascal I noticed now that v6 DrawMeshFalseColors don’t work

It looks like it’s not picking colors from VertexColors in v6. In v5 works fine. Below screen of DrawMeshWires(working) and DrawMeshFalseColors(bug) it in v6. Can somebody also confirm that?

Hi @D-W,

The attached cheezy test command seems to work - even under VMware.

TestDrawMeshFalseColors.cs (2.8 KB)

What am I missing?

– Dale

Hmm… thats weird - i assume you were compiling this agains newest rhinocomon?

I think that only one other thing is that im appending multiple meshes to one big mesh so maybe there color info is lost in v6?

Hi @D-W,

After you finish appending, confirm that the vertex color count is equal to the vertex count.

— Dale

Dear @dale,

hmm it seems that in terms of appending everything is ok (screen below). Could you complie your example against rhinocommon 5.1?

i have 10k of boxes each 8 verts so it seems to be ok but as you see theres no color there
vercolv6

screen from v5 with the same code:
v5meshfalsecolr

The version of RhinoCommon that you compile against should be irrelevant. The version of RhinoCommon that ships with the Rhino that you are running is the version that is being used with your plug-in at runtime.

@stevebaer ok so i’m facing this issue with Rhino 6 SR7 2018-7-9 (Rhino 6, 6.7.18190.21071, but in v5 - Version 5 SR14 64-bit (5.14.522.8390, 22.05.2017) everything is ok.

[Edit] @dale I tried your example and here is what i get:

some are colored and some are black and also i get weird black (normals?) flickering when rotating viewport

What happens when you make a single box with vertex colors?

Keep in mind the sample generates random colors…

Ok using your code making directly this:

protected override void PostDrawObjects(DrawEventArgs e)
{
  var mesh = new Mesh();

        mesh.Vertices.Add(new Point3d(0.5, 0.5, 0.5));
        mesh.Vertices.Add(new Point3d(0.5, 0.5, -0.5));
        mesh.Vertices.Add(new Point3d(0.5, -0.5, 0.5));
        mesh.Vertices.Add(new Point3d(0.5, -0.5, -0.5));
        mesh.Vertices.Add(new Point3d(-0.5, 0.5, 0.5));
        mesh.Vertices.Add(new Point3d(-0.5, 0.5, -0.5));
        mesh.Vertices.Add(new Point3d(-0.5, -0.5, 0.5));
        mesh.Vertices.Add(new Point3d(-0.5, -0.5, -0.5));

        mesh.Faces.AddFace(0, 1, 5, 4);
        mesh.Faces.AddFace(0, 4, 6, 2);
        mesh.Faces.AddFace(0, 2, 3, 1);
        mesh.Faces.AddFace(7, 3, 2, 6);
        mesh.Faces.AddFace(7, 6, 4, 5);
        mesh.Faces.AddFace(7, 5, 1, 3);

        for (var i = 0; i < mesh.Vertices.Count; i++)
            mesh.VertexColors.Add(Color.Red);

        e.Display.DrawMeshFalseColors(mesh);
}

I get this in v6

@dale i changed your command to have still colors like

private Mesh CreateMeshBox()
    {
        var mesh = new Mesh();

        mesh.Vertices.Add(new Point3d(0.5, 0.5, 0.5));
        mesh.Vertices.Add(new Point3d(0.5, 0.5, -0.5));
        mesh.Vertices.Add(new Point3d(0.5, -0.5, 0.5));
        mesh.Vertices.Add(new Point3d(0.5, -0.5, -0.5));
        mesh.Vertices.Add(new Point3d(-0.5, 0.5, 0.5));
        mesh.Vertices.Add(new Point3d(-0.5, 0.5, -0.5));
        mesh.Vertices.Add(new Point3d(-0.5, -0.5, 0.5));
        mesh.Vertices.Add(new Point3d(-0.5, -0.5, -0.5));

        mesh.Faces.AddFace(0, 1, 5, 4);
        mesh.Faces.AddFace(0, 4, 6, 2);
        mesh.Faces.AddFace(0, 2, 3, 1);
        mesh.Faces.AddFace(7, 3, 2, 6);
        mesh.Faces.AddFace(7, 6, 4, 5);
        mesh.Faces.AddFace(7, 5, 1, 3);

        //for (var i = 0; i < mesh.Vertices.Count; i++)
        mesh.VertexColors.Add(Color.Red);
        mesh.VertexColors.Add(Color.Green);
        mesh.VertexColors.Add(Color.Blue);
        mesh.VertexColors.Add(Color.Yellow);
        mesh.VertexColors.Add(Color.Magenta);
        mesh.VertexColors.Add(Color.Orange);
        mesh.VertexColors.Add(Color.White);
        mesh.VertexColors.Add(Color.Teal);

        mesh.FaceNormals.ComputeFaceNormals();
        mesh.Normals.ComputeNormals();
        mesh.Compact();

        return mesh;
    }

and i get again black flickering normals:

[Edit] I tried now:

for (var i = 0; i < mesh.Vertices.Count; i++)
            mesh.VertexColors.Add(Color.Red);

So difference is that i dont calculete normals for this mesh and it is black

when i add:

mesh.FaceNormals.ComputeFaceNormals();
mesh.Normals.ComputeNormals();

i get this:

and black ones are flickering randomly while rotating - and in my scenario i want uniform boxes without shading like i showed in post number 5 of this topic

and just to be clear with above full example like:

for (var i = 0; i < mesh.Vertices.Count; i++)
            mesh.VertexColors.Add(Color.Red);

        mesh.FaceNormals.ComputeFaceNormals();
        mesh.Normals.ComputeNormals();
        mesh.Compact();

i have this desired result:

I can repeat this. I’ll add code to our shader in V6 to detect the no normal case and just draw unlit colors.

https://mcneel.myjetbrains.com/youtrack/issue/RH-47295

2 Likes

Can you post the details about your system and video card (Help > System Info…).

Thanks,

– Dale

1 Like

WIN 10 / i7-6700HQ / 32GB RAM / Quadro M5000M/PCIe/SSE2 (OpenGL ver:4.6.0 NVIDIA 391.33)

OpenGL Settings
Safe mode: Off
Use accelerated hardware modes: On
Redraw scene when viewports are exposed: On

Anti-alias mode: 8x
Mip Map Filtering: Linear
Anisotropic Filtering Mode: Height

Vendor Name: NVIDIA Corporation
Render version: 4.6
Shading Language: 4.60 NVIDIA
Driver Date: 3-22-2018
Driver Version: 23.21.13.9133
Maximum Texture size: 16384 x 16384
Z-Buffer depth: 24 bits
Maximum Viewport size: 16384 x 16384
Total Video Memory: 8 GB

The normals in the corners are getting averaged among the faces which is not what you want for a box. In this case, you probably want to call Unweld to create unique vertices and normals per face.

        mesh.Unweld(0, false);
        mesh.Normals.ComputeNormals();

Thanks @stevebaer that works but have huge impact on the calculation and drawing of big sets of meshes here in my test case 10k regenerates ~250% longer also not sure why in v5 these calculations are way faster and in case of drawing with 10k of boxes i have ~0.021 sec per frame while without normals i have ~0,014 sec per frame and in v5 it takes ~0.011sec.

How are you computing your times? V6 typically takes longer to set up data on the GPU during the first frame, but subsequent frames are typically faster than V5.

Lighting calculations are being applied and blended with the false colors in V6 which I’m sure has some impact on the performance. Once the false youtrack issue that I created above is implemented, we should be able to draw false color meshes without vertex normals and will have something better for comparison.

@stevebaer Well in v5 in case of regenerate whole mesh from ground up for 10k boxes it pops almost immediately in case of v6 i takes ~4-5 secs ( it is long enough to freeze whole rhino ).

One moment I’ll put there stopwatch and i will give you exact times.

Ok @stevebaer here you are exact times of the same block of code performed by v5 and v6 - as you see the difference is massive.

Now i understood what was the question about i have stopwatch inside and it starts in CalculateBoundingBox and ends right at the end of PostDrawObjects and i throw this to Rhino.UI.StatusBar.SetMessagePane

Are you creating the mesh every frame and then drawing that mesh? If so there are two distinct phases that we should measure to understand where the bottleneck is.

Steve no i don’t as i said earlier i have event hooked up when core notify that theres new set of objects i get those objects and merge them to big mesh for as fast as possible preview while generating frames and that particular method (merging of meshes before passing to display) behaves so differently in v5 and v6.