Planetside Software Forums

Support => Terragen Support => Topic started by: iaminonsiner on February 06, 2019, 02:03:58 pm

Title: Object and terrain interactions
Post by: iaminonsiner on February 06, 2019, 02:03:58 pm
Hello !

I have question about objects :

How can I link an object and the ground on which it is placed? I'm not sure how to illustrate this, but I'd like to do it in the future with buildings and pretend that the building is a "piece" of the terrain and not an object ON the terrain... In my mind, I want to see a building with the same colour / textures of the terrain ( not the effects like power fractal or twist, just the " surface ").

Image for illustrate :

[attachimg=1]


I think I've already seen this on the forum but I can't find the topics.

Thank you guys.

EDIT : as if I had made an "extrusion" from the ground and not an import from an external object
Title: Re: Object and terrain interactions
Post by: archonforest on February 06, 2019, 02:20:13 pm
Just connect the PF that covers the ground to the surface layer of the object. Then you will have the same coverage.
Title: Re: Object and terrain interactions
Post by: iaminonsiner on February 06, 2019, 02:27:28 pm
Quote from: archonforest on February 06, 2019, 02:20:13 pm
Just connect the PF that covers the ground to the surface layer of the object. Then you will have the same coverage.


How ? and what's the "PF" ?
Title: Re: Object and terrain interactions
Post by: iaminonsiner on February 06, 2019, 02:30:01 pm
I tried to connect the " base colour " of a default scene to the sphere object and I think it works.

Do you think can I do the same for the terrain geometry ?


[attachimg=1]
Title: Re: Object and terrain interactions
Post by: archonforest on February 06, 2019, 02:38:15 pm
Quote from: iaminonsiner on February 06, 2019, 02:27:28 pm
Quote from: archonforest on February 06, 2019, 02:20:13 pm
Just connect the PF that covers the ground to the surface layer of the object. Then you will have the same coverage.


How ? and what's the "PF" ?


Ahh...sorry. PF is the short version of Power fractal. Take a look of the attached file. Is this what u need?
Title: Re: Object and terrain interactions
Post by: iaminonsiner on February 06, 2019, 03:40:18 pm
Power fractal obviously and yes this is something like that.

Do you think can I do the same for the terrain geometry ? ( You can see the image above )


Title: Re: Object and terrain interactions
Post by: archonforest on February 06, 2019, 03:53:18 pm
Quote from: iaminonsiner on February 06, 2019, 03:40:18 pm
Power fractal obviously and yes this is something like that.

Do you think can I do the same for the terrain geometry ? ( You can see the image above )

I am not sure about the question...Can u explain?
Title: Re: Object and terrain interactions
Post by: iaminonsiner on February 06, 2019, 04:01:07 pm
Quote from: archonforest on February 06, 2019, 03:53:18 pm
Quote from: iaminonsiner on February 06, 2019, 03:40:18 pm
Power fractal obviously and yes this is something like that.

Do you think can I do the same for the terrain geometry ? ( You can see the image above )

I am not sure about the question...Can u explain?


On your image ( and mine ), I have the same color ( object and terrain ) but the object is too smooth and I was wondering if the geometry of the terrain could also "apply" to the object like color? Like an extrusion, like if the object IS the terrain and not just an imported object.
Title: Re: Object and terrain interactions
Post by: archonforest on February 06, 2019, 04:19:57 pm
Got it. Not sure if this is possible since the PF will look different on the small sphere. Perhaps you can just attach a PF to the sphere's displacement input and play with the setting until it looks more on less than on the planet...

I will think about this tomorrow. Perhaps someone will come up with a good idea. I am not a power TG user at all.
Title: Re: Object and terrain interactions
Post by: Dune on February 07, 2019, 01:09:38 am
If it's a low poly object, displacements won't work well. You'd have to set the object to 'force displacement' anyway. So you need objects with a high poly number, and feed your last terrain shader through a transform shader set to final/world position. But don't expect very much of it, especially not in terms of big displacements; the object will probably be torn apart.
For just a sphere, better use the internal sphere.
Title: Re: Object and terrain interactions
Post by: digitalguru on February 18, 2019, 07:25:56 pm
If you delete the UVs on your poly object it will shade any power fractals in the same space as the terrain.You won't see any scaling / texture placement differences and it will appear to blend in better.

You could also try to convert your mesh into a displacement map, (preferably a vector displacement map) and then use a displacement shader to place it on your terrain - it would look like it's growing out of the terrain.

some posts on a Blender forum:
https://blender.stackexchange.com/questions/1161/how-to-make-a-displacement-map-from-existing-3d-geometry
Title: Re: Object and terrain interactions
Post by: digitalguru on February 18, 2019, 08:44:28 pm
This works with a teapot stripped of UVs  :)
[attachimg=1]
[attachurl=3]



Title: Re: Object and terrain interactions
Post by: Dune on February 19, 2019, 02:11:00 am
If you don't want to strip your object of UV's, it can be done with UV'd objects too, just pull your shaders through a transform shader set to world/final position.
Title: Re: Object and terrain interactions
Post by: digitalguru on February 19, 2019, 09:06:03 am
If you have the professional version of Terragen, you can create a displacement map from an object:
Original geometry:
[attachimg=1]
Object shape displaced from terrain
[attachimg=2]

You can render the geo with an orthographic camera and output the tgSurfPos (surface position) as a Render Element. The green channel of the tgSurfPos is the vertical position, equivalent to displacement values (render as 32bit EXR). You can then pipe this onto your surface using a Displacement shader and a Green to Scalar to extract the vertical channel. The downside is that it won't work with complex geometry like the teapot in the previous example (that would need vector displacement) but for simple geo that has no undercuts it works quite well.

When you render the render element for the tgSurfPos file, make sure the object is on a flat undisplaced terrain or you'll get that baked into the map.

example TG scene:
https://www.dropbox.com/s/nnkgl0m204y1f6m/object_displacement.zip?dl=0

I did try a render with the teapot with UVs and the transform shader, but I get displacement cracks where the UV shells are:
[attachimg=3]
Title: Re: Object and terrain interactions
Post by: Dune on February 19, 2019, 09:41:41 am
Strange. So the UV-mapping is really disturbing the displacement somehow. I wonder why that is so. In the default shader UV is automatically assigned, so maybe when using a surface shader it won't happen... Have to try that, as I can imagine people won't like to get their objects stripped of UV's. In fact I wouldn't know how to purge the UV mapping (unless in LW or so). I don't think you can delete UV's in Poseray.
Title: Re: Object and terrain interactions
Post by: digitalguru on February 19, 2019, 10:40:44 am
QuoteI don't think you can delete UV's in Poseray.


You can do it in Meshlab (free program) by loading the object and re-saving it with texcoord option turned off.

QuoteHave to try that, as I can imagine people won't like to get their objects stripped of UV's


If it's something like a rock, which would be much better procedurally shaded in Terragen it's no hassle to make a copy with the UV's deleted, though as that's something that might happen often it would be good too have a button to ignore UVs in the obj loader? - though being Terragen there might be another way around it  :)

Title: Re: Object and terrain interactions
Post by: sboerner on February 19, 2019, 11:04:14 am
QuoteIf it's something like a rock, which would be much better procedurally shaded in Terragen it's no hassle to make a copy with the UV's deleted, though as that's something that might happen often it would be good too have a button to ignore UVs in the obj loader? - though being Terragen there might be another way around it


A option to select global coordinates for shading/displacements would be handy. But that doesn't address why the shells are breaking apart in the first place.

Interesting thread.
Title: Re: Object and terrain interactions
Post by: Oshyan on February 19, 2019, 04:37:51 pm
I'm pretty sure if you just bypass the Parts Shader you're working without UVs. This of course shades the entire object. You can't shade part of an object without UVs as far as I know.

- Oshyan
Title: Re: Object and terrain interactions
Post by: Dune on February 20, 2019, 02:54:49 am
Strangely, I don't get the torn edges when rendering with UV, and with parts shader and default shader from your basic setup, but through transform shader. Though it's an older version of TG (3.7).
And they're not hidden behind that (bucket error) block  ;)
Title: Re: Object and terrain interactions
Post by: Matt on February 20, 2019, 03:08:16 am
Quote from: digitalguru on February 19, 2019, 09:06:03 am
I did try a render with the teapot with UVs and the transform shader, but I get displacement cracks where the UV shells are:


The UVs (or lack of) would not cause this. It's an issue with the normals.
Title: Re: Object and terrain interactions
Post by: Matt on February 20, 2019, 03:10:58 am
Quote from: Oshyan on February 19, 2019, 04:37:51 pm
I'm pretty sure if you just bypass the Parts Shader you're working without UVs. This of course shades the entire object. You can't shade part of an object without UVs as far as I know.


The Parts Shader's purpose for is for selective assignment of different materials to different parts of the object. That is a completely different thing from UVs, although UVs are often used to map different parts of an object into the same material. Bypassing the Parts Shader doesn't bypass UVs.
Title: Re: Object and terrain interactions
Post by: sboerner on February 20, 2019, 12:22:11 pm
QuoteStrangely, I don't get the torn edges when rendering with UV, and with parts shader and default shader from your basic setup, but through transform shader. Though it's an older version of TG (3.7).


Same result here with Terragen 4. Just downloaded and mapped the teapot and rendered with the displacement going through a transform shader. Digitalguru, would you mind sharing the model that was breaking apart? I'm curious to take a peek at those normals.

Title: Re: Object and terrain interactions
Post by: Oshyan on February 20, 2019, 06:31:17 pm
Quote from: Matt on February 20, 2019, 03:10:58 am
Quote from: Oshyan on February 19, 2019, 04:37:51 pm
I'm pretty sure if you just bypass the Parts Shader you're working without UVs. This of course shades the entire object. You can't shade part of an object without UVs as far as I know.


The Parts Shader's purpose for is for selective assignment of different materials to different parts of the object. That is a completely different thing from UVs, although UVs are often used to map different parts of an object into the same material. Bypassing the Parts Shader doesn't bypass UVs.


How are the Parts Shaders determined/derived in the first place then?

- Oshyan
Title: Re: Object and terrain interactions
Post by: digitalguru on February 20, 2019, 07:37:58 pm
Aha! I see what I did - I had the Transform shader after the default shader not going into function slots of the shader - works with UVs and no UVs now.
Title: Re: Object and terrain interactions
Post by: Matt on February 20, 2019, 11:32:25 pm
Quote from: Oshyan on February 20, 2019, 06:31:17 pm
How are the Parts Shaders determined/derived in the first place then?


There are various ways that object materials or groups can be defined in an OBJ file. If the OBJ has lines beginning with "usemtl" or "usemap", Terragen interprets those as material assignments and creates a "part" for each one. For example "usemtl leaf", "usemtl trunk" and so on. Also, OBJs sometimes contain "groups", and Terragen looks at those if it doesn't find any material-related commands that it knows about.

UVs are a completely different concept. They are the X,Y texture coordinates for each vertex. Every vertex should have a UV value attached if you want to do texture mapping.

UVs can be used to texture map an OBJ even if there was no material description. And materials/groups can be used to set up different shaders even if there are no UVs, as long as you don't need any texture maps.

Of course, most OBJs have both of these sets of data.
Title: Re: Object and terrain interactions
Post by: sboerner on February 21, 2019, 10:05:00 am
QuoteAha! I see what I did - I had the Transform shader after the default shader not going into function slots of the shader - works with UVs and no UVs now.


Glad it's working!