populations sit on terrain and Power Fractal Shader?

Started by fferro, October 05, 2009, 02:41:47 PM

Previous topic - Next topic

fferro

I have a Heightfield shader with a Terrain loaded as Heightfield.
Its output is connected to the Base Colours .
As the DEM file has a very low resolution, I have added a Surface layer shader with a Power Fractal Shader V3. as a child of it.
So:
Heightfield Load > Heightfield > Compute Terrain > Base Colours > Surface layer < Power Fractal V3.

I don't know if this is the right order but now the terrain looks very good, with very realistic details of snow and rocks.
The problems starts trying to populate trees over this ground surface. Specifically with the Terrain tab of the Populator shader.

Using the Surface layer only as sit on terrain parameter (disconnecting the Power fractal child), the trees look more or less over the terrain but they are not considering the Power Fractal so, some trees are below the ground and some are flying around (not at a very long distance of the terrain).
When I connect the Power Fractal as a child of the Surface layer, the trees are all flying around at a very long distance.
I guess the Power Fractal is working as a kind of multiplier of the original heightfield but I'm not sure about this.
Which is the correct shader I have to use in the populators v3 terrain parameter?

The Base Colours has no displacement.
The Surface layer has a Displacement multiplier of 1 and no Displacement function.
The Power Fractal Shader v3 has a Feature Scale of 600, Leading Scale of 20, Smallest Scale of 3. And a Displacement Amplitude of 100 Along Normals.

Thanks in advance.

Tangled-Universe

You've already figured out that you can change the "sit on" shader for populations, so that is good.

The reason it doesn't work in your situation now is because you have added displacements after a compute terrain.
Briefly explained:

Compute normal: computes and updates terrain normals
Compute terrain: computes and updates terrain normals + texture coordinates

So in your case your network computes the heightfield correctly, but doesn't compute and update the normals of the powerfractal anymore.
The populator "thinks" the terrain is just the heightfield before the compute terrain and therefore the instances aren't placed correctly.
You need to add an additional compute terrain/normal to have the instances being placed correctly.
Use a compute normal when you don't use any further restrictions. If you also want to restrict populations by height/slope then you need texture coordinates and thus need a compute terrain.

That's a solution for your case, however, you have deviated from the "standard" workflow of TG2:

Normally you would apply all displacements before a compute terrain.
After the compute terrain you only add surface layers for color/textures.
If you happen to have displacements after a compute terrain then you may need to add another compute terrain to have restrictions etc. to work correctly, especially when you want to add populations.

In your case you would have to change your setup slightly to this:

Heightfield Load > Heightfield > Power Fractal V3 > Compute Terrain > Base Colours > Surface layer

A surface layer doesn't work before the compute terrain because of the afore mentioned reason that there aren't any texture coordinates available at that point in the network.
Also, you added the powerfractal as a child to the surface layer and as far as I know the surface layer node needs texture coordinates to work properly.
Hope this is more clear.

Cheers,
Martin

fferro

thanks Tangled-Universe,

This Power Fractal has a Blend shader (distance from camera) to add details far away from the camera and not close to it.
With the Heightfield as input, the output does not show the original terrain close to the camera, because of the Distance shader.
May be I have to use a Heightfield Merge instead (between the original and the Power Fractal), but I don't know how.

RArcher

Here is a node screenshot of how the network should be laid out with the perfect advice Martin gave you, but including the distance shader.

fferro

Thanks RArcher,
I've added a Displacement Shader with the Heightfield as input and the Power Fractal as Function.
Now it's working.
As I can see, the Colour tab of the Power Fractal controls the height added to the original terrain, (the Displacement tab has no effect).
Just a little problem:
I need to "offset" the height to get some spots over the original and some below. Is it possible?
Thanks in advance.

Tangled-Universe

Quote from: fferro on October 07, 2009, 03:53:29 PM
Thanks RArcher,
I've added a Displacement Shader with the Heightfield as input and the Power Fractal as Function.
Now it's working.
As I can see, the Colour tab of the Power Fractal controls the height added to the original terrain, (the Displacement tab has no effect).
Just a little problem:
I need to "offset" the height to get some spots over the original and some below. Is it possible?
Thanks in advance.

Can you post a screenshot or the .tgd of your project? This sounds a bit weird...

fferro

That's it:


By fferro

The Power fractal shader add some details to the Heightfield shader.
The Base colours shader just paint all the ground with brown.
The Surface layer "Nieve Total" paint the ground with White, with a Slope constraint active.
The Image map "Trees Area Mask" (as a Blending shader) occlude some colour regions of the Surface layer Nieve Total.
Thanks

dandelO

QuoteAs I can see, the Colour tab of the Power Fractal controls the height added to the original terrain, (the Displacement tab has no effect).

The power fractal's displacement tab has no effect if the fractal is set as a function to another shader, here, your displacement shader.
The displacement shader is taking colour data only from the fractal and it(the displacement shader) then applies the displacement, based on the greyscale pattern of the fractal.

fferro

Thanks dandelO,

I can see that, but cannot find a solution to this:

Quote from: fferro on October 07, 2009, 03:53:29 PM
Just a little problem:
I need to "offset" the height to get some spots over the original and some below. Is it possible?
Thanks in advance.

Now the Power fractal "add" only to the oringinal.
Thanks again.

dandelO

You could try putting a power fractal(any scale, not important), with 'apply displacement' checked but with no displacement multiplier, first in your network, before the heightfield shader.

Use the 'displacement offset' of this new fractal either in positive or negative values to move the following terrain up and down.

I'm not sure I understand if that's exactly what you're asking, though.