Skip to content

Commit

Permalink
Add Blender tut
Browse files Browse the repository at this point in the history
  • Loading branch information
joa-quim committed Aug 23, 2024
1 parent 817553b commit e6f64b4
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 2 deletions.
6 changes: 4 additions & 2 deletions documentation/utilities/gmtread.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ the chance of letting the data type be guessed via the file extension. Known ext

- Grids: .grd, .jp2 .nc
- Images: .jpg, .jp2 .png, .tif, .tiff, .bmp, .webp
- Datasets: .dat, .txt, .csv
- Datasets: .shp, .kml, .json, .geojson, .gmt, .gpkg, .gpx, .gml (or *.zip.ext)
- Datasets: .dat, .txt, .csv, .isf
- Datasets: .arrow .arrows .shp .kml .kmz .json .gmt .feather .fgb .gpkg .geojson .gpx .gml .ipc .parquet .sqlite (or *.ext.zip)
- CPT: .cpt
- PostScript: .ps, .eps

Expand Down Expand Up @@ -43,6 +43,8 @@ Specify data type (with *type*=true, e.g. `img=true`). Choose among:
(the one with `gdal`) uses GDAL to read the cube and outputs and 3D array in row major order.
Remember that the ``layout`` member of the GMTgrid type informs about memory layout.

- `inrows`: Select specific data rows to be read. Valid args include ranges or a string with an hard core GMT -q option.

- `stride`: When reading table data via GMT (but not GDAL), this option allows subsampling the data.
Provide a number to be used as stride for the rows. A `stride=2` will read every other row.

Expand Down
11 changes: 11 additions & 0 deletions tutorials.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@
~~~</a>~~~
@@

@@box
~~~<a class="boxlink" href="blender_shading/blender_rt/">~~~
@@title Raytrace shading@@
@@box-content
~~~
<img src="/tutorials/blender_shading/tilelogo.jpg">
~~~
@@
~~~</a>~~~
@@

@@box
~~~<a class="boxlink" href="mosaics/mosaics/">~~~
@@title Images mosaic@@
Expand Down
3 changes: 3 additions & 0 deletions tutorials/blender_shading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Shading with Blender

{{list_folder_with_images blender_shading}}
66 changes: 66 additions & 0 deletions tutorials/blender_shading/blender_rt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Shading with Blender

This tutorial shows how we can create stunning shaded relief images using the Blender ray tracer to solve
the hard jobb of computing illumination with realist shadows of a DEM surface. The tutorial linked bellow
takes some time to follow and the time needed to compute the raytraced image is on the order of minutes.
However, as the author says at the end, once we have it set for one case it is easy and fast to adapt it
to other cases. In a posterior improvement of this tutorial we will show how to modify needed parameters
of the _.blend_ file that is run by Blender to create the raytraced image.


\begin{examplefig}{}
```julia
using GMT

# Extract a region of West Ibaria from the 15 arc sec grids stored in the GMT server
Gwib = grdcut("@earth_relief_15s", region=(-10.5, -5, 35, 44));

# Create a tint image from the Gwib grid
I = grdimage(Gwib, C=:earth, img_out=true);
viz(I, coast=true)
```
\end{examplefig}

Load the previously created raytrace image computed with Blender following the tutorial
[Creating Shaded Relief in Blender](https://somethingaboutmaps.wordpress.com/2017/11/16/creating-shaded-relief-in-blender/)
But note that the first part of that tutorial where it explains how to cretae the UInt16 _heightmap_ can be replaced by
this simple command:

\begin{examplefig}{}
```julia
using GMT

gdalwrite("Gwib.tiff", rescale(Gwib, type=UInt16))
```
\end{examplefig}

Load the gray scale image and show it:

\begin{examplefig}{}
```julia
using GMT

Iblend = gmtread("https://oceania.generic-mapping-tools.org/cache/wiberia_shade_blender.png");
viz(Iblend, coast=true)
```
\end{examplefig}

Now apply the techniques explained in this tutorial [Adding Shaded Relief in Photoshop](https://somethingaboutmaps.wordpress.com/2014/10/26/adding-shaded-relief-in-photoshop/)
to blend the tint, the shades and illumination


\begin{examplefig}{}
```julia
using GMT

I = grdimage(Gwib, C=:earth, img_out=true); # Hide
Iblend = gmtread("https://oceania.generic-mapping-tools.org/cache/wiberia_shade_blender.png"); # Hide
# Blend the tint and the shades (darken)
Iburn = blendimg!(I, Iblend, mode="LinearBurn", new=true);

# Apply illunination to the previous image
Ib = blendimg!(Iburn, Iblend, mode="Screen", new=true);

viz(Ib, coast=true)
```
\end{examplefig}
Binary file added tutorials/blender_shading/tilelogo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e6f64b4

Please sign in to comment.