heightmap from object

Started by Dune, January 24, 2021, 06:26:41 AM

Previous topic - Next topic

Dune

I have an object of which I need to make a heightmap, but I'm a bit uncertain about lineair or non-lineair. What I do is make an ortho render with a luminosity gradient at 8k resolution and AA=8. Highest point is about 17m, lowest 0, so I have set min altitude at 0m with fuzzy zone at 17, which also looks good enough eyeballing it. The trouble is that the object is supposed to have -2m depths, but I see some areas to have -5m, so to be sure I raised it 5m. It probably doesn't matter very much is the whole range of black to white is shifted a bit, as long as it's giving the accurate heights at every level in the end.
So this gradient and output is the point, as I want it to be accurate. Is there anything in the renderer or Photoshop that I should take care of? Altitude/fuzzy settings - I used Y and better continuity, but is that lineair? - and tonemap gamma and contrast in TG?
And curves in PS? I'm inclined to pull highs down and lows up until clipping just doesn't occur.

Any advice is greatly appreciated.

Tangled-Universe

Hi Ulco,

My take on this would be a bit different these days I think.
I would feed your luminosity function with a 'get altitude -> colour adjust' function and then set white to -5 and black to 17.
This avoids fuzzy zone tinkering, something I personally find very annoying to deal with.

You could also use a white surface layer and feed that function into the colour function of that surface layer.
Set up a sunlight at 90 degrees angle and turn off atmo, shadows and GI.

And of course, render to EXR for linear, but you probably know.

Another thing you could do is to set up the camera close up above the object, facing down, and render an AOV of z-depth and set far clipping to the distance of the bottom of your object.
Also disable those shading flags for shadows and atmo.

Dune

#2
Thanks, Martin. I'll experiment with that. AOV is an interesting thought.

EDIT: the get altitude - color adjust method doesn't work, neither does the get position in geometry - Y to scalar - color adjust. With or without a compute terrain, which in my idea doesn't do anything if only the object is rendered.  I'll have a try at the AOV method...

Tangled-Universe

Maybe the get altitude does not work because it is being applied to an object.
I often mix up which one I need, so perhaps you need "get altitude in texture" which might give you the coordinate within the coordinate space of the object.
Or "get (final) position -> Y to scalar" might the combo you need.

Dune

I tried those all, but I guess it's the compute terrain needed (for normal work) that doesn't apply here. I'll stick to the altitude and fuzzy zone. With RTP it's very easy to check how it looks.

Tangled-Universe

You don't need a compute terrain, perhaps that's the basic cause of why it's not working.

I'll try it myself and post you my findings...

Tangled-Universe

This seems to work:

<terragen_clip>
<colour_adjust_shader
name = "Colour adjust shader 01"
gui_use_node_pos = "1"
gui_node_pos = "-760 -100 0"
gui_group = ""
enable = "1"
input_node = "Y to scalar 01"
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
black_point = "50 50 50"
black_point_adjust = "50"
white_point = "-50 -50 -50"
white_point_adjust = "-50"
gamma = "1 1 1"
gamma_adjust = "1"
clamp_below_black = "1"
clamp_above_white = "1"
>
</colour_adjust_shader>
<y_to_scalar
name = "Y to scalar 01"
gui_use_node_pos = "1"
gui_node_pos = "-760 -40 0"
gui_group = ""
enable = "1"
input_node = "Get position 01"
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
>
</y_to_scalar>
<get_position
name = "Get position 01"
gui_use_node_pos = "1"
gui_node_pos = "-760 20 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
>
</get_position>
<default_shader
name = "Default shader"
gui_use_node_pos = "1"
gui_node_pos = "-720 -160 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
diffuse_colour = "0 0 0"
colour_image = ""
colour_function = ""
translucency = "0 0 0"
translucency_image = ""
translucency_function = ""
luminosity = "1 1 1"
luminosity_image = ""
luminosity_function = "Colour adjust shader 01"
specular_roughness = "0.8"
specular_roughness_image = ""
invert_specular_roughness_image = "0"
convert_specular_roughness_image_to_linear = "0"
specular_roughness_function = ""
specular_roughness_model = "3"
metalness = "0"
metalness_image = ""
convert_metalness_image_to_linear = "0"
metalness_function = ""
reflectivity = "0.75 0.75 0.75"
reflectivity_image = ""
reflectivity_function = ""
reflection_tint = "1 1 1"
index_of_refraction = "1.5"
displacement_direction = "1"
displacement_multiplier = "0.01"
displacement_image = ""
convert_displacement_image_to_linear = "0"
displacement_function = ""
displacement_offset = "0"
opacity = "1 1 1"
opacity_image = ""
use_alpha_channel = "0"
invert_opacity_image = "0"
opacity_function = ""
alpha_from_colour = "0"
alpha_key = "0 0 0"
key_tolerance = "0.1"
image_projection = "4"
projection_camera = ""
unpremultiply_colour = "0"
unpremultiply_metalness = "0"
unpremultiply_translucency = "0"
unpremultiply_luminosity = "0"
unpremultiply_reflectivity = "0"
unpremultiply_specular_roughness = "0"
>
</default_shader>
<rock
name = "Rock 01"
gui_use_node_pos = "1"
gui_node_pos = "-720 -220 0"
gui_group = ""
enable = "1"
population_mode = "0"
preview_options_use_preview_colour = "0"
preview_options_preview_colour = "1 1 1"
preview_options_main_hidden = "0"
preview_options_main_bounding_box = "0"
preview_options_main_wireframe = "0"
preview_options_wf_bounding_box = "0"
preview_options_main_smooth_shaded = "1"
preview_options_main_textured = "0"
show_b-box_in_preview = "1"
show_wireframe = "1"
number_of_faces = "20"
diameter = "1"
unique_variations = "100"
seed = "6771"
shatter = "0"
shatter_probability = "1"
number_of_shatter_planes = "1"
shatter_separation = "0.1"
subdivide_mesh = "0"
subdivision_level = "3"
mesh_displacer = ""
surface_shader = "Default shader"
displacement_tolerance = "1"
shadow_bumps_at_terminator = "1"
visible_to_camera = "1"
visibility = "2"
visible_to_other_rays = "1"
cast_shadows = "1"
double-sided_surface = "0"
use_smooth_normals = "0"
flip_normals = "0"
render_method = "0"
sorting_bias = "0"
translate = "0 0 0"
rotate = "0 0 0"
scale = "100 100 100"
heading = "0"
elevation = "0"
distance = "1"
import_offset = "0 0 0"
import_scale = "1"
import_motion_filename = ""
>
<default_shader
name = "Default shader 01"
gui_use_node_pos = "1"
gui_node_pos = "200 60 0"
gui_group = ""
enable = "1"
input_node = ""
gui_use_preview_patch_size = "0"
gui_preview_patch_size = "1000 1000"
diffuse_colour = "0.5 0.5 0.5"
colour_image = ""
colour_function = ""
translucency = "0 0 0"
translucency_image = ""
translucency_function = ""
luminosity = "0 0 0"
luminosity_image = ""
luminosity_function = ""
specular_roughness = "0.8"
specular_roughness_image = ""
invert_specular_roughness_image = "0"
convert_specular_roughness_image_to_linear = "0"
specular_roughness_function = ""
specular_roughness_model = "3"
metalness = "0"
metalness_image = ""
convert_metalness_image_to_linear = "0"
metalness_function = ""
reflectivity = "0.75 0.75 0.75"
reflectivity_image = ""
reflectivity_function = ""
reflection_tint = "1 1 1"
index_of_refraction = "1.5"
displacement_direction = "1"
displacement_multiplier = "0.01"
displacement_image = ""
convert_displacement_image_to_linear = "0"
displacement_function = ""
displacement_offset = "0"
opacity = "1 1 1"
opacity_image = ""
use_alpha_channel = "0"
invert_opacity_image = "0"
opacity_function = ""
alpha_from_colour = "0"
alpha_key = "0 0 0"
key_tolerance = "0.1"
image_projection = "4"
projection_camera = ""
unpremultiply_colour = "0"
unpremultiply_metalness = "0"
unpremultiply_translucency = "0"
unpremultiply_luminosity = "0"
unpremultiply_reflectivity = "0"
unpremultiply_specular_roughness = "0"
>
</default_shader>
</rock>
</terragen_clip>

Dune

That works, great. Thanks very much. Now I'm curious what the differences will be with the fuzzy zone method.

Tangled-Universe

Your method will probably work as well, cannot see why not. I just like this approach better, because for me it takes out the guesswork. Yours does the same, but all in one node, definitely something to say for that approach.

Dune

The only difference maybe being the calculation of the fuzzy zone. I have no idea how 'lineair' that is (with or without the better continuity being checked, as that must result in some difference). Your method seems more lineair anyway, I only wonder why get altitude didn't work and get position and Y to scalar does. Or I messed something simple up in the hurry, because now that I think of it, I used the surface shader's luminosity I think (not the default shader's), and might have forgotten the altitude checks.

It works anyway, and I've got a nice heightmap to work in.

sboerner

Interesting discussion . . . bookmarking for future reference.