Planetside Software Forums

General => Terragen Discussion => Topic started by: monks on June 26, 2012, 07:42:55 PM

Title: Masking Fake Stones
Post by: monks on June 26, 2012, 07:42:55 PM
Hi, I'm trying to use multiple layers of fake stones using surface layers. I'm controlling slope distrib via the surface layers and the terrain normal slope key. How would I go about masking the fake stones so that they don't end up stacking up on top of each other?
I've tried using the output from the fake stones as a mask, inverted, into the blend shader of the next surface layer, each mask added in series, but it's not working. The fake stones distrib is driven by a power fractal, and I've also tried using that output as a blend mask. Same results.

I was looking at the 'scalar to boolean' to try and convert the power fractal colour output to an on/off mask, so that I'm guaranteed a more accurate mask. That's not working to plan though as the colours in the power fractal are not black and white.

Anybody got any ideas how to go about this?

monks

Title: Re: Masking Fake Stones
Post by: Tangled-Universe on June 27, 2012, 01:58:29 AM
This is one of the FAQ, thus easy to find using the search function in the forum ;)

http://www.planetside.co.uk/forums/index.php?topic=11331.msg116207#msg116207

The output of the bottom merge shader needs to go into the child layer port of a surface layer.
Make sure the surface layer has no colour and you may need to enable "smoothing" in the surface layer.
This reverts the surface to the smoothed version of the last compute terrain before that specific surface layer and thus cancelling out displacements.
If you don't use this then the fake stones will incorporate the displacements of the terrain or small displacements after the compute terrain (for example).
Title: Re: Masking Fake Stones
Post by: billhd on June 27, 2012, 04:30:55 PM
A simple approach is to apply the stone layers such that smaller stones go underneath the bigger stones on the terrain, thus in the network the smaller stone nodes would cascade into the large ones in size succession. 

I too tried the masking, but for a different reason- I wanted to use a fake stone shader with big stones to make a mask that would be "expanded" in grayscale terms so that I could use it to distribute smaller stones right around the large stones, "chips off the old block".  I was not successful, tried scalar to color and could not get it but never addressed the forum on the question - I'm curious if anyone has a tip.  Bill
Title: Re: Masking Fake Stones
Post by: monks on June 27, 2012, 07:15:52 PM
Thanks Tangled, I'll take a look at it. billld I'm also wondering about the other method- of controlling placement via mask manipulation- would be useful for other things too. It would be good to be able to turn all non black areas to white- which I think is what the scalar to boolean does, but I had problems getting 1 and 0. I've no doubt it can be done. I don't really understand the interface or the colour adjust node- it's remapping? Which slider maps what? The method Tangled linked looks simpler.

monks
Title: Re: Masking Fake Stones
Post by: penboack on June 28, 2012, 10:03:05 AM
I've been having some problems with Fake stones as well.

Using a network of Fake Stones shaders before the last (only in this case) Compute Terrain node I was able to get the Populator to populate on top of the stones, and to use the Fake stones shader output as a mask for a white (boring) Surface Layer shader. Obviously this isn't so useful with trees! but it would be useful for adding a population of rocks on top of boulders. [Scene Fake-Stones_1_v2]

[attachimg=1]

The problems comes when I add Fake Stones to a Fractal Terrain and want to use the output of the last node in the Fake stones network as a mask for a Surface Layer shader.

In the test scene the Fake stones should be white, and the terrain the default colour, but it doesn't work. What I am struggling with is how to update the texture coordinates so that the masking works, or technically where to put a Compute Terrain node or nodes to update the texture coordinates.

[attachimg=4]

I tried adding an additional Compute Terrain node after the Fake stones shaders and then merging the Fractal terrain, but that didn't produce the expected result, instead some of the white surface layer texturing still appears on the terrain. [Scene: Fake-Stones_2_v3]

How do you add Fake stones to a terrain before the Compute Terrain node and use the Fake stones shader output as a mask for texturing?
Title: Re: Masking Fake Stones
Post by: monks on June 28, 2012, 12:29:05 PM
Penboack, looking at these to get some tips. :) In both versions I think the smallest fake stone are plugged into the wrong node. Is this affecting anything?

monks
Title: Re: Masking Fake Stones
Post by: Hetzen on June 28, 2012, 12:50:41 PM
Does un-checking Vary Density in the Fake Stones shader help? There is/was a bug with texture alignment.
Title: Re: Masking Fake Stones
Post by: Tangled-Universe on June 28, 2012, 02:46:34 PM
There was an error in your setup, but that didn't affect anything (you had one fake stone layer as merge controller, instead of 'shader A')

Ok, here it is:

You have a fractal terrain and to that you add fake stones.
However, the data-flow doesn't provide information from the compute terrain where the fake stones actually have been added.
Both terrain and fake stones were calculated at once and share all the same coordinates.
This results in a misalignment when you use the fake stones as a blendshader downstream in the network, since the fake stones at that point weren't supplied with proper texture coordinates and normals, yet.

I'll try to explain, but it's a bit hard to do that easily, so I'll do my best :)

What you need is to create 2 stages, as follow:

1) create terrain and compute
Now the terrain has been calculated first, providing base texture coordinates and normals to perform proper masking on for altitude and slope respectively.

2) add fake stones after the computed terrain fractal
These fake stones are now created onto the terrain which has properly calculated texture coordinates and normals as a base.
The resulting texture coordinates and normals will align with the base terrain.

3) compute again
Because the stones are separately added the compute terrain will update the texture coordinates and normals with the data provided from the fake stones.
Now the terrain and fake stones are "merged" as final* texture coordinates and normals of the terrain and thus will align properly.

In other words: because the fake stones addition is calculated again the program is now aware of the difference between the terrain and the added fake stones when you use the fake stones as a blendshader downstream in the network.

(*final: in this case NOT the same to final position/normal as seen in the distribution shader. Final position/normal is the state of the data stream when computed in the planet node)

4) shade and/or blend for fake stones

I'll read this message again a bit later and try to make it more clear.
Anyway, the images speak for themselves.

Mask_stones_misalignment.jpg shows what happens when you do not calculate everything separately. As you can see the white colour is misaligned because it follows the terrain instead of the terrain + fake stones.

Cheers,
Martin
Title: Re: Masking Fake Stones
Post by: penboack on June 29, 2012, 05:23:54 AM
Thanks Martin.
I understand it now. It is not easy to explain these things.

Aside from having Compute Terrain nodes in the correct places, the key seems to be to use a Surface Layer node's child input to add in the Fake Stones network output so that it overrides the terrain, rather than using a Merge node which sort of mixes up the texture coordinates. For a while now I've been struggling a bit with the whole problem of generating Terrain features and using the sub-network that creates them as a mask for texturing. I can see that this technique could be very useful for solving these types of problem.

Thanks to both of you for spotting the mistake in my Fake Stones network.
Title: Re: Masking Fake Stones
Post by: Tangled-Universe on June 29, 2012, 07:14:14 AM
Quote from: penboack on June 29, 2012, 05:23:54 AM
Thanks Martin.
I understand it now. It is not easy to explain these things.

Aside from having Compute Terrain nodes in the correct places, the key seems to be to use a Surface Layer node's child input to add in the Fake Stones network output so that it overrides the terrain, rather than using a Merge node which sort of mixes up the texture coordinates. For a while now I've been struggling a bit with the whole problem of generating Terrain features and using the sub-network that creates them as a mask for texturing. I can see that this technique could be very useful for solving these types of problem.

Thanks to both of you for spotting the mistake in my Fake Stones network.


You're welcome, no problem.

The surface layer is just a base. I'm not really sure what you mean by 'overrides'. It's just a placeholder for the fake stones to exist on. But indeed, you're right that using a merge shader probably isn't right. I haven't tried that yet actually in this setup. You can replace the surface layer with a merge shader and see if it still works.
The most important aspect is the 2-step calculation.

The most important reason for a surface layer is something else, actually. For example, you perform medium scale and quite some small scale displacements after the compute terrain. That's most of the times not a real problem.
However, if you add in fake stones then they will incorporate those displacements, resulting in messed up stones.
The surfacelayer has an option called "smoothing" which tells the shader (surface layer) to NOT use the current state at that point in the data-stream, but look up for the nearest computed terrain up in the network and use the terrain and texture coordinates at that point.
By that you will by-pass the medium and small scale displacements for your fake stones, but also allows for completely separate shading of your stones :)
Title: Re: Masking Fake Stones
Post by: bobbystahr on June 29, 2012, 11:05:36 AM
Well, out of inspiration today I deceided to dive into this one and am floundering. I managed to get the FS nodes set up as described but cannot for the life of me, figure out how to apply different textures to each size of FS....Help pleeeeeze, and thanks up front....attached is my .tgd if someone could fix my set up...seems the only way I learn is by seeing sometimes....
Title: Re: Masking Fake Stones
Post by: inkydigit on June 29, 2012, 11:58:32 AM
Hi Bobby, the only way really that I have found is to have separate surface layers for each (set) of fake stones...trying to find an easier way has been almost impossible for me!
:)
Title: Re: Masking Fake Stones
Post by: bobbystahr on June 29, 2012, 01:44:53 PM
Quote from: inkydigit on June 29, 2012, 11:58:32 AM
Hi Bobby, the only way really that I have found is to have separate surface layers for each (set) of fake stones...trying to find an easier way has been almost impossible for me!
:)
Where do I put them mate?...I can't seem to get it to work from the Shader Tab...
Title: Re: Masking Fake Stones
Post by: monks on June 29, 2012, 08:11:36 PM
Martin's explanation did help a lot. Bobby that's exactly what I ended up looking into- still trying to do that now  :D

monks
Title: Re: Masking Fake Stones
Post by: monks on June 29, 2012, 10:10:19 PM
Bobby. you might try this http://www.planetside.co.uk/forums/index.php?topic=2573.msg25643#msg25643

Plug two power fractals into a colour mixer and plug the output into your rock surface shder. Do that for each stone size and that might work...testing it now.  Maybe not the best way, think surface layers would be better, but it looks like a possible improvement.

//I think the merge shader is better than the colour mixer.
For some reason my imag keeps failing security checks so here's a link.

Am I right in saying that you can stack surface layers like this with a series of child nodes going into the fakes stones shader input?
[link expired]
monks
Title: Re: Masking Fake Stones
Post by: Dune on June 30, 2012, 03:09:11 AM
Check this out, Bobby. Maybe it helps.
Title: Re: Masking Fake Stones
Post by: Tangled-Universe on June 30, 2012, 03:57:14 AM
I think Bobby wants to have each fake stone layer a different texture.

As Jason (Inkydigit) pointed out you will need surfacelayers/powerfractals separately for every fake stone shader.
Jason, there's no easier way to do it. It makes perfectly sense of course to give every fake stone shader it's own set of shading if you want that done separately ;)

I've attached an example below, it uses Ulco's scene as a base, so in order to reproduce this exactly you will need his .tgd above.
Title: Re: Masking Fake Stones
Post by: Tangled-Universe on June 30, 2012, 04:23:17 AM
It can easily get pretty daunting though.
Below you can see how the network looks of those stones.
There's a lot of displacement being performed and computed and then every stone has separate shading, although they do share some fractals.
Just to give an idea what's possible.
Title: Re: Masking Fake Stones
Post by: inkydigit on June 30, 2012, 08:41:13 AM
thanks guys for jumping in, I did not have time to have a look at the tgd last night as I was busy!
(sorry Bobby)
@Martin, I know there is no easier way to do it, but I always try to find a shortcut if possible!!...my node networks can get pretty complicated very quickly when using fake stones!
my last image (http://www.planetside.co.uk/forums/index.php?topic=14753.0) used 11 layers of stones using merge shaders and 'highest raise' to separate the different sizes effectively...
:)
Jason
ps Martin, love the displacements on those stones... they look great!
Title: Re: Masking Fake Stones
Post by: monks on June 30, 2012, 09:34:10 AM
That's awesome guys...I did try the surface layer into the shader input of the fake stones node last night but it didn't immmediately look like it was going in the right direction. Was going to try it again today...but here we have it! :-D
I think getting this right is a strong basis for any project so I think I've learned something really invaluablel here.  :)

monks
Title: Re: Masking Fake Stones
Post by: bobbystahr on June 30, 2012, 09:46:16 AM
wow...now we're cooking with gas. I sense a creative surge coming on...if only a similar solution could be had for my SSShader separate texturing conundrum from a while back. It has me currently scratching my head like this FS thing had till all y'all figured it our so elegantly...thanks to all the participants....off to play...
Title: Re: Masking Fake Stones
Post by: bobbystahr on June 30, 2012, 09:48:26 AM
Quote from: monks on June 30, 2012, 09:34:10 AM
That's awesome guys...I did try the surface layer into the shader input of the fake stones node last night but it didn't immmediately look like it was going in the right direction. Was going to try it again today...but here we have it! :-D
I think getting this right is a strong basis for any project so I think I've learned something really invaluablel here.  :)

monks
That's what's so freakin' great about this forum...so many 'gurus' to call out to....
Title: Re: Masking Fake Stones
Post by: bobbystahr on June 30, 2012, 04:54:31 PM
Well that was most educational. Here's a WIP of the image I'm working on with this set up. I use image maps almost exclusively due toi my colour blindness so it is good to get them in the pipe...
Title: Re: Masking Fake Stones
Post by: monks on June 30, 2012, 05:15:27 PM
They rock!  :D I've seen a lot of great results with image maps. Might give that a try myself at some point. Are you using bump maps for these?

monks
Title: Re: Masking Fake Stones
Post by: bobbystahr on June 30, 2012, 10:14:10 PM
Quote from: monks on June 30, 2012, 05:15:27 PM
They rock!  :D I've seen a lot of great results with image maps. Might give that a try myself at some point. Are you using bump maps for these?

monks
Yes, but only on import objects....terrains and FSs and I think Simple Shape Shaders will all displace, as they connect to the terrain is my theory......the colour maps came with displacement, alpha and specular as well as regular bumps but I displace the FS's with the displace one....
Title: Re: Masking Fake Stones
Post by: penboack on July 01, 2012, 08:17:28 AM
Can anyone explain what the "Separate Geometry" parameter does?
My searches aren't coming up with anything other than people saying they don't use it!
Title: Re: Masking Fake Stones
Post by: inkydigit on July 01, 2012, 11:01:10 AM
@ Bobby, that looks great!...
about the 'SSShader separate texturing conundrum', did you try using the output from the SSS as the blending shader input for your image map or surface layer?
:)
Title: Re: Masking Fake Stones
Post by: monks on July 01, 2012, 11:20:45 AM
Bobby, so, do you use the displacement map as an image map to displace with? Which node of which shader type would you plug that into to?

monks
Title: Re: Masking Fake Stones
Post by: bobbystahr on July 01, 2012, 12:12:43 PM
Quote from: monks on July 01, 2012, 11:20:45 AM
Bobby, so, do you use the displacement map as an image map to displace with? Which node of which shader type would you plug that into to?

monks
When using images I proceed thus:
1. add Surface Layer
2. in Colour Tab>Colour function select from the + Create new shader>Colour Shader>Image map shader
3. select map from the dir you choose and select mapping method from Projection type and scale the map as needed then
go to the Flip, Repeat Tab and select repeat in both directions.
For displacement follow these steps in the Displacement Tab [this is where you add your Displace image..generally an exact copy of the colour map but in grayscale ] adding your displacement with the slider or type in the field.
hope this helps
Title: Re: Masking Fake Stones
Post by: bobbystahr on July 01, 2012, 12:25:35 PM
Quote from: inkydigit on July 01, 2012, 11:01:10 AM
@ Bobby, that looks great!...
about the 'SSShader separate texturing conundrum', did you try using the output from the SSS as the blending shader input for your image map or surface layer?
:)


yup...think I've tried everything I can think of. They seem to be a part of the terrain calculation and that screws them up as separate objects for texturing. Here's one to mess around with if y want....
Title: Re: Masking Fake Stones
Post by: Kevin F on July 01, 2012, 02:01:47 PM
re - Can anyone explain what the "Separate Geometry" parameter does?
My searches aren't coming up with anything other than people saying they don't use it!

From what I remember it's not actually in use or been in use since day one. Oshyan said something years back about it being a to be feature, but so far it's not been activated or removed. Matt?
Title: Re: Masking Fake Stones
Post by: monks on July 01, 2012, 03:21:48 PM
Thanks for that Bobby, that's very helpful!  ;)

monks

Title: Re: Masking Fake Stones
Post by: Matt on July 02, 2012, 09:00:48 PM
"Separate geometry" doesn't do anything. I don't know why we still have the parameter in there - we should remove it.

Matt
Title: Re: Masking Fake Stones
Post by: bobbystahr on July 03, 2012, 08:46:04 AM
Quote from: Matt on July 02, 2012, 09:00:48 PM
"Separate geometry" doesn't do anything. I don't know why we still have the parameter in there - we should remove it.

Matt


Hear Hear!!!!been driving me nuts with it's non usefulness...keep wanting it to do something useful like float the stones in 3D...then we could make rain with stones
Title: Re: Masking Fake Stones
Post by: Dune on July 04, 2012, 02:59:32 AM
You can make stone rains (hailstorms) if you like, just sit several pops of stones on virtual very displaced terrains.
Title: Re: Masking Fake Stones
Post by: bobbystahr on July 04, 2012, 06:45:50 AM
Quote from: Dune on July 04, 2012, 02:59:32 AM
You can make stone rains (hailstorms) if you like, just sit several pops of stones on virtual very displaced terrains.
yup and make the terrain invisible...was just tryin t think of a use for that button...
Title: Re: Masking Fake Stones
Post by: Dune on July 05, 2012, 02:44:31 AM
A PF sidetrack (or even loose) is enough for them to sit on.

10 second example:
Title: Re: Masking Fake Stones
Post by: bobbystahr on July 05, 2012, 12:32:17 PM
checking this out...thanks mate....