Download

How can I make a simple hardsurface shader that works like marmoset toolbag 2?

1st picture : How the object looks in marmoset toolbag 2.
2nd picture: My shader setup using the same textures I used in marmoset toolbag 2.
3rd picture: How the object looks in UE4.

I was really excited to see pbr like marmoset toolbag 2 in a game engine but so far I’m not getting the results I was looking for since I’m not a shader wizard. :confused:

UE4’s PBR uses information that you supply about certain properties to accurately determine what it should look like. The “Metallic” input tells the engine how metal-like it is. You’ll need a simple node network connected to Metallic, since I assume that your fire extinguisher is mostly metal. 0 means it isn’t metal, the closer to 1 the more metallic; you can adjust it with your texture and a Lerp node. Next you should disconnect specular and leave it alone, you should leave specular at default for metals or anything that behaves like one. Roughness is just what it sounds like, setting it to 0 will result in a perfectly smooth surface, a higher value will be rougher and light will be scattered. For the roughness, you can use a linear interpolate to vary the roughness between two values for different parts of the object based on the texture. This link is very informative and will help you understand what everything does. Study the Roughness section and play with the slider, it will help you achieve the results you want in conjunction with the metallic input; most of your mesh will need a roughness value in the higher range to look correct.

Why should I leave specular at 0? The whole point of the specular map is to control the reflectivity and reflected color of different parts of my object. I have 5 different materials In this mesh that marmoset was able to show through texture and not actual different shaders. For example I have plastic, rubber, paper, painted metal, and a chrome like metal that I want to be able to store all on one shader(glass was a different shader) that illustrates the principles from marmosets pbr workflow. It almost seems to me like UE4 forces you to do something similar to a metalness workflow but not all artists want to work that way I still like my specular maps. I guess I will have to read up on the material editor and try to find a way to get the same results I can get in marmoset. I was hoping it would be a bit simpler than that. I’m going to go through the example projects and see if they have a shader that does what I want first though.

Specular is not 0 by default. If you’d read that link you would know that; the specular input is not used by the engine for metallic materials either, and your mesh is mostly metal. If you want it all on one shader you’ll have to do a little more work than just plugging texture samples into stuff. You can use the aforementioned Lerp node to adjust values for metallic and roughness on the different parts of the mesh.

Specular is useless for metallic materials as MuchToLearn said. And you should use your roughness map to Lerp between different roughness and metallic values instead of using it directly like that. It works better that way.

Are you talking about RGB Mask packing? If so you can do it inside of UE4 but it’s not as simple as Marmoset makes it. You need to build that shader using either the make or break material attribute nodes or buy making a bunch of different material functions that you can blend together using the material Layer Blend nodes.

Toolbag is doing a good bit of tricks behind the scenes to get the subtle surface shading and reflections. The part that you will be missing is having a proper environment to reflect and shade the surface. Toolbag lets you change up cubemaps and environment maps to make it seem like its in different lighting conditions. If you preview your object in unreal without having some type of environment either faked (hdr on a sphere with inverted faces) or and actual scene you will never be able to replicate the results in a blue sky with a checkerboard ground. PBR materials and unreal are powerful that they let you do amazing things with specular and diffused reflections, but the real magic is always both the object that is doing the reflections and the stuff that its reflecting ie, car advertisements that have white cards placed above them for tight spec hits on incidence angles.

Hi Misciagno3d,

I would try unhooking the specular color texture you are using, and modify/tweak the surface properties of the metal by adjusting roughness and metallic inputs as others have mentioned. Ref:

http://upload.wikimedia.org/wikipedia/en/0/0d/USCG_AFFF.JPG

there is a white reflection (maybe little yellow) from what looks like a flourecent light, and a blue reflection on the side which looks like sky. You can achieve this look with a low roughness value, and low metallic value, some placed lights, and a more detailed ambient cubemap.

Realistically, the reflection on a red-painted fire extinguisher is not red, but whatever color the light that is shining onto the surface is (its paint, not metal). In previous tech, we used color in our specular to fake surface properties, and accent the color of an asset. We no longer need, or should do this (unless a specific style calls for it), your lighting and surfaces should be defined realistically - ie if its metal or nonmetal (0-1), smooth or rough (0-1), and allow the lighting and ambient cubemap to do the heavy lifting.

I’d also unhook the AO texture for the time being, and try only base color, normal, roughness, and metallic. I haven’t played with Toolbag, but have read about some people needing to invert the values or roughness used in it compared to UE4. 0 = smooth, 1 = rough. I like to think of it like 0 = false, so 0 roughness means rough is false - or it is smooth (mirror).

So I’ve tweaked the textures to try and get a more realistic look and played around with the shader stuff some more. I’m getting closer but still not getting the desired look. The difference between the first shader setup and the second was that the first had a map that was supposed to act like a mask to tell the shader what was metal and what wasn’t, the second setup just had the specular map in both the specular and metal slot(weird thing is that looked better imo but still not what I want).

I’m only double posting because I could not upload more than 4 images at a time. This is what I’m trying to get.

I think the engine folder in the asset browser has a few material functions that you can call in your material and those are made specifically for these things. You might want to search for those and bring them in your material then plugging them in. My answer to your issue is that you have to learn a bit the workflow of PBR and start evolving, Plugging 1 or 2 nodes wont do the job always. You will have to do a lot of things in order to get it right, But once you got it right you will have a basic template ready for this kind of objects. Metallic, Organic and so on.

PS: You can also open any of the example assets materials and see how they have those set up, They use those functions i mentioned about too.

It may also be worth noting that the Specular input does NOT respect colour information. I’m not sure what channel of the texture input it actually uses (I’m assuming red, but green has better DXT compression), but colour information into the specular input is NOT used. I’m not experienced with Marmoset at all, but I guess it uses a much more complex PBR system being a rendering program. UE4 is optimized as best as possible for quick framerates, and uses a much simpler system.

A detailed normal map might help the situation here, it looks like right now the normal map in UE4 isn’t breaking up the specular highlight as much as marmoset is.

Well see that’s the problem I’m having. In marmoset you can define multiple materials in one shader through texturing techniques and I learned their pbr methods, but UE4 is different. In marmoset you show weather something is a metal or not through the specular/reflective map there is no metal input like UE4 they seem to have a different approach to their pbr. CRYENGINE’s pbr is more like marmoset where its more texture based so I will probably just have to wait for that because I’m not really having a good experience with UE4 so far unfortunately. I feel like I have more control over the material when it relies on texture techniques more than what UE4 is doing. I’m sure UE4 lets you do more in the long run but I want to spend my time trying to get better with texturing and modeling right now more than trying to learn how to create shaders. I’m really surprised there aren’t like standard presets for ppl like me that have in depth comments that tell me exactly how the shader works. I’m not talking about the documentation for creating the shaders I can see that is clearly all there I just feel like there should be like a standard hard surface shader and a skin shader and other common stuff that relies on textures and not tweaking values in nodes and all this other stuff. I was really hoping to find something like that in the example projects but it doesn’t look like EPIC’s art team uses that type of approach at all because of the way their pbr is set up. I’m starting to think UE4 just isn’t for me to be honest.

A couple of quick pointers that might help:

  1. Best to avoid touching the specular input at all! It probably doesn’t do what you think it does. We’re thinking about renaming this property.
  2. Metallic is almost always a 0 or 1 value. How many surfaces do you know that are “half metallic”? (There are some- car paints for eg. Are not described very well with this shader, but your example here does not have any half metallic surfaces)
  3. If unsure, use a mask and tweak the vales with a lerp. (If you set up the material and make a material instance from it, you can tweak the values in real time without recompiling- we probably need to improve the material workflow to make it this easy all the time :slight_smile:
  4. Does your test scene have a reflection capture actor in it? If not, your metals aren’t going to look right! Having an interesting background will help you get the best results.

Can’t wait to see your results once you get it ironed out :slight_smile:

Nick

https://docs.unrealengine.com/latest/INT/Engine/Rendering/LightingAndShadows/AmbientCubemap/index.html

You need to make a mask to define which parts are metallic and which parts are not. Then use that mask to Lerp between different roughness and metallic values. Metallic materials give colored reflections, so, if you want the red paint to have a bit of colored reflections then give it 0.2 - 0.3 metallic value. It will also help boost the reflections.

Edit: I was late. Listen to Nick. :slight_smile:

Another thing to look for - your grayscale textures may be getting gamma corrected, and will alter the values being used to set the roughness or metallic property. Uncheck sRGB on those textures, or set to TC_Mask compression.

Maby Cube map brink in?
PS didn`t read post up))

First of all, even if marmoset is using physical based shading…they have to take care about way less things than Epic, because Toolbag features small scene renders without functionality compared to UE4 which is a game engine.
Of course they have to approximate differently so save computing power. Also…Toolbag has a forward renderer which, for example makes it a lot easier to properly implement translucent shading.

However, it is still possible to provide results that come very close to Toolbag2 with UE4.

Some of the things needed are already explained in posts above, but for the sake of completion, I will just quickly summarize what I did to achieve good results. Since I am at work right now, I cannot provide an example for you, but if you are interested I could add one as soon as I am back home in the evening :wink:

So, what makes stuff in Toolbag look like it does? (thats the first question you need to answer) Mainly, Toolbag uses Image Based Lighting to a) make a nice ambient light environment (fake GI) and b) provide reflections based on that image.
So what you should do first is: get in a nice HDR cubemap (sometimes you can get lucky and find the same one online that you specified in toolbag) which you can put into the scene. You also might want to have that image mapped onto your skydome, so you should also import the jpg file that is mostly with it as well so you can map it on the skydome (hdrs dont really work well for that).

Next thing is that you should decide if you want it static or dynamic. If you want it static, add a skylight to your scene, if not, chose the ambient cubemap slot in the post volume (note that you can also do it dynamicaly with the skylight, …basically just dont bake it…but you will loose the nice shadowing from it when you do not bake it) If you go for the skylight, you can switch from captured scene to use a cubemap which would then be your HDR image.

If you now put your asset into that scene, you will have almost the same lighting situation as in Toolbag.

Then you can add additional lights that match sources and directions found in the HDR image. Toolbag does something like this as well.

Now lets get to the interesting part…shaders:

First of all, that marmoset does not use metallic is not really true. Toolbag has the option to switch to whatever workflow you prefer. So if you want to use metallic, just switch under reflection from specular to metallic, and blub…you will need a metallic mask instead of a spec map, and color bleeding for metal reflection is defined by their color in the albedo/diffuse/base color/whatever map.
Then you can use a gloss map under microsurface…that means that black is rough and white is glossy. However, you can also say that you want to use roughness (where black is glossy and 1 is rough), so you switch the slot to that and enable sRGB and bämm…looks the same as before if you did it right^^

What that means is, just put all these maps into unreal as you used to (you just need that metallness map) take your glossmap and put a 1-x node after it and use it as a mask for the lerp to get more control over it. Also, you need to uncheck sRGB in the texture properties as mentioned by someone else here.

That should actually get you quite close the Toolbag2. The rest will just be tweaking and improving things.

BTW: If you are working like that, then you dont need reflection capture actors because the ambient cubemap is also your reflection. And if you go for dynamic, they dont work anyways since they read from the lightmap data which is obviously not there if you go for dynamic lighting :wink:

Okay Mister Misciagno3d^^

I know you wrote me a pm and we could have handled it that way, but I think we might all benefit if I share my findings openly here

So, first of all…this is how my Wheel looks like in Toolbag 2 without too much tweaking

http://imagizer.imageshack.us/v2/xq90/21/1jhi.png

I basically do exactly what I described in my last post (this is for the dynamic setup now…so no baking etc. However, I am still using the skylight since it looks more accurate than the AC from the post volume)
When all the textures are in, I build my material which looks as basic as this here:

http://imagizer.imageshack.us/v2/xq90/594/oyvx.jpg
Note that the tesselation is plugged in, but not working right now…need to set this up properly^^

And after some minor changes in the post volume (mainly locking the auto exposure, deactivating lens flare, bloom almost and dof (only suuuper slightly to blur the bg)) it looks like this:

http://imagizer.imageshack.us/v2/xq90/833/j0jr.jpg

So this is almost out of the box. Just spend like 10 minutes to tweak the light direction and played a bit with some color correction stuff in the pp (cannot stop this =D)

I would say they both look pretty convincing. I know the roughness for example is not yet there on the wheel in UE4, but hey…spent 5min more on tweaking the power and lerp and you are there :slight_smile:

Cheers