Planetside Software Forums

General => Terragen Discussion => Topic started by: Elegy on July 19, 2009, 07:52:49 AM

Title: Question about redirect shader and merge shader (and warp shader)
Post by: Elegy on July 19, 2009, 07:52:49 AM
Firstly, I'm quite confused about what exactly the difference is between lateral displacement, such as when you select 'Lateral Only' from within the Power Fractal, and a redirect shader with a displacement plugged into both the X and Z shaders.

In both cases, displacement is applied along only two axes - X and Z - and yet the displacements produced seem to be very different. Why is this? I know that redirect shaders 'redirect' the input along any axis but what does that mean exactly?

Secondly, I know that the Merge Shader when left to default settings is set to 'Mix' displacement. I take it this means that the mean altitude of both inputs is used as the output. But what if one of the inputs has two altitudes at one point (ie, has overhangs)? Does it simply take the mean of all altitudes at a given set of 2D coordinates?

I appreciate any answers.
Title: Re: Question about redirect shader and merge shader
Post by: Matt on July 23, 2009, 08:20:21 PM
Quote from: Elegy on July 19, 2009, 07:52:49 AM
Firstly, I'm quite confused about what exactly the difference is between lateral displacement, such as when you select 'Lateral Only' from within the Power Fractal, and a redirect shader with a displacement plugged into both the X and Z shaders.

In both cases, displacement is applied along only two axes - X and Z - and yet the displacements produced seem to be very different. Why is this? I know that redirect shaders 'redirect' the input along any axis but what does that mean exactly?

The Redirect Shader "tricks" the shaders which are attached to it into thinking that the surface normal points along the positive X axis, positive Y axis or positive Z axis. Basically it modifies the shading state variable for the surface normal before calling the shaders, so that they think they are displacing a surface with a different normal. Any shader that displaces along the normal will then displace along these directions. Displacement in the negative X,Y,Z directions is accomplished if the displacement shader displaces negatively (e.g. if it indents a surface rather than raising it).

Some shaders make more complicated decisions about the displacement direction, or they let you choose. The Power Fractal defaults to displacing "Along Normal", but some of its other settings allow for interesting effects. "Lateral Only" still uses the surface normal, but it cancels out any amount of displacement which occurs directly upwards/downwards away from the planet's centre. On a level surface, the surface normal points directly upwards, and the displacement will be completely cancelled out. On the side of a cliff, however, where the surface normal points away from the usual up-down direction, the displacement is much stronger. They only displacement allowed is displacement not in the up-down direction. It's a simple way to get the appearance of horizontal layers in your displacements, especially if you combine it with XYZ stretching of the noise pattern.

"Lateral Normalized" is similar to "Lateral Only" except that the magnitude (length) of the displacement is kept, and only the direction of the displacement is changed. This means that the displacement won't fade out on surfaces which are nearly pointing upwards, and you'll always get strong lateral displacement.

"Vertical Only" is the opposite to "Lateral Only", and cancels out any displacement which does not occur along the up-down vector which points away from the centre of the planet.

"Along Vertical" ignores the surface normal completely, and uses the up-down vector which points away from the centre of the planet.

Some of these names include the words "requires computed normal". A Compute Terrain node is sufficient to give you a computed normal anywhere downstream from that node. You don't need another Compute Normal node.

Quote
Secondly, I know that the Merge Shader when left to default settings is set to 'Mix' displacement. I take it this means that the mean altitude of both inputs is used as the output. But what if one of the inputs has two altitudes at one point (ie, has overhangs)? Does it simply take the mean of all altitudes at a given set of 2D coordinates?

I appreciate any answers.

The displacement vector (which includes the direction and distance of the displacement provided by a shader) is simply the weighted mean of the two input displacement vectors.

Overhangs are the result of bending the 2D surface over itself through the use of interesting displacement vectors, but each point on the terrain only comes from a single point on the undisplaced planet. It is still a 1-1 mapping from the flat surface of the planet to any point on the displaced surface. The upper part of an overhang comes from a completely different part of the surface than the lower part which it overhangs. So there is no averaging of overhanging points that overlap in 2D space, because the shaders don't even know that is happening.

Matt
Title: Re: Question about redirect shader and merge shader
Post by: Henry Blewer on July 23, 2009, 08:27:34 PM
Matt, this is the comprehensive explanation of this I have seen so far. Thanks!
Title: Re: Question about redirect shader and merge shader
Post by: Elegy on July 23, 2009, 09:01:19 PM
Thank you, this is very helpful. This explains why I wasn't getting the results I was expecting in a project I was working on a while back - I was using Lateral Displacements when I should have been using a redirect shader.

While I'm here, may I ask how the warp shader works exactly? I've been experimenting but as yet, I've only been able to muster up a very vague idea of what it does.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Matt on July 23, 2009, 09:24:19 PM
With the Warp Shader, the displacement vector from the warper is used to offset the texture coordinates before they are used by the shader. This almost looks like the warper bends the final result, but it's actually bending the space before it is read by the shader. It's hard to explain without examples, but a simplistic way you can think about it is that the shapes from the warper will bend the final texture (but in the opposite direction).

The reason the Warp Shader and the Redirect Shader often work well together is because the Redirect Shader allows you to construct displacement vectors which go in all directions, which can be useful for warping a 3D function such as the Power Fractal. If you just use a single fractal operating along the normal as your warper, you might not easily see its warping effect.

Matt
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Hetzen on July 23, 2009, 09:44:01 PM
Ahh, this makes some sense now. Thanks for the explaination.

Would you mind giving an over view on the transform shader too.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Elegy on July 23, 2009, 09:47:49 PM
It's at times like this I wish I hadn't forgotten my maths A-level but I think I understand and this will definitely be useful. Thanks again.

If I might make a suggestion - these explanations would significantly improve the node reference guide you have on your website. The current explanations for the redirect and warp shaders ("The Warp Shader warps one shader by the input of another." and "The Redirect Shader allows you to "redirect" the effect of the input shader along a specific axis.") are pretty much just stating the obvious and aren't too helpful.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: dandelO on July 24, 2009, 08:26:03 AM
As I see it, the transform shader simply moves the coordinates of the input shader so, if you have a displacement(for example) at X=0, Y=0, Z=0, changing the transform shader's parameters simply moves that displacement to the transformed coord's.

Or, it rescales the entire shader input by the factor you specify in the scale boxes. To double the size of the original shader, you'd have 2,2,2 in the XYZ - to half it, you'd use 0.5, 0.5, 0.5 in the XYZ.

It just moves or rescales the original shader input.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Oshyan on July 25, 2009, 02:50:03 AM
Quote from: Elegy on July 23, 2009, 09:47:49 PM
It's at times like this I wish I hadn't forgotten my maths A-level but I think I understand and this will definitely be useful. Thanks again.

If I might make a suggestion - these explanations would significantly improve the node reference guide you have on your website. The current explanations for the redirect and warp shaders ("The Warp Shader warps one shader by the input of another." and "The Redirect Shader allows you to "redirect" the effect of the input shader along a specific axis.") are pretty much just stating the obvious and aren't too helpful.

These kinds of more in-depth explanations will definitely be added to the Node Reference soon. Lots to do behind the scenes at the moment! ;D

- Oshyan
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on July 29, 2009, 08:08:24 PM
Let me get this straight. The warp node takes the warper input and uses it to domain distort the shader? Could have been useful to know this a while back, especially on the Why Mojo users won't use TG2 thread. I never used warp node before but now I see why people have got some of the effects I've seen in some renders.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: old_blaggard on July 29, 2009, 11:21:20 PM
Thanks for the explanations. I've long suspected many of these things, but it's really good to get clear descriptions of where each operation takes place in the rendering pipeline. The bit about the redirect shader also clears up some of the weird texturing results I was getting after having used it to displace parts of the terrain.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Matt on July 30, 2009, 06:38:18 PM
@Efflux: yes. I'm sorry you didn't know about this shader already. I thought I'd seen plenty of TG2 renders from you that use it... ?
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: glen5700 on July 30, 2009, 07:07:05 PM
I'm not trying to hijack your thread but I do have a question about the warp shader and thought maybe we could benefit from it.

I'm trying to get an even warping affect across the Voronoi noise function. Please see the attached images-

Voronoi warp and Voronoi no warp images are from TG2 and the dt_cell is from DarkTree, I realize I am not comparing apples to apples but I'm hoping to get closer than were I'm at right now. Look at the two images from TG2 and you can tell the warping is very uneven - some areas have a lot of warping and some ares almost none, the Power fractal shader (used for warping) noise is pretty even, you can view it using the shader preview(see uploaded clip file). Power fractal shader seems to hold the key, I've tried scale settings and have gotten some improvement but it still needs more. The other thing I found is the displacement amount (Power fractal shader) controls how much warp is applied.

The DarkTree image just shows Voronoi with a warp applied to it, I don't expect to get the same look (different noise functions- Terragen vs DarkTree), just a even warp.

I might even be going about this all wrong...

Any thoughts comments would be appreciated - Thanks,
Glen


Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on July 30, 2009, 07:24:16 PM
I am real happy I found it. I have been doing similar things but not with this shader.

On the Planetside site, under node references, the warp shader has no proper description.

I haven't tended to download many files from the forums. Maybe if I had I would have found out about this shader.

First test:

Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on July 30, 2009, 07:30:40 PM
glen5700,

What you are after is maybe a voronoi fractal - the powerfractal but with an option for voronoi basis. This I would badly like to have.

However, I am going to work a bit more with this warp shader now and see what I can get.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on July 30, 2009, 07:54:25 PM
To get that "cell" look you need to use a voronoi 3D A vector and invert it.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: glen5700 on July 30, 2009, 09:09:47 PM
efflux,

I would love to have voronoi fractal but the first thing I'm after is a more consistent warp effect over the whole texture it is applied too.  To make it more clear I'm uploading an animated gif so it is easier to see what I'm talking about. Watch as it changes, some areas have a lot of warp to them while others areas hardly have any. I can see were this would be desirable but I also want the warp effect to be consistent over the texture it's applied too.

I wasn't too interested in the cell look but I'm glad you brought it up, I need to learn a lot more about functions so i will give it a go.

Thanks,
Glen
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on July 30, 2009, 09:25:53 PM
That Darktree looks quite good but I have Mojoworld. You can all that stuff in Mojoworld and export as texture. Mojoworld does not have Manhatten Voronoi though. Otherwise, in my opinion, nothing beats Mojoworld for procedural textures.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on July 30, 2009, 09:38:47 PM
I just set up a cell type texture. I added a gain to make it very round with the displacement. You can experiment with other functions to change the shape. However, it takes a long time to render.

The warping is problematic because the more you warp the more you lose the voronoi shapes.

Ideally what we want is multiple octaves of voronoi.

I'm going to try to warp with other functions to see what happens.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on July 30, 2009, 10:33:28 PM
I tweaked around with your file and got this. Higher displacement settings in the warping fractal and I reduced the displacement setting in the surface layer to get some displacement:
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: glen5700 on July 30, 2009, 11:05:49 PM
efflux,
Nice!! It's really what I was after, my problem is I need to keep working with the functions/nodes to get a good understanding of them. I have a scene that I'm working on and once it gets to a decent point I will share the image and a clip or scene file. Hopefully it will be useful to the group.

Thanks,
Glen
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on July 30, 2009, 11:18:49 PM
I thought maybe I took it too far and you wanted to retain more of the voronoi shape. That's why we need a voronoi fractal but I think this warping can get some great results.

I was actually warping stuff before I came across what this node does. I was doing it with other functions but this node opens up a whole lot of extra techniques.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Henry Blewer on July 30, 2009, 11:55:46 PM
It does make an interesting marble texture. It could be rendered, saved, made seamless and then used as an image map.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on August 12, 2009, 02:45:57 AM
Quote from: Matt on July 23, 2009, 09:24:19 PM
With the Warp Shader, the displacement vector from the warper is used to offset the texture coordinates before they are used by the shader.

I looked back at what I did in the "Why Mojo user's will not adopt TG2 thread". It turns out I did actually use the warp shader for a file created there then I reverted back to not using it for some reason.

The above quote is a better explanation that the one in the Mojo thread.

It's only when users get a clear picture in their head of the flow in geometry that they can utilize it.

We need explanations collected in the node reference documentation but these explanations need to be very precise. There has to be logic and consistency in all the language and names used.

The position nodes in Mojo are named after whatever position space they are working from.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on August 12, 2009, 02:59:13 AM
For example. Mojo users talk about "domain distortion". This is a very clear term which makes you understand exactly what you are doing. What the hell is "warping". Warping what? I understand now but didn't before because of the bad terms used.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on August 12, 2009, 03:12:41 AM
Why are "surfaces" in TG2 not simply called materials as is the case in every other other 3D app or maybe in this case surface is actually a better name.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on August 12, 2009, 04:36:08 AM
Of course I understand that the idea of domain distortion in Mojoworld is actually different. You distort the position directly with a fractal's output not displacement but still, this "warp" node badly needs a good description entered in the node reference.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on August 12, 2009, 05:36:21 AM
Warp + redirect along with some negative displacement in the lower area. Taken to extremes of course. I think my next planet may be called Hoodoos.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: FrankB on August 12, 2009, 08:30:23 AM
Quote from: efflux on August 12, 2009, 03:12:41 AM
Why are "surfaces" in TG2 not simply called materials as is the case in every other other 3D app or maybe in this case surface is actually a better name.

maybe because a surface shader in TG2 is color & displacement, not just color? To me it makes sense.

Regards,
Frank
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Matt on August 12, 2009, 08:34:12 AM
Sorry, I've always called it warping the texture space. I see that there's strong precedent for the term 'domain distortion' in various fields, so perhaps I should have called it that. The addition of the word domain or texture coordinates or something might have helped.

The things that are made up of polygons are called surfaces in TG, to distinguish them from volumetrics/atmospherics. I can't call the actual surface a material because a material is something which is assigned to a surface, not the surface itself. (If we're using other 3D apps as an example.) Actually, underneath the GUI I use the term 'material' to assign whole shader trees to a particular surface, e.g. the planet, or a leaf of a plant, but the whole planet or the whole leaf has the same material (in standard 3D app terminology). You don't ever get to use the term material in the GUI because it's represented by the final shader connection to the planet. A material is built up of shaders, and that's where the real work needs to be done. Maybe Surface Layer could be called Material - is that what you meant? But really it's not - it's a smaller component than that, it's just one shader which builds up a whole material which is implied by the connection to the planet. If there were a separate list in the GUI for object parts and the materials assigned to them, then yes I would call them materials, but right now they're defined by the final shader in the shader tree which makes up their materials.

Matt
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: FrankB on August 12, 2009, 10:18:58 AM
Also, Matt, as I wrote, I would be confused by calling a surface shader "material", which in my mind is not more than the color of a surface. As the surface layer is color and displacement at the same time, I think it's accurate to call them surface layers.

At least, that sounds intuitively correct to me :-)

Frank
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on August 12, 2009, 10:30:51 AM
OK thanks Matt. Surface is actually better. In most 3D apps you have materials that contain all the components created by various textures. They do have colour and displacement but they are connected to one object or polygon group.

I understand how the warp shader works which is the main thing.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: efflux on August 12, 2009, 10:44:24 AM
See only now (after 2 1/2 years) can I actually explain to other Mojo users how TG2 does everything compared to Mojo. This is why there are no Mojo users here. They can't work out how to do things even although most of the basic same results are possible.
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Matt on August 12, 2009, 05:24:07 PM
I never really set out to copy Mojoworld ;)  There are inevitably going to be many things that Mojo names differently.

Matt
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Matt on August 12, 2009, 05:31:06 PM
Quote from: efflux on August 12, 2009, 10:30:51 AM
OK thanks Matt. Surface is actually better. In most 3D apps you have materials that contain all the components created by various textures. They do have colour and displacement but they are connected to one object or polygon group.

It's the same in Terragen. A material, under the bonnet, is the thing that's connected to one object or polygon group. It's just implied by the shader connections so you don't ever need to see which 'material' is attached to the planet because there is only one material attached to the planet.

With imported objects that use the Object Part nodes and Parts Shader, it's a bit more confusing. Perhaps the Object Part node could be named Material instead, but really it refers to the polygon group, with the material assignment being the actual shader connection, as with the planet. Well, that's not always true, depending on how the materials were read from the object and the material file. It gets complicated.

Matt
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: Matt on August 12, 2009, 05:34:28 PM
Quote from: FrankB on August 12, 2009, 10:18:58 AM
Also, Matt, as I wrote, I would be confused by calling a surface shader "material", which in my mind is not more than the color of a surface. As the surface layer is color and displacement at the same time, I think it's accurate to call them surface layers.

At least, that sounds intuitively correct to me :-)

In CG usually a material is a collection of all shaders, textures, attributes etc. - everything that defines the look of a surface or volume, not just its colour.

Matt
Title: Re: Question about redirect shader and merge shader (and warp shader)
Post by: R3igN on August 13, 2009, 06:51:26 AM
Hi

Question:

1) How do i apply two color in my terrain and blend this two color together?

Do i need a shader?

2) In the altitude constraints and slope constraints.. If i dont check the "limit maximum altitude" does putting/altering
the value still works?

3) When i put "surface layer 02" below that of "surface layer 01" does color of surface layer 01 overlaps color of surface layer 02?
Or Surface layer 02 is out?---How to blend to colors?

4) What's Input node, colour function, luminousity function, displacement function, break up shader, child layer and blending shader?

If i put "Surface layer 02" and connect it to any of this nodes to "Surface layer 01" what will happend?

Thnx!  few more info and i guess i will be PRO..XD ----I dont think so-

Please help!