I need help with the most basic things!

Started by shadowphile, August 16, 2009, 07:23:52 PM

Previous topic - Next topic

shadowphile

Read the tutorials, played for days, searched the forums.  Finally gotta ask...

I'm having trouble wrapping my head around the TG2 paradigm, despite being very familiar with nodes, shaders, etc.

I'm trying this without luck:
-generate the default terrain, it looks like rocky ground ok
-paint a big fat diagonal stripe across the terrain to create a new painted shader (call it 'stripe')
-wire the stripe output to the shader input of the default loaded heightfield generate node
-regenerate the heightfield
-I get a completely flat field rather than rocky terrain within the stripe, (or outside the stripe, whatever)
However, I stumbled into a method that works, although I have no idea why this works and not the previous:
-Apply the stripe output to the blending shader input of the heightfield shader.
I suppose that begs the question: what does the shader blend input actually do on a height-field generater?

I've also tried many permutations using the convert nodes, shader-to-heightfield, etc.

And terrain vs shaders with displacement turned on...  both seem to create height data, what's the diff?
thanks

rcallicotte

Maybe it is too late at night for me to understand your question.  What is your question - what are you wanting to do and do not understand how to do?
So this is Disney World.  Can we live here?

shadowphile

I am trying to make learn how to control the terrain.
I am trying to use the painted shader as a mask to flatten a certain region of my terrain.
The blend shader input should act like an alpha mask using the the painted shader I created, which is a big solid white stripe across a black background.
But the heightfield does not respond as I expect, but instead acts as if the entire painted shader is solid black.
I tend to try to understand how things work rather than memorize how to do certain things, so bear with me please.

Matt

#3
The way to do this is to use your mask (painted shader or other shader that generates colour) as a blend shader in the Heightfield Shader. That doesn't affect the heightfield data, but it masks how the heightfield data is applied as displacement by the Heightfield Shader.

To affect the heightfield data directly, you would plug a displacement shader into the shader input of the Heightfield Generate node. However, that completely replaces the built-in fractal generation with the displacement shader you supply; it is not actually a mask. Still, it's reasonable to think you might get some recognisable height data from the painted shader, but the reason this doesn't work is that the shader input is specifically for generating a terrain from a displacement shader. In Terragen 2, some shaders generate colour and usually apply that colour as a diffuse colour (e.g. the painted shader), some shaders affect the appearance of a surface in some other way that doesn't generate diffuse colour (e.g. a reflective shader), some apply displacement (e.g. the alpine fractal shader), some do more than one of the above (e.g. the power fractal shader which generates colour, applies that as diffuse surface colour, and generates displacement with roughness parameters which can vary from the colour roughness parameters). The painted shader only generates colour and applies that colour to a surface as diffuse colour, but it does not generate displacement on its own. So if you try to generate a terrain from that it will be flat. You can turn colour into displacement by using the Displacement Shader, and then you could plug that into the Heightfield Generate.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

Matt

Generally I would recommend using your painted shader as the blend shader in the Heightfield Shader, so that the location and resolution of your mask is independent of the heightfield data. It's also the easiest to set up. But if for some reason you specifically need to mask the heightfield data that you generated (e.g. if you want to apply erosion operators to the result), you would probably need to do it as follows. Feed your painted shader into the function input of a Displacement Shader (Create Shader -> Displacement Shader -> Displacement shader). Feed the Displacement Shader into the shader input of another Heightfield Generate node, making sure to use the same size in metres, size in pixels, and all coordinates on the Shader tab. Then use a Heightfield Merge node to combine the two Heightfield Generate nodes, with the merge mode set to "Multiply".

Matt
Just because milk is white doesn't mean that clouds are made of milk.

rcallicotte

So this is Disney World.  Can we live here?

shadowphile

thanks Matt, I got that to work.
I'm confused about the multiply operation though.
When I try some of the other math operations, they make no sense.
It's almost as if the the painted shader is an alpha layer or something that gets ignored by most of the math operators except for the multiply.  For example, shouldn't I be able to simply stack the two heightfields with the Add option?  Instead it's like the painted shader-turned-heightfield was completely flat, and only the other heightfield shows.

FrankB

the heightfield itself doesn't have color by default, hence any operators expecting color in the input are not going to work. The painted shader (by default) is only a white texture at the coordinates you painted on.

I think you may be trying the "merge shader"? Just in case, Matt means the "heightfield merge shader", found in the heightfield shader menu.

Matt, using "multiply" actually flattens out the merged result a lot. It seems that you get more usable results when set to "mix", although that really changes the result and may not meet the initial purpose.

Frank

Matt

#8
Quote from: shadowphile on August 19, 2009, 04:54:30 AM
thanks Matt, I got that to work.
I'm confused about the multiply operation though.
When I try some of the other math operations, they make no sense.
It's almost as if the the painted shader is an alpha layer or something that gets ignored by most of the math operators except for the multiply.  For example, shouldn't I be able to simply stack the two heightfields with the Add option?  Instead it's like the painted shader-turned-heightfield was completely flat, and only the other heightfield shows.

The values in the painted shader are probably producing values between 0 and 1. If you plug that into a displacement shader with default settings, you will only get a displacement of 1 metre. That will be virtually invisible on a large terrain. The displacement shader has a multiplier which you can use.

If you add that 1-metre high terrain to a much larger terrain that's hundreds of metres high, you just won't see it.

Multiply mode works OK because multiplying works with even small values. Actually the multiply operator normalises the range of both heightfields to 0 to 1 before it performs the multiplication, and the result should have the same minimum height as the left input and anything up to its maximum height. This normalisation is necessary because multiplication of the raw heights would give extremely large values for typical terrains. For addition and other modes, the actual heights are used as-is.

All of this stuff works better as blend shaders for the Heightfield Shader, and if you can do it that way I would really recommend it.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

Matt

#9
Quote from: FrankB on August 19, 2009, 05:42:29 AM
Matt, using "multiply" actually flattens out the merged result a lot. It seems that you get more usable results when set to "mix", although that really changes the result and may not meet the initial purpose.

Most of a terrain will be less high than its highest point. These values are normalised to the 0..1 range before multiplying. Since most values are less than 1, multiplying them together gives even smaller values. So you will only ever retain the same height range if you have areas of maximum altitude in the same places on both heightfields.

If using a terrain that's built from a basic black and white mask, you can see that it does work. From the original post I figured that shadowphile was trying to use the painted shader as a mask, so multiply is the best merge mode.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

FrankB