Planetside Software Forums

General => Terragen Discussion => Topic started by: mhaze on August 12, 2019, 06:23:17 AM

Title: Optimising Path Tracing Renders
Post by: mhaze on August 12, 2019, 06:23:17 AM
Iv'e been working on a picture that will benefit from a PT render.
But
Standard render no clouds  - 6mins
Standard render with 3 layers of clouds - 40min
Path Traced 9 Hours 6 mins !!!!

Detail .8 AA 8 

Any tips for optimisation?
Title: Re: Optimising Path Tracing Renders
Post by: N-drju on August 12, 2019, 06:31:25 AM
I'm afraid I also don't get the idea of path tracing...

I tried it two days ago on a couple of trees and a cloud layer and the entire image was just one grainy piece of trash.

I've seen other people doing PT renders with fabulous shadow depth and fantastic surface details so it has to be doable. But I have no idea how...
Title: Re: Optimising Path Tracing Renders
Post by: cyphyr on August 12, 2019, 07:08:43 AM
To be fair the Path Tracing is under than 3 times longer, that's not too bad really! :)

First thing I would do is lower the Detail and AA settings.

Start low and work your way up. (0.5, 3 then 0.7, 5 maybe)

Grain in clouds comes mostly from lower quality settings in the cloud and atmo nodes not so much from the detail or AA settings.

If you're using any merge nodes see if the same results can be obtained through simple Function Add_Colour or Multiply_Colour nodes.

See what happens if you remove the Compute terrain node, depends on the scene how vital it is, and if you do plug any populations into the last node before the planet.
Title: Re: Optimising Path Tracing Renders
Post by: mhaze on August 12, 2019, 07:25:46 AM
40mins standard compared to 9hrs PT is 13.5 times longer!
Title: Re: Optimising Path Tracing Renders
Post by: cyphyr on August 12, 2019, 07:44:01 AM
Indeed it is
Pre-coffee I read "3 layers of clouds - 40min" ...  as ...  3hours 40min!!
lol
Title: Re: Optimising Path Tracing Renders
Post by: Tangled-Universe on August 12, 2019, 10:19:09 AM
As far as I know...if you render a clouds v3(!) only scene, so without any surfaces, there's no use in using the path tracer, since cloud v3 has its own GI and shading approach.
Path tracing is awesome if you have vegetation/shadows/low sun angle type of lighting etc.
Title: Re: Optimising Path Tracing Renders
Post by: Oshyan on August 12, 2019, 12:41:35 PM
First and foremost, I would ask: Does your scene need to be path traced? 

Path Tracing is most effective where there is a lot of geometry (e.g. imported object populations), or generally more potential for bounced light. It handles complex interactions of light bouncing better than the normal renderer. But for example in a mostly-terrain scene with a few scattered objects and a lot of direct sunlight, you're probably not going to see much benefit. If you move the sun lower in the sky to create lots of shadows, a sunset for example, then you might see more benefit. But the greatest gains will tend to be in thicker vegetation, or on more complex objects.

Path Tracing also doesn't really affect the atmosphere, its main effects are on the ground, the terrain and anything sitting on it. So don't enable it if you are hoping for some improvement in the sky. It can, however, create more realistic lighting on the ground from the sky, to some degree.

So, if you decide your scene would benefit from Path Tracing, then the render settings do often need to be different than regular renders. We are working on a guide for this, but in the mean time some quick tips (not necessarily in order of importance):

#1: Don't use high MPD

Path Tracing enables "Defer All" shading. Defer All is a rendering method which makes much more detailed terrain (similar to "Defer Atmo" which makes smoother clouds). This means MPD values can be lower for equivalent detail. You would be fine with 0.5. 

You can test how Defer All compares to regular rendering on its own, without Path Tracing. Just enable Defer All separately (without Path Tracing), and maybe render a crop of terrain and test the render time. You can use MPD 0.8 for the non-Defer All render and MPD 0.5 for the Defer All. See which is better and what the render times are.

#2: If you have Soft Shadows Enabled, Reduce Samples

Again, because of Defer All being enabled with Path Tracing, you get higher quality surface shading. This includes Soft Shadows. So you can use fewer samples. I recommend a value of 2 when Defer All or Path Tracing are enabled. Again you can test this with a crop.

#3: Use Robust Adaptive Sampling (especially in v4.4)

The new Robust Adaptive Sampling helps a lot to reduce render time with Path Tracing, while maintaining quality. You can use a value of AA8 or AA6 with Robust Adaptive and 1/64th samples as a starting point. Increasing the amount of adaptivity, i.e. the "First sampling level", will reduce render time but can add to noise. If you use AA8 you can consider 1/256, but at AA6 I would stick to 1/64.

Then adjust the Pixel Noise Threshold *only* to get the level of noise under control. Start with the default value and go down if you want less noise, or up if noise looks fine but render time is too long. You may find you can get away with a lower Pixel Noise Threshold. Do renders in crops to reduce time needed for checking the best values, and you should include an area of shadow in your crop for most accurate results.

Note that Robust Adaptive is improved in v4.4 vs. 4.3.

#4: Don't Bother with High GI Values

The GI Cache Detail and Sample Quality values do have an effect with path tracing, but they only control GI contributions from the atmosphere into the path tracer, which is used for the terrain illumination. I.e. the Path Tracer essentially replaces the cache-based GI system when rendering the terrain. So these GI settings can generally be fairly low (e.g. 2/2 or 3/3) because the atmosphere contribution is fairly diffuse in most cases, and the terrain lighting will be made accurate by the path tracing itself. 

Put simply: you don't need high Cache Detail or Sample Quality values to get good path tracing results on your terrain. 

---

That should get you a good ways toward faster path traced renders. We'll put out more info in the near future.

- Oshyan
Title: Re: Optimising Path Tracing Renders
Post by: N-drju on August 12, 2019, 01:33:57 PM
Thank you for this coherent explanation Oshyan. That should probably solve all the issues.
Title: Re: Optimising Path Tracing Renders
Post by: mhaze on August 12, 2019, 02:22:20 PM
Thanks Oshyan, brilliant explanation. The main reason I tried PT was for the terrain but I can see now ways in which I can improve it. BTW what is MPD?
Title: Re: Optimising Path Tracing Renders
Post by: Oshyan on August 12, 2019, 02:43:54 PM
MPD is Micro-Poly Detail or just "Detail", as you called it. It only affects elements of the scene that are rendered with the Micro-polygon Renderer, as opposed to being Deferred or Ray Traced. The "Micro-poly" part of the name is important as it does not control e.g. the detail of the sky when Defer Atmo or Defer All are enabled (and thus is not an overall "detail" control). It's a very understandable shorthand to use though ("Detail") because it's the most visible non-AA detail control, and up until Defer Atmo became common place, it did act largely as an overall detail control.

- Oshyan
Title: Re: Optimising Path Tracing Renders
Post by: WAS on August 12, 2019, 04:03:08 PM
Quote from: Oshyan on August 12, 2019, 12:41:35 PMFirst and foremost, I would ask: Does your scene need to be path traced?

Path Tracing is most effective where there is a lot of geometry (e.g. imported object populations), or generally more potential for bounced light. It handles complex interactions of light bouncing better than the normal renderer. But for example in a mostly-terrain scene with a few scattered objects and a lot of direct sunlight, you're probably not going to see much benefit. If you move the sun lower in the sky to create lots of shadows, a sunset for example, then you might see more benefit. But the greatest gains will tend to be in thicker vegetation, or on more complex objects.

Path Tracing also doesn't really affect the atmosphere, its main effects are on the ground, the terrain and anything sitting on it. So don't enable it if you are hoping for some improvement in the sky. It can, however, create more realistic lighting on the ground from the sky, to some degree.

So, if you decide your scene would benefit from Path Tracing, then the render settings do often need to be different than regular renders. We are working on a guide for this, but in the mean time some quick tips (not necessarily in order of importance):

#1: Don't use high MPD

Path Tracing enables "Defer All" shading. Defer All is a rendering method which makes much more detailed terrain (similar to "Defer Atmo" which makes smoother clouds). This means MPD values can be lower for equivalent detail. You would be fine with 0.5.

You can test how Defer All compares to regular rendering on its own, without Path Tracing. Just enable Defer All separately (without Path Tracing), and maybe render a crop of terrain and test the render time. You can use MPD 0.8 for the non-Defer All render and MPD 0.5 for the Defer All. See which is better and what the render times are.

#2: If you have Soft Shadows Enabled, Reduce Samples

Again, because of Defer All being enabled with Path Tracing, you get higher quality surface shading. This includes Soft Shadows. So you can use fewer samples. I recommend a value of 2 when Defer All or Path Tracing are enabled. Again you can test this with a crop.

#3: Use Robust Adaptive Sampling (especially in v4.4)

The new Robust Adaptive Sampling helps a lot to reduce render time with Path Tracing, while maintaining quality. You can use a value of AA8 or AA6 with Robust Adaptive and 1/64th samples as a starting point. Increasing the amount of adaptivity, i.e. the "First sampling level", will reduce render time but can add to noise. If you use AA8 you can consider 1/256, but at AA6 I would stick to 1/64.

Then adjust the Pixel Noise Threshold *only* to get the level of noise under control. Start with the default value and go down if you want less noise, or up if noise looks fine but render time is too long. You may find you can get away with a lower Pixel Noise Threshold. Do renders in crops to reduce time needed for checking the best values, and you should include an area of shadow in your crop for most accurate results.

Note that Robust Adaptive is improved in v4.4 vs. 4.3.

#4: Don't Bother with High GI Values

The GI Cache Detail and Sample Quality values do have an effect with path tracing, but they only control GI contributions from the atmosphere into the path tracer, which is used for the terrain illumination. I.e. the Path Tracer essentially replaces the cache-based GI system when rendering the terrain. So these GI settings can generally be fairly low (e.g. 2/2 or 3/3) because the atmosphere contribution is fairly diffuse in most cases, and the terrain lighting will be made accurate by the path tracing itself.

Put simply: you don't need high Cache Detail or Sample Quality values to get good path tracing results on your terrain.

---

That should get you a good ways toward faster path traced renders. We'll put out more info in the near future.

- Oshyan

This could use some cleaning up (make it more official), maybe more elaboration in some areas, but seriously keep this post on hand for docus in the future.

+Kudos. Quality content.
Title: Re: Optimising Path Tracing Renders
Post by: Oshyan on August 12, 2019, 04:21:39 PM
Thanks! Like I said we're writing a guide, so this level of content will definitely be included. May indeed make sense to use this as a starting point for some sections.

- Oshyan
Title: Re: Optimising Path Tracing Renders
Post by: WAS on August 12, 2019, 06:31:44 PM
Quote from: Oshyan on August 12, 2019, 04:21:39 PMThanks! Like I said we're writing a guide, so this level of content will definitely be included. May indeed make sense to use this as a starting point for some sections.

- Oshyan

Definitely, if anything something to refer to. It was very fluid, and understandable. That may be just dependent on my comprehension of TG, but it seemed laid out very nicely for a new user (especially when the mentioned settings and sections of TG are linked to pages on them them-self).
Title: Re: Optimising Path Tracing Renders
Post by: cyphyr on August 12, 2019, 06:56:56 PM
Definitely one for the "Official Documentation".
Great work
Title: Re: Optimising Path Tracing Renders
Post by: Dune on August 13, 2019, 01:33:32 AM
Thanks Oshyan. Very good for (especially new) users to have it this concise and clear in one paragraph.
Title: Re: Optimising Path Tracing Renders
Post by: digitalguru on August 13, 2019, 08:00:17 AM
Thanks Oshyan, great to see those tips in one place  :)

QuoteBut for example in a mostly-terrain scene with a few scattered objects and a lot of direct sunlight, you're probably not going to see much benefit.
I did try PT on my recent animation and didn't see much difference to the standard renderer, good to know that's the case.
Title: Re: Optimising Path Tracing Renders
Post by: Oshyan on August 13, 2019, 02:09:37 PM
Quote from: digitalguru on August 13, 2019, 08:00:17 AMThanks Oshyan, great to see those tips in one place  :)

Quote from: undefinedBut for example in a mostly-terrain scene with a few scattered objects and a lot of direct sunlight, you're probably not going to see much benefit.
I did try PT on my recent animation and didn't see much difference to the standard renderer, good to know that's the case.
In the vegetation you should see some difference, but given the amount of movement in the video it may not have been that visible. If you had been rendering the truck in TG though, the shadow with the ground and onto plants might have been a more notable area of difference though, for example.

- Oshyan
Title: Re: Optimising Path Tracing Renders
Post by: N-drju on September 08, 2019, 03:57:54 PM
Again - a great set of guidelines Oshyan. I'm trying these settings out now using the AA8, FS 1/256 rule of thumb. It's rendering quick enough and looks ok.

Still needs some practice of course, but it's apparently working. i also discovered that high soft shadow samples can actually deteriorate shadow quality when used in conjunction with PT.
Title: Re: Optimising Path Tracing Renders
Post by: Tangled-Universe on September 08, 2019, 04:17:26 PM
I just downloaded your zip file, sorry it took a bit longer than I wanted.
It seems you have received some great help and advice already, so I will incorporate some of those and see if I can help with shading/texturing as well, because by the looks of it that's also a major player here.
Title: Re: Optimising Path Tracing Renders
Post by: N-drju on September 08, 2019, 04:36:01 PM
Quote from: Tangled-Universe on September 08, 2019, 04:17:26 PMI just downloaded your zip file, sorry it took a bit longer than I wanted.
It seems you have received some great help and advice already, so I will incorporate some of those and see if I can help with shading/texturing as well, because by the looks of it that's also a major player here.

That's okay Martin. Like I said - this is nothing urgent. I am, however, willing to learn and explore so hit me back up with any conclusions and suggestions you may have.

Yep, like I said - this time I made the shader network far more complicated than it usually is.