Translucent Material Function - Layered Car Paint Shader

Hey everybody,

I am building a multi layered car paint shader, which includes three layers: Base coat, metallic, and clear coat. So far I have made good progress on the first two layers. The one that is giving me trouble is the gloss.

I am unable to make a translucent material function, to act as the clear coat, which will be blended on top of the other two layers.

When I plug in vector for opacity in a material function, it does not affect the transparency. Normal materials require you to change the blend mode in the details box of the shader, to create a translucent material. There is no translucently drop down in the details box of a material function. Is there a method could use to make the material function behave as translucent glass?

You can’t get that coating effect by merging translucent and opaque in the same material. You’ll have to fake it in the same opaque material somehow.

Interesting, I was hoping there was a stock way around it. I did discover a technique using a seperate piece of geometry for the clear coat. Once I get home I’ll do some tests and post up some images. It was looking promising!

Yeah, you can use a duplicate of the mesh on top of the original one to give the coating effect but it would require some crazy work to do for a whole car. :\

What does your material setup look like so far?

It’s interesting, because I am using the same geometry with the painted materials, added the clear coat shader to it to the duplicated geometry, and there hasn’t been any of the negative effects I would have expected. No Z fighting or other artifacts.

My shaders are a little messy because of all the experimenting. Eventually I will clean them up and optimize, add parameters for instancing as well.

This first shader is the gloss clear coat, being added to the duplicated mesh. It’s fairly simple with added grunge and orange peel normal map.

This second material is handling two shaders, the base color, and a metallic shader for the paint flake. The individual flakes are being driven by the alpha blend. I was originally going to use this layering technique for the entire shader, but because the clear coat didn’t work out, I think I will condense these three shaders into one material. Although blending two materials into a third makes adjustment simpler, I don’t think it’s worth having all the materials separated.

These are the results so far. Still needs a lot of work. But I think I will be going forward using this technique. If I get it looking good enough, I’ll put together a tutorial for my process.

Have you considered using Fresnel? You can have effects like these and push the reflections to the edges if you play around with it:

You can also use your flake texture again as a mask to Lerp between that fresnel roughness branch and another value.

Edit: The bike looks awesome, btw. :slight_smile:

Cool! I will have to give that a shot today.

And thanks on the bike! I am developing a Cafe Racer game. I’m keeping up a blog here: caferaces.com

I’ve not had much time to work, but I have been able to produce some good looking results! The fresnel helps complement the look of some of the features.

Hey man,

this looks quite cool (but also familiar if you followed the Marmoset Toolbag2 discussions over on polycount^^)

Actually I am working on the same thing as you so I just wanted to share some thoughts. :slight_smile:

First of all, I think your shaders look really nice and you have been able to really stretch what is possible with translucency right now. I also tried it, but I threw it away for the following reasons:

-no good reflection support for translucent materials (no caption actor blending + low rez quality, no SSR support)
-no support for specular highlights from light sources

The specular highlights together with SSR are the most important things not working atm, so I never really got the desired results. However, I would like to get back to it as soon as has Epic upgraded their translucent shader model to be rendered forward so we will get all this working.

However, this will also make it way more expensive because of the second rendering pass.

So I tried my second way with which I was able to get very convincing results. However, please note that the paint shader is far from being finished (actually I am way further down the road than you will be able to see in the images, so I have to update the thread :D)

Feel free to check out my post over at the Unreal forums to see my results:

What I tried with the second technique is quite interesting to work on and its also a lot of fun :smiley: Basically I mask the roughness with fresnels and flake textures and also some fresnel on the base color and metallic to get the impression of multilayered carpaint.

So I have flakes that have super low roughness to give that sharp reflection, and they also add to the metallic and the in betweens have a higher roughness to give that more smooth feeling combined with fresnels and clever masking.

As mentioned, the screens are a bit outdated, but you can see in which direction it is going. :wink:

Would love to get some feedback as well and will update the thread soon with new stuff :slight_smile:

Cheers!

Hey there,

I’m glad to hear that I’m not the only one hitting walls while creating car paint shaders. I haven’t had much time to condense my multi-layerd shader into a singal shader, but it does seem like a strong method for getting, good looking results at the moment.

I don’t have the chops for coding my own shaders, but I like the idea of using multi layered shaders to simulate car paint. I believe it is the correct path for simulating the most accurate surface. Using the physically based rendering system to its fullest.

That being said, the limitations of the stock shader systems is preventing the material from reaching the point where it is: versatile, performs well, and reflects light correctly.

My shader system’s greatest shortcoming is real-time reflections on dynamic lights. Because the 3D capture actor doesn’t update in real time, reflections with dynamic lights are pretty much impossible - at least with my limited knowledge of the engine right now.

I know Forza team did not use real-time reflections for their entire paint shader. They used blended capture maps for all the undercoats. The only surface that used real-time reflections was their clear coat.The session about Forza shaders at GDC 2014 by Arthur Shek was extremely enlightening. If you have access to the Vault, you should definitely give it a watch.

Right now I’m working with what Epic is offering, but I agree with you: to get these shaders really looking right, we need the translucent materials to be improved. I imagine it will take some time for that to happen. But I have faith in the UE4 dev team. UE4 has given us so much cool new stuff to work with, I don’t mind waiting for a bit, or taking the initiative to start coding my own shaders.

Good luck with your project! I will keep an eye on your post and any progress you make.

Best of Luck!

-Vince

Here is a shot of my latest progress on my material.

Regarding real time reflection, yes it is possible!

Add a Scene Capture Cube component to the vehicle actor.

Create a TextureRenderTargetCube on the content browser, and assign the Scene Capture Cube component to update that texture.

On the material, add the TextureRenderTargetCube and as its UVs, add a Reflection Vector node. Connect this texture to the material’s Emissive.

There is an example of this in the Content Examples, I think it’s on the Reflections map.

Oh, I forgot to mention: in a full scene, this is very heavy for performance. I’m using 64 for my cube capture size (default is 256) and the performance drop is noticeable.

Hey man

thanks a lot! I still think your stuff looks awesome for what can be achieved right now, but you are totally right with the shader limitations.

However, dont get confused with the layered materials :wink: Its not a multilayered material^^ Epic uses this term because they layer multiple material functions that have features of real materials into one material, but its actually quite far off of a multilayered mat^^ (you can basically just lerp them on a per pixel level, but you can not really do see-through stuff)

Like you encountered as well, you can not use different base shaders. A real multilayered BRDF however can do that because it can calculate transmission/translucency in one layer and can then render different shader characteristics below it.

Most of the newer car racing games do exactly that: they use a layered BRDF.
There is also stuff on the net about this…TriAce for exampled shared some research papers on multilayered BRDFs and David Miranda was able to custom code HLSL shaders using their approach for Unreal 3. However, UE4 doesnt support custom lighting due to g-buffer constraints/limitations, so the actual shader slots (opaque, translucent etc.) are hardcoded. You could for example drop one of these and implement your own custom BRDF, but that requires quite some sick knowledge of that stuff xD

And btw…IMO I dont think that the cars in forza look that good^^ Their paint shader is pretty weak compared to others and the cars still have that kind of plastic feel to them, so I dont know what exactly they are doing wrong/different^^ I would say that GT has way better paint shaders and they even looked better on PS2. What I would aim for now when it comes to quality is definitely project cars, that thing just always blows my mind when I see it :smiley:

Thanks a lot for you feedback and opinions! Highly appreciated! :slight_smile:

PS: what you could do for realtime reflections, add render to texture to the player vehicle (only this one^^) but thats very cheaty

Hey man,

just a small update, this is where I am at right now with my paint shader.
Just keep in mind that this is showed on a unfinished highpoly model with superbad quick UVs :smiley: (flakes texture has stretching etc^^)

http://imageshack.com/a/img838/7791/edpq.jpg

Just for the sake of contribution i gave it a go and here’s the results;

and two more here;


And the material setup;

I’m not sure what you mean by real time reflections from dynamic lights not working though, Stimpanzee. Screen space reflections work as expected with dynamic objects, sometimes you may see black surfaces because of the screen space behaviour when you use fully dynamic lighting. You may also consider using a skylight too, and even go for LPV if you havent tried it already.

Awesome! Similar to Unreal 3 then. I will have to give this a shot sometime soon. Thanks!

I need to play around with the content examples more often.

Thanks for the detailed info. I am by no means, a shader guy. I have a lot to learn with materials and UE4 in general.

I don’t know if I would ever have the drive to learn the skills to code my own layered BRDF system, but I sure wouldn’t mind having one. I’m curious what the performance cost some of these modern shader systems are.

Gran Turismo has always been my favorite as well. It’s quality and attention to detail is pretty much unmatched.

I think he means the following…since he is using the translucent second shell, he doesnt get SSR because they are not supported yet…so it looks like no dynamic stuff is reflecting :wink:

BTW…nice results Jacky! would love to see this without this crazy post and a nice HDR image :slight_smile:

Looks good! I would love to see what it looks like being rendered on my machine. Pictures don’t do it justice.