Planetside Software Forums

General => Terragen Discussion => Topic started by: cyphyr on June 28, 2019, 06:15:53 AM

Title: PBR Workflow
Post by: cyphyr on June 28, 2019, 06:15:53 AM
I have been looking at some of the models produced by KitBash3D and really like the quality and variety of their models. I will probably get a couple of kits when they are next on sale (they are on the pricey side but you do get about 30 models per kit!).
They use PBR images for their textures.

My question regarding Terragen is about the application of the PBR texture.

I assume that the sliders in the default shader should be set to 1 where a texture is loaded since the value of the texture is held within itself rather than in the shader node.
A fully black texture with the defuse slider set to 1 will give a fully black output.
A 50% grey texture with the defuse slider set to 1 will give a 50% output.
By setting the slider to 1 this allows the PBR texture to fully control its own values (as PBR textures are designed to do).
Is the above correct?
Obviously once this is set up the sliders can be tweaked for fine control.

Secondly in the specular tab should I be using Glossy or Metal textures?
Either way I assume the slider should be set to 1 to allow the PBR to do its work.

Thanks and advice greatly appreciated

Richard
Title: Re: PBR Workflow
Post by: digitalguru on June 28, 2019, 11:01:59 AM
Interesting question,  I'm curious how those would to preserve energy conservation since AFAIK the TG shaders are not energy conserving.

Seem to remember a post where Matt showed how to balance translucency with diffuse to keep energy to equal 1 (with a kind of percentage formula) I guess the same would hold true with specular conservation too.

QuoteObviously, once this is set up the sliders can be tweaked for fine control.

I would modify the source images rather than tweaking the shaders, I'm doing a project where I'm mixing the same populations both in Terragen and Maya and keeping the adjustments to the bitmap level meant both renders matched very well.
Title: Re: PBR Workflow
Post by: Matt on June 28, 2019, 02:23:45 PM
I've edited this post to add instructions for the Fresnel effect on metals, and also updated the instructions for using roughness maps.

Quote from: cyphyr on June 28, 2019, 06:15:53 AM
I assume that the sliders in the default shader should be set to 1 where a texture is loaded since the value of the texture is held within itself rather than in the shader node.
A fully black texture with the defuse slider set to 1 will give a fully black output.
A 50% grey texture with the defuse slider set to 1 will give a 50% output.
By setting the slider to 1 this allows the PBR texture to fully control its own values (as PBR textures are designed to do).
Is the above correct?
Obviously once this is set up the sliders can be tweaked for fine control.

Yes, that's all correct.

Quote
Secondly in the specular tab should I be using Glossy or Metal textures?

If you have a glossiness map, use that, but enable "invert roughness image", because glossiness is the inverse of roughness.

If your metalness map is close to black, just ignore it. But if you have highly metallic surfaces then you should take a different approach.

I assume that if you have a metalness workflow then you also have an albedo (or base colour) map. For non-metals (i.e. dielectrics, which most materials are), albedo or base colour should be assigned to "diffuse colour". For metals, albedo or base colour should be assigned to "reflectivity".

To create a non-metal surface:

1. Set "diffuse colour" to white (1). Assign the albedo map to "diffuse colour image".
2. Set "reflectivity" to white (1), "reflection tint" white (1). You can use "index of refraction" at the default value of 1.5.
3. Set "roughness" to 1.0. Then either assign your roughness map to "roughness image" or use a separate Image Map Shader to load your roughness map and then plug the image map shader into the "roughness function". If you use an Image Map Shader you can experiment with the "data is linear" option on its Colour tab. Make sure you set the Image Map Shader's projection mode to "UV (if available)", and enable "Tile X" and "Tile Y" to avoid some surprises.

If you have a glossiness map instead of roughness, assign the glossiness map to "roughness image" and enable "invert specular roughness image".

To create a metal surface:

1. Set diffuse colour to black. This is important.
2. Make your surface highly reflective by setting "reflectivity" to 1 (no texture map) and "index of refraction" to 10.
3. Assign your albedo map to "reflectivity image".
4. Set "roughness" to 1. Create a separate Image Map Shader to load your roughness map. Then connect the image map shader into the "roughness function" of the Default Shader. Make sure you set the Image Map Shader's projection mode to "UV (if available)", and enable "Tile X" and "Tile Y" to avoid some surprises.
5. Add a Reflective Shader after the Default Shader (the Default Shader should feed into the main input of the Reflective Shader). Set its roughness to 1, and connect the same roughness function that you did for the Default Shader. The reason to use a Reflective Shader is to add a Fresnel effect to make the reflectivity ramp up to 1 at glancing angles. In the real world this occurs even on dark and coloured metals. Without it your edges might look too dark.

If you have a metalness map that has different values within it, then really you need to mix two materials and use the metalness map as the mix controller. You can use a Merge Shader to do the mixing, and make use of its "mix controller" input. For most natural objects the metalness should be black (0) so you don't have to do this.

Notes on roughness vs. glossiness:

As I said earlier, glossiness is basically the inverse of roughness. But there may be discrepancies between renderers if they use a different mapping between 0 and 1. I plan to add more options to the shader to control the gamma/colour space of the image to help account for these differences. Without those options, you may need to experiment with gamma corrections of 2.2 or 0.454 on your roughness and/or glossiness images.

I recommend using a separate Image Map Shader to load the roughness map. This way you can experiment with the "data is linear" option on its Colour tab. This also helps if you need to connect the same roughness function to more than one shader, which happens a lot.

If you see any these issues, please send me comparison renders of what something looks like in TG vs. what it looks like in other renderers. This helps me understand what changes I need to make or what options I need to provide in the UI.

Matt
Title: Re: PBR Workflow
Post by: Matt on June 28, 2019, 02:32:16 PM
Quote from: digitalguru on June 28, 2019, 11:01:59 AM
Interesting question,  I'm curious how those would to preserve energy conservation since AFAIK the TG shaders are not energy conserving.

Seem to remember a post where Matt showed how to balance translucency with diffuse to keep energy to equal 1 (with a kind of percentage formula) I guess the same would hold true with specular conservation too.

This only applies to translucency. If you don't use translucency then the Default Shader is energy conserving as long as you stay within the slider ranges for all parameters.
Title: Re: PBR Workflow
Post by: cyphyr on June 28, 2019, 02:57:14 PM
Thanks Matt.
Good to have it laid out systematically.
Title: Re: PBR Workflow
Post by: digitalguru on June 28, 2019, 03:25:50 PM
QuoteIf you don't use translucency then the Default Shader is energy conserving as long as you stay within the slider ranges for all parameters.

Good to know, and ditto Cyphyr's comment, great to see the shader recipe laid out, bookmarking this post!
Title: Re: PBR Workflow
Post by: WAS on June 28, 2019, 03:55:47 PM
Quote from: Matt on June 28, 2019, 02:23:45 PM
To create a metal surface:

1. Set diffuse colour to black. This is important.
2. Make your surface highly reflective by setting "reflectivity" to 1 (no texture map) and "index of refraction" to 8.
3. Assign your albedo map to "reflectivity image".
4. This is the same as for non-metals: Set "roughness" to 1.0. Assign your roughness map to "roughness image". If you have a glossiness map instead of roughness, use that but enable "invert specular roughness image".

If you have a metalness map that has different values within it, then really you need to mix two materials and use the metalness map as the mix controller. For most natural objects the metalness should be black (0) so you don't have to do this.

The Metallic directions don't seem right. The output is very bugged. Certain angles of the surface just come out black (couple maps weren't on repeat), and the material doesn't look right at all. It does have a high value metallic map, but it seemed to just indicate everything reflective but the pock marks so I ignored it.

https://cc0textures.com/view.php?tex=Metal05
Title: Re: PBR Workflow
Post by: WAS on June 28, 2019, 04:01:16 PM
Seems much more closer to the textures just using the metallic as reflectivity, roughness as roughness and albedo as albedo.
Title: Re: PBR Workflow
Post by: Matt on June 28, 2019, 07:38:02 PM
WAS, you'll get better results with the path tracer. But the appearance depends a lot on the environment. The screenshot on the website appears to be an interior shot.
Title: Re: PBR Workflow
Post by: WAS on June 29, 2019, 01:27:12 AM
Quote from: Matt on June 28, 2019, 07:38:02 PM
WAS, you'll get better results with the path tracer. But the appearance depends a lot on the environment. The screenshot on the website appears to be an interior shot.

I did a test inside a illuminated cube, with a "ceiling" light just for good measure, and it was immediately still wrong and not even worth finishing.

I think with the case of rough metals, one may have to do a mix of the two methods -- metallic albedo, and than metallic map reflectivity. This gives the richer depth from metallic albedo, but allows for indirect surfaces to still be somewhat lit, not as bright as it would be in a entirely lit cube, with additional light source however.

Also a note; PT is sooo slow inside a cube -- and still a issue with only 55-70% CPU usage across both cores / four threads -- additionally CPU doesn't feel the need to boost itself any and peaks at 3.7 instead of going to overclock limit of 4.2ghz. The benchmark renders pretty quick but also doesn't use all my CPU.

Added a TGD of what I was doing, maybe I am doing something wrong with your method (top one). Textures located here: https://cc0textures.com/view.php?tex=Metal05

It's possible this is related to the fact this metallic surface is suppose to be highly diffused due to imperfections, and the provided displacement doesn't adequately allow for this effect with TG shaders without an additional displacement map mixed in.
Title: Re: PBR Workflow
Post by: WAS on June 29, 2019, 01:57:38 PM
Also having issues with TG suddenly not reading displacement correctly for PBRs or displacement based on images. No matter what, TG will only apply displacement in certain points, and by points, I literally mean points. It ignores all other data, despite plenty of it throughout the whole image.

https://cc0textures.com/view.php?tex=Ground23

This is the texture set, and it cannot produce the displacement provided by the texture set, nor any custom displacement maps I give it. The always only have a tiny points of peaks. No matter how intense, or how smooth I make it, the same issue occurs.

FYI, nothing is wrong with the maps, they render right in Unreal/Blender/CrazyBump, and I've used this shader set before and remember leaf-like shapes and branches, not this weird effect.
Title: Re: PBR Workflow
Post by: DannyG on June 29, 2019, 03:56:28 PM
I was messing with these a lot some time ago, I do know with ground textures like this 8K is the only way to go anything else will look cheesy. Not sure what size you guys are using. This is my test with 8K
Title: Re: PBR Workflow
Post by: WAS on June 29, 2019, 04:01:01 PM
Quote from: DannyG on June 29, 2019, 03:56:28 PM
I was messing with these a lot some time ago, I do know with ground textures like this 8K is the only way to go anything else will look cheesy. Not sure what size you guys are using. This is my test with 8K

Interesting. I'm using 8k too, including edited 8k maps from diffuse.

Wait, I see the problem, I left the image source enabled in the default shader!!
Title: Re: PBR Workflow
Post by: DannyG on June 29, 2019, 04:50:04 PM
Here a render w/ pathtracer & exaggerated srf details.
Scale on your file is 5m. I would definatly make that 1m X 1M also Add the AO map, pass the basecolor & AO through a multiply color
Title: Re: PBR Workflow
Post by: WAS on June 29, 2019, 05:14:14 PM
Quote from: DannyG on June 29, 2019, 04:50:04 PM
Scale on your file is 5m. I would definatly make that 1m X 1M also Add the AO map, pass the basecolor & AO through a multiply color

Yeah, as noted, I upped scale trying to debug the issue.

PT makes the mug/dirt look much more realistic and not like puddy. Probably the exaggerate details. Can work in some cases, but can look really bad in others (grainy).

Repairing some of the broken cc0 textures I got in the rock category (the ones with lines in their seams). I'll probably re-upload them here (since they are CC) so they can be used properly.
Title: Re: PBR Workflow
Post by: Matt on June 30, 2019, 05:10:32 AM
Quote from: WASasquatch on June 28, 2019, 03:55:47 PM
The Metallic directions don't seem right.

You're right. I forgot to add something to handle the Fresnel effect on metals. This is needed to make glancing angles highly reflective for dark or strongly coloured metals. I've edited my instructions to include this now.

I tried the textures you linked to ( https://cc0textures.com/view.php?tex=Metal05 ). They work better if you enable "data is linear" on the Image Map Shader that loads the roughness map.
Title: Re: PBR Workflow
Post by: WAS on June 30, 2019, 12:21:57 PM
Cool thank you, also, I'm curious, with metallic surfaces with coloured metallic based on albedo, would it be safe to use albedo as diffuse and it's metallic coloured as reflectivity?

Also about displacement, it may be well worth while to disable base input if a function is fed, or maybe make them work together and just apply both displacements instead of the weird effect I was getting.
Title: Re: PBR Workflow
Post by: Matt on June 30, 2019, 02:48:01 PM
Quote from: WASasquatch on June 30, 2019, 12:21:57 PM
Cool thank you, also, I'm curious, with metallic surfaces with coloured metallic based on albedo, would it be safe to use albedo as diffuse and it's metallic coloured as reflectivity?

Not really. That would give a different result than what the asset creator intended.
Title: Re: PBR Workflow
Post by: Matt on June 30, 2019, 09:27:18 PM
Here is my setup using the Metal05 textures from cc0textures.com:

https://planetside.co.uk/forums/index.php/topic,26668.msg265894.html#msg265894
Title: Re: PBR Workflow
Post by: WAS on July 01, 2019, 12:31:11 PM
Quote from: Matt on June 30, 2019, 09:27:18 PM
Here is my setup using the Metal05 textures from cc0textures.com:

https://planetside.co.uk/forums/index.php/topic,26668.msg265894.html#msg265894

I've noticed a subtle, but interesting inversion of lighting on the sphere with direct light sources facing same directions as the camera. It's visible in your second image too. The colour (albedo) of the pocks (especially) simply picks a boundary to invert colours in darkness, taking on a blur black tone from red brown. The fresnel also takes on a suddenly darker tone too.
Title: Re: PBR Workflow
Post by: Matt on July 01, 2019, 05:22:25 PM
I think I set the displacement too high. It has this problem because it's not true displacement, just bump mapping, although the displacement changes where the terminator occurs.
Title: Re: PBR Workflow
Post by: WAS on July 01, 2019, 06:16:39 PM
Quote from: Matt on July 01, 2019, 05:22:25 PM
I think I set the displacement too high. It has this problem because it's not true displacement, just bump mapping, although the displacement changes where the terminator occurs.

Good catch, that makes sense. I didn't think of that and was thinking reflection due to colour inversion effect.
Title: Re: PBR Workflow
Post by: Matt on July 01, 2019, 07:05:01 PM
Reducing the displacement amplitude to 0.003 gives this:
Title: Re: PBR Workflow
Post by: WAS on July 01, 2019, 07:53:42 PM
Quote from: Matt on July 01, 2019, 07:05:01 PM
Reducing the displacement amplitude to 0.003 gives this:

Yeah that's what I ended up at too, looks much better, smoother transition. Thanks again for the example.
Title: Re: PBR Workflow
Post by: WAS on July 02, 2019, 03:54:15 AM
I notice that the diffuse is slightly showing without reflection around the boundary of the reflection surface, this seems remedied by adding a Colour Adjust after your metallic mixer and bringing the white point down a bit. In the case of Metal23 (https://cc0textures.com/view.php?tex=Metal23) I had to go down to 0.6. This effect seems present in the example on cc0 texture too but is a little more noticeable in TG when there's a lot inbetween light/dark surfaces and can noticeably tell it's not shiny metal, but metal colour.
Title: Re: PBR Workflow
Post by: masonspappy on July 02, 2019, 04:38:33 AM
Thanks!!
Title: Re: PBR Workflow
Post by: Agura Nata on July 15, 2019, 04:18:33 PM
Great thank you!

As a texture, I always take a main picture that I mix something with a diffused image to create some dirt.
Since I do not have all the different types of images available, I still connect them with reflection, roughness and displacement. if you tinker with the settings you can also achieve nice results. So quite banal.

I will try the tips on free PBR times.

Title: Re: PBR Workflow
Post by: Agura Nata on August 26, 2019, 03:07:01 AM
Korgon 1-8
PBR Material testing
The sphere is a TG object edited with "displacement shader".
PBR material for Sphere and Fake stones shaders.

The rocks were created by 2 different fake stone shaders and have each been assigned a PBR material, the settings for this quality were not easy to implement with the PBR, so the pictures are correctly assigned to the inputs.
I mixed the hight map with the normal map in the rough rock and regulated by the AO picture, because you get a headache.
In addition, I put with the stones, AO in the reflection entrance, looked better.

Swamp water from Dune Planetside Forum.
Render in Terragen 4.4
PBR Material from:
https://cc0textures.com/view.php?tex=Metal05
https://freepbr.com/materials/grimy-metal/