Author Topic: Masked water.tgd (Massive render time chopper)  (Read 16471 times)

Offline dandelO

  • Member
  • *
  • Posts: 2401
Masked water.tgd (Massive render time chopper)
« on: February 01, 2010, 02:59:55 AM »
These .tgd/.tgc remove the rendering of subterranean water. The water mask is driven by a painted shader.

Here are some images describing how it works:

Firstly, the image on the right uses my masking method to render the river. The left hand image doesn't. You will also notice that there is water rendering beneath the terrain on the image that hasn't finished rendering, this doesn't happen with my masking technique.
the unfinished render time is roughly equivalent to the finished one. It isn't even halfway rendered using default TG2 water settings.
22367-0

Here's the finishing times for both renders, notice that the amount of final microtriangles is significantly less in the masked, quicker render. This is because they aren't rendered before the terrain is, at all. This has aproximatelly halved the render time.
22369-1

See following post for more...
« Last Edit: February 01, 2010, 03:12:32 AM by dandelO »

Offline dandelO

  • Member
  • *
  • Posts: 2401
Re: Masked water.tgd (Massive render time chopper)
« Reply #1 on: February 01, 2010, 03:09:45 AM »
Painted mask:
22371-0

Output:
22373-1

And water only:
22375-2

In the clipfile version see this small image on usage:
The input coming from the top left is from the painted mask. You will need to create your own painted shader mask to fit your own scene, it would be pointless using mine. Also, the river here in all examples is a 1000m2 plane object, this isn't included in the clipfile version either. The technique will work on any water object in TG2, from planes, to lakes, to spheres.

22379-3

Thank you for reading! :)
« Last Edit: June 25, 2012, 01:13:28 PM by dandelO »

Offline Klas

  • Member
  • *
  • Posts: 201
    • TERRA Lights.de
Re: Masked water.tgd (Massive render time chopper)
« Reply #2 on: February 01, 2010, 09:31:01 AM »
Thank you for reading! :)
Thank you for sharing. Good that you are back!

Offline Dune

  • Terragen Alpha Tester (Win)
  • ***
  • Posts: 14155
    • www.ulco-art.nl
Re: Masked water.tgd (Massive render time chopper)
« Reply #3 on: February 01, 2010, 09:42:12 AM »
I might want to add that you'd have to slide the color in the deafult shader to black! If you don't, the water turns milky. It does dramatically reduce rendertime. These two screenshots show what happens in my quick tests, the time with painted mask was 2.55, without 3.43 min.

---Dune


Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masked water.tgd (Massive render time chopper)
« Reply #4 on: February 01, 2010, 10:59:02 AM »
I think I may have an explanation for that.

I suspect that the lake object doesn't "know" about its surface, unless some sort of color information is being fed into it.
With DandelO's setup, the painted shader is the blend input to the default shader, which in turn will only exist where the paint exists.

Now the default shader feed into the input of a surface layer. The surface layer doesn't have a surface to exist on, other than what's coming through from the default shader.
Because the water shader is applied as a child to the surface layer, it also exists ony where the default shader exists, which means that the water shader is only able to provide the lake object with coordinates about the lake's surface, where the painted shader exists.

Hence, TG2 will only render the water shader on the painted area.

Frank

Offline Tangled-Universe

  • Terrevangelist
  • *
  • Posts: 6129
    • CGScenery.com - Terragen Tutorials!
Re: Masked water.tgd (Massive render time chopper)
« Reply #5 on: February 01, 2010, 12:23:17 PM »

Now the default shader feed into the input of a surface layer. The surface layer doesn't have a surface to exist on, other than what's coming through from the default shader.
Because the water shader is applied as a child to the surface layer, it also exists ony where the default shader exists, which means that the water shader is only able to provide the lake object with coordinates about the lake's surface, where the painted shader exists.

This particular part is what I missed when thinking about this. Since there is no surface yet, the painted opacity IS working as a blendshader.

Offline Tangled-Universe

  • Terrevangelist
  • *
  • Posts: 6129
    • CGScenery.com - Terragen Tutorials!
Re: Masked water.tgd (Massive render time chopper)
« Reply #6 on: February 01, 2010, 12:26:38 PM »
In continuition of this:

This works with a painted shader, very nice :)
Even more interesting and useful would be to use a surface layer tightly restricted to a certain height to use as blendshader.
I remember I tried something similar, but it didn't work. I might try this again, since I obviously made a "thought-mistake" before.

Cheers,
Martin

Offline Henry Blewer

  • Member
  • *
  • Posts: 6333
  • The cooler weather is great!
    • flickr.com/photos/njeneb/
Re: Masked water.tgd (Massive render time chopper)
« Reply #7 on: February 01, 2010, 01:16:20 PM »
Nice technique. I'll have o try it out. One of the render problems I have is water being rendered where it does not show. This will speed things up!
http://flickr.com/photos/njeneb/
Forget Tuesday; It's just Monday spelled with a T

Offline normhol

  • Member
  • *
  • Posts: 73
Re: Masked water.tgd (Massive render time chopper)
« Reply #8 on: February 01, 2010, 03:14:40 PM »
Welcome back dandel0!!!
Although I am mainly a "lurker" and not very good at creating pictures yet, I [and many others] missed your expertise and postings.
Glad you decided to press on regardless.
Cheers,
Norm.

Offline dandelO

  • Member
  • *
  • Posts: 2401
Re: Masked water.tgd (Massive render time chopper)
« Reply #9 on: February 01, 2010, 03:54:48 PM »
I think I may have an explanation for that.

I suspect that the lake object doesn't "know" about its surface, unless some sort of color information is being fed into it.
With DandelO's setup, the painted shader is the blend input to the default shader, which in turn will only exist where the paint exists.

Now the default shader feed into the input of a surface layer. The surface layer doesn't have a surface to exist on, other than what's coming through from the default shader.
Because the water shader is applied as a child to the surface layer, it also exists ony where the default shader exists, which means that the water shader is only able to provide the lake object with coordinates about the lake's surface, where the painted shader exists.

Hence, TG2 will only render the water shader on the painted area.

Frank

Frank's essentially got it, yes.

The painted shader is simply driving everything that follows. The default shader doesn't have a blending input, I use the opacity channel of this to make the colour only visible where the white of the paint describes. The opaque parts are rendered, the transparent parts are just not.

The following 'surface layer', you'll notice, still has apply colour un-checked. It is only for parent-shader purposes, it is the water shader's parent, only. You can use the 'surface layer' as extra blending aswell(usefull if you're texturing a sphere or curved surface, not really so useful on a flat plane/lake).

The water shader is simply a child to the surface layer that is now only shaded where your paint shader tells it to. Te rest of the water object's surface is simply omitted from rendering.

In my example file, I have cut the render time in half.
If, for example, you need a very, very long, thin river in a scene you could either make a long thin plane as the water object(you will still however need to render water beneath the terrain this way) OR, you could now simply make a giant lake/plane covering everything where water needs to be, a default lake object is HUGE, this no longer matters because it simply won't render water unless you tell it where you want it, e.g. with your river displacement paint.

I made this method over a year ago, probably closer to 2 years ago. I'm very surprised that it hasn't been implemented yet. It was in my vol.2 Library pack, which has had literally hundreds of downloads.

*EDIT: I first uploaded a version of this in October 2008. Over a year, then. It used a B/W image map because the painted shader hadn't been invented at that point. I updated it when the painted shader was introduced.
« Last Edit: February 01, 2010, 03:56:32 PM by dandelO »

Offline dandelO

  • Member
  • *
  • Posts: 2401
Re: Masked water.tgd (Massive render time chopper)
« Reply #10 on: February 01, 2010, 04:05:43 PM »
I should also point out an error on my part in my example.tgd...

Towards the bottom right bank, you'll see that the water doesn't quite meet the land at one point. I should have lowered the water plane very slightly more to fix this issue(or displaced the river cut less). Regardless, it's just an example file.

:)

Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masked water.tgd (Massive render time chopper)
« Reply #11 on: February 01, 2010, 06:56:46 PM »
... or just use a slightly wider brush.

Offline Tangled-Universe

  • Terrevangelist
  • *
  • Posts: 6129
    • CGScenery.com - Terragen Tutorials!
Re: Masked water.tgd (Massive render time chopper)
« Reply #12 on: February 01, 2010, 08:13:50 PM »
I should also point out an error on my part in my example.tgd...

Towards the bottom right bank, you'll see that the water doesn't quite meet the land at one point. I should have lowered the water plane very slightly more to fix this issue(or displaced the river cut less). Regardless, it's just an example file.

:)

Sadly enough I used that particular part in testing your approach :( *sigh*


I'd like to apologise you for my unfortunate choice of words for two times in discussing this technique with you.


First by saying that "I can't see why it should work" I mostly meant that I[/u] didn't understand it, rather than I'd suggest your approach makes no sense.
Secondly by saying that "I'm a bit surprised you don't understand...": as far as I know you and how we interact here we always understand each other very well.
I got a bit frustrated that I wasn't able to make my point clear, because we normally understand each other so easily and well.
This time I couldn't put it very well in words what I meant to say/explain and I felt you didn't understand me.
It was logical that I couldn't explain it and did not understand your approach until Frank posted about the how and why, then it was suddenly completely clear why it does work! :)

I reasoned about the working of this technique and missed an essential conceptual part of why it should work.
Secondly I tested the wrong spot in the example files, which made me believe I had a good point.
All in all very unfortunate :(

Martin, we already discussed this in private and I know the sky is and has always been clear, but I thought it would be good to state clearly here for everybody how this happened by some unfortunate actions and choice of words which I regret.
By no means I wanted to criticise your technical skills or personally. I know you know, but let that be clear for everybody please.

Cheers,
Martin
« Last Edit: February 01, 2010, 08:15:27 PM by Tangled-Universe »

Offline MGebhart

  • Member
  • *
  • Posts: 911
  • Find work that feels like play
Re: Masked water.tgd (Massive render time chopper)
« Reply #13 on: February 01, 2010, 08:25:16 PM »
dandelO,

Thanks for the file. I'm dissecting it to get a better understanding how it works. This is rather ingenious and well thought out.

Excellent work.

Marc 
Marc Gebhart

Offline FrankB

  • Member
  • *
  • Posts: 3603
Re: Masked water.tgd (Massive render time chopper)
« Reply #14 on: February 01, 2010, 09:56:45 PM »
now let's all have a party ;)

 

anything