Planetside Software Forums

General => Terragen Discussion => Topic started by: Dune on March 18, 2014, 12:47:04 PM

Title: challenge
Post by: Dune on March 18, 2014, 12:47:04 PM
If anyone can get this to work..... warp the stripes so they angle with the bend, like railway sleepers........
Title: Re: challenge
Post by: choronr on March 18, 2014, 10:34:46 PM
I think they need to adhere to the degrees of arc of a radius - inside and outside???
Title: Re: challenge
Post by: Dune on March 19, 2014, 03:17:04 AM
Yes, the rotation of each individual stripe needs to have a relation with the angle the total line makes with the main axis, so some combination of blue nodes (degrees?) could work. It can be done, no doubt, but I haven't figured it out (yet).
Title: Re: challenge
Post by: j meyer on March 20, 2014, 12:04:27 PM
Played with your file,tried some other horizontal procedural stripes to no avail.
After some more thinking I could at least come up with this
[attachimg=1]
Still far from being perfect or even usable,but it illustrates some points I consider
as pretty crucial for this task.
1.It's better to warp a ladder like (rails+sleepers) structure than only horizontal
   stripes.
2.It will be most likely very hard to get rid of the stretching that occurs when
   warping.Seems to happen with anything you warp.

Best would be some spline like feature in TG to slide/pull such a sructure onto,
just like you can pull a snake model onto/along a spline in some modeling/
animation apps.

Title: Re: challenge
Post by: j meyer on March 20, 2014, 12:18:18 PM
Forgot to mention that,if one would succeed with what bob suggested,you
would of course loose the rectangular shape of the sleepers.Instead you'd
have wedges/trapezes rather.

And something else in regard to my file,there is a discrepancy between the
shader preview and the rendered image/main preview.In the shader preview
the structure is displayed much more distorted than in the actual render.
Don't know why,though.
Title: Re: challenge
Post by: Dune on March 21, 2014, 03:53:50 AM
The stretching is indeed the problem, but you got quite far. Actually I was testing this with an image map of some horizontal stripes (repeated in Z), and thought each 'instance' of the map should be rotated by some computation, derived from the angle the warped line makes. Hence my thoughts about blue nodes...
Ideally, a 'rotation by function shader' would be useful (for a lot of stuff), and I've mentioned that before, long time ago.

Thanks for having a go!
Title: Re: challenge
Post by: inkydigit on April 29, 2014, 06:46:07 AM
...if we could get objects (in a population) to all face (or face away from)a specific point would be bonus too, like radial vectors?
Title: Re: challenge
Post by: Dune on April 29, 2014, 08:13:56 AM
Yeah, that would be handy in some circumstances. I mentioned some 'rotate by function' functionality as well, so you can even rotate by fractal noise (gray), but that could be hard. Don't know. Mogn had some setup, but I failed to get that to work  :(
Title: Re: challenge
Post by: inkydigit on May 01, 2014, 03:23:22 PM
some sort of conditional 'if' -'then' function nodes... if 'a' is 'xx' from 'b' then rotate by etc etc...?
Title: Re: challenge
Post by: mogn on May 02, 2014, 03:24:23 AM
Quote from: Dune on April 29, 2014, 08:13:56 AM
Yeah, that would be handy in some circumstances. I mentioned some 'rotate by function' functionality as well, so you can even rotate by fractal noise (gray), but that could be hard. Don't know. Mogn had some setup, but I failed to get that to work  :(

My rotate Works. The following example rotates a voroni noise 90 degrees pr 1000 m from origin.
Title: Re: challenge
Post by: Dune on May 02, 2014, 04:05:24 AM
Good of you to chime in, Mogn. I should try it again.... thanks.

EDIT: I just tried to rotate an image map by your 'vortex' but couldn't get it to work. How would you go about warping/rotating this? The idea would be to make some irregular sweeps, but where the stripes rotate along with the sweeps, so do not stay 'left to right'....
Title: Re: challenge
Post by: mogn on May 02, 2014, 08:49:13 AM
Image map is not good for changes, since the you cant change  the input variables.
I have create a scaled functional map with scale 100m meter in each direction. The z direction is modulated
by a noise function.
Ofcause the scales in both direction and the noise amplitude can be changed.

Title: Re: challenge
Post by: Dune on May 03, 2014, 04:05:16 AM
Thanks Mogn, I'll have a go at getting this to work.

EDIT: still don't understand how I can get this (attached) to work. I need the lines to be like the black ones. Is that possible at all?
Title: Re: challenge
Post by: mogn on May 04, 2014, 08:45:13 AM
Y
This is a real challenge.
To use real measures:
The distance between the sticks (I dont know the English Word) 625 mm.
The Width of the tracks 1435 mm.
The masked width must be larger (to include the end of the sticks)
The radius of the curve must be less than 600 m.
Both the the mask and the tracks must be included in the rotational transform.
I am working on it but it might take some time.

Title: Re: challenge
Post by: Dune on May 04, 2014, 09:39:42 AM
Yes, I thought so. I use this for railways, and real measures would be: 'sticks' (sleepers): 255cm long, 22.5 cm wide, space between them: 30cm.
If you can figure this out, you're my hero!
Title: Re: challenge
Post by: j meyer on May 04, 2014, 11:41:42 AM
Ulco,do you need the exact measures for an infinite length (of track) ?
Or just a predefined length,e.g. a short straight and 1 or 2 curves?

Approaching this problem from a graphical/geometrical point of view suggests
that the warping method TG uses can't give the wanted result.
To have an accurate curve you'd need at least an outer radius and an inner
radius and you don't get these by warping,not even with hetzens parallel warp.
Not to mention the changes of direction.

Maybe time to consider a modular system or so.

Title: Re: challenge
Post by: bobbystahr on May 04, 2014, 04:22:29 PM
For RR tracks and the like the ideal would be to be able to populate along a path(which we don't have yet)as that way just one small mosel of the track could be built and populated like in other apps, well at least my old modeler Imagine...missing it a lot lately it seems.
Title: Re: challenge
Post by: Dune on May 05, 2014, 02:42:43 AM
Yes, populate along a line would be a good feature as well, also for lines of trees along roads for instance. And pylons for monorails.

And @Jochen: no, actual measures are not the most important, but nice to get near. But if there is a way to calculate it, it would be for the whole track, I assume. Until now I kept my POV such that it was just above an area of track which went kind of straight North or West, but as soon as you'd want to animate and travel along a winding railway, you'll see the still parallel sleepers while the track is making a bend. So if the angle of a warped track (that's the easiest way to bend it) can be translated into a localized rotation.....

I didn't call it a challenge without it being one  ;) But it's not that I really need it; it's just that I want to get further than possible, as always.
Title: Re: challenge
Post by: mogn on May 05, 2014, 05:53:13 AM
The easy part, the Railway ladder.
Title: Re: challenge
Post by: mogn on May 05, 2014, 07:55:10 AM
The modified ladder.
Not good enough, the sleepers are disturbed, due to their Width.

Title: Re: challenge
Post by: Dune on May 05, 2014, 08:21:27 AM
Well, you are getting really close  :D  In fact the bends may be a lot softer, so the width 'problem' may be no longer a problem. I'll check this out.

Checked it out. Great. If you replace the get... geometry by a get... texture you can resize it to actual needed size. Maybe possible elsewhere, but this was easy. Can this work with another warping method (like my file), mogn, instead of the perlin 3D way?
Title: Re: challenge
Post by: bobbystahr on May 05, 2014, 08:35:19 AM
amazing...mogn's the man
Title: Re: challenge
Post by: j meyer on May 06, 2014, 11:00:49 AM
The last file mogn provided looked very promising,so I downloaded it
to give it a try.Unfortunately it turned out to be as useless as all of
our previous attempts.The only thing that is really better is the spacing
of the sleepers (sticks).
For the image I've just replaced the "get pos..." with a "get p ..in texture"
and scaled it down 10 times and then moved it 150 m along the z-axis.
So it's still the same network.

[attach=1]

As you can see here and more clearly when you disable the stripes the warping
shows the same shortcomings as all the other approaches.

We need a method to bend a stripe/band where we want and how much we want.
And it needs to be a stripe/band not a line without dimension.

As an addition to the suggested spline/path thing,how about a virtual bulldozer? ;)
We could build even serpentine roads.

Title: Re: challenge
Post by: Dune on May 06, 2014, 11:27:24 AM
Too bad. In this screendump you can see how warping works (for those who don't know) and immediately recognize the problem. Although it might be possible to use the grays from the warping fractal (testcolor; purple = white, no purple = black) for a rotation of the sinus driven lines, they will not all be rotated right. The blue and red stripe need opposite rotation, but the gray is the same value at those points. And at the white and black areas the rotation should be zero.
Title: Re: challenge
Post by: j meyer on May 07, 2014, 11:11:51 AM
The warp shader seems to be the wrong tool for this task,at least imo.

I think we need someone who is capable of constructing a formula that
can bend a stripe.That would have some minor shortcomings,too.
Namely wedge shaped sleepers.
That wouldn't solve everythingelse,but it'd be a start.

[attach=1]
This illustrates bending

[attach=2]
This illustrates the ideal (just the principle)

Furthermore we would need a way to define the course and where to put curves,
define the radii thereof,keep the sleepers perpendicular to the centerline of the
course/track.Or in other words : a good programmer is needed.
If you think about it,you may find that I roughly described something that is
similar to a spline/path.....oh well.

Waaayy beyond my mathematical capability.
And constructing this from SimpleShShs,....hahaha... no way.
Title: Re: challenge
Post by: Dune on May 07, 2014, 11:27:15 AM
Agreed, it is hard, and way beyond me as well. Nice schedule though, but I wouldn't worry too much about 'wedginess', as a railtrack wouldn't go round that short. I keep my hopes on mogn or another skilled mathematician....
Title: Re: challenge
Post by: bobbystahr on May 08, 2014, 09:30:21 AM
Quote from: Dune on May 07, 2014, 11:27:15 AM
Agreed, it is hard, and way beyond me as well. Nice schedule though, but I wouldn't worry too much about 'wedginess', as a railtrack wouldn't go round that short. I keep my hopes on mogn or another skilled mathematician....

agree, even on a major curve' the circumfrence they'd follow would have a wide gentle curve.
Title: Re: challenge
Post by: mogn on May 12, 2014, 06:35:19 PM
Quote from: j meyer on May 07, 2014, 11:11:51 AM
The warp shader seems to be the wrong tool for this task,at least imo.

I think we need someone who is capable of constructing a formula that
can bend a stripe.That would have some minor shortcomings,too.
Namely wedge shaped sleepers.
That wouldn't solve everythingelse,but it'd be a start.

[attach=1]
This illustrates bending

[attach=2]
This illustrates the ideal (just the principle)

Furthermore we would need a way to define the course and where to put curves,
define the radii thereof,keep the sleepers perpendicular to the centerline of the
course/track.Or in other words : a good programmer is needed.
If you think about it,you may find that I roughly described something that is
similar to a spline/path.....oh well.

Waaayy beyond my mathematical capability.
And constructing this from SimpleShShs,....hahaha... no way.

This is actual easier than construct the sleepers along a random curve.
The danish Railways specifies a minimum radius of 600 m.
With a distance between the sleepers 52.5 m this gives an angle between the sleepers of 5.013381
degrees = 0.087500 radians. Each sectors (slice) of 0.087500 radians is numbers 0..72.
If you applies atan2(z,x) to the current point from the get function, you can calculate which slice number
the current point belongs to.
Then you rotates the current slice to slice number 0. Do the calculation in slice number 0.
Note that the point in the orginal slice is not changed, i.e it Works as you have done your calculation in
the original slice. (As if slice 0 is rotated back to current slice).
Title: Re: challenge
Post by: bigben on May 12, 2014, 07:23:00 PM
Quote from: j meyer on May 07, 2014, 11:11:51 AM
The warp shader seems to be the wrong tool for this task,at least imo.

The masked man suggests describing sections of track mathematically so you have pieces like a train set.   ;)

Joining them up would be difficult'ish, but building the pieces would be the first step.

Constants: center of curvature, inner/outer radius of sleepers/track, start and end angles of curve.
Sine function on the angle from the center of curvature to create radial spokes at the frequency of the sleepers, colour adjust node applied to that to define the width of the sleepers multiplied by a mask for inner/outer radius of sleepers.
The sleeper would not be rectangular, but at a radius of 600m they'd be close enough.

Straight sections of track could be trickier (when not along X or Z)
[EDIT] Straight sections: 
What we know: Position of end of the track, tangent to the track curvature at the ends (direction the straight track should go).
Using a similar approach, sine function of X or Z to define spacing of sleepers, rotate to match tangent, colour adjust to define edge of sleepers, transform to fix spacing of sleepers at the join, mask with SSS to define ends of sleeper and length of track. Sounds possible.

You'll also want a gradated radial mask parallel to the track so that you can create different track features (distribution of rocks, raising track above terrain), but the basic building blocks would be similar.

[/EDIT]
Title: Re: challenge
Post by: Dune on May 13, 2014, 02:07:31 AM
Sounds promising, but please now in real language = TG language  ;)  I'd prefer a way to use a 'normal' warp setup, so you can make random curves, but it will still be hard to derive data from that curve I'd say. I haven't a clue about how your ideas exactly work.
Title: Re: challenge
Post by: bigben on May 13, 2014, 06:03:19 AM
I'll have a play on the weekend.  My math brain is occupied helping some researchers obtain the GIS coordinates of cows in a paddock from fisheye images shot by a GoPro on top of an 11m tower... They seemed equally bemused at my optimism.  ;)

Most of my job involves describing things in terms that can be passed on to a computer to do stuff. My trigonometry is a bit rusty but I think what I described is possible... not necessarily practical, but possible.
Title: Re: challenge
Post by: Dune on May 13, 2014, 07:11:03 AM
Crossing my thumbs for a nice outcome, Ben. Thanks!
Title: Re: challenge
Post by: bigben on May 13, 2014, 07:56:44 AM
Don't ask me for dog spikes  ;-) Some light reading for reference:
Sleepers: http://www.asa.transport.nsw.gov.au/sites/default/files/asa/railcorp-legacy/disciplines/civil/esc-230.pdf (http://www.asa.transport.nsw.gov.au/sites/default/files/asa/railcorp-legacy/disciplines/civil/esc-230.pdf)
Tracks: http://www.asa.transport.nsw.gov.au/sites/default/files/asa/railcorp-legacy/disciplines/civil/esc-210.pdf (http://www.asa.transport.nsw.gov.au/sites/default/files/asa/railcorp-legacy/disciplines/civil/esc-210.pdf)
Title: Re: challenge
Post by: Dune on May 13, 2014, 10:42:24 AM
There are a lot differences between regions and countries regarding sizes of sleepers and rails. Interesting read.
Title: Re: challenge
Post by: j meyer on May 13, 2014, 11:15:18 AM
mogn - thanks for the reply.Unfortunately I'm not able to understand what you
          wrote.

bigben - Seems like you are describing in a more scientific way what I was hinting
            at with my lay babble.(modular system etc)
            As you said not necessarily practical,but possible.
            Or why use an image map when it's possible to do it in a more complicated
            way? ;)
            Agog to see what you'll come up with.

Ulco,can you make a quick tutorial on how to cross thumbs,please? ;D ;)
Title: Re: challenge
Post by: Dune on May 13, 2014, 12:00:53 PM
Didn't you know? I have 5 thumbs on each hand, all pointing up  ;D (I know, I meant fingers  :P )
Title: Re: challenge
Post by: Ogre on May 13, 2014, 12:20:23 PM
I thought perhaps evenly spacing a population along the surface of a displaced plane rotated on its side may work.  I cannot get the objects to tip to the planes surface normal, they just tip in the Y direction
Title: Re: challenge
Post by: Dune on May 14, 2014, 02:28:40 AM
Yes, same problem, their angles should depend on the angle of the whole stretch.
Title: Re: challenge
Post by: mogn on May 14, 2014, 05:57:35 AM
Quote from: bigben on May 12, 2014, 07:23:00 PM
Quote from: j meyer on May 07, 2014, 11:11:51 AM
The warp shader seems to be the wrong tool for this task,at least imo.


Straight sections of track could be trickier (when not along X or Z)
[EDIT] Straight sections: 
What we know: Position of end of the track, tangent to the track curvature at the ends (direction the straight track should go).
Using a similar approach, sine function of X or Z to define spacing of sleepers, rotate to match tangent, colour adjust to define edge of sleepers, transform to fix spacing of sleepers at the join, mask with SSS to define ends of sleeper and length of track. Sounds possible.


The straight tracks just requires a prerotate of the coordinate system, eg a path of 23 degrees requires a rotate of -23 degrees.
Title: Re: challenge
Post by: mogn on May 14, 2014, 07:38:01 AM
My rotate rotates anti clockwice so a change to negative of the angle is not needed.
Title: Re: challenge
Post by: bigben on May 14, 2014, 09:40:31 AM
OK, I had to have a preliminary play.  Here's a 500m radius circle of sleepers, 23cms wide, 13cm high, 244cm long, 60cm apart.
The approach:

or here's the TGD  ;)
There are a few unused nodes in there in preparation for adding tracks and masks for gravel and track surrounds.

[EDIT] For the 2 people that downloaded the TGD, I hadn't saved the camera position so you'll have to look for the tracks to the south east. Updating the TGD[/EDIT]
Title: Re: challenge
Post by: Dune on May 14, 2014, 11:31:08 AM
Hey Ben, that's pretty nifty! 
Title: Re: challenge
Post by: j meyer on May 14, 2014, 01:07:41 PM
Indeed!
May take a while to digest,though.(for me that is)
Title: Re: challenge
Post by: bigben on May 14, 2014, 05:56:20 PM
Thanks guys. Don't worry, I had to step through the math in a Word document because it started to. Do my head in. I've been thinking about how I can make it more sustainable/usable and I think it may be possible to connect bits of track by changing how the positions are defined.
First problem I had was how do I place the centre of a circle 500m out of camera and place the track where I wanted it in the frame. 

My initial model defines the position of the track from the centre of curvature or the centre of the straight, but if I change to calculate the centre from a position and compass bearing for one end of the track I can calculate the position and bearing of the other end of the segment and pass that on to the next piece of track. In theory it should be possible to construct a string of straights and curves in such a way that modifying the length of any piece will readjust the position of all adjoining pieces.  that would be sweet.

A little trickier is what to do with the terrain around the track. This will take a bit of fiddling outside of TG but I'm thinking an orthogonal render of the track mask with the terrain disabled to provide a base image for defining the altitude. Load this into  photoshop and add linear gradients along the track to match the changes in altitude. Blur it a bit and then use this image map to create a second terrain masked by the track area (additional mask to be added to the track model). Merge the 2 terrains and you should have a nice flat surface for the tracks to sit on with realistic gentle slopes as well as producing cuttings and embankments. If it works as well as it does in my head it will be awesome.

At least with thumbs crossed I can still type ;)
Title: Re: challenge
Post by: bobbystahr on May 14, 2014, 06:21:06 PM
Quote from: bigben on May 14, 2014, 05:56:20 PM
Thanks guys. Don't worry, I had to step through the math in a Word document because it started to. Do my head in. I've been thinking about how I can make it more sustainable/usable and I think it may be possible to connect bits of track by changing how the positions are defined.
First problem I had was how do I place the centre of a circle 500m out of camera and place the track where I wanted it in the frame. 

My initial model defines the position of the track from the centre of curvature or the centre of the straight, but if I change to calculate the centre from a position and compass bearing for one end of the track I can calculate the position and bearing of the other end of the segment and pass that on to the next piece of track. In theory it should be possible to construct a string of straights and curves in such a way that modifying the length of any piece will readjust the position of all adjoining pieces.  that would be sweet.

A little trickier is what to do with the terrain around the track. This will take a bit of fiddling outside of TG but I'm thinking an orthogonal render of the track mask with the terrain disabled to provide a base image for defining the altitude. Load this into  photoshop and add linear gradients along the track to match the changes in altitude. Blur it a bit and then use this image map to create a second terrain masked by the track area (additional mask to be added to the track model). Merge the 2 terrains and you should have a nice flat surface for the tracks to sit on with realistic gentle slopes as well as producing cuttings and embankments. If it works as well as it does in my head it will be awesome.

At least with thumbs crossed I can still type ;)

Can't wait to see the outcome of this. The technique with the terrains could be also used for roads.
Title: Re: challenge
Post by: bigben on May 14, 2014, 06:47:43 PM
Quote from: bobbystahr on May 14, 2014, 06:21:06 PM
Can't wait to see the outcome of this. The technique with the terrains could be also used for roads.

It could indeed. Strip out the rails and replace the sleepers with white lines. The masking requirements are very similar. The only drawback I can think of is that  I can only build circular curves, but the approach of smoothing the terrain could be adaptable to other models. I have a couple of other ideas for generating the second terrain but that'll be something to try a the end.
Title: Re: challenge
Post by: mogn on May 15, 2014, 02:18:32 PM
I think I have found a pure blue nodes solution. I don't like nodes where the outcome depends on an artistic evaluation.
The solution requires 3 perlin noises.
The creation of a sleeper attached. 


Title: Re: challenge
Post by: bigben on May 17, 2014, 04:48:12 AM
A little more masking. There are a few problems when you try and work with sharp displacements and I may need to at least put a small gap in the sleepers to place the tracks rather than merging the sleeper and rail displacements.  There are some problems that come when you work with very sharp displacements, so this may be a theoretical exercise.

In this version:

The mask model is symmetrical. I decided against doing individual inner/outer (or left/right) masks
Title: Re: challenge
Post by: Dune on May 17, 2014, 06:03:01 AM
Yes, you need a little softness to the edges, that's why I always worked with image maps (with the problem of not being able to rotate the sleepers with the track). Or a smooth step or color adjust will do in this case. Procedural rails can't be lifted off the ground and have to be inversely masked by the sleepers for a level top. I used some bent elongated displacable cubes lately. But you have to bend them (redirect/vector displace) the same way as the track.
Title: Re: challenge
Post by: bigben on May 17, 2014, 07:35:43 AM
That looks pretty good.

The beveled edges aren't too much of a problem in mine. They're just in there for visual representation at the moment. The linear mask can be used to control the merging of a displaced terrain rather than doing the actual displacement.  Have to learn more about vector displacement
Title: Re: challenge
Post by: Dune on May 17, 2014, 08:42:26 AM
Vector displacement is very interesting!
Title: Re: challenge
Post by: bobbystahr on May 17, 2014, 09:24:30 AM
Quote from: Dune on May 17, 2014, 06:03:01 AM
Yes, you need a little softness to the edges, that's why I always worked with image maps (with the problem of not being able to rotate the sleepers with the track). Or a smooth step or color adjust will do in this case. Procedural rails can't be lifted off the ground and have to be inversely masked by the sleepers for a level top. I used some bent elongated displacable cubes lately. But you have to bend them (redirect/vector displace) the same way as the track.

Edging on photo real on these tracks...great work.....
Title: Re: challenge
Post by: bigben on May 17, 2014, 10:17:55 AM
One of the problems with my procedural approach is you have the roughness of the fractal terrain.  I experimented with a quick idea I had for creating embankments and cuttings.  Produced an orthographic render of the terrain with a shader to give me a greyscale displacement map from a specified minimum altitude.   Opened that in Photoshop and performed a Gaussian blur and used the resulting image as a displacement map for a second terrain. Connect both terrains to a merge node and use the embankment displacement mask from the first test as the mix controller.

The blurred terrain should be higher at dips and lower at ridges than the original terrain. The mix controller will then automatically create both embankments and cuttings. The resulting smoother terrain under the tracks fixes a lot of the problems with sharp displacements for the sleepers and tracks resulting from small scale displacements in the fractal terrain.
Title: Re: challenge
Post by: bobbystahr on May 17, 2014, 11:04:51 AM
Quote from: bigben on May 17, 2014, 10:17:55 AM
One of the problems with my procedural approach is you have the roughness of the fractal terrain.  I experimented with a quick idea I had for creating embankments and cuttings.  Produced an orthographic render of the terrain with a shader to give me a greyscale displacement map from a specified minimum altitude.   Opened that in Photoshop and performed a Gaussian blur and used the resulting image as a displacement map for a second terrain. Connect both terrains to a merge node and use the embankment displacement mask from the first test as the mix controller.

The blurred terrain should be higher at dips and lower at ridges than the original terrain. The mix controller will then automatically create both embankments and cuttings. The resulting smoother terrain under the tracks fixes a lot of the problems with sharp displacements for the sleepers and tracks resulting from small scale displacements in the fractal terrain.

Well beyond my ability to do/understand really, but I'm totally impressed...
Title: Re: challenge
Post by: j meyer on May 17, 2014, 12:48:53 PM
Cool development.
I'm still trying to understand the first file and look forward
to inspect the next one.
Title: Re: challenge
Post by: bigben on May 17, 2014, 10:28:47 PM
I wouldn't be too impressed Bobby, I screwed up the placement of the image map (forgot to centre it) and when I fixed that, the noise in the image destroyed the model  ::). So a vector displacement of a plane it will have to be.  At the end of this, most of the nodes doing the math can be hidden, leaving just the nodes required for placing the track and connecting the pieces left visible.

I'm happy to explain specific bits in detail if it helps Joel. This approach to building masks is very useful eg my old tiled terrain method (those masks can now be simplified with using SSS), or my river/lake model where a single base mask can be turned into several different masks with a few simple adjustments. I'll make a version which previews a few of the "landmark" nodes in the progress of constructing the final mask.

One thing I've got out of this is that while trying to figure out how to smooth the transitions between masks, particularly changing the altitude of the track I finally spotted the obvious... use a sine function on the linear gradients.
Title: Re: challenge
Post by: Dune on May 18, 2014, 03:16:33 AM
I'm curious about your last sentence, Ben.
Regarding the fractal noise hindering the track, that's why I use a very smooth terrain to begin with, and mask out the track area for the finer/rougher displacements.
Title: Re: challenge
Post by: bigben on May 18, 2014, 05:02:49 AM
I wanted to keep the track level even on slopes. I've moved the embankment/cutting and gravel base (without fake stones) into the terrain where it really belongs.  I was aiming for the tracks to be able to go through any terrain, and to this end I'll be adding a start and end altitude for each section. I'll have two terrains that will be merged using one of the masks as a mix controller.  That will ensure both a level track and a smooth surface for the subsequent displacements.

There is still the problem of colours "streaking" up the vertical faces of the sleepers and rails. Not sure of the best way to deal with that, maybe make the sides not-quite vertical.  I also get the colour from the sleepers going up the side of the rails... You can see these best on the vertical sides of the rails.
Title: Re: challenge
Post by: bigben on May 18, 2014, 06:12:27 AM
A quick check on combining with a random terrain to test cuttings and embankments.
Title: Re: challenge
Post by: Dune on May 18, 2014, 09:25:42 AM
If you make the rail mask slightly soft, you can color adjust the mask for the rail color mask, and loose the bleeding. That's what I did.
Title: Re: challenge
Post by: j meyer on May 18, 2014, 11:24:59 AM
 ;D Joel,is that me? hee hee.....the name is Jochen,no problem,though.
Explanations won't help much in my case,I'm afraid.Generally I can follow
what you are doing.So far I haven't found out what some of the nodes do,
because the preview just shows white or black and I'll have to find out an
other way to see what happens.That takes some time usually,but I'm used
to it,kind of.You'll always have to translate things into your own terminology/
language to understand,at least in my opinion.
Anyway,thank you Ben,very inspiring material :).
Title: Re: challenge
Post by: bobbystahr on May 18, 2014, 11:34:29 AM
very happy to have notify enabled on this thread even though I understand only about 1%...at least thats a + number...heh heh heh
Title: Re: challenge
Post by: bigben on May 18, 2014, 05:18:47 PM
Oops... That would be my faded memory playing tricks on me Jochen  :-[. That's what you get for being a nomadic wandere and only returning periodically  ;)
I'm thinking I need to use some naming convention as we'll to pick out landmark nodes. I have trouble picking the right nodes myself sometimes.

I was thinking of softening the edges as well, particularly the sleepers. Back to multiplying the linear gradients instead of the Boolean nodes. That will also give some roundness to the corners of the sleepers.
Title: Re: challenge
Post by: Dune on May 19, 2014, 03:32:31 AM
As an in-between:
Quotevery happy to have notify enabled on this thread
I used to have that; but now I don't. Just click the second line from above in screen and 'show unread posts since last visit'. You won't miss a thing, which is very helpful in getting to grips with TG.
Title: Re: challenge
Post by: bobbystahr on May 19, 2014, 03:49:26 AM
Quote from: Dune on May 19, 2014, 03:32:31 AM
As an in-between:
Quotevery happy to have notify enabled on this thread
I used to have that; but now I don't. Just click the second line from above in screen and 'show unread posts since last visit'. You won't miss a thing, which is very helpful in getting to grips with TG.

D'oh....
Title: Re: challenge
Post by: bigben on May 19, 2014, 04:20:10 AM
Quote from: bobbystahr on May 18, 2014, 11:34:29 AM
very happy to have notify enabled on this thread even though I understand only about 1%...at least thats a + number...heh heh heh

I'm planning to post a few samples of some of my basic masking methods. I'm familiar with the way you work and I know you'll find them useful
Title: Re: challenge
Post by: bobbystahr on May 19, 2014, 07:08:11 AM
Awesome Ben....thanks in advance
Title: Re: challenge
Post by: bigben on May 20, 2014, 08:32:43 AM
Still have a few things to do but figured I'd post  an updated TGD that's a bit easier to follow.
I've renamed some of the key nodes with all uppercase letters partly for myself (easier to find) and a few extras you can connect to the last surface shader mask to preview.
Still to do:
Title: Re: challenge
Post by: Dune on May 20, 2014, 10:46:36 AM
This looks very good, Ben. I'll check out your file later...
Title: Re: challenge
Post by: j meyer on May 20, 2014, 11:57:59 AM
As for the still to do list that's the stuff I'm really looking forward to,
since I have not the slightest idea how that could be done.
Title: Re: challenge
Post by: bigben on May 20, 2014, 07:20:42 PM
Joining tracks and sloping the terrain were certainly the biggest dilemnas I've had but my approach has been geared towards this end. There are many ways to mathematically describe a rectangle, which is why I started with the circular track. The key parts were separating the model into a terrain and a displaced surface so that the terrain could be sloped without affecting the sleepers and rails.

I had a think about doing double tracks and this helped narrow down the approach. You couldn't just duplicate this setup and offset it a bit as the terrains would overlap and screw each other up. Circular tracks would have the same centre of curvature but different radii depending on which way the track curved and things quickly get messy from here.

It struck me at this point that the circular track model was constructed as a reflection of half a track along the track centre. So a) it would be relative straightforward to just create extra rails further away from the track centre, lengthen the sleepers etc... to have muliple parallel tracks and b) the path of the track(s) is defined as a single path which simplifies the math for joining two sections together. The only position that will be manually entered is the start position. The position and bearing of the end of the track is calculated from the other settings entered and then passed on to the next track segment. So for all subsequent sections of track you only define a length for straight sections, and a final compass heading and direction of the turn for circular sections.

Had I started with a straight section of track I probably would have defined the outer edges first and then worked my way in which would have made joing sections much trickier (calculating 4 corners or edges instead of 1 line).

Tidying up the sleepers at the joins is another matter. I originally thought I could just add a scalar to change the length to fix up any sleepers that got cut in half but that's too messy as well. To handle that, I think it will be better to adjust lengths and compass headings to muliples of the separation between sleepers. The deviations from manually entered values should be trivial.
For the straight sections I'm leaning towards SSS with transformations to position it by the centre of the segment and rotated to the compass heading

Smoothing the slope between sections will involve calculating the slope at the ends of each section, splitting the difference and defining a new slope with this value. A cosine function can then be used to adjust the height along the track from the starting slope to the final one.

Sounds good in my head anyway  ;)
Title: Re: challenge
Post by: Dune on May 21, 2014, 02:44:31 AM
You're strength obviously lies in thinking it out in theory. As you get to know TG, I find that easier to do as well; think ahead what certain combinations of nodes will do, and test it. Many times however, they react slightly different than anticipated, like an example I will post shortly (Niagara Falls).
Title: Re: challenge
Post by: Shigawire on May 22, 2014, 03:21:15 PM
Quite an impressive challenge to beat.. so it seems bigben beat the challenge? ;)
Title: Re: challenge
Post by: bigben on May 22, 2014, 05:25:19 PM
A long way to go, and it will only ever be an approximation.  As I sit waiting for the train I look at the relationship between the track and the terrain and think.... no, can't replicate that..  ;)