A function only landscape

Started by David Burnett, February 18, 2007, 08:19:57 AM

Previous topic - Next topic

rcallicotte

#30
Thanks for help in understanding the functions.  There's no way to have any sense that I even am beginning to understand this, though.  I hope someone will write an extensive explanation of these and maybe write a book on what all can be done.  Someday.  Thanks again.  This has been great.

The waves below were created using some of these functions.  Ooolala!
So this is Disney World.  Can we live here?

Oshyan

Calico, I think it's a lot more about understanding the mathematical basis for all of it than understanding any particular TG2-specific aspects. The people who seem to have achieved good results with functions also seem to have a good grasp on math and most of the existing function operators will be familiar to anyone versed in that level of math. The connections of the functions to perform mathematical operations may require a little explanation, but beyond that it's really more important to know the math than the system I think. So in other words pick up a math book, or perhaps better yet some sort of "applied shader development" book. Jo Meder posted a good example here, although it's a bit pricey: http://forums.planetside.co.uk/index.php?topic=151.msg1417#msg1417 (read the replies below it as well)

- Oshyan

Arandil

Quote from: calico on March 15, 2007, 11:07:19 AM
Thanks for help in understanding the functions.  There's no way to have any sense that I even am beginning to understand this, though.  I hope someone will write an extensive explanation of these and maybe write a book on what all can be done.  Someday.  Thanks again.  This has been great.

The waves below were created using some of these functions.  Ooolala!

The larger wave forms appear too much like a layer of watery foam padding to me, but the detail on the waves and the color is excellent!  Post another with the larger wave forms tweaked a bit!  ;D

rcallicotte

Thanks, Oshyan.  I was just discussing this with my brother (a math major) and both of us love the algebra here, but he loves it with math knowledge.   :P  Thanks for the recommendation.  I'm going to Amazon right now to find the book.  Thanks for your attention.  It keeps us going.  Thanks.

Quote from: Oshyan on March 15, 2007, 06:29:41 PM
Calico, I think it's a lot more about understanding the mathematical basis for all of it than understanding any particular TG2-specific aspects. The people who seem to have achieved good results with functions also seem to have a good grasp on math and most of the existing function operators will be familiar to anyone versed in that level of math. The connections of the functions to perform mathematical operations may require a little explanation, but beyond that it's really more important to know the math than the system I think. So in other words pick up a math book, or perhaps better yet some sort of "applied shader development" book. Jo Meder posted a good example here, although it's a bit pricey: http://forums.planetside.co.uk/index.php?topic=151.msg1417#msg1417 (read the replies below it as well)

- Oshyan
So this is Disney World.  Can we live here?

Dark Fire

In my opinion, 'Decision mathematics' is the most useful area of maths to know about when using T2TP - it's all about things like node networks, critical path analysis, algorithms and linear programming. (CPA and linear programming are only relevant when trying to optimise render quality and size).

Sengin

Does anyone know exactly how a Build Vector function node works (create -> function -> convert -> Build Vector)?  It takes 4 inputs, an input node, an x value, a y value, and a z value.  First intuition tells you to simply put a value in there that you want.  However, if that were true, you could use a Get Position node feeding into 3 nodes (x to scalar, y to scalar, and z to scalar), and then plug those 3 values into the x, y, and z inputs of the Build Vector node feeding into a displacement shader's function input and that output to the compute terrain node, and get the same terrain you started with (you are saying, given this point (x,y,z), build a vector that has it's 3 values as (x,y,z)).  However, this is not the case, as the result is that the spherical planet is now an upside-down cone (yes, a cone, all sides circular coming to a point at (0,0,0)).  The only solid information I've come up with is that if you have a build vector and have a constant as it's y input (say the constant scalar is 10), every point would be 10 meters higher (so in essence, you move the terrain up).

David Burnett

The displacement shader is expecting a scalar feed into the function input. Feeding a vector into something expecting a scalar seems to have a defined behaviour, for example
feeding Get Position into a Sine Function gives you concentric rings of peaks and troughs.
See...
http://forums.planetside.co.uk/index.php?topic=843.msg9911#msg9911

The build vector node works as you've described it plus, IIRC, if you populate the 'input node' with a vector feed, scalar feeds into x, y or replace the x, y or z of the input node.

David Burnett

To create my function only landscape I'm going to use the pyramid, the linear sand dunes and Perlin's noise.

To to start off create a linear sand dune node network and add a pyramid node network, or load the tutorial4_start tgd file.

[attachurl=1]

Now we will put some kinks in those straight lines, using Perlin's noise.


  • Add a Perlin 3D scalar, a  Constant Scalar, a Multiply Scalar and an Add Scalar node.
  • Connect the linear dunes Get Position to the Perlin 3D scalar.
  • Connect the output of Perlin 3D scalar and the Constant Scalar to the Multiply node .
  • Connect the Multiply Scalar node to the Add Node.
  • To distort the Noise connect the X to Scalar node to the new Add node, and feed the Add
  • node into the linear dunes Modulo node instead of the X to Scalar Node.
  • Set the New Constant node to 1 to start of with and play with the value until you like
  • the distortion. I'm going to use 1.0.

To add the pyramid into the scene we need to use our old friend the Condition Scalar.
Were the pyramid overlaps the sand dunes we want to pick the highest value, so the
condition we want is "Greater than".


  • Add a Conditional Scalar, set the Condition to "Greater Than".
  • Connect the end of linear dune node network to the Input Node and If result.
  • Connect the pyramid node network to Comparison value and Else result.
  • Connect the Conditional Scalar output to the Displacement Shader.

You may have to look around for the pyramid or you could just set the camera to position 395, 15, -800 and rotation -0.5,-35, 0

It's a bit flat so lets add some big dunes, using Perlin's noise again.


  • Add a  Perlin 3D scalar, two Constant Scalars, a Multiply Scalar and an Add Scalar node.
  • Connect a Get Position to the Perlin 3D scalar.
  • Connect a Constant Scalar to the Scale input node of the Perlin 3D scalar, Set the constant to 25.0 .
  • Connect the output of Perlin 3D scalar and the other Constant Scalar, set to 10.0, to the Multiply node .

This time we do not want the Highest value to use used as we want linear dunes on the other dunes
so to do this we add the new Perlin noise on the linear dunes.


  • Connect the Multiply Scalar node to the Add Node.
  • Connect the Conditional Scalar at the end of the linear sand dune node network to the new Add Node.

Now we need to tie the the dunes into the Conditional Scalar before the Displacement shader, however I'm
going to do it in a Surprisingly different way.


  • Connect the new Add Node to the If result input on the Conditional Shader.

I've left linear dune node network feeding into the Input Node. This means that where the linear dunes
were visible before the new dunes will be used. All we need to do now is change the Base Color Shader
to something that looks Sandy and hopefully you have something that looks like this..

[attachimg=2]

Here's the finished tgd in case you got lost

[attachurl=3]

You might want to connect the dunes to the Input Node to see the effect, and for extra marks work how to make the plains
it creates use the linear dunes.


Sengin

Quote from: David Burnett on March 21, 2007, 11:59:23 AM
The displacement shader is expecting a scalar feed into the function input.  Feeding a vector into something expecting a scalar seems to have a defined behaviour

Oh, ok.  That would explain the cone then.  But how can I use the Build Vector node into anything so that I can create a terrain using those vectors?  Is there a shader, or do I just plug the output into something?  I've tried just connecting the output to the compute terrain, but the ground stayed flat.  Any ideas?

David Burnett

Quote from: Sengin on March 22, 2007, 03:03:51 AM
Oh, ok.  That would explain the cone then.  But how can I use the Build Vector node into anything so that I can create a terrain using those vectors?

Maybe the Redirection shader, but you propably would not use the build vector in the first place as you'd have to feed the X, Y and Z scalars into displacement shaders, then into the redirection shader.
I think you would also need to substract your vector from the original position to make it an offset.

Something to try when I gt home.

Dave

David Burnett

I've now copied the tutorial parts to the User-contributed Tutorials

Arandil

Thanks a lot David!  This is great stuff.

old_blaggard

You've spent a lot of time clarifying these.  Thanks for your efforts!
http://www.terragen.org - A great Terragen resource with models, contests, galleries, and forums.

nethskie

#43
Dave,

Thank you for the function tutorial because of this tutorial i was able to create this:



Full View: http://nethskie.deviantart.com/art/The-Great-Pyramids-of-Kaiser-1-174843418

Thanks and Best Regards,

Ken

Henry Blewer

That's a neat image. Nice work.
http://flickr.com/photos/njeneb/
Forget Tuesday; It's just Monday spelled with a T