Author Topic: Corona Layered Material: Normal Map Combine  (Read 8711 times)

2020-01-28, 09:33:14

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
How are normal maps being combined in Corona Layered Material, e.g. overlay?

I have a Corona Layered Material representing a single texture set of a cellar door. The surface contains wooden and metal elements. In Corona, this material is implemented with a Corona Layered Material consisting of a dielectric (Base) and metal layer (Layer 1). Does the normal map of the base layer need to be piped into the metal layer, OR is the normal map of the base layer the "correct" representation of the bump?
« Last Edit: 2021-06-28, 21:38:08 by cjwidd »

2020-01-28, 16:10:21
Reply #1

steyin

  • Active Users
  • **
  • Posts: 375
  • BALLS
    • View Profile
    • Instagram Page
From what I recall bump/displacement only works in the base layer, so you have to overlay all maps there. Unless that got fixed....

2020-01-28, 16:29:07
Reply #2

Juraj

  • Active Users
  • **
  • Posts: 4761
    • View Profile
    • studio website
From what I recall bump/displacement only works in the base layer, so you have to overlay all maps there. Unless that got fixed....

Displacement yes,..but also bump? I thought bump has to be propagated to every layer.
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!

2020-01-28, 16:52:42
Reply #3

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12764
  • Marcin
    • View Profile
I just got some weird results here with the 27.01 V6 build. Will look into this.
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2020-01-28, 19:02:36
Reply #4

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
I should note, autobump is disabled in the posted images, legacy displacement (2.5D displacement is disabled). Corona version 5.

@steyin, Yes I have heard the same thing, that displacement only affects the base layer, but I have not heard the same about normal / bump. I was under the same impression as what @Juraj described, but maybe @Maru has identified something in the build that is affecting bump performance(?)
« Last Edit: 2020-01-28, 20:19:37 by cjwidd »

2020-01-29, 20:49:21
Reply #5

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
@maru did you end up identifying an issue in the build?

2020-01-30, 07:45:56
Reply #6

GeorgeK

  • Corona Team
  • Active Users
  • ****
  • Posts: 838
  • George
    • View Profile
How are normal maps being combined in Corona Layered Material, e.g. overlay?

I have a Corona Layered Material representing a single texture set of a cellar door. The surface contains wooden and metal elements. In Corona, this material is implemented with a Corona Layered Material consisting of a dielectric (Base) and metal layer (Layer 1). Does the normal map of the base layer need to be piped into the metal layer, OR is the normal map of the base layer the "correct" representation of the bump?

My take on this, is that order of bump seems to be based on mask intensity and type, there is a bump overlay/overlap from base layer but I would investigate this further, since displacement works strange for me in v5.
George Karampelas | chaos-corona.com
Chaos Corona QA Specialist | contact us

2020-01-30, 13:52:32
Reply #7

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12764
  • Marcin
    • View Profile
Returning to the 1st post:
If I understand it right (do I?) - there is only one normal map involved in this setup - right? It's like a "global" normal map for the whole door object. There is no separate normal map for the wood and for the metal?

If so, then I would say the normal map has to be plugged into the layer1 material and that's all.

I did some simple tests:
- Create material A with convex bump (bubbles)
- Create material B with concave bump (the same bubbles, but inverted)
- Create a layered material which will mix material A and B

The expected would be that setting layer to 50% should result in no bump at all, right? Because it should negate the other bump (the concave bubbles should negate the convex bubbles, or vice versa). But it doesn't work like that. It looks like it renders something like 50% visible convex bump and 50% visible concave bump on top of each other. This results in having something like fully spherical bubbles visible on the surface. :)

Another thing:
Let's say that we remove any bump from the layer1 material. The expected would be that there should be no bump visible in the resulting layered material at all, right? Because there is a layer1 material without bump on top of the base material which has bump. It doesn't work like that. Instead, we are getting some strange tiny bubbles.

I will now report this to our dev team, because right now I am not sure what is right and what is wrong. :)
I would be great to learn about some common use cases of layered mtl with bump - that would help us find the issues and come up with correct solutions.

Update: it's the same in V5 and V6.

Starter task:
(Internal ID=453249334)
« Last Edit: 2020-01-30, 14:10:21 by maru »
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2020-01-31, 10:59:11
Reply #8

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
I'm providing some renders under the three conditions described in the original post, but with an additional image rendered in Marmoset Toolbag for comparison. In MT, realtime light calculations are determined by the normal map, whereas the displacement map only displaces vertices without affecting light calculations, so you may see some displacement artifacts in the Corona render but not the MT render - there are artifacts in the map itself that are invisible in MT, but not Corona.

The images are meant to emphasize the light response to the normal map - try to ignore differences in color management.

It's not *entirely* clear whether the 'normal (base)' or 'normal (Layer_1)' is more veridical(?)

















« Last Edit: 2020-01-31, 11:28:11 by cjwidd »

2020-01-31, 11:20:17
Reply #9

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
@Maru I've uploaded the texture set to the private uploader for your convenience, you can see the screen grab posted above for the shader connections.

2020-01-31, 12:30:21
Reply #10

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8850
  • Let's move this topic, shall we?
    • View Profile
    • My Models
As far as i can tell, your layered material is composed of wood and metallic materials with distinct mask separating both materials. By not plugging normal map into either base or layer1, you just simply disabling normals details from wood or metal. Frankly, i don't understand what you're trying achieve here?
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2020-01-31, 19:18:19
Reply #11

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
@Romullus, I submitted the texture set to the private uploader if you'd like to take a look for yourself. The question the post is asking is whether it is more "correct" for the normal map to be plugged into the Base Material, Layer 1, or both the Base Material and Layer 1 for a Corona Layered Material. As you can see, the surface response of the material is different under all three of those conditions, but which is the correct method?

The texture set represents both a dielectric and metal surface, i.e. there are not separate textures representing the metal and wood surfaces, the surface is represented by a a single texture set - that is why the texture set is parsed into a Corona Layered Material with two sub-materials: a dielectric and a metal.

Importantly, in the above comparison post, the normal map IS plugged in to either the Base Material or Layer 1, i.e. the post is illustrating the visual difference. Disabling normals from either the Base Material Layer 1 is not depicted.

2020-01-31, 19:33:06
Reply #12

TomG

  • Administrator
  • Active Users
  • *****
  • Posts: 5468
    • View Profile
Romullus won't be able to see it on the private uploader, as he isn't a member of the Corona Team (just an incredibly useful, helpful, and invaluable forum member).

PS - and we wouldn't be able to share it with anyone outside of the Corona team, which is why it is called a Private Uploader after all :)
Tom Grimes | chaos-corona.com
Product Manager | contact us

2020-01-31, 19:38:16
Reply #13

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
Oh, Tom, my bad - I forget about this, although it does say so on Romullus' handle 🤦‍♂️

2020-01-31, 19:59:11
Reply #14

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
@Romullus, I can send the textures to you, personally, if you'd like to take a look. Otherwise the provided images should give some indication of what I'm trying to achieve.

2020-02-01, 00:19:21
Reply #15

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8850
  • Let's move this topic, shall we?
    • View Profile
    • My Models
As you can see, the surface response of the material is different under all three of those conditions, but which is the correct method?

But of course it is different... and that is expected outcome. If you unplug normal map from wood material, then wood will be rendered without micro details. In your case, the only correct way is to plug normal map into both materials. There's no other option. It seems that for some reason, you simply overthinking the "issue" :]
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2020-02-01, 02:23:10
Reply #16

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
That's right, it is expected that there should be a difference between the three possibilities, however, it is not clear based on the rendered image that plugging the normal map into both the Base Material and Layer 1 is the correct setup; insofar as it does not match the rendered output from Marmoset as well as either the case of when the normal map is plugged into only the Base Material or only Layer 1.

There seems to be some conflicting answers based on the information that is provided on the forum, but my impression was that the logic of how displacement maps behave in a Corona Layered Material (i.e. displacement only affect base material) would extend to normal maps as well.

2020-02-01, 03:01:46
Reply #17

PROH

  • Active Users
  • **
  • Posts: 1219
    • View Profile
Hi. This made me curious, so I made some simple test with Corona 5, and based on that it's clear that bump and normal maps doesn't work the same way as displacement maps.

If your use two different materials and a black & white mask, it's easy to see, that bump and normal maps follow the materials as expected, whereas displacement maps unfortunately only works in the base layer.

When the mask is greyscale however, there might be some differences in how the maps blend (like in Marus example). Can't say for sure, since I haven't tested this in dept.

2020-02-01, 03:17:33
Reply #18

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
Thank you for sharing your findings @PROH, this is *precisely* why I am posting; because the metalness mask I am using is a greyscale image, not a quantized black and white image.

2020-02-01, 09:39:47
Reply #19

sprayer

  • Active Users
  • **
  • Posts: 794
    • View Profile
maybe difference what you may see in marmoset because you need to invert channel on normal map and forgetting this what gives difference in corona?
Also there is topic in bug section how bump rendering different on Intel CPU in corona this also may be the case.

2020-02-01, 09:58:41
Reply #20

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
Marmoset defaults to OpenGL and Corona defaults to DirectX, iirc. For this example, the normal map is inverted in Marmoset, but not in Corona.

2020-02-01, 10:06:11
Reply #21

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8850
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Comparing directly to Marmoset, isn't the best idea, because difference in shading methods, can be deceiving. There is simple method how to test if Corona layered material is giving correct output. Create new Corona material and plug only normal map into it. You may want to add semi glossy reflectiveness and make sure that your lighting have enough contrast, to better see micro details. Assign newly created material to the door object and render it. Save picture to disk or render history. Now create layered material and plug your previous material to both, base and layer 1 slots. Add metallness mask, assign layered material to the door object. Render and compare with previous render. If two renders are different, then it means that Corona layered material doesn't treat normal maps correctly. If that's the case, then the only option to get trully correct output, is to use single material and performe blending through maps, not through materials.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2020-02-01, 12:27:54
Reply #22

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
Yeah, after conducting more tests, including the one you described (@Romullus), I agree: the only correct way is to plug the normal map into both materials.

The fact that the Corona Layered Material is being masked by a greyscale image is probably the only reason it was ever a question to me in the first place. In this example, the greyscale image masks the bump amount such that it is not *obvious* that one arrangement is wrong compared to another, particularly when viewed at a distance. In a close-up, it is clear that the correct arrangement is for both materials to receive the normal map in a Corona Layered Material.

2020-02-01, 20:28:37
Reply #23

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
Thanks for the clarification everyone, really means a lot, thank you :)

2020-02-11, 18:22:27
Reply #24

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12764
  • Marcin
    • View Profile
Ok, so just to close this thread and also officially remove it from my todo ;)

What happens when we have two materials with different normal maps and we are blending between them: basically it can be seen as just rendering both materials with 50% transparency and then stacking them together on layers. If you have concave normal on one material and convex bump on another material, blending them won't make the resulting surface flat, but instead will show both the convex and the concave bump. See: https://forum.corona-renderer.com/index.php?topic=27703.msg163341#msg163341
This may be a bit unexpected, and having different normal "blending modes" would be really great (so that for example one normal on top of each other would neutralize the underlying one, or would amplify it.

What happens when we have two materials with different properties and we want to blend them, but we want to show one normal map on the whole object: the above description applies. So if we apply the normal map to material 1 only, we will see it only in the areas covered by material 1. If we apply it to material 2 - we will see it only on material 2 areas. If we blend between the materials (for example using a gradient mask) - we will see the normal only on the material to which it is applied, and it will be fading into the non-bumpy material. To get the effect of a single normal map applied to all areas (material 1 and material 2), the normal map has to be applied to both materials.

I am adding an archive here and a .max file saved in 2017 format + renders showing different scenarios (hopefully self-explanatory when accompanied by the above description). Feel free to experiment.

There is also a small bug which produces weird artifacts under specific circumstances, but so far I encountered it just once, and it is reported. So forget about it. :)
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2020-02-11, 20:35:37
Reply #25

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
This is a really helpful demonstration, especially 'mat1mat2-gradient-mask.jpg' illustrates the transformation clearly

2020-02-11, 20:37:33
Reply #26

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8850
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Ok, so just to close this thread and also officially remove it from my todo ;)

I did little test too. I think there's definitely room for improvement in how Corona handles normal map blending. In attached examples you can see how normal maps are blended in layered material now and how it could look if normal vectors would be properly* averaged. I think difference is quite obvious. maru, i would like you to reconsider that and add this task back to your todo list :]

* that's the best what i could achieve in slate editor, using mix nodes, but i'm pretty sure that proper normal vector calculation and re-normalization would give even better results.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2020-02-13, 14:19:18
Reply #27

maru

  • Corona Team
  • Active Users
  • ****
  • Posts: 12764
  • Marcin
    • View Profile
Ok, so just to close this thread and also officially remove it from my todo ;)

I did little test too. I think there's definitely room for improvement in how Corona handles normal map blending. In attached examples you can see how normal maps are blended in layered material now and how it could look if normal vectors would be properly* averaged. I think difference is quite obvious. maru, i would like you to reconsider that and add this task back to your todo list :]

* that's the best what i could achieve in slate editor, using mix nodes, but i'm pretty sure that proper normal vector calculation and re-normalization would give even better results.

What exactly did you do here? In what way is the "unexpected" result different than the "expected" one (technically, not visually).
I think what you are showing here is what I described here:
https://forum.corona-renderer.com/index.php?topic=27703.msg163341#msg163341
So blending identical convex normal map with an identical concave normal map will show both with 50% transparency instead of showing fully flat surface - right?
Marcin Miodek | chaos-corona.com
3D Support Team Lead - Corona | contact us

2020-02-13, 14:35:39
Reply #28

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8850
  • Let's move this topic, shall we?
    • View Profile
    • My Models
No, not exactly.  Blending with opacity will give wrong results, because normal maps defines vectors and you can't simply mix them to gect correct result. Overlay blending gives more correct result, so that's what i did there. I'm attaching screenshot of shader tree. As you can see, it's not very practical and that's only with two maps. If you would want to mix three or more normal maps, the tree would get ridiculously complex. I could upload the scene with maps to private uploader if you want, i think i saved it somewhere on the disk.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2020-02-15, 00:47:41
Reply #29

Juraj

  • Active Users
  • **
  • Posts: 4761
    • View Profile
    • studio website
"Stacked" layering (not just of normals) always remind of the Ready&Dawn material system for Order 1866, everyone should look up that paper/presentation on it.

It would make material creation in CGI so much more logical, so much easier.

Current LayeredMaterial is just opacity blending in Photoshop..not very useful.
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!

2021-06-28, 21:36:29
Reply #30

cjwidd

  • Active Users
  • **
  • Posts: 1077
    • View Profile
    • Artstation
I completely forgot about this problem and then ran into it again during a recent project - what is the current best practice for this situation?
« Last Edit: 2021-06-28, 22:04:29 by cjwidd »