L3DT users' community
Large 3D terrain generator

Imported heightmap doesn't have smooth normals

Got a problem or need advice?

Imported heightmap doesn't have smooth normals

Postby LoneDwarf » Sat Nov 08, 2014 5:22 pm

Hi,

Short version, importing a 16bit png with a min alt of -120.269997 and max of 251.649994 and it gives me a terrain that looks like it's using flat shading.

I used L3DT 12.0 Pro to create my terrain and export it as a mesh. I then used XSI to optimize the mesh and I put some simple splatting on it. The mesh was also modified to fit gameplay and missions. So it no longer mirrors the original mesh from L3DT. I did several mission using this method and the game has been released, all was fine. I mention this because I have now decided to do chunked LOD. So I wrote a tool that did a raycast along a regular grid (2049x2049) to generate the heightmap. All was fine and the people rejoiced. CLOD is working in the game. Now I want to import the heightmap into L3DT to generate new splat info and lighting as it does a great job.

I have imported the heightmap, changed the horizontal scale to 1m and set the vertical range Min. alt -120.27 and Max .alt 251.65. Heightfield image looks correct. It actually looks very close to the original one made by L3DT as the geometry didn't change that much. In fact if I export the original heightmap from L3DT and added it as a layer to Photoshop using difference mode and it's pretty much black. I tried to resize it to 2048 with no luck. Also tried to do a merge using replace.

I have a pretty height degree of confidence that the heightmap isn't the issue. Below is a rough idea as how I encode the heightmap.

Code: Select all
float   fRangeZ   = fMaxZ - fMinZ;
float   fScaleZ   = 65535.0f / fRangeZ;
float   fPixel   = (fHeight - fMinZ) * fScaleZ;
Attachments
attribmap.jpg
normalmap.jpg
heightmap.jpg
LoneDwarf
Member
 
Posts: 10
Joined: Sat Mar 06, 2010 1:09 am

Re: Imported heightmap doesn't have smooth normals

Postby Aaron » Sun Nov 09, 2014 11:32 am

Hi LoneDwarf,

I'm sorry to say it, but those facets are in your heightmap. They look to be the work of a mesh optimiser.

Even if I wanted to make those facets in your heightmap, which of course I don't, L3DT doesn't actually have the critical algorithm to do it. Firstly, it would have to convert the heightmap into an optimised mesh (which L3DT has), and then secondly rasterise it back into a heightmap (which L3DT does not have, although it has been requested a few times).

The horizontal and vertical scale settings will only change the slope of the whole map; they can't change the shape of some areas of the terrain to make them into facets.

I guess it's reasonable to ask why this faceting wasn't obvious in the 2D greyscale view of the heightmap? In a greyscale view, those facets will appear as areas where the rate of change of greyscale intensity is constant, but that's pretty hard to judge by eye. However, it would also show up as long, straight regions on contour lines where the facets intersect the contour lines. That is abundantly evident in your heightmap image.

If you're not satisfied by my assessment, I recommend you find a 3rd party application to load your PNG and render it as a heightmap in 3D (just the geometry, without textures & normals). If you do so, I'm quite certain you will see strong faceting in the affected areas.

Best regards,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Re: Imported heightmap doesn't have smooth normals

Postby LoneDwarf » Sun Nov 09, 2014 3:26 pm

Hi Aaron,

Dead on. The reality is that I have optimized the mesh and then sampled it and therefore original information is forever lost. Pretty 101 stuff :( I think what prevented me from seeing this fact, was that the original heightmap that generated the nice images didn't show any difference from mine in Photoshop difference to blend them. Perhaps because they are both 16bit images and the difference isn't that much so it doesn't show up enough. Doesn't matter I guess.

Anyway, sorry and thank you for the time spent.

Leigh
LoneDwarf
Member
 
Posts: 10
Joined: Sat Mar 06, 2010 1:09 am


Return to Help and support

Who is online

Users browsing this forum: No registered users and 7 guests

cron