Planetside Software Forums

General => Terragen Discussion => Topic started by: sjefen on December 01, 2021, 06:53:49 PM

Title: Shader setup help
Post by: sjefen on December 01, 2021, 06:53:49 PM
Hi,


I'm trying to setup a shader for some trees where there are two different shaders for the bark. One at the bottom that goes a few meter up and then the other one takes over, but I have no clue how to do this and make the textures respect the object and not the elevation (or whatever). It works fine if the trees are all at the same elevation, but if some of them are higher up a hill for example, the bottom texture disappear. I hope that makes sense. Can someone help me out?  ;D

As seen in the image of the trees, one of them are lifted from the ground, but the red texture stops at the same height as the other tree.



Stupid trees.jpg
stupid tree nodes.jpg

- Terje
Title: Re: Shader setup help
Post by: Dune on December 02, 2021, 02:05:24 AM
It does work if you use position in terrain/texture and Y.
Title: Re: Shader setup help
Post by: Hannes on December 02, 2021, 03:58:29 AM
Hmmm. Doesn't seem to work for me. I used other values for maximum altitude as well, even extreme ones, positive and negative, but I don't get the effect you had.
(In my image the foliage shaders are set to zero opacity).
Title: Re: Shader setup help
Post by: Hannes on December 02, 2021, 04:14:16 AM
I'm an idiot. In my example I used the RTP, but didn't enable shading... ::)

Nevertheless, I can't get the desired effect, even with other colors. (Edit: "Values" of course!!)
Title: Re: Shader setup help
Post by: KlausK on December 02, 2021, 06:09:56 AM
Doesn`t seem to be as straightforward as one might think. I can`t get it to work either...
I use a elongated cube from TGs object list. Similar aproach/thinking as sjefen, I believe.
Gave up after trying to click together each and every combinations of surface shaders, merges, altitude limits and colour shading.

Btw what kind of object are you all using that can attach the shaders on the outside? I forgot how to do that.

CHeers, Klaus
Title: Re: Shader setup help
Post by: Kadri on December 02, 2021, 07:55:44 AM

I tried it with your setup Klaus and it didn't work for me too.

But with a population it worked in this way (i used your nodes).

It is different for populations and moving separate single object maybe (Objects with UV's and without are an another consideration too...) ?

We have to use the translate node for moving objects maybe?
Title: Re: Shader setup help
Post by: Kadri on December 02, 2021, 07:59:02 AM
Quote from: KlausK on December 02, 2021, 06:09:56 AMBtw what kind of object are you all using that can attach the shaders on the outside? I forgot how to do that.

CHeers, Klaus

You can right click in the internal node network on a node and assign any node that is in the outside.
Title: Re: Shader setup help
Post by: KlausK on December 02, 2021, 08:48:02 AM
Thanks for testing my file, Kadri.
I had the same thought regarding the Transform Shader but every connection in the setup, every setting in the node did not help.
Maybe I did not do it correctly, of course.

So that is maybe why Ulcos setup worked. Looks like he used populations too.
But if this works with a population it only makes things more complicated.
I would like to be able to use this on single objects with each its own shader setup.
To me it is like sjefen wrote: some sort of a "object space" would be needed, like in 3d programs.
Wht the animation shows is "world space" Lightwave style - as far as I know and remember it.

Fiddling on....

CHeers, Klaus
Title: Re: Shader setup help
Post by: Dune on December 02, 2021, 09:12:55 AM
Strange that it doesn't work for you guys. But perhaps there's also a way to use the displacement to scalar from terrain and warp a level (terrain, not final) by it over Y and use that as mask (though transform at world.
\

EDIT: I had another look. This works. You just need a gradient (image map) and use the UV. By resizing the map, and adjusting Y you can play with the extent of the mask on the bark.
Title: Re: Shader setup help
Post by: Kadri on December 02, 2021, 09:54:24 AM

For populations it works Ulco. But for the single moving object in Klaus's example not.

Klaus your scene works with an OBJ that had UV's with the setup you see below.

But why it works only in this way i don't know. Maybe because of The UV's like in your example Ulco.
Title: Re: Shader setup help
Post by: Kadri on December 02, 2021, 10:04:08 AM
I tried an OBJ without UV's and that didn't work with that setup. You need UV's to get that setup to work as it looks.
Title: Re: Shader setup help
Post by: WAS on December 02, 2021, 12:36:27 PM
An objects space doesn't align with world space, just like a cloud doesn't unless in final. Probably the issue. Your mask is probably far below the object.

Depending on the objects location on Y the actual "0" of Y is offseted.

For me when I set a level, without it being final position, I can move a single object and the surface layer remains in position.

It's good to note that the scale of the altitudes seems to be somehow related to the object, and not world space. For example. The tree is only lifted 1 meter in this example. And the tree is only a little over 4m, but the altitude settings, as you can see, do not relate to these dimensions. The cut-off is 10 meters high, with a 5 meter fuzzy zone.

(https://media.giphy.com/media/OOXe1n6Q7fzIjPRkZn/giphy.gif) (https://giphy.com/gifs/terragen-OOXe1n6Q7fzIjPRkZn)
Title: Re: Shader setup help
Post by: sboerner on December 02, 2021, 04:11:01 PM
Interesting thread!
Title: Re: Shader setup help
Post by: KlausK on December 02, 2021, 05:13:55 PM
Quote from: sboerner on December 02, 2021, 04:11:01 PMInteresting thread!
Yep!

Thanks for the file Kadri.
And WASs example shows what I found trying to use the Altitude Min-Max.

So, built in objects in TG like the cube I used do not carry UVs then?
I somehow always assumed they did, in a way...

CHeers, Klaus
Title: Re: Shader setup help
Post by: WAS on December 02, 2021, 05:32:30 PM
Quote from: KlausK on December 02, 2021, 05:13:55 PM
Quote from: sboerner on December 02, 2021, 04:11:01 PMInteresting thread!

So, built in objects in TG like the cube I used do not carry UVs then?
I somehow always assumed they did, in a way...

They do, so I'm not sure what that's about. I've always used UV projections with textures for them. Even the planet has UV.

That being said, it would be cool if TG shipped with a UV grid for them (for other programs to align textures) or able to export UV grids.
Title: Re: Shader setup help
Post by: KlausK on December 02, 2021, 07:09:13 PM
Well,

I found the solution to move the textures with the built in cube in the Wiki:
https://planetside.co.uk/wiki/index.php?title=Sphere
Under the "Rotate" paragraph the procedure is described.

You have to use a "Transform input shader" after Textures and / or Displacements
and move them the same amount as the cube object in y. If you rotate the cube in
x and z then you have to do the rotation in the transform as well.

In the case of using the "Altitude Min-Max" settings in the "Surface Layer" you
have to subtract or add depending from the amount of translation in the "Transform input".

The cube object is animated and the "Transform input" in y as well.
Scene file, screenshot and animation attached.

Not ideal but also not too much hazzle for only a few objects, I guess.

CHeers, Klaus
Title: Re: Shader setup help
Post by: WAS on December 02, 2021, 07:25:40 PM
Really loving all the new wiki pages. Kevin is doing an amazing job.

So it's the Y offset I was mentioning earlier primarily causing the issue. Translating the shaders is a bit weird. You'd think you'd use final space otherwise the 0,0,0 of texture space should follow the origin of the primitive.
Title: Re: Shader setup help
Post by: sboerner on December 02, 2021, 09:11:20 PM
QuoteReally loving all the new wiki pages. Kevin is doing an amazing job.
Second this. Updating those pages is a *lot* of work and it is much appreciated.
Title: Re: Shader setup help
Post by: Dune on December 03, 2021, 01:56:58 AM
Translating textures to displacable objects indeed always needed the location of the object (either directly or through transform shader), like for a moon/planet spherical image projection.
Title: Re: Shader setup help
Post by: WAS on December 03, 2021, 03:13:27 AM
If it is indeed a population, a final position displacement to scalar before the compute terrain should indeed push up the as needed. I may actually say you'd have better results with less hard warping doing a heightmap and smoothing it.  Than warp the distribution shader for maximums altitude. May need to negatively warp. I had to do that earlier with clouds though wasn't a terrain to scalar. Then final position that making network. For single populations the above described works fine for just setting the objects locations themselves.
Title: Re: Shader setup help
Post by: sjefen on December 03, 2021, 07:19:16 PM
I feel a little stupid now. I was gonna use this for a population, I just didn't think that mattered. I was just setting up the shaders for the model and testing them when I noticed the "issue". It works for populations, so I'm happy. Would still be nice with an option there that only is for "object" along "position in terrain/texture" and "final position" tho.

- Terje