Planetside Software Forums

General => File Sharing => Water => Topic started by: dandelO on January 31, 2010, 10:59:55 PM

Title: Masked water.tgd (Massive render time chopper)
Post by: dandelO on January 31, 2010, 10:59:55 PM
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.
[attachimg=#]

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.
[attachimg=#]

See following post for more...
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: dandelO on January 31, 2010, 11:09:45 PM
Painted mask:
[attachimg=#]

Output:
[attachimg=#]

And water only:
[attachimg=#]

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.

[attachimg=#]

Thank you for reading! :)
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Klas on February 01, 2010, 05:31:01 AM
Quote from: dandelO on January 31, 2010, 11:09:45 PM
Thank you for reading! :)
Thank you for sharing. Good that you are back!
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Dune on February 01, 2010, 05: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

Title: Re: Masked water.tgd (Massive render time chopper)
Post by: FrankB on February 01, 2010, 06: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
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Tangled-Universe on February 01, 2010, 08:23:17 AM
Quote from: FrankB on February 01, 2010, 06:59:02 AM

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.
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Tangled-Universe on February 01, 2010, 08:26:38 AM
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
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Henry Blewer on February 01, 2010, 09:16:20 AM
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!
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: normhol on February 01, 2010, 11:14:40 AM
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.
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: dandelO on February 01, 2010, 11:54:48 AM
Quote from: FrankB on February 01, 2010, 06: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

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.
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: dandelO on February 01, 2010, 12: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.

:)
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: FrankB on February 01, 2010, 02:56:46 PM
... or just use a slightly wider brush.
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Tangled-Universe on February 01, 2010, 04:13:50 PM
Quote from: dandelO on February 01, 2010, 12: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.

:)

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
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: MGebhart on February 01, 2010, 04: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 
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: FrankB on February 01, 2010, 05:56:45 PM
now let's all have a party ;)
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: dandelO on February 01, 2010, 05:57:31 PM
And a render!
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: FrankB on February 01, 2010, 06:03:52 PM
and a beer.
... or two.  :P
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Henry Blewer on February 03, 2010, 09:03:21 AM
I will have a twelve pack, ;D
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Oshyan on February 04, 2010, 03:06:13 AM
Group hug? ;D

- Oshyan
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Goms on June 20, 2010, 04:23:41 AM
First: Sorry for re-opening, but i think in this case its ok.

There is a way to do this depending on the terrain.
If you combine your Terrain, made black with a distribution shader, and a power fractal that has (maybe, if you the water is not rendered where it should be) some displacement offset and is all white with a merge shader set to highest and use this as opacity input for a default shader, you will get exactly this. :)

without this in 2:23
(http://img717.imageshack.us/img717/117/223ri.jpg)

with this in in 1:34
(http://img64.imageshack.us/img64/3451/134i.jpg)

the nodes:
(http://img687.imageshack.us/img687/5585/nodes.jpg)


and the TGD is attached. :)
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: choronr on June 22, 2010, 02:58:23 PM
Thanks Martin; I'll be trying this soon.
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: AndyWelder on August 15, 2010, 05:29:41 PM
Thanks a lot for this great contribution, DandelO. Works like a charm.
I would like to ad a caveat however: Keep in mind the .TGD originally has only 2 render threads enabled and the subdivision cache is limited to 200 MB. If you have a quad core system you might want to enable 4 threads and raise the subdivision cache to 400MB.
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: dandelO on August 15, 2010, 06:11:16 PM
Thanks, Andy. I know, sorry about that, it's a very good point.
Lots of my shared files actually will be like that. They'll mostly be set for whatever machine I'd been using at the time, which has been usually a single or dual core with not much RAM.
I'm rewriting many of my uploads for my own site, in time. I'll be sure to right the SD cache and open up the max threads field in my uploads in future.
I noticed this myself before when I had to download an early voronoi caustic file I'd shared, I was on a higher spec pc and that file was saved to use 1 thread, I noted it as something I need to fix, when I update the files, soon...

Cheers, man! :)
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Floating.Point on November 05, 2010, 06:00:17 AM
Firstly thankyou so much for this excellent resource!

I would like to confirm that this does indeed work with the default lake object.

Also, I have noticed a significant issue with using a plane instead of a lake object...
Im not sure the technical reasons for the obvious "reduction of niceness"

But here is an example of using the same waterplane masking method on a lake object, and a plane object...
Notice how yucky the transparency is, with that hard edge... also the noise and general quality is not as nice.

(http://dl.dropbox.com/u/792881/Posted%20Photos/WaterplaneIssue.jpg)

But it doesn't really matter.... because the masking technique works on the lake object anyways!
Cheers!
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: dandelO on November 05, 2010, 12:02:24 PM
Uncheck 'cast shadows' on the plane! ;) If you check the settings of a default lake, you'll see that shadow casting is unchecked by default. That's all it is.

:)
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Floating.Point on November 05, 2010, 01:53:32 PM
Ahhh okay awesome!!! cheers!
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: neuspadrin on December 04, 2010, 02:32:18 PM
Hey, long time no forum/terragening, but I was bored today taking a break from school work and was looking at this (and playing with new update) and then expanded on this clip a little.

Basically taking this clip, then extending the idea by allowing it to follow terrain (like a river flowing down a mountain side, all easily painted).

I used a plane object instead of a lake (I believe this is the same method dandelO used to make a waterfall), and sent the computed terrain as input into the water area mask.  

I created a very basic distribution shader that was blended by the painted shader, which then attaches to a displacement shader right before compute terrain, which has a negative multiplier allowing it to make a ditch.

That distribution shader also goes into the displacement of the "water surface - plug in here" layer, which then has a displacement multiplier of positive 4 in this image I believe.


Anyways, just thought I would share that quick modification possible to turn this clip into a very nice paintable river for down hills/rapids/whatever you wish.

Heres a quick scene I whipped up to demonstrate it, and a screenshot of the relevant node network.
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Henry Blewer on December 04, 2010, 02:38:24 PM
With just a little extra work on the water shading, rough water could be done well using this, I believe.
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: Dune on December 05, 2010, 03:49:11 AM
This is the way I did downhill rivers as well, but the main problem is that the displacement used on the water base will have its 'sideways irregularities'. It will kind of follow the sideways curve of the mountain if you don't pick your POV carefully. For a real rough river it works though, especially if you throw some rocks into the riverbed and some foam (I use two layers, one overall, and one for steeper water).
Title: Re: Masked water.tgd (Massive render time chopper)
Post by: max_thehitman on April 21, 2011, 10:46:30 AM

Very cool ideas and great info too! Thanks for sharing your expertise on this matter.
I will keep this as a tutorial for future reference.
THANKS EVERYONE! Great art you create!

Cheers
MAX