Author Topic: Impact of Mesh Topology on the Refraction Behavior of Glass (Curved Surfaces)  (Read 5856 times)

2024-05-30, 18:42:42

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Impact of Mesh Topology on the Refraction Behavior of Glass (Especially Curved Surfaces)
Hello,

I have a question regarding the impact of mesh topology on achieving realistic refraction of glass in Corona. As a professional 3D modeler, I primarily use CAD-based software like Rhino, which doesn’t require extensive adjustments to topology and edge flow, unlike 3ds Max or Blender.

In offline render engines like Corona or V-Ray, achieving accurate light behavior and refraction in glass materials often necessitates using quad meshes, especially on curved surfaces. Adjusting weighted normals or smoothing groups often doesn’t resolve shading issues, leading to jagged and inaccurate refractions. (See attached images: Pic 1 with quad mesh, showing perfect refraction, vs. Pic 2 exported from Rhino without quads, showing jagged refraction.)

When exporting models from Rhino as meshes in FBX or OBJ formats, the resulting meshes are precise but not in quad form. This non-quad topology causes issues with physically accurate refraction in traditional render engines. These refraction shading issues are particularly noticeable on curved surfaces!

My question is: Will the Corona developers consider implementing changes to the light solvers or other algorithms so that accurate refraction of glass does not depend on quad mesh topology? As you can see from the attached images, thanks to the precision of CAD software like Rhino, we can achieve highly precise 3D models that are 3D printable or fabricable, regardless of whether they use quad or non-quad meshes.

It's crucial for render engines to tackle these refraction issues caused by mesh topology. Current solutions, such as the Weight Normal modifier in 3ds Max, are not satisfactory. If Corona can address these challenges, it would allow us to focus more on the quality of render outputs rather than being constrained by mesh topology and normals. CAD applications offer great precision, and it's time for render engines to align with these capabilities and resolve the issues related to quad topology and refraction.

looking forward to the feedback.

2024-05-30, 19:15:07
Reply #1

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Triangulated mesh shouldnt make a difference, It sounds more like your smoothing groups (or some UV error if you are using them).

Quad:
Quad" border="0

Triangulated:
Triangle" border="0

Quad Wire:
Quad2" border="0

Triangle Wire:
Triangle2" border="0
Triangle3" border="0

2024-05-30, 19:17:40
Reply #2

Juraj

  • Active Users
  • **
  • Posts: 4800
    • View Profile
    • studio website
Weighted normals are often weird in Corona, not sure if Corona reads them correctly. It looks correct in viewport, but then Corona often does something else.
I think Pokoy and Romullus have investigated this issue. Too bad because it can often be one-quick solution to shading CAD files. I too work often with Rhino.
Please follow my new Instagram for latest projects, tips&tricks, short video tutorials and free models
Behance  Probably best updated portfolio of my work
lysfaere.com Please check the new stuff!

2024-05-30, 19:49:40
Reply #3

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Thanks, James. As you can see in my render, the reflections are accurate, but the shading issue is related to the refraction behavior. The file "2 mesh.jpeg" is an exported OBJ from Rhino.

2024-05-30, 19:59:02
Reply #4

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Yes, exactly, Juraj! The weighted normal modifier not only behaves weirdly in refraction but also ruins reflections. So, I decided not to use it in Corona Render, even though it should be an improvement, but it isn't in fact!

2024-05-30, 20:05:26
Reply #5

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Can you upload this mesh for inspection? Im curious now. No textures required.

2024-05-30, 20:31:15
Reply #6

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Yes sure, both of these meshes are closed and have their own specific smoothing groups. They are directly exported from Rhino, are precise for 3D printing, and have real-world scale.

2024-05-30, 20:34:03
Reply #7

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile

2024-05-30, 20:58:29
Reply #8

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Would be best if you also upload the quad version for comparison.

However I put your obj2 in the scene, rendered with corona sky/clouds & hdri, looks fine.

Are you using the Corona Physical Glass Preset?


2024-05-30, 22:36:13
Reply #9

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Thanks, James. To ensure everything is the same in the rendered scene, it would be better to use the same HDRI, which is the 4K free one available from https://polyhaven.com/a/canary_wharf . The quad version is just a simple one for testing, which I modeled in 3ds Max. And yeah, I'm using the new Corona Physical material.

2024-05-31, 11:06:17
Reply #10

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Ah yes I see what you mean. As a test it also does the same thing in Vray. Welding, Edit Normal, Smooth, Crease modifiers dont seem to help either. Ill take another look this evening and see if I can find anything useful. When I rebuilt it using a clean mesh it worked as expected. Edit: Doesnt rhino have a quad mesher now, does it help at all?
« Last Edit: 2024-05-31, 11:14:18 by James Vella »

2024-05-31, 11:16:45
Reply #11

pokoy

  • Active Users
  • **
  • Posts: 1936
    • View Profile
The OBJ exports are fine and render perfectly for me, you are probably removing normals either on import or with an operation/modifier in Max.

There's a difference in how surface normals are created in CAD apps vs Max.
In CAD, the surface curvature is typically perfectly described by mathematical functions (yeah, super simplistic way to put it) and for mesh display/rendering, the surface is tesselated, with each triangle/polygon getting a surface normal derived from these functions which is very accurate and independent from mesh resolution. The result is that, even for coarse tessellation, the surface curvature looks good. This is called 'explicit normals' in Max and you should always try to keep them when importing CAD meshes into Max.

In Max, the concept of smoothing means that surface normals are calculated by averaging the face/polygon vertices which is heavily dependent on the tessellation and will be worse than what CAD apps are doing, especially with triangulated meshes (quad meshes are better suited for this).

It looks like you are not importing explicit normals correctly, or removing/invalidating them in Max. Various modifiers will invalidate explicit normals on imported CAD meshes, so will space warps, Booleans (or attaching/detaching mesh elements in earlier Max versions). Once invalidated, Max will fall back to using smoothing groups which will not look well on triangulated meshes, this is what's happening here.

On OBJ import make sure, that in the dialog's 'Normals' section 'Import from file' is enabled.
To check if a CAD imported object has correct normals in Max, use an 'Edit normals' modifier on the object - if it displays green normals, you've imported and kept them, and the object will render fine. If they're blue, it means you have either not imported them correctly, or some operation/modifier has removed them. Unfortunately, there's no way to get them back in Max without re-importing the object.

You may be facing a different issue with CAD meshes further down the road where the shadow terminator may look jagged (with non-transparent materials). This is due to the way Corona handles lighting vs surface normals. Let us know if you see this, there's a way to fix it but it may not be satisfactory. But it's unrelated to the issue you've been running into.
« Last Edit: 2024-05-31, 12:02:21 by pokoy »

2024-05-31, 12:11:49
Reply #12

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Strangely pokoy my normals are green on object import, and it still does the same behavior as Ata describes. When I rebuild it its clean (ignore the warping along the poles of there sphere I cut)

File attached (hdri too large, just download from Ata link)
« Last Edit: 2024-05-31, 12:24:10 by James Vella »

2024-05-31, 12:24:04
Reply #13

pokoy

  • Active Users
  • **
  • Posts: 1936
    • View Profile
Strange, what do you mean by rebuild? The mesh looks like it's the same...

I'm on Max2021 with Corona 9hf1 so can't open your file. It might be that it's why I'm seeing a different result but I doubt it.

2024-05-31, 12:25:09
Reply #14

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Strange, what do you mean by rebuild? The mesh looks like it's the same...

I attached the file (previous post), I just rebuild the mesh using a sphere, cut it, shell it and apply the same glass material and place it kind of in the same location as original imported obj (its rough but its kind of close, missing the bottom extruded lip but the reflection on the surface is easy enough to see from here). Check the layer names

edit:
Ah I see what you mean, yes this is his mesh wireframe, just showing its green (normals). This is the wire from the rebuild mesh. Again the poles are a problem but im just looking at the main surface.
« Last Edit: 2024-05-31, 12:32:54 by James Vella »

2024-05-31, 12:27:52
Reply #15

pokoy

  • Active Users
  • **
  • Posts: 1936
    • View Profile
I'm on max 2021.

Looking at your mesh screenshot, the wire looks identical in both cases (imported, not rebuilt), that's why I was asking.

2024-05-31, 12:33:18
Reply #16

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Ive attached the 2021 version to my previous post.

2024-05-31, 12:34:15
Reply #17

pokoy

  • Active Users
  • **
  • Posts: 1936
    • View Profile
Oh wait, I'm seeing it now, missed the artifacts on the lens type of mesh. The cylindrical mesh looks good however. It's strange indeed.

@OP - can you post the CAD objects exported to IGES or STEP? Since you can import these in Max it's worth trying going with CAD formats imported directly instead.

2024-05-31, 12:38:55
Reply #18

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
The cylindrical mesh looks good however. It's strange indeed.

I thought so too at first, but when I rotated it a little more I start to see the center seam (not as bad stretching as the OP but it shouldnt have this seam)

2024-05-31, 13:28:33
Reply #19

pokoy

  • Active Users
  • **
  • Posts: 1936
    • View Profile
You're right, seeing this one now, too.

An explanation might be that the OBJ exporter does that, or the import does weird things.
Another reason might be that the objects aren't modeled accurately in the CAD app. The tessellation on both objects suggests that there are irregularities in the surfaces itself, these might be a result of manual placing of control points. Especially for the cylindric mesh, the tessellation should be completely regular at the center but it's not, suggesting there actually IS a sharp seam.

I'm currently reconstructing both objects in CAD to check if accurately modeled surfaces would introduce similar artifacts. On a quick cylinder test, I'm not seeing any problems at all.

@OP - if you can, please share both objects in CAD formats, either 3dm, STEP or IGES will do.

2024-05-31, 14:56:45
Reply #20

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Hi James,

As you can see, the unusual shading issue on refractions is still present. Smoothing groups and normals are exported correctly, as these issues only occur with the refraction of glass; the reflections are accurate.

Hi Pokoy,

I am an experienced 3D modeler using Rhino (CAD-based software). The exported 3D meshes are simple curved surfaces with low complexity, yet the unusual render outputs from Corona suggest that the issue might be related to the light solver and rendering algorithms of engines like Corona. Consequently, I am posting these refraction render issues here in the hope of receiving assistance and potentially seeing improvements from the active developer teams.

Creating quad or non-quad meshes is a technique to achieve precise 3D models, not an end goal. CAD-based 3D software can generate highly accurate meshes that are 3D printable and more, without the need for time-consuming topology optimization. It would be highly beneficial if render engine solvers could separate realistic refraction behavior from topology, regardless of whether the mesh is quad-based or not.

For instance, 3ds Max added the Weighted Normal modifier due to the importance of bridging 3D software meshes together, but it cannot handle the refraction issue. I hope the Corona engine can address this specifically, as it is a rendering issue and not a modeling one.

As illustrated in the attached pic1, my normals are correctly exported as an OBJ file. I understand the importance of explicit normals, and for this case, I also tried exporting in FBX format, but the refraction issues persist.

I appreciate any insights or suggestions you might have to improve the realistic output and address the refraction issues. 🤠

2024-05-31, 15:10:21
Reply #21

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Interestingly when I import this into blender and use one of the built-in HDRIs. Indeed the geometry looks correct (same obj as the one imported into 3dsmax).

2024-05-31, 15:19:51
Reply #22

pokoy

  • Active Users
  • **
  • Posts: 1936
    • View Profile
At least for the cylinder, there's a tiny angle at the center. In my CAD test object, there's no seam visible. You probably mirrored one half of the object but there's a tiny angle at the center, resulting in a slight break in surface continuity. Sorry if you feel like I'm stepping on your toe but the tessellation suggests this, too, and I just can't think of any other reason why a cylinder should have a slight angle at its center.
For the lens object - mine looks less mangled but it still displays some clearly visible artifacts at the edges.

In Corona, light/camera normals and surface normals are two different things, similar to how shadows will produce artifacts on the shadow terminator or SSS/absorption will reveal geometry tessellation. On top of that, Corona can't properly handle explicit normals in some cases. At least for the lens object, it's quite inacceptable.

Devs/support should chime in and give their perspective but this is a long standing issue and with the current target audience (archviz/DCC apps not CAD) I guess the priority will be low.

For the record, I totally support this and think that CAD objects should render perfectly in Corona, too.

FWIW, I'm rendering some comparisons and will post images + a max scene.

2024-05-31, 16:21:27
Reply #23

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Oh, James, could you provide more render shots by rotating the object in the viewport?

Thanks, Pokoy. but the convex shape is an accurate model. As you focus and zoom in to the boundaries of the topology, refraction issues start to appear where the quad meshes change into non-quads!

2024-05-31, 16:31:44
Reply #24

pokoy

  • Active Users
  • **
  • Posts: 1936
    • View Profile
Here are my tests:

1. Cylinder - original object -> seam visible


2. Cylinder - reconstructed in CAD -> no seam visible


3. Lens - original object -> heavy artifacts visible


4. Lens - reconstructed in CAD, imported as BodyObject, Face Angle 10 -> less artifacts visible


5. Lens - reconstructed in CAD, imported as BodyObject, Face Angle 1 -> no artifacts visible



The cylindric objects - mystery remains but it looks like a clean start resolves the issue.

As for the lens - yes, artifacts will be visible, probably due to the fact that Corona doesn't interpolate explicit normals (like it does for normal smoothing).

The only solution (or rather a workaround, not a solution) I found is to use high tessellation. If you import the original CAD file in an format that Max can read, you can dynamically change the tessellation to whatever is needed.
For this to work: Import file > Convert to Mesh = OFF, this will import the object as a BodyObject where tessellation can be controlled at any time.

Attaching a zip file with the max 2021 scene and the exported IGS CAD objects from MoI3d.

FWIW - @OP, you'll find similar problems with shading for non-transparent objects. Two options to handle this:
- again, high tessellation
- or: Render dialog > 'Development/Experimental Stuff' rollout (might have to be enabled in Corona System setting, enabled by checking 'enable devel/debug mode') > 'Terminator Handling' > set 'Shadow Shift' to 1 (0 by default). This will mostly fix shadowing artifacts on CAD models. Might however introduce shading artifacts on low resolution geometry using standard Max smoothing.

Guess development needs to have a look at properly handling CAD normals sooner or later. We have to use workarounds for quite some time now so please have some mercy devs :D
« Last Edit: 2024-05-31, 16:49:09 by pokoy »

2024-05-31, 16:41:51
Reply #25

James Vella

  • Active Users
  • **
  • Posts: 640
    • View Profile
Blender file attached (Blender 4.1 required), just go to render mode in viewport and click on the object and rotate it, it looks fine from all angles.

2024-05-31, 17:38:50
Reply #26

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Yeah, the 4. Lens.jpg you uploaded shows the same refraction issue that I have. As you said, it seems it's time for Corona developers to tackle this refraction issue. I was hoping the new physical materials in Corona could handle it, but they can't. Considering the fact that a vast number of professional 3D artists sync their meshes between CAD-based 3D software like Rhino and 3ds Max, it could be a priority to resolve! 

Let's enhance rendering to be more realistic and seamless for everyone!🤠
« Last Edit: 2024-05-31, 17:43:49 by ATa »

2024-06-01, 23:47:25
Reply #27

ATa

  • Active Users
  • **
  • Posts: 12
    • View Profile
Corona Team,

Today, I decided to investigate further into the jagged refraction issue on glass renders. I applied the retopology modifier to the mesh to convert it into quads, hoping it would solve the problem. However, as you can see from the attached pictures, the issue has worsened.

As discussed previously, this mesh is a closed OBJ export from CAD-based software (Rhino7). It's a simple model without complexity, including its smoothing groups and normals. Despite testing various methods like weighted normals, the problem persists, indicating a rendering issue rather than a modeling one.

For 3D artists, importing/exporting between CAD and non-CAD software and adjusting topology (quad or non-quad) are standard practices. These modeling techniques should not negatively impact rendering.

Please provide an explanation and resolution for this bug in future updates, or if I am mistaken, help me resolve it, as this issue is quite frustrating.

Thank you for your attention to this matter.

The OBJ mesh is attached for reference.

2024-10-14, 11:36:16
Reply #28

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 13154
  • Marcin
    • View Profile
Sorry for reviving such an old thread, but I have some findings:
- The issue is related to refraction, not reflection. You can check this by assigning a Corona Legacy Material to the object and then enabling refraction only without reflection (or reflection only without refraction).
- The object renders the same (with the jagginess error) in both Corona and V-Ray. I doubt that both renderers are doing something wrong, so I would blame the CAD > Max import process. Something gets wrong with the mesh smoothing and it results in broken refraction.

Unfortunately, I don't think there is anything we could fix in Corona here.
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us