Hi,
I tried to add the ClearCoat block and add the typical PBR ClearCoat to the material, but it won’t work. I tried to do it similar like in the PBR D20 dice playground… but I have no clue why adding the ClearCoat outputs show no result.
https://nme.babylonjs.com/#UU0EXV#2
If you might wonder - I try to have a different color on light parts than on dark ones (like car paint). And the perfect result would also allow ClearCoat reflections on the mesh.
I tried nearly everything but without any result
Cheers
Robin
Okay, I tried to start from scratch. That made no sense at all
Step 1:
create a playground using the node material.
https://playground.babylonjs.com/#FL6LH3
it seems there is a bug with the reflection node of the PBR…
Do you know… those days when nothing works…
the console screams:
Offending line [182] in vertex code: vec3 reflectionVector = vec3(reflectionMatrix * vec4(normalize().xyz, 0)).xyz;
It seems you need to reuse the WorldPos
block and connect it to the worldPosition input of the PBR block and not create a new one (which is also better for performance).
In your first PG:
- add a
ReflectionBlock
- either remove the
ambientOcc
input or set it to 1, not 0
- link directly the lighting output to the fragment block (the
flakesTexture
being empty, you will get black color in the end)
- indexOfRefraction = 0 is not a valid value. You should either remove the connection (it is not mandatory), or set a valid value.
With those changes: https://nme.babylonjs.com/#UU0EXV#8
1 Like
Your hints helped a lot.
https://playground.babylonjs.com/#FL6LH3#1
I’m using 2 fresnel nodes for the colors. Looking quite good so far. Now I have to add the flakes. I guess best would be to add them as a kind of normal map I guess?
I think @PatrickRyan will know better than me for this one.
Yes, @Robin_McLaut, you will want to use both a normal map and a custom metallic map so that you can set your paint flakes to metal while the paint substrate is dielectric. If you look at some of the car paint materials that Allegorithmic has produced on Substance Source, you will see that they have quite a lot of information built into the normal map of the paint, knowing there will be a clear coat over it. To illustrate, this is one of their metallic flake materials with no clear coat, rendered large on a shader ball:
There is a lot of variation in the normal map to account for the flakes which will actually be very small so the detail does not have to be crisp. Using the same noise texture, the metallic map switches between metallic and dielectric so that the base color of the flake will be reflected in the specular reflections on each flake (giving it a metallic feel).
Your clear coat normal will smooth out the environment reflections on the surface of the material, but you want the undercoat of paint to be a bit noisy so that you reinforce the metallic flakes in the paint. Hope this helps you visualize what you need to do.
2 Likes