TextureMapping Performance in Rhino 8 Problem

Hello everyone,
I have developed a plugin in Rhino7 using RhinoCommon in C# and currently working on creating a plugin version for Rhino8. One of the functionalities in this plugin involves assigning and modifying texture mapping. While the functionality works smoothly in Rhino7, I’ve encountered two specific efficiency issues in the Rhino8 version. I need assistance in resolving these problems.

  1. Texture Assignment Code Efficiency: In Rhino7, I use the following code to assign texture mapping:

Csharp code

resultInt = obj.SetTextureMapping(channel, tm);

Here, tm is a mesh with textureCoordinate made by us. The process is so slow in Rhino8, sometimes exceeding 10 seconds under certain mesh conditions. In Rhino 7 it is never happened.

If I SetTextureMapping Once, It will be fast when I do that again.

  1. Redraw Time After Texture Modification: I also modify the texture mapping within the plugin. After modification, I use the same code obj.SetTextureMapping(channel, tm); to assign it back. The assignment is fast, but when I invoke view.Redraw(), the redraw time becomes excessively long.

Additionally, I’ve noticed that our plugin experiences slower performance under .NET 7.0 or .NET 4.8, but it performs normally in Rhino7.

Rhino8 Version:8.2

Your assistance in resolving these performance issues would be greatly appreciated. Thank you!

I apologize for repeating this issue, but I’m genuinely in need of assistance.

@dale Please assist me in solving this problem, Thank you!!!

@andy - can you have a look at this?

Hello @陳志鵬

Sorry, it took this long to get to this. I’m looking into it now.

I’m running the code I received by email on a 500k poly mesh.

These timings are made with Debug builds:

Rhino 7:
New Object Set the Same TextureMapping Back. Time:1 ms
New Object Set rebuild TextureMapping Time:10872 ms
New Object Set rebuild TextureMapping AGAIN. Time:6 ms

Rhino 8:
New Object Set the Same TextureMapping Back. Time:10515 ms
New Object Set rebuild TextureMapping Time:2 ms
New Object Set rebuild TextureMapping AGAIN. Time:2 ms

I will do some profiling next to see where the time is spent. Sometimes SetTextureMapping modifies the object attributes and causes ModifyObjectAttributes event.

The time is spent computing texture coordinates for the object mesh (for mesh objects there aren’t separate render meshes as there are for nurbs objects). This involves looking at the mapping mesh and the object mesh and figuring out how they would best map to one another. This computation sometimes happens as the object is drawn, sometimes it happens right away when new mapping is set and sometimes it may for example happen when an object is exported to file. This may explain why sometimes it is the SetTextureMapping that takes long and sometimes the Redraw call.

I have logged a bug about computing texture coordinates when object attributes are changed: https://mcneel.myjetbrains.com/youtrack/issue/RH-79898

Sometimes valid texture coordinates get copied when an object is duplicated. So in those cases the texture coordinate computation will usually be skipped completely.

We have gradually changed how texture mapping is done since Rhino 6. So it is expected that there is difference between Rhino 7 and Rhino 8 as well. However, if there is a model that shows significantly longer times for Rhino 8 then I would like to take a look. Please upload such files to Rhino - Upload to Support

Hey @curtisw, who would be the right person to assist with this?

Hi Jussi,
I have uploaded our file, thank you!

Thank you, I have received the model. I will inspect it next week :slight_smile:

1 Like

Hi Jussi,
Could you please provide an update on the problem?
If there are any additional documents required, please let me know. Thank you!

I could not see a big difference in times between Rhino 7 and Rhino 8 with your model. But I see different behavior in which calls take the time. Some plug-ins modify texture mappings and that could be the reason why your Rhino 8 behaves different to mine. You can run _SystemInfo command and send the report so I can check.

We are actively working on the texture mapping area at the moment.

Thanks for your replying!
I have uploaded our system information files to [ Rhino - Upload to Support
If there is any way to resolve or circumvent this problem, please let us know.
Thank you!