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

2024-05-30, 18:42:42

ATa

  • Active Users
  • **
  • Posts: 13
    • 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: 645
    • 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: 4804
    • 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: 13
    • 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: 13
    • 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: 645
    • 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: 13
    • 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: 13
    • View Profile

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

James Vella

  • Active Users
  • **
  • Posts: 645
    • 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: 13
    • 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: 645
    • 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: 1942
    • 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: 645
    • 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: 1942
    • 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: 645
    • 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 »