Hi all,
what is the best way to sample the altitude of a given point on the xz plane?
Example: at point (12;y;5), what is y?
Thanks
Frank
Is that the current Position in Texture? If so, you can just use Get Altitude in Texture:
http://planetside.co.uk/wiki/index.php?title=Get_Altitude_in_Texture
This basically does something like the following:
displacement = GetPositionInTexture - GetPositionInGeometry
altitude = DotProduct(displacement, GetNormalInGeometry)
But if I wanted to compute this for some arbitrary position called A, I would do the following:
displacement = A - GetPositionInGeometry
altitude = DotProduct(displacement, GetNormalInGeometry)
You can do this with the following nodes:
A, GetPositionInGeometry
\/ \/
SubtractVector, GetNormalInGeometry
\/ \/
DotProduct
Matt
Hi Matt, thanks!
I think the last example might be what I am looking for.
To be precise, based on the current position, I want to know what the altitude of the point 1m next to the current position is (on e.g. x)
So if I understand correctly, I would construct a vector GetPositionInTexture + (1;0;0) = A
Then follow your last example code, right?
Thanks
Frank
If you just need to find out the altitude of the point in space that is 1 meter to the right of the current position, it's going to be almost exactly the same altitude as the current position because you haven't changed the Y at all (unless you are far, far from the origin).
Do you want to sample the displacement at a point 1 meter to the right? That's a completely different problem, much more tricky to solve. It should be possible with Transform Shaders but networking the nodes in a way that's useful is quite tricky.
Matt
Correct, that's what I meant. I need the displacement at that point to the right.
Any idea how? I can see no way with the currently available functions, how I could specify a point on xz relative to the current position and THEN get its displacement value.
Frank
wouldn't a right click > copy altitude, do that for you and then move over 1 m. and do it again or am I missing something esoteric here?
Hi Bobby, what you suggest isn't what I need, because I need to sample continuously as TG renders. I don't need just the position for 1 point, I need it for millions of points, so I need to construct this within the node network itself.
Regards,
Frank
You sparked my curiosity; what do you need it for?
I shall not say. ;-)
It's for a NWDA project. I would like to improve the procedural road and take it to the next level.
There, I rat! :-D
Try the Transform Shader. That works by changing the texture coordinates that are used by its "shader" input. To translate a shader by (-1, 0, 0) it offsets the texture coordinates by (1, 0, 0).
Matt
Ah, then you might as well stop your secret business, Frank ;) I'm almost there releasing a setup for a mountain road. I guess that's what you're after...
That's great, Ulco! Good news!
However I still would like to solve that puzzle. As you may know, the road setup I use is 100% procedural without a SSS or any file based mask. I would really like a way to embed that road in any terrain by accurately sampling its environment and then altering the surrounding displacement based on the sampling result.
Awesome though that you are going to make available your (working) solution to the problem! That's going to be great!
Cheers
Frank
Thanks, Frank.
Work fast then, because you're about to get the riddle unraveled. Although my setup uses simple shapes (they can be replaced by blue nodes no doubt, but this is easier for everybody I think), it can be fitted into any terrain. Here's a quick and not perfect teaser.
edit: and another one by just hitting the terrain seed...
I've been working on this on and off but have only got the basics down so I look forward to both your solutions. I was looking at sampling altitude but didn't realise how difficult it would be needless to say I got nowhere. In the end I came up with an SSS solution which is very basic but works, just, it could be considerably improved. Mick
Hey Ulco, there is no race I'm on - even beyond this project, there's got to be a blue node way to sample the displacement of any given point on the planet, and use that for further calculations. I have a hard time imagining that your solution does that, but I'll let myself be surprised! :-)
Cheers
Frank
My solution is basically very simple, once you know ;)
My guess is that you make a very soft SSS and then extract multiple masks from it using a colour adjust shader.
Increase black color would tighten/narrow the mask, for instance.
This way, using multiple colour adjust shaders, you can relatively easy create a mask for the road (hard), roadside (medium soft) and surrounding terrain (very soft).
Something like that, I guess.
Quote from: Dune on December 17, 2012, 07:03:28 AM
My solution is basically very simple, once you know ;)
These are the best ones! :-)
Quote from: FrankB on December 17, 2012, 07:17:12 AM
Quote from: Dune on December 17, 2012, 07:03:28 AM
My solution is basically very simple, once you know ;)
These are the best ones! :-)
Therefore I think my idea of how's he doing it qualifies for being (part of) the actual way he's doing it :)
The road SSS is not even that soft, set at 8m wide and a soft edge of 1m, or a certain percentage. The road part, lines and verges is the easy part, actually. It's the way I can get the road flat against a steep hillside that is the crucial part. I had another setup a while ago, but the road tilt had to be adjusted a little depending on the side of the mountain (east or west). This setup doesn't need that, it's always straight.
exactly that's the hard part in case of the road. Looking forward to your solution!
Comment on fait pour que la route soit seul mais fermer qu'on puisse faire un " random seed" pour varier la route ?
Sinon, on peut m'envoyer un mp, pour la réponse.
How do you that the road is only closed but you can do a "random seed" to vary the road ?
Otherwise, you can send me an mp, for the answer.
(google translate)
If you want to vary the road, you need to hit the power fractal seed that warps the road. What I did in my new file (which will be available soon) was hitting the terrain seed, but the road stayed at its position (only the Y changed with the Y of the terrain).
Hi Frank
If you use the colour output of a PF to drive a Displacement Shader, rather than it's own displacement tab, you can warp that texture by set amounts in each direction around the sample point, then divide the sum of the grey values by the number of the samples taken, to give you an average grey value. Which in essence flattens an area defined.
It's easier to define the road as a straight line along x with a set width in +/- y along the origin, which you can then warp. This allows you to take weighted samples infront and behind to create gentle slopes for the road over your grey terrain, and can create in-cuts and rises. With a little more math you can create drainage ditches as well.
I had a go at this a while back with another forum member, but I've forgotton who I was working with now. Sorry.
I'll see if I can dig out the TGC.
Quote from: Dune on December 17, 2012, 07:03:28 AM
My solution is basically very simple, once you know ;)
simple but elegant appearing, it works very well...congrats on your solve
Quote from: FrankB on December 17, 2012, 07:00:24 AM
Hey Ulco, there is no race I'm on - even beyond this project, there's got to be a blue node way to sample the displacement of any given point on the planet, and use that for further calculations. I have a hard time imagining that your solution does that, but I'll let myself be surprised! :-)
There is :) I hinted at one solution here: http://www.planetside.co.uk/forums/index.php?topic=15377.msg149644#msg149644
The Transform Shader calls the shader at a modified point. But maybe that's not enough if you need function-based control over the exact offset. If so, use a Warp Shader instead. This basically does what the Transform Shader does, but using a displacement shader to control the offset.
Matt