Chaos Corona Forum

General Category => General CG Discussion => Topic started by: lacilaci on 2017-12-06, 17:12:20

Title: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2017-12-06, 17:12:20
Hi guys,

I'm curious how you think about CAD-exported type of 3D models.

Let's say Rhino or Alias etc, pre-tesselated models. Not messy and overlapping geometry but no subD and clean topology.

Do you use these type of models in your viz or other type of renderings or do you avoid it and prefer clean subD topology?
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-06, 18:37:18
If you get CAD data from a client you probably don't have time and resources to remodel but that certainly depends on the amount of work. Remodeling can be beneficial (more organic appearance, less problems when unwrapping) but some things are just super hard or impossible to model with polys/subDs alone. Tris aren't a problem unless you happen to use tools in Max that invalidate explicit normals, in that case you are going to either have to live with shading problems or remodel... or fix normals manually, super cumbersome if too many.
However, current Max versions handle NURBS meshes well most of the time - it was much worse with max 2012 for example - and there are workarounds that help you keep the normals intact.

We are using a lot of CAD data here but the quality varies a lot, some models have all the details but are constructed sloppily, for example when surface patches aren't sewed and you get tiny holes between them. This is actually a common problem since CAD programs may tesselate on the fly and always display perfect meshes, CAD people usually aren't really aware of the fact that this may causes headaches for other folks down the road.

Some datasets are really great and clean but may not have sufficient detail or don't reflect the final product. CAM data used for production is very detailed and has all the final changes in it but many of the last second changes aren't back-ported into the CAD model once the data is handed out to the manufacturer to save cost.

Depending on the desired level of detail, we either add small stuff and details as separate poly objects, keep everything as is if it's good enough or remodel if it solves a lot of problems in one go and is manageable in regards to the budget and deadline. Sometimes I'll use MoI3d (an inexpensive NURBS modeling app, however not as powerful as the full-fledged packages) to sew patches, clean out garbage data, cut holes, add chamfers etc. IF possible.

One thing I'm grateful for is that importers are now included in Max, this makes it a lot easier, though both importers (Body Objects vs ATF) have their issues.

But CAD data is such a broad topic - what info exactly are you after? :D
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2017-12-06, 19:17:06
Thanks for that answer.

I'm trying to figure out best way to tesselate my cad models and want to know what other people find important in cad-exported data, or even if they would use such if there was an option to go for clean topology instead of controlled surface.

One important thing you mentioned was sewing/welding vertices. But what if tesselation was good enough that the elements touch and possible gap between meshes would be under a 0.01mm? Would it still be a problem?

I was working with cad data for long time and never cared about such things as long as client got what they wanted. But now i have a chance to work with rhino/alias and if i end up sharing my models i want to make sure the data is readable for someone else and also good enough quality.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-06, 20:20:07
I see. Yes, the sewing part is important because it's something that can't be fixed in Max once it's tesselated, and the Body Object will often fail to sew open edges properly... and it has no undo. So working with problematic NURBS geometry in Max is quite a painful and fruitless endeavor. In addition, if you happen to discard explicit normals, be it intentionally or accidentally, Max' smoothing will not be able to build smoothing groups correctly across patches. It will produce artifacts in all cases, but if patches aren't sewed, edges will not line up between adjacent surfaces and it's likely to produce even more artifacts.

If you want to sell/hand out tesselated models, I really like how you can evenly divide the surfaces with Body Objects. Usually, NURBS packages will export meshes where some tris may end up being reeeeally long and thin, and if you'd like to deform or bend the object in Max you're screwed and end up having to remodel those objects.

One thing I haven't mentioned that's quite important is accuracy in NURBS. I have seen quite a few models that suffer from trim leftovers that NURBS internally use for chamfers and subsequent booleans, where spheres or cylinders will be visible in places that were chamfered. The more accurately the models are constructed the better are the tesselated results. Your CAD app may not display any problems but you never know what the exporters and importers do.

Best way to test the quality of CAD models - for Max, can't speak for other use cases - is to import as Body Object and go through a few of the tesselation options and see if/when they break. For example, do you get open edges that never close regardless of the level of detail? Are the geometries coming in as solids or do you always get open edges? This is often a side effect of low accuracy that works fine in the CAD app but not in the vertex world.

Yet another thing to keep in mind though is that the current Body Object library in Max is outdated. It's licensed from NPower but apparently they don't use NPower's most recent libraries. I've come across a considerable number of STEP and IGES files that will have issues when imported as Body Object but import perfectly fine when using current plugin versions from NPower. Maybe newer Max versions use newer version of their tech, but for Max 2016 it's not the case, and I doubt it since they focused on their own ATF importers with Max 2017 and up. It's a bit of a black box, unfortunately.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2017-12-06, 20:45:47
Yeah i used default max importer and also npower translators in past. However the more complex objects the more deffective import seemed to be. From missing parts to ineffectively tesselating some areas while over - tesselating others. Body object options help here and there especialy from rhino and siemens nx exports from what i've seen. However so far the best results I've seen were direct object exports from alias(optimal polycount, no defects, basicaly you can get nice result as seen in viewport ) Still connections not welded but so far I haven't seen rendering defects...

Will probably share here some excercise models, but need to finish them first.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-06, 21:36:09
Great, if you share something I can have a look.

As you say, the ATF importer is too black-boxy for me, no control over the tesselation and inconsistent density. What it does really good, though, is that it'll manage to get perfectly closed solids without errors, and everything's welded correctly. But, too little control for my needs.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: Shawn Astrom on 2017-12-07, 02:05:24
I use MOI for geometry conversion has an amazing capability for exporting. Still though Corona has issues reading the notmals correctly in C4D. Maybe someone could actually test MOI exports inside of 3ds Max to see how they look?

- Shawn
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2017-12-07, 06:47:52
Never used MOI but from experiences with alias, it's much easier to fix normals in there before export, than in max.

Usualy the surfacing software will need evaluation tool to show where are the surfaces facing.

If you checked normals in MOI and they turn during export it might be a bug though.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-07, 08:24:46
I use MOI for geometry conversion has an amazing capability for exporting. Still though Corona has issues reading the notmals correctly in C4D. Maybe someone could actually test MOI exports inside of 3ds Max to see how they look?

- Shawn
Not sure if the shadow terminator fix made its way into C4d, but if this happens only with Corona try disabling it if the controls are exposed. In Max, it will produce artifacts in some cases when used on CAD meshes with explicit normals.

If you happen to have a CAD mesh that has problems, post an OBJ here and we can compare how it looks in Max.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: Shawn Astrom on 2017-12-07, 17:18:18
Thanks so much pokoy! Below is a link to the .obj file and some reference renderings of the issue with Corona and Cinema 4D normals/vertex normals not being rendered correctly... This had been driving me crazy because every other render engine I use renders these CAD exports just fine :)

Let me know what you think. Here's a link to the .obj file I tested... https://we.tl/d10e1ltBDu

- Shawn


I use MOI for geometry conversion has an amazing capability for exporting. Still though Corona has issues reading the notmals correctly in C4D. Maybe someone could actually test MOI exports inside of 3ds Max to see how they look?

- Shawn
Not sure if the shadow terminator fix made its way into C4d, but if this happens only with Corona try disabling it if the controls are exposed. In Max, it will produce artifacts in some cases when used on CAD meshes with explicit normals.

If you happen to have a CAD mesh that has problems, post an OBJ here and we can compare how it looks in Max.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: Shawn Astrom on 2017-12-07, 17:32:41
P.S. I still feel as if Corona is not reading Cinema's Vertext Normals (tag) correctly apart from the shadow terminator fix... I believe the latest C4D beta is using the 1.7.2 Corona core...
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2017-12-07, 17:58:43
I've looked at your obj and there are no problems in rendering until i try to remove smoothing groups and do an autosmooth inside max. Then it gets weird and shows those artifacts.

EDIT: I think one way of solving this would be to actually keep the fillets unwelded so that smoothing doesn't go from fillet to another surface. But if that obj is all you got to work with, that might be a problem.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2017-12-07, 18:18:46
The way I think about it is, that one thing is tesselation tolerances and another welding tolerances.

If you have good tesselation tolerance set up connections between surfaces can stil create tiny gap that might not even be visible during rendering until you go super close.

But if you enforce welding, then some vertices might get moved and break surface continuity and also smoothing will be prone to artifacts. If the model is built to some class A standards bellow 0.003mm i guess, then a really good tesselation could be made even if you need super crazy close ups..
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: jasond on 2017-12-07, 18:31:08
The default cad format importer in Max is horribly outdated. If you work with IGES or Step files more often, take a look at PolyTrans (https://www.okino.com/conv/conv.htm), been using it for a few years now on all our CAD assemblies. You can fully customize your import options and mesh quality... You won't get perfect quads but you'll get good enough tesselation that might solve the problem with your current model. All the welding, etc. is done for you (unless the cad model is sketchy).
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-07, 18:50:56
Sorry but it's really the shadow terminator fix, at least in Max.

Have a look at the attched images (apparently we can't use attached images in the posts):

CAD_Geometry_Viewport.jpg - This is how it looks in Max. Actually, there's a problem with how Max reads the MoI object. It retriangulates n-gons and will mess up holes, at least for Max you should always export OBJ with tris&qads from MoI. But still, normals are perfect.

CAD_Geometry_Terminator_Fix_OFF.jpg - Rendered with Shadow Terminator set to OFF (value = 1, not 0 as one would assume)

CAD_Geometry_Terminator_Fix_ON.jpg - Rendered with Shadow Terminator set to ON. Say hello to normal artifacts.

In C4D though, it could be that explicit normals are recalculated, I think this would happen if Corona assumes the Phong tag automatically. To be sure, you should disable the Shadow Terminator fix and see if it helps. If it doesn't help you'll have to talk to the devs to see if they handle explicit normals correctly in C4D.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-07, 18:52:49
Conclusion: If you want to render CAD meshes in a clean way without normal issues, always disable the Shadow Terminator fix.

(At least for now, let's see if that can be fixed)
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: Shawn Astrom on 2017-12-07, 18:53:14
The geometry conversion out of MOI is fantastic and works wonders for getting clean meshes from .STEP or other CAD formats. The problem is Corona or at least the Cinema 4D plugin is not reading the vertex normal tag in Cinema correctly IMHO.

Every other renderer I've used for these CAD files translates the normal shading correctly, Arnold, Redshift, Vray, and both Physical and ProRender inside of Cinema render these meshes without artifacts.

Can someone post a Corona render of the .obj file I provided to show that Corona can, in fact, render the geometry correctly? If this is the case than we know that it is something wrong with C4D Corona plugin... Thanks, everyone looking into this and testing it out :)

- Shawn
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: Shawn Astrom on 2017-12-07, 18:56:08

Thank you Pokoy! This is what I needed to see! I think you have found the issue! I'll see if I can turn off the shadow terminator in C4D but I'm not sure if that is possible at the moment...

Thanks again this is wonderful!!!

- Shawn



Sorry but it's really the shadow terminator fix, at least in Max.

Have a look at the attched images (apparently we can't use attached images in the posts):

CAD_Geometry_Viewport.jpg - This is how it looks in Max. Actually, there's a problem with how Max reads the MoI object. It retriangulates n-gons and will mess up holes, at least for Max you should always export OBJ with tris&qads from MoI. But still, normals are perfect.

CAD_Geometry_Terminator_Fix_OFF.jpg - Rendered with Shadow Terminator set to OFF (value = 1, not 0 as one would assume)

CAD_Geometry_Terminator_Fix_ON.jpg - Rendered with Shadow Terminator set to ON. Say hello to normal artifacts.

In C4D though, it could be that explicit normals are recalculated, I think this would happen if Corona assumes the Phong tag automatically. To be sure, you should disable the Shadow Terminator fix and see if it helps. If it doesn't help you'll have to talk to the devs to see if they handle explicit normals correctly in C4D.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2017-12-07, 19:26:45
Well well, so is this a bug then?
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: houska on 2017-12-07, 19:27:59
Well well, so is this a bug then?

Yep it's a bug in the terminator handling that is in the Core and thus appears both in Max and C4D
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-07, 19:32:30
Well well, so is this a bug then?
According to Ondra it's a limitation, or better a side effect of the terminator fix. Unfortunately it's not feasible to exclude arbitrary objects form the fix as it's a global thing. I'll try to point him to this thread and see what he says.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-07, 19:33:49
Well well, so is this a bug then?

Yep it's a bug in the terminator handling that is in the Core and thus appears both in Max and C4D
Ok then - so it is possible to fix? That would be fantastic.
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: Shawn Astrom on 2017-12-07, 19:41:56

Here is a new test setting the Terminator to 1 in Cinema 4D. This is great news for me! This will work for the time being for my CAD assets!!!

Thanks, guys so much for the help!

- Shawn
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: pokoy on 2017-12-07, 19:56:21
Glad it worked! There's nothing more frustrating than hitting a wall on something one would expect to be trivial.

If a fix is possible I'd be super happy to get it. Right now it's like with a blanket that's too short - it's either cold shoulders or cold feet :D
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: Shawn Astrom on 2017-12-07, 20:00:24
Yeah, for now, this is great for me! I'll be interested to see how this effects other good quad based geometry though... I'm going to have a play around some more with some other files...

Thanks again!!!!!

- Shawn


Glad it worked! There's nothing more frustrating than hitting a wall on something one would expect to be trivial.

If a fix is possible I'd be super happy to get it. Right now it's like with a blanket that's too short - it's either cold shoulders or cold feet :D
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2017-12-13, 08:59:15
Alright,

So here's my "first" surface/nurbs modeling attempt.

It's a philips air purifier, I was doing it by just a handful of pictures and rough overal dimensions so not technicaly precise at all.

I think best way of exporting and sharing such model would be split by material so that it can be shaded very quickly, I did all the details in the mesh so no textures..

I still haven't found best way to tesselate the mesh. One big problem is that even though I model to catiaV5 tolerances I absolutely have to close even a 0.002mm gap otherwise it will screw up tesselation and depending on where it happens it might show up in rendering pretty badly.

I explored most of the recommended options of export/tesselation and sadly since I put some insanely small fillets in there every option fails in different way unless I blow up polycount to sky(then everything works, of course).

So, the question is now, ho many poly is too much :D? What angers me the most, is that low-poly is not really an option since the mesh will break terribly in that case.

Anyways, if you find any use for this object, go ahead: https://we.tl/gVVW2OCnQw
Title: Re: CAD / NURBS surfaces vs clean topology
Post by: lacilaci on 2018-01-10, 15:42:25
Continuing with my suffering/learning nurbs modeling...

Is there anyone who knows how to meaningfully UV map cad models?

I mean, those models always have nicely unwrapped patches by default, however not sure how to create continuous UV across patches that are not welded and are not flat so simple projection would not work.

Basicaly I guess what I need is to know if I can sort of align and keep aligned edges of UV shells/islands while unwrapping... :/