Shading with Blender

Blender can produce stunning shaded illumination maps using ray-tracers. It knows nothing about projections but once we get the shade grayscale image we can use it in GMT. Here’s an example (not fully comprehensible, I know)

using GMT

Gib = grdcut("@earth_relief_15s", region="-15/4/34/45");
color = gdaldem(Gib, "color-relief"; color="earth");
Iblend = gmtread("iberia_rt_s15.png");                # ALMOST ALL WORK LIES HERE
Iburn = blendimg!(color, Iblend, mode="LinearBurn", new=true);
Ib = blendimg!(Iburn, Iblend, mode="Screen", new=true);
viz(Ib, proj=:guess, coast=1)

I have created this little tutorial that has some more informations to support the involved mechanics
https://www.generic-mapping-tools.org/GMTjl_doc/tutorials/blender_shading/blender_rt/

3 Likes

Bless the projection, a post about Blender!

I’m going to try this. I’ve used GMT to prepare tiff’s to do this in Blender, but not with Julia. Hope it’s Ok with some Q&A, even though it’s a showcase(?)

Just using GMT to prepare grids to import to Blender for further work is also interesting.

GMT can also just be used to prepare heightmaps for use in Blender.

Take your grid and use grdmath’s NORM function;

  • For UInt16:

    $ gmt grdmath dtm.tif NORM 2 16 POW MUL = heightmap.tif=gdal:GTIFF
    
  • For UInt32:

    $ gmt grdmath dtm.tif NORM 2 32 POW MUL = heightmap.tif=gdal:GTIFF
    

Why anyone would ever need UInt32, I don’t know (this gives 2^32 = 4.29E9 levels)
UInt16 (2^16 = 65535) is also a very high number, but Byte/Int8 (2^8 = 255) may be too low. If your terrains elevation difference is 1000’s of meters, it’ll not be enough levels. (Is byte the same as UInt8?)