fogleman / hmm

Heightmap meshing utility.
MIT License
571 stars 50 forks source link

why is zscale required? #16

Open ghorn opened 2 years ago

ghorn commented 2 years ago

Why is zscale a required argument? Is it nonlinear - if you scale before vs after does it make a difference?

I ask because I postprocess the mesh to scale x/y to something independent of heightmap resolution, and at that time I have to consider the hmm z scaling. It'd be easier for my use case to either pass an x/y scaling as well as z to hmm, or to not pass a z scaling to hmm and do it myself afterwards alongside x/y. But if I have to pass an accurate z scaling to hmm for the algorithm to work well, then that's a good reason for it to be the way it is.

DEF7 commented 10 months ago

A grayscale heightmap image basically maps Z from zero to one. However, when outputting the resulting heightmap mesh the XY coords are in pixel coordinates of the heightmap. Hence, a zscale of 1 means that the grayscale heightmap will result in a mesh that can only be as tall as the width of one pixel (because zero-to-one is the width of a pixel on the X and Y axes).

zscale lets you specify how many pixel widths tall that the resulting mesh should be.