Planetside Software Forums

General => Terragen Discussion => Topic started by: wubba on July 28, 2018, 05:31:59 AM

Title: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 28, 2018, 05:31:59 AM
Hey all... Fairly new with Terragen as have dabbled in the past but now I'm in knee deep in trying to achieve integration with a 3ds max scene...
Ok so I've imported a .fbx scene from Max which consists of just a camera on a path with multiple twists and bends...

The completed scene will be a 1st person cockpit view of a small space ship crashing through an array of trees, eventually coming to a halt near a coastal shore..

Problem I have is the terrain I'm using in Terragen is a displacement .tiff height map & the terrain I'm using in Max is identical as is the exact same .tiff height map applied using a Displace modifier..
When all imported into Terragen.. the camera path is not aligned to its correct X,Y,Z position... I'm unable to move the camera so I move the terrains instead manually guessing it's correct position to what it is in Max..
Unfortunately once I comp it all in after effects, the max render is all out of sync with the Terragen render...

Is there a way to accurate reposition the terrain in Terragen so it syncs up with my Max animation?.. Would be great if I could import the .fbx terrain along with the camera path from the one .fbx file into Terragen??...



Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: KlausK on July 28, 2018, 01:21:58 PM
test
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: KlausK on July 28, 2018, 01:24:27 PM
Sorry, can`t post more than a few words. I am constantly redirected to "Start a new topic".
I have attached a txt file instead.
CHeers, Klaus
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: Matt on July 28, 2018, 01:56:03 PM
Welcome to the forum!

Before importing the camera, I would export the terrain from Max as an OBJ (or a proxy of your terrain). Bring the OBJ into Terragen and make sure it has the correct size in world space (Terragen units are metres). If the scale is off, then usually it's by a factor of 0.01, 0.1, 10 or 100.

Now see if the camera sits correctly in this space. If not, it's usually just a scaling issue, as with OBJ, so try reimporting with different scale factors.

Rotation order shouldn't be a problem with FBX.
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: Matt on July 28, 2018, 02:01:23 PM
FBX cameras sometimes import with the wrong FOV because of a difference in film back / aperture settings. You might be able fix this by changing the Terragen camera to "Use horizontal FOV" after importing it.
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 29, 2018, 01:53:02 AM
Thanks heaps guys for the replies!!! :) .. I've been working on the suggestions you've all posted but unfortunately still no success... I'm not at my computer atm but will upload my scene files and assets once I get back. .. Hopefully give a better insight..
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 29, 2018, 04:41:27 AM
Think I got it working  ;D ...  The height map needed to be flipped! .. & I also had the wrong X&Y coordinates inputted to the heightfield terrain... Been doing so many tests, saving so many variations of the same files, I think I may have got muddled & mixed stuff up!?.. Anyway... Looks good.. can't wait for the final render!!!  8)

PS: Thanks to KlausK & Matt from Planetside Staff for the prompt help!!!
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: KlausK on July 29, 2018, 10:35:36 AM
Well done, you got it!

I couldn`t resist and rendered a sort of low res version. Hope you don`t mind.
Looks quite nice. I am curious how it works out in the end.
Crashing through the trees and debris  and dust and all.
Let us know, please.
CHeers, Klaus
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 29, 2018, 07:30:30 PM
Quote from: KlausK on July 29, 2018, 10:35:36 AM
Well done, you got it!

I couldn`t resist and rendered a sort of low res version. Hope you don`t mind.
Looks quite nice. I am curious how it works out in the end.
Crashing through the trees and debris  and dust and all.
Let us know, please.
CHeers, Klaus
Not at all! :) .. I just posted the screen capture coz i didn't have time to render it.. Looks like The camera is slipping underneath the terrain towards the end... I may need to adjust either the height of the terrain or camera path in Max?? .. either way I know the process works!
You can check my progress on here if like :)

facebook.com/projectinfinity3d
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 29, 2018, 10:11:44 PM
Uh Oh!... Never plain sailing is it.. & in my case I'm not even hitting the water!!!..
So... I've comped it in with my trees and I'm 99.9% sure all elements are in their correct position, though the palm trees look like their still floating and moving with the camera (slightly)... I assume it has something to do with how Terragen interprets the height map terrain..  with the camera so close to the surface, the terrain has a 'staircase' like appearance, which does not do the same in Max!?... Went from a 2k to 4k map & made little to no difference at all so I'm beginning to think I've hit a brick wall here??... or is there a way to remove the staircase effect???...  :-\
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: Matt on July 29, 2018, 11:52:26 PM
You probably need to use a 16 bit displacement map, if you're not already.

If Max doesn't show the stair-stepping, perhaps your terrain is subdivided too coarsely in Max? If you increase the subdivisions high enough, I'd expect the Max terrain show the same stair-stepping.
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 02:22:27 AM
Quote from: Matt on July 29, 2018, 11:52:26 PM
You probably need to use a 16 bit displacement map, if you're not already.

If Max doesn't show the stair-stepping, perhaps your terrain is subdivided too coarsely in Max? If you increase the subdivisions high enough, I'd expect the Max terrain show the same stair-stepping.
Yeah I've been reading up on the 16 bit requirement.. At first I downsized the res from 4k to 2k in 8bit. The original png is actually 24bit.. which I loaded into Terragen & still shows the stair artefacts so I don't know..
Does it need to be exactly 16 or are you saying you can't avoid it altogether?
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: Kadri on July 30, 2018, 02:58:31 AM
Quote from: wubba on July 30, 2018, 02:22:27 AM
..
Yeah I've been reading up on the 16 bit requirement.. At first I downsized the res from 4k to 2k in 8bit. The original png is actually 24bit...
Your 24 bit image is actually a 8 bit image (8 bit for Red+8 bit Green+8 bit Blue= 24 bit). It can be confusing at first.

"This means that the 8-bit setting (BPC) is in fact 24-bits per pixel (BPP). Meaning that each pixel can have values ranging from 0 to 16,777,215, representing about 16 million colors.
...
Similarly the 16-bit setting (BPC) would result in 48-bits per pixel (BPP). The available number of pixel values here is mind boggling (2^48). More than 16 million times more numerical values then the 8-bit setting. Again, this may seem like an overkill, but if you consider the neutral color gradient again, the maximum amount of tonal values is 'only' 65,536."


From here:
https://www.diyphotography.net/8-bit-vs-16-bit-color-depth-use-matters/

You need HDR images like an EXR file for example.
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 03:54:56 AM
Quote from: Kadri on July 30, 2018, 02:58:31 AM
Your 24 bit image is actually a 8 bit image (8 bit for Red+8 bit Green+8 bit Blue= 24 bit). It can be confusing at first.

"This means that the 8-bit setting (BPC) is in fact 24-bits per pixel (BPP). Meaning that each pixel can have values ranging from 0 to 16,777,215, representing about 16 million colors.
...
Similarly the 16-bit setting (BPC) would result in 48-bits per pixel (BPP). The available number of pixel values here is mind boggling (2^48). More than 16 million times more numerical values then the 8-bit setting. Again, this may seem like an overkill, but if you consider the neutral color gradient again, the maximum amount of tonal values is 'only' 65,536."


You need HDR images like an EXR file for example.

That blows because the heightmap is just right for my scene, not to mention I've already put in a fair bit of work around it... Its exported from Unity World Creator.. the only export format options are .jpg .png .raw8 raw16 & .obj... I tried the .raw16 format but it wont open in Photoshop, under 16bit settings as states 'Specified image is larger than file'!??.. Hmmm... I wonder if Camera Raw will convert it safely to .tiff16??...

Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: Matt on July 30, 2018, 04:22:06 AM
I wonder if their PNG saver has a 16 bit option. If not, raw16 is probably your best bet. You'll need to tell Photoshop what the resolution is. And I assume must be greyscale, not RGB. If you enter the same X and Y size as in World Creator I think it can be made to work. Is there anyone else here who's tried this and can help?
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 04:51:26 AM
Quote from: Matt on July 30, 2018, 04:22:06 AM
I wonder if their PNG saver has a 16 bit option?
Unfortunately it only exports 24 bit, as Kadri pointed out is still only 8 bit :(
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: Dune on July 30, 2018, 04:56:56 AM
You could enlarge it considerably in Photoshop, make it 16bit, blur it and add detail in TG. You could get rid of the steps then.
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 05:25:27 AM
Quote from: Dune on July 30, 2018, 04:56:56 AM
You could enlarge it considerably in Photoshop, make it 16bit, blur it and add detail in TG. You could get rid of the steps then.
Might be worth a shot?.. though not sure if that's gonna help with the floating trees effect??...
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: Dune on July 30, 2018, 05:40:23 AM
Did you sit the tree pop on the last node before it's going into planet? Maybe add (another) compute terrain there (just for the pop to sit on).
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 06:00:22 AM
Quote from: Dune on July 30, 2018, 05:40:23 AM
Did you sit the tree pop on the last node before it's going into planet? Maybe add (another) compute terrain there (just for the pop to sit on).
I'm not using population (at this stage).. I've rendered a cluster of test trees in max with them roughly positioned but not floating above the terrain.. if anything partially submerged...
I haven't tinkered with population yet.. reading up on it now but can you tell me what the limitations are?..

I want to use specific plant models (various palm trees) and be able to animate (branches moving in the wind)..
Having said this, it still doesn't fix the stair artifacts??...
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 06:48:50 AM
Hope this helps, but when trying something similar in World Machine  (exporting .raw32) - changing the file extension to .raw will let it load in Photoshop - when you import you have the option of specifying the bit depth you know it is.

Just had a quick look at the World Creator website and it says it can export to raw32 - that would be your best bet - you would just need to change the extension as mentioned to .raw and specify 32 bit on import to Photoshop

Quoteunder 16bit settings as states 'Specified image is larger than file
this is simply that the raw importer in Photoshop needs to know the resolution of the image you're trying to load - looks like the default is 4096 x 4096.

So if your image is 2048 x 2048, you'll have to set that manually, but if you can export a higher resolution image from World Creator try as high as you can go to get more detail

Terragen won't load the .raw file though, so you could convert it to OpenExr to load it into Terragen and turn it into an RGB image. Photoshop is a bit behind the times with 32 bit Exr images so when I was trying this workflow I found a free plugin for Photoshop that exports full 32 exrs:

https://www.exr-io.com/

So here's a suggestion for a workflow to get the most out of your map:

You can then load the exr into Terragen via a heightfield load or a displacement node, my personal preference is via a heightfield node as you then get the extra fractal fine detail displacement on the heightfield shader for free.

Possible pitfalls:

When I tried this from World Machine the map seemed to be normalized - that is the values don't match "real world" values - for instance, if the highest point in your World Creator scene is 350 meters,, then the brightest pixel in your map will need to be 350. If it isn't, then you will have to:


In my workflow, I used Nuke to get an exact value for this multiplier.

That should help with displacement maps - though couldn't you export a .obj to load into 3ds max and a .ter file for Terragen?




Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 08:59:37 AM
Quote from: digitalguru on July 30, 2018, 06:48:50 AM
Hope this helps, but when trying something similar in World Machine  (exporting .raw32) - changing the file extension to .raw will let it load in Photoshop - when you import you have the option of specifying the bit depth you know it is.

Just had a quick look at the World Creator website and it says it can export to raw32 - that would be your best bet - you would just need to change the extension as mentioned to .raw and specify 32 bit on import to Photoshop
From what i gather, it depends on which World Creator you're using.. Unity WC2 exports .raw (8 & 16 bit) and those extensions are .raw... WC2 'standalone' exports .raw .r16 & .r32 (I'm assuming .r* is still raw?)... Later versions I cannot account for but changing the .r16/32 extension gets the same  'Specified image/larger file' error in Photoshop as the unity WC2 .raw (16) does... I can only play with lower res settings to open it & then they only display corrupt so!?...

(IM CONFUSED!!!) - BUT!...

I did manage to import the Unity WC2 a 4k .raw (16)  into Lightroom & export it to 4k .tiff (16), which opened fine in Photoshop.. I then flipped it & downsized to 2k maintaining the 16 bit depth. (My 3ds Max terrain is also set at 2048x2048)..

Well the extra bit depth does make a difference but not as much as I was hoping for.. but I think it is passable considering it is a fast paced scene and most of the terrain will be eventually scattered with vegetation & covered by cockpit internals.. May have to use another approach for trees.. as for now I'm exhausted!!!

[attachimg=1]
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 09:16:40 AM
QuoteUnity WC2 exports .raw (8 & 16 bit)

Yeah, I suspected the Unity version might have different export formats.

I guess it doesn't export to Terragens .ter format either.

If you don't mind, could you upload the original raw file from unity to have a look?
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 09:35:17 AM
Quote from: digitalguru on July 30, 2018, 06:48:50 AM
That should help with displacement maps - though couldn't you export a .obj to load into 3ds max and a .ter file for Terragen?
-------------------------------------------------------------------------------------------------------------------------------------------
Yeah, I suspected the Unity version might have different export formats.
I guess it doesn't export to Terragens .ter format either.
If you don't mind, could you upload the original raw file from unity to have a look?

No unfortunately it dont.. yeah sure... cant attached it here as its 32mb... download it here :)

http://www.mediafire.com/file/g8homh1q2p83210/heightmap4k%20unityWC2%20%28RAW16%29.rar
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 09:54:04 AM
Got it - what's the resolution (pixel dimensions) of the file?
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 10:01:15 AM
Quote from: digitalguru on July 30, 2018, 09:54:04 AM
Got it - what's the resolution (pixel dimensions) of the file?
4097×4097 .. which I found odd.. I assume a Unity thing?
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 10:08:49 AM
getting somewhere - what's the size of the terrain area in meters?

QuoteI assume a Unity thing

some progs add a pixel so the rez is not an exact power of two - don't know why though - maybe it's a memory allocation thing
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 10:23:02 AM
Quote from: digitalguru on July 30, 2018, 10:08:49 AM
getting somewhere - what's the size of the terrain area in meters?

Not exactly sure on the metres... Could it be the 'Terrain Real Width'?
[attachimg=1]
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 10:35:39 AM
Quote
Not exactly sure on the metres... Could it be the 'Terrain Real Width'?

hopefully :-)

I'm getting something like this - does that look like the shape of your terrain?
[attachimg=1]

p.s the heightmap looks like this:
[attachimg=2]
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 11:15:10 AM
Quote from: digitalguru on July 30, 2018, 10:35:39 AM
does that look like the shape of your terrain?
------------------------------------------------
p.s the heightmap looks like this:

Nope! way off ;) .. I got that washed away effect myself when importing the raw16 into Photoshop under lowres settings I think??.. but here is how its meant to look. :)

[attachimg=1]
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: Kadri on July 30, 2018, 11:16:33 AM
Quote from: wubba on July 30, 2018, 10:23:02 AM
...
Not exactly sure on the metres... Could it be the 'Terrain Real Width'?
[attachimg=1]

Just curious.
If this is for Unity and game oriented you might get a resolution depending image that takes the camera position in account too. I use neither programs so i am not sure.

There is a "Detail Distance" parameter there in your image for example.
It is 100 so maybe already at  full percent (still place to go on the right side of the slider) but just in case.
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 12:48:45 PM
got it :-)

in the Raw options in Photoshop set channel to 1 and the other options like this:
[attachimg=1]

and the image imports correctly:
[attachimg=2]

change mode to RGB color and export to OpenEXR

attached a Terragen project file - import the full rez open exr and check it out.

Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: KlausK on July 30, 2018, 02:50:53 PM
Thanks, digitalguru. Gonna have to try this.

Btw. your scene file crashes my TG 4.1.25 installation immediately.
On startup I see the Network window with the Notes then before the gui is build completely it crashes.
Could it be that 4.2.x.x files not backward compatible?
CHeers, Klaus
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 03:51:38 PM
QuoteCould it be that 4.2.x.x files not backward compatible?

probably doesn't help, but it seems that when Terragen can't find the heightfield exr it crashes - made a 4.1 scene file also

I've uploaded the exr file to Dropbox, just put it in the same folder you launch the scene from.
https://www.dropbox.com/s/i8mz9euc4o03ha0/heightmap4k%20unity_32bit_pshop.exr?dl=0

Alternatively, you can edit the project file in a text editor and insert the name of your file there

search for:
name = "Heightfield load 01"

then insert the name of the file in the quotes next to file name i.e:

   <heightfield_load
      name = "Heightfield load 01"
      gui_use_node_pos = "1"
      gui_node_pos = "-920 1140 0"
      gui_group = "Terrain"
      input_node = ""
      read_from_file = "1"
      filename = "heightmap4k unity_32bit_exrio.exr"


Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: KlausK on July 30, 2018, 04:29:32 PM
Thank you very much.
You are right , it is because I did not have the *.exr and the scene file in the same location.
Now the 4_2 file opens fine (complaining about some new features missing, of course) with all the files together in place.
I would have thought it would simply complain about the missing file.
On the other hand deleting the Fractal Terrain node set from a default scene also crashes TG.
Perhaps the Compute Terrain node suddenly has nothing to compute anymore.

Anyways, gonna take a look at your notes now.
CHeers, Klaus

Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 04:48:37 PM
There's a Terragen 4.1 project file attached to the previous post :-)

The heightfield file load has a recent addition of a file refresh option, probably a new bug.

QuoteOn the other hand deleting the Fractal Terrain node set from a default scene also crashes TG.

Yes, that happens to me sometimes

Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 07:13:12 PM
Quote from: Kadri on July 30, 2018, 11:16:33 AM
There is a "Detail Distance" parameter there in your image for example.
It is 100 so maybe already at  full percent (still place to go on the right side of the slider) but just in case.
Good morning! :D .... Yes I will give that a shot and see what difference that makes..

Quote from: digitalguru on July 30, 2018, 12:48:45 PM
got it :-)

in the Raw options in Photoshop set channel to 1 and the other options like this and the image imports correctly:
change mode to RGB color and export to OpenEXR

attached a Terragen project file - import the full rez open exr and check it out.
Ahh!..don't think I changed the channel setting, Will try that! ... Thank you for your efforts digitalguru!!!.. I'm not at the computer to test this but dare I ask.. does importing the 4k openexr into Terragen improve/remove the stair artefacts??

As importing the 4k tiff16 from Lightroom didn't make any difference compared to 2k tiff16 I downsized (other than scale)
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 30, 2018, 07:25:16 PM
Yes it does :)
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 07:48:53 PM
Quote from: digitalguru on July 30, 2018, 07:25:16 PM
Yes it does :)
Sweet!  ;D Look forward to testing it out!! Just want to move on & complete this scene!!!
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 30, 2018, 11:17:48 PM
Man this is wrecking my head! :S ... I got the .exr exported so thanks for that digitalguru but concerning the last 2 .tgd files you uploaded.. They open fine (except the 2nd one which seems to load fine but gives errors), though the minute I attempt replicate your stack in Terragen, it displays the .exr heightmap correctly in the 'Heightfield load' sub-level (small Preview window) but displays like a flat bed in the render/camera preview!?
I swear I've copied the settings note for note so is it just me or a version issue?..I also loaded your .exr into my replicated stack and did the same!?...

Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 31, 2018, 02:04:03 AM
I got it working! :D (Nevermind;).. Ooh Yeah!! converting to .exr REALLY makes the difference!!!

Thanks again digitalguru  :)

[attachimg=1]
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on July 31, 2018, 04:11:29 AM
Nice. Glad it worked out  :)

QuoteThey open fine (except the 2nd one which seems to load fine but gives errors)

The second .tgd was created in Terragen 4.2 08 (Frontier build) so the errors are probably just the differences in versions

Quotedisplays like a flatbed in the render/camera preview!

I'm guessing the vertical scale wasn't set up in that example. I like the way Terragen uses Open Exr in that it stores the height value properly and you don't have to work out a multiplier for the height. Hopefully, OpenExr will become a standard for all these types of programs soon.
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 31, 2018, 10:57:39 PM
Quote from: digitalguru on July 31, 2018, 04:11:29 AM
I like the way Terragen uses Open Exr in that it stores the height value properly and you don't have to work out a multiplier for the height.

Still have issues with the height value whether it be the height map or camera...  This time in Max I imported a 2049x2049 (full resolution) .obj from UnityWC2 (500mb!.. autosave takes forever!!).. UWC2, units are set to 'metres'
[attach=1]
Inside Max, the units are also set to 'metres'
[attach=2]
When I import the .obj, It is set it to convert to metres as 'current' is greyed out & set to centimetres for default!?  ???
Once the .obj is imported into Max, these are its 'Object Properties'
[attach=3]
And the 'Absolute World' position..
[attach=4]

So to give you an idea of where the camera path begins relative to the landscape mesh in Max
[attachimg=5]

& inside Terragen, imported .exr heightmap & .fbx camera animation from Max with 'correct' settings applied?..
[attachimg=6]

I have added a second 'Heightfield Adjust Vertical' into the stack, increasing the Z position (NOT the heightmap peaks) but I have no idea what to set it to now!?
(Max's Absolute World Z: 124.379 goes way under heightmap!?)..

I need it to be exactly equal to Max otherwise my palms wont sync!?...
[attachimg=7]


***In UWC2, the 'Real Terrain Height' is set to 300, but doesn't get equally translated to the .obj export!? inside Max's Object Properties (X:2048 Y:2048 Z:248.773)!??
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on August 01, 2018, 06:11:49 AM
.
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on August 01, 2018, 09:29:52 AM
it's a bit of a minefield isn't it?

I don't have World creator or use 3ds max - so I'm just guessing here,

Quote***In UWC2, the 'Real Terrain Height' is set to 300, but doesn't get equally translated to the .obj export!? inside Max's Object Properties (X:2048 Y:2048 Z:248.773)!??

I would say the Real Terrain Height is a kind of end stop in WC2, and the actual max height as defined by the fractal generator is actually 248.773

So this could be the yardstick by which you figure out the correct scaling for your heightmaps.

For example, if I'd generated a similar terrain in World Machine (x 2048 by Y 2048 with a height of 248.773) and I'd exported a .ter file then I'd expect the brightest pixel to be 248.773 (and it is)

If the raw map is normalized ( darkest pixel is 0 and the brightest pixel is 1), the conversion is simple, since you know the actual height is 248.773 then use that as a height multiplier in Terragen.

Things get a bit murkier with the raw files out of your WC2. In the file you posted the brightest pixel was 0.722329 ( not 1.00) so you would:

248.773 divided by 0.722329 = 344.4040042695226 (to be exact  :) )

This is what I had to do when I rendered a raw32 map out of World Machine. This might be a similar situation in World Creator.

I used a tool in Nuke (curve tool) to figure out the brightest pixel in the raw file, if you don't have Nuke that might be tricker - I haven't seen any other program that does that.

If the file you posted is the file you're using, then 344.4040042695226 is the multiplier to use.

You would then use that value in Terragen.
Load the heightfield.
Insert a Heightfield resize - check Re-size in meters and set the x y size of your terrain in meters - 2048*2048
Insert a Heightfield adjust vertical - check Multiply height by  - and enter  344.4040042695226

If you're using a different map - you'll have to figure out the brightest pixel manually - or if you're in a jam, send me the file and I'll give you the value.

This worked for me - but bear in mind I'm using a different program to generate the raw file, it might work for you.


Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on August 01, 2018, 09:47:28 PM
Very handy info to know!!!.. can't totally recall as exported a few .raw's with varied settings during this saga but unlikely its the same :( ... I don't have Nuke unfortunately as I've heard nothing but positive things about the program.. More an After Effects guy & having said that, would not import the .raw16 & only the .exr.. The Curves tool in AE appears to only adjust curves & not display any data for the file imported!? ..
Would be greatly appreciated if you could please get me the equation though :) .. 

Here's an updated 2k & 4k .raw16.. I could not export the .obj 'Heightmap Resolution' at 4096 as the vert count was crazy like 14 million when 'attempting' to import into Max so had no choice but to export at 2048. My head is a little muddled with all the specs, I figured I'd give you both just to be safe :)

http://www.mediafire.com/file/zkbt5py1kkyjn8g/heightmap2K_unityWC2_%28RAW16%29_new.rar/file

http://www.mediafire.com/file/f8kh66407rubh7x/heightmap4K_unityWC2_%28RAW16%29_new.rar/file
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on August 02, 2018, 06:54:39 AM
QuoteThe Curves tool in AE appears to only adjust curves

Not the same thing, the curve tool in Nuke finds the darkest and brightest pixel to match flickering light sources but is very useful for getting these values from heightfields. It's a shame that programs like Photoshop or After Effects (especially) don't have anything similar.

The brightest and hence the highest point in your raw file is 0.729185 (pretty close to your original value) and was the same for both 2K and 4K files.

So if the height of your terrain is 248.773 (from the obj) then your multiplier should be
248.773 / 0.729185 = 341.1658221164725

with the setup mentioned in the previous post
[attachimg=1]
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on August 03, 2018, 12:47:39 AM
Quote from: digitalguru on August 01, 2018, 09:29:52 AM
This worked for me - but bear in mind I'm using a different program to generate the raw file, it might work for you.
---------------------------------------------
So if the height of your terrain is 248.773 (from the obj) then your multiplier should be
248.773 / 0.729185 = 341.1658221164725

You've been great digitalguru.. thankyou seriously but I don't know if this can be overcome (unless I just do it all in Max!? which I'm trying to avoid) ...
If you're out of ideas, I'll understand as this is ridiculously difficult to overcome!!!

The first terragen screenshot is the closest I've got it synced with Max!, though I had to use the 2k .exr as the 4k was out of X,Y position.. I also had to 'Add Height' on top of the multiplier but as you can tell its still out of whack looking at it in After Effects!?...

[attachimg=1]
[attachimg=2]
[attachimg=3]
[attachimg=4]

I've checked the camera settings as they all seem to be match!?.. Max has few extra specs which doesn't seem to be in Terragen, though I'm fairly confident camera is not the issue..
If I raise/lower the multiplier or height value, the peaks misalign even worse so maybe its the source?.. that dreaded .raw file!? :/
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on August 03, 2018, 07:21:27 AM
I sympathize, I went thru all this with Terragen/Maya -and eventually wrote my own scripts once I'd worked it all out - but it took a while to figure out.
QuoteI've checked the camera settings as they all seem to be match!?
Did you check the Use Horizontal/vertical Fov on the Terragen camera? As Matt mentioned this can sometimes be set to the wrong value.

QuoteI also had to 'Add Height' on top of the multiplier

You shouldn't have to do that - just experiment to find the right multiplier.

If you think the problem is the wrong multiplier for the terrain generated from the raw file in Terragen - if you have the pro version of Terragen, export the terrain via the Micro exporter.
Bring this into Maya and you should have a terrain that matches your Terragen scene. The height might be different, so you might have to tweak your camera animation to compensate.

Or go entirely Terragen, just bring in your trees and plant them manually or use the populations to put them in the scene. You can use the painted shader to paint a map of where you want the trees to appear.

Here's a link to some tutorials I've made that might help give you some ideas:

https://www.youtube.com/watch?v=bTKfAeEPDhY&t=912s

https://www.youtube.com/watch?v=ALbWYn_YHMI
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on August 04, 2018, 08:58:36 PM
Quote from: digitalguru on August 03, 2018, 07:21:27 AM
QuoteI've checked the camera settings as they all seem to be match!?
Did you check the Use Horizontal/vertical Fov on the Terragen camera? As Matt mentioned this can sometimes be set to the wrong value.
There is no setting for this as I'm using a 'Target Camera' in Max with basic presets, which I applied. I wonder if I should be using a 'Physical Camera'?, though I can't find anything on Hori/Vert FOV.. perhaps it has differered terminology?
Thanks for all the help... Gonna tinker a few approaches of attack! :)
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: digitalguru on August 05, 2018, 07:03:30 PM
Quotethough I can't find anything on Hori/Vert FOV

that's the setting on the Terragen camera - sometimes you need to switch between horizontal or vertical.

QuoteI wonder if I should be using a 'Physical Camera
shouldn't make any difference
Title: Re: Matching 3ds max camera/terrain to Terragen 4
Post by: wubba on July 25, 2020, 09:49:25 PM
It's been awhile but I thought I'd show you guys the finished scene.. I ended up doing it mostly in 3ds Max & After Effects...

Hope you all like!!!  ;D

https://www.youtube.com/watch?v=1ULlB8cLzQE