Obj reader mesh displacer?

Started by sboerner, December 11, 2017, 12:38:21 PM

Previous topic - Next topic

sboerner

I'm working on a scene that will include a railway about 3 km long over gently sloping terrain. The railway is an imported object that will need to hug the underlying displacement. I've exported the terrain to Maya and can handle the railway displacement there, but it would be better if it could be done directly in Terragen.

At first glance the Obj Reader's Mesh Displacer modifier seems just the thing for this: Assign an image map and use it to vertically displace the vertices of the railway object. Yes?

Can this modifier used to create this kind of large-scale displacement? Am I understanding it correctly?

In testing it, though, I haven't been able to get this modifier to work at all. I've assigned simple shape and power fractal shaders to basic imported objects (an elongated cube and a plane, both with plenty of geometry), and nothing happens. The objects' render methods are set to "force displacement." But no matter the scale or contrast of the input nodes, no displacment shows in the 3D or render views.

There are very few references to this modifier on the forum, and I can't find any that explain the basics of setting it up. I'm assuming that it takes a color input, but maybe not? (Displacement inputs don't seem to work, either.)

What am I doing wrong? Even if this doesn't work as I imagine it might for this project, it seems like it should be handy for other things.

Steve

j meyer

In TG 3.4 you just had to connect a Power Fractal etc and you could see an effect.
But, as soon as you changed a parameter nothing would happen unless you unconnect
and then reconnect the displacer. Everytime, after any change.
Don't know, if it still is like that in TG 4, though.

sboerner

Thanks. I saw a couple mentions of that and have tried it, but no go. Been switching back and forth from simple shapes to power fractals. I must be overlooking something else.

Oshyan

The Mesh Displacement input works for *non-displaceable* objects (any arbitrary imported geometry), but does not do any subdivision. It takes Displacement as input, not color.   Force Displacement does not need to be on (not should it be) for it to work, though it won't break the effect if it is. If you're not seeing an effect, make sure your Displacement Amplitude is strong enough and that your mesh has enough subdivisions. The mesh displacer does not do any subdivision.

Unfortunately the bug still exists where you need to disconnect/reconnect the node to see changes to your Mesh Displacer input shader reflected in the displacement. I'll make sure that's in our bug DB.

- Oshyan

Dune

If the terrain can be procedural, I have a procedural railway setup at NWDA. If it's a set terrain, that won't work.

sboerner

#5
QuoteThe Mesh Displacement input works for *non-displaceable* objects (any arbitrary imported geometry), but does not do any subdivision. It takes Displacement as input, not color.  Force Displacement does not need to be on (not should it be) for it to work, though it won't break the effect if it is.

Thanks, Oshyan. That answers a couple of basic questions that I was having a hard time answering. Strange thing though is that the displacements appeared when I reopened the test file I had been working on. ??? Maybe it was a delayed effect of the connect/disconnect bug? Anyway everything is working as expected now.

Here are my results so far. I'm going into some detail in case anyone else might find this info useful. If I've gotten anything wrong, please feel free to correct it.

The displacements are centered at the imported object's pivot point and are proportional to the distance between the pivot point and the surface of the mesh. This means that nothing will happen if you displace a basic plane with a centered pivot because the pivot and the mesh are coplanar. If you want the displacement to affect any 3D shape as a whole – instead of merely displacing the surfaces out from the center – the pivot must be moved outside of the mesh before the object is imported into Terragen. Once I realized this I moved the pivot for my test objects –100m on the Y axis in Maya before freezing transforms and exporting.

Even so, with displacement in the source node set to Vertical Only or Normal, the resulting displacements were all angular based on the distance from the pivot point to the mesh. Here's a displacement from a plane, based on a circular Simple Shape:

[attachimg=1]

Setting the displacement type to Normal and piping the output through a Redirect shader fixes this.

[attachimg=2]

X and Z are set to 0, with the displacement going through Y.

[attachimg=3]

Does this sound right? Everything is working as expected so far. Here is a power fractal displacement applied to a plane.

[attachimg=4]

And the same displacement applied to a cuboid with 1 x 1 x 100 faces.

[attachimg=5]

So the moral is, be careful what you ask for. This is the exact result that I was looking for, but it clearly won't work well for railroad tracks! But it's cool to know how this feature works, and I'm sure I'll find other uses for it.

[Edit: I wasn't able to figure out a way to use a heightfield as the displacement source. That would be useful indeed.]

sboerner

QuoteIf the terrain can be procedural, I have a procedural railway setup at NWDA. If it's a set terrain, that won't work.

Thanks, Ulco. I'd heard about your railway setup but hadn't see examples of it yet. Really great, amazing that it's all procedural. My scene is heightfield based, though, and there are bridges and maybe a culvert or two involved, so I think imported objects are the way to go. I have a method worked out that looks promising, very precise and with little or no guesswork. If it works as hoped I'll post the results and try to explain.

Steve

KlausK

Thanks for the example!
I had almost given up on the Mesh Modifier input.
The way how you use the Redirect shader here also is a nice example for the node itself.
Never was quite clear about that.
Cheers, Klaus
/ ASUS WS Mainboard / Dual XEON E5-2640v3 / 64GB RAM / NVIDIA GeForce GTX 1070 TI / Win7 Ultimate . . . still (||-:-||)

j meyer

QuoteI have a method worked out that looks promising, very precise and with little or no guesswork. If it works as hoped I'll post the results and try to explain.

Please do so, very interesting subject.

Kadri

#9

You could try it with an object population of the railway too.
But i am not sure if it would be easier and-or look good (the parts where every population object would touch).

Dune

That probably won't work; it's already difficult/impossible to make straight row of trees if you need the pop to rotate by any degree.

Kadri

#11
Quote from: Dune on December 13, 2017, 12:26:05 PM
That probably won't work; it's already difficult/impossible to make straight row of trees if you need the pop to rotate by any degree.

Yes probably.
I would try it only with a small part of a railway not with bigger long standard parts.
Even with this it would look maybe only good from a distance probably. 

Dune

And it would be virtually impossible with any bends. Better do all procedural for distance and maybe add some object if really needed up close. But my setup will be pretty good up close too, btw.