Author Topic: Obj reader mesh displacer?  (Read 646 times)

Offline sboerner

  • Member
  • *
  • Posts: 140
    • Steve Boerner Typography & Design
Obj reader mesh displacer?
« on: December 11, 2017, 04:38:21 PM »
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

Offline j meyer

  • Member
  • *
  • Posts: 2077
    • orkwarts
Re: Obj reader mesh displacer?
« Reply #1 on: December 11, 2017, 05:34:56 PM »
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.

Offline sboerner

  • Member
  • *
  • Posts: 140
    • Steve Boerner Typography & Design
Re: Obj reader mesh displacer?
« Reply #2 on: December 11, 2017, 05:48:03 PM »
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.

Offline Oshyan

  • Planetside Staff
  • *
  • Posts: 12056
  • Holy snagging ducks!
Re: Obj reader mesh displacer?
« Reply #3 on: December 12, 2017, 03:12:18 AM »
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

Offline Dune

  • Member
  • *
  • Posts: 13396
  • Corkscrew Bird
    • www.ulco-art.nl
Re: Obj reader mesh displacer?
« Reply #4 on: December 12, 2017, 07:37:16 AM »
If the terrain can be procedural, I have a procedural railway setup at NWDA. If it's a set terrain, that won't work.
In case you still haven't seen enough of my work: www.ulco-art.nl

Offline sboerner

  • Member
  • *
  • Posts: 140
    • Steve Boerner Typography & Design
Re: Obj reader mesh displacer?
« Reply #5 on: December 13, 2017, 05:15:01 AM »
Quote
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.

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:



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



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



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



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



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.]
« Last Edit: December 13, 2017, 05:20:57 AM by sboerner »

Offline sboerner

  • Member
  • *
  • Posts: 140
    • Steve Boerner Typography & Design
Re: Obj reader mesh displacer?
« Reply #6 on: December 13, 2017, 05:26:13 AM »
Quote
If 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

Offline KlausK

  • Member
  • *
  • Posts: 351
  • Land ho!
Re: Obj reader mesh displacer?
« Reply #7 on: December 13, 2017, 12:51:27 PM »
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 780 / Win7 Ultimate

Offline j meyer

  • Member
  • *
  • Posts: 2077
    • orkwarts
Re: Obj reader mesh displacer?
« Reply #8 on: December 13, 2017, 03:40:37 PM »
Quote
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.

Please do so, very interesting subject.

Offline Kadri

  • Member
  • *
  • Posts: 8000
Re: Obj reader mesh displacer?
« Reply #9 on: December 13, 2017, 04:12:16 PM »

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).
« Last Edit: December 13, 2017, 04:14:34 PM by Kadri »

Offline Dune

  • Member
  • *
  • Posts: 13396
  • Corkscrew Bird
    • www.ulco-art.nl
Re: Obj reader mesh displacer?
« Reply #10 on: December 13, 2017, 04: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.
In case you still haven't seen enough of my work: www.ulco-art.nl

Offline Kadri

  • Member
  • *
  • Posts: 8000
Re: Obj reader mesh displacer?
« Reply #11 on: December 13, 2017, 04:34:52 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. 
« Last Edit: December 13, 2017, 04:39:11 PM by Kadri »

Offline Dune

  • Member
  • *
  • Posts: 13396
  • Corkscrew Bird
    • www.ulco-art.nl
Re: Obj reader mesh displacer?
« Reply #12 on: December 13, 2017, 04:37:27 PM »
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.
In case you still haven't seen enough of my work: www.ulco-art.nl

Offline Kadri

  • Member
  • *
  • Posts: 8000
Re: Obj reader mesh displacer?
« Reply #13 on: December 13, 2017, 04:41:58 PM »
...But my setup will be pretty good up close too, btw.

Yep :)