Car Paint nodes explanation

Post your tutorials and help questions in this forum
User avatar
Janusz Biela
Posts: 3992
Joined: Mon Mar 13, 2006 10:39 am
Location: Finland
Contact:

Re: Car Paint nodes explanation

Postby Janusz Biela » Wed Mar 09, 2016 8:21 pm

Please remember shader doesn't mean it will be good and fast.
To make good code is not enough to be good coder...you need to be really good - good. I know G. maybe is not fast (also this life event with child make some delays ) ...but he is FREAKING genius :idea: ....

thomas
Posts: 402
Joined: Tue Aug 31, 2010 9:59 am

Re: Car Paint nodes explanation

Postby thomas » Wed Mar 09, 2016 11:59 pm

Hehe, good to know. And of course I know that writing shaders is not easy: you need to find really brilliant ways to optimize your code and squeeze every last drop of performance.

User avatar
Keraressi Abdelkarim
Posts: 826
Joined: Sun Jan 24, 2010 4:44 pm

Re: Car Paint nodes explanation

Postby Keraressi Abdelkarim » Thu Mar 10, 2016 3:00 am

:mrgreen:
Last edited by Keraressi Abdelkarim on Thu Mar 10, 2016 3:01 am, edited 1 time in total.

User avatar
Keraressi Abdelkarim
Posts: 826
Joined: Sun Jan 24, 2010 4:44 pm

Re: Car Paint nodes explanation

Postby Keraressi Abdelkarim » Thu Mar 10, 2016 3:00 am

thomas wrote:Hi all,

By request of Lightwave3D (the Kray user, not the software), I'll share a little "car paint" nodes setup here. Let's start simple and expand on this in next steps. The result of this first step is shown here:
Car Paint Test 02.jpg


Okay now. Nodes always look complicated at first, but when you start to break things down into smaller components they are usually fairly easy to follow. Let's give it a try!

Basically what is going on in car paint is that you have a top coat of glossy varnish, and underneath is a paint coat in the color of the car, often in metallic paint. The top coat is very glossy, and the bottom paint looks very "matte", or with a very blurry reflection.

Explaining this in another way: a ray of light hits the top varnish coat of the car first. This coat is transparent, so the situation is simple: a part of the light is reflected, and the part of light that is not reflected is allowed to continue on and hit the second layer, the paint coat.

So let's recreate this using nodes!!!

First of all, you'll see in the node tree, that there is a ClearCoat fresnel calculation on top. This give the correct amounts of reflection for the glossy top coat, with an index of refraction of 1.45. The ClearCoat reflection is perfectly sharp, so we create a reflection "shader", and we multiply the fresnel value with the reflection shader (of the ClearCoat) which results in the correct total reflection for the glossy topcoat.

Let me explain a bit more why I work like this. The fresnel value tells lightwave HOW MUCH reflection there is for a given spot on our object, but not how sharp or blurry the reflection is. The reflection shader tells lightwave HOW SHARP the reflection is for a given spot (and how it is colored, and how much glancing stretch if you use this), but not how much reflection there is. To get the final reflection, you need to multiply HOW the reflection looks with HOW MUCH reflection there is. That is what the "ClearCoat Total Reflection" multiplier does. This multiplier is a VECTOR multiplier, because the reflection shader expresses a color value (RGB), and if a value has more than 1 component, you need to use a vector multiplier instead of a simple scalar multiplier.

Okay, now let's do exactly the same thing for the paint layer that lies under the glossy topcoat (the ClearCoat):

Create a Fresnel node ("Paint Fresnel"), with a value of 2.2 for a nice metallic reflection value, and create a reflection shader ("Paint Reflection (Blurry)") with blurriness set nice and high. I use the reflection shader from DP Kit, and I suggest you do the same because it allows you to set the number of samples you want to use, which is always handy. I set the blur amount to 250% and samples to 10. If you use the native LW reflection shades I think blurriness of 60% is okay (the value for the DP Kit reflection shader always needs to be a lot higher for the same effect).

Then, turn on the "tint refractions" for the reflection shader of the paint (I know, that should be "tint reflections" but it's spelled wrong in the node), and create a color node with the paint color. Then connect this paint color node ("Paint Color" in my setup) to the color input of the reflection shader for the paint. Now, as we did for the clearcoat layer, use a vector multiplier node to multiply the AMOUNT of the paint reflections with the SHADING of the paint reflections ("Paint Total Reflection").

Okay, now we have TWO reflections: one for the top glossy clearcoat, and one for the paint coat. We are going to add these two together, but first we need to make one more change to keep things "physically accurate", sort of:

The top coat get 100% of the light that falls on the surface. The paint coat however, does not get all of the light, because a part is reflected on the top coat. This means that only the part of light that is NOT reflected from the top coat goes on to the lower paint coat! Luckily the fresnel node has a handy "Inverse" output, that outputs the inverse of the reflection value, and this is the amount of light that goes on to the paint coat. If, for a given spot on the surface, the top coat reflection is 20%, then 80% of the light goes on to the paint coat. In this situation the fresnel result for the top coat would be 0.2 and the inverse would be 0.8. Since only the 80% (in this case) goes on to the paint coat we need to multiply the light going to the paint coat by 0.8.

This is hard to do with nodes, but that is no problem: we can also just multiply the output of the paint coat by 0.8, or better said by the inverse of the top coat fresnel value (since this means "the amount of light not reflected, so going through to the paint coat").

So, we need to multiply both the "Paint total reflection" node, and the inverse value of the "Paint Fresnel" node by the inverse of the ClearCoat fresnel. By the way: the top coat was 100% transparent, so there the inverse fresnel value meant how much light was let through the transparent coat. The paint coat is 100% opaque, so here the inverse fresnel means the diffuse value (= everything that is not reflected).

And that's about all I need to explain. So the paint fresnel INVERSE value (= the paint diffuse component) is multiplied by the ClearCoat inverse fresnel value, and the the paint total reflection is also multiplied by the same ClearCoat inverse fresnel value. The diffuse value can use a simple scalar multiplier, because it multiplies two scalars, but the "paint total reflection" is in RGB value so needs a vector multiplier.

Then the end is simple! Connect the base paint color to the color input of the final Surface node of the material, connect the multiplied diffuse of the paint coat to the diffuse input of the surface, connect a scalar 1 value to the reflection input of the surface node, and add the ClearCoat Total Reflection and the multiplied Paint Total Reflection (= "Paint Reflection * "rest" lighting) with a vector add node, and connect this last one to the Reflection shading input of the surface.

That's it! My fingers are tired :D

Object, scene and surface attached. Any questions?


WOWwwwwwwwwww MAn THANK YOU VERYU MUCH . i know it easy for u . hihi it hard for me. i gonna learn from this. thank u sir! (Y) :mrgreen: thnx for your time dudde.

THANK YOU THOMAS!

Fabian-Eshloraque
Posts: 76
Joined: Sun Nov 17, 2013 3:29 pm

Re: Car Paint nodes explanation

Postby Fabian-Eshloraque » Fri Mar 11, 2016 11:55 am

HI Kray Users,

I spend last night on making a car metallic shader. Here is the result: (first clearcoat, then flakes, then result combined)

metallic_kray-lightwave_Vs001.jpg


So here's a small overview of what I did:

1. Lightwave lighting: since lightwave does not render the lights in the reflection but only a simpel impression in the specular channel, I used specular on the clearcoat. Kray does make area light vissible in the render but neither of both render engines does it for spotlight. Aka the sun is not visible in a render on for example metallic surfaces. You can use the physical sky or sunsky to fix this. But I decided to clone my light and set one to specular and other to diffuse. The diffuse light I set to area light, specular light to spotlight.

So my conclusion is that you need to use specular on high reflective materials for outside scenes. (This is why for example Arnold is good for outside scenes, because its mainly a specular render engine)

2. For some reason I cant make a LM or layered material. I need to work on this. Maybe Janusz can help me a bit with it. So I made 2 models: 1 for the clearcoat (scaled 101%) and 1 for the base paint with flakes. This is how we use to do it back in the old days, we used to make SSS and stuff with this setup. If I can make the LM material then this is solved.

3. Render times are at 2 minutes. Will work on this, but its okay allready.

4. The clear coat is simple glass material with some darkening for the Fresnel. But I used specular to simulate the reflection of the sun.

5. Flake layer is half bump/normals. Other half is setup with cook terrance. This is a shader model driven by specular. I only use it to place the bright flakes where the specular from the sun is.

So now I will sleep a bit and maybe later I will tweak a bit and share the result.

TO NEWTEK: please make spotlights visible in render, this is something thats been an issue for too long. I understand thats its easy to use specular - but it should be in the reflection channel of the render. And how difficult is it to make a working carpaint material, even Unity has a cool one...

Best and I will keep you posted!

Fabian-Eshloraque
Posts: 76
Joined: Sun Nov 17, 2013 3:29 pm

Re: Car Paint nodes explanation

Postby Fabian-Eshloraque » Fri Mar 11, 2016 4:52 pm

So did not sleep, continued working on it.

So this is what you need to do:

Modeler:
1. Select body of car. Surface this as carpaint.
2. Copy body of car, set to new layer. Surface this as clearcoat AND Smooth scale it (modify > transform > more > smooth scale) Set to 3 mm. This creates the thicknes of the clearcoat layer.

Layout:

1. Copy my surface settings
2. Play with the values. Color of the clearcoat and carpaint. Etc. Some fresnels/incidenceangles needed to be done with curves. So open them and play with the values.

Surface settings:
Carpaint_Vs002.srf
(51.3 KiB) Downloaded 99 times

Clearcoat_Vs002.srf
(51.09 KiB) Downloaded 97 times

Let me know how it goes!

Best...
Attachments
Clearcoat_Vs002.srf
(51.09 KiB) Downloaded 82 times

thomas
Posts: 402
Joined: Tue Aug 31, 2010 9:59 am

Re: Car Paint nodes explanation

Postby thomas » Sat Mar 12, 2016 9:16 pm

Hi Fabian,

I checked your stuff yesterday, very interesting stuff, and I must admit I only understand half of it! :D I'll try to grasp more of it in the next few days!


Return to “Help and Tutorials”

Who is online

Users browsing this forum: No registered users and 2 guests