Masked water.tgd (Massive render time chopper)

Started by dandelO, January 31, 2010, 10:59:55 PM

Previous topic - Next topic

dandelO

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...

dandelO

#1
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! :)

Klas


Dune

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


FrankB

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

Tangled-Universe

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.

Tangled-Universe

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

Henry Blewer

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

normhol

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.

dandelO

#9
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.

dandelO

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.

:)

FrankB


Tangled-Universe

#12
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

MGebhart

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

FrankB