landscape_modeling_example - ptabriz/geodesign_with_blender GitHub Wiki


my alt text


Landscape modeling with GIS data

Contents:

Required software and materials

  • Download and install latest version of Blender from here.
  • Download and install Blender GIS addon from here. Installation guide available here.
  • Download and unpack sample_data folder from here

I. Setting up the blender Scene

GUI

  • Run Blender and open the file "example_Landscape.blend".
  • Select the default Cube object in 3D viewport and delete it (right-click on the object > press delete > ok )
  • Set render engine to "Cycles". You can find it in the top header, the default is "Blender Render"
  • To increase the Lamp elevation and change the Lamp type to "Sun" for appropriate lighting:
    • Left click on the Lamp object in Ouliner (on the right side wih objects' list) to select it
    • Go to Properties editor > Object (the orange cube icon) > Transform section > in the Location matrix, change the Z value to 1000 (see below figure if needed)
  • To change lamp type to Sun and increase the emission:
    • In Properties editor > Lamp (two icons to the right of the Object icon) > expand the Lamp section > Change lamp type to Sun
    • Expand the Nodes section > Click on Use Nodes to enable modifying Sun parameters.
    • Set the Strength parameter to 6.00
Blender Viewport Changing the lamp elevation

Python editor

import bpy
# remove the cube
cube = bpy.data.objects["Cube"]
cube.select = True
bpy.ops.object.delete()

# change lamp type and elevation
import bpy
lamp = bpy.data.lamps["Lamp"]
lamp.type = "SUN"
lampObj = bpy.data.objects["Lamp"]
lampObj.location[2] = 1000

# Setup node editor for lamp and increase the lamp power
lamp.use_nodes = True
lamp.node_tree.nodes["Emission"].inputs[1].default_value = 6

# Set render engine to cycles
bpy.context.scene.render.engine = 'CYCLES'

a. Georeferencing setup

  • Download the BlenderGIS addon
  • Go to fileuser preferences ( Alt + Ctrl + U ) ‣ Add-onsInstall from File (bottom of the window)
  • Browse and select "BlenderGIS-master.zip" file
  • You should be able to see the addon 3Dview: BlenderGIS added to the list. If not, type "gis" in the search bar while making sure that in the Categories panel All is selected. In the search results you should be able to see 3Dview: BlenderGIS. Select to load the addon.
  • From the bottom of the preferences window click Save User Settings so the addon is saved and autmatically loaded each time you open blender

Adding a new predefined coordinate reference system (CRS)

Before setting up the coordinate reference system of the Blender scene and configuring the scene projection, you should know the Coordinate Reference System (CRS) and the Spatial Reference Identifier (SRID) of your project. You can get the SRID from http://epsg.io/ or spatial reference website using your CRS. The example datasets in this exercise uses a NAD83(HARN)/North Carolina CRS (SSRID EPSG: 3358)

  • In BlenderGIS add-on panel (in preferences windows), select to expand the 3D View > BlenderGIS
  • In the preferences panel find Spatial Reference Systems and click on the + Add button
  • In the add window put "3358" for definition and "NAD83(HARN)/North Carolina" for Description. Then select Save to addon preferences
  • Select OK and close the User Preferences window
Blender Viewport Installing addon and setting up Coordinate System

Learn more about Georefencing management in Blender

b. Adjusting viewport display parameters

Blender's default settings are set to optimize viewport rendering performance and thus transparency parameters are set to minimum. Thus, Before modeling the vegetation we adjust the Blender setting to ensure that the alpha maps are properly displayed on screen.

  • In the Blender User Preferences (Alt + Ctrl + U)> System :
    • In General section > adjust DPI to increase/decrease icon size based on your preferences and monitor resolution.
    • In OpenGLsection > deactivate Mipmaps , GPU Mipmap Generation, and 16Bit Float Textures.
    • Set Selection to Automatic.
    • Set Anistropic filtering to Off.
    • Set Window Draw Method to Automatic and No MultiSample.
    • Deactivate Text Anti-aliasing.
    • In Texture section set Texture limit size to Off.
    • Set Images Draw Method to GLSL.
  • Click on Save User Settings on the bottom left corner of user preferences.

II. Modeling the terrain


my alt text     my alt text Terrain object before (left) and after the material assignment


a. Importing the terrain surface

In this example, we use BlenderGIS import function to import a terrain model with a geotiff format (.tif) and NAD1983 projection.

GUI

  • Go to file > import > Georeferenced Raster
  • On the bottom left side of the window find Mode and select As DEM
  • Set subdivision to Subsurf and select NAD83(HARN) for georeferencing.
  • Browse to the Sample data folder and select 'terrain.tif'.
  • Click on Import georaster on the top right header.
  • If all the steps are followed correctly, you should be able to see the terrain in 3D view window.

b. Shading the terrain object

We create a simple Terrain material using a Diffuse BSDF shader with a grass image texture.

  • Change viewport display mode to Material.
  • Go to Properties tab > Material > press + New button to create a new Material. Rename the Material to Grass.
  • To create the diffuse Shader:
    • In the Surface panel notice that the Diffuse BSDF shader is selected by defaults as the surface shader.
    • Click on the radio button in front of the Color parameter to open a drop-down. From the second column, select Image Texture.
    • Click on Open and navigate to the folder sample_data/textures/ > Select grass.jpg.

my alt text     my alt text Grass material shown in properties editor (left) and node editor (right)



III. Modeling the water feature


my alt text Low sample Viewport rendering of the water surface


a. Importing the water raster

For modeling water feature, We import a geotiff raster of a shallow pond created in and exported from Grass GIS.

  • Repeat the raster import procedure described in 1.1 to import the water surface using water.tif.
  • Select the Water object.
  • Move the object 6 meters in minus Z direction to so that the object fits the depression.

b. Shading the water object

For shading the water object, we use a more complex material that is composed of several shaders to mimic the color, reflection, wave and ripple characteristics of the actual water surface. This time we use the Node editor to create the material.

  • Go to Properties tab > Material > press + New button to create a new Material. Rename the Material to Water.
  • In the Node editor, bottom header use Add menu to add the following nodes:
    • Add > Shader > Transparent BSFD to create the surface transparency.
    • Add > Shader > Glossy BSDF to create the surface reflection. Set the Roughness to 0.05 Select a pale blue for the color to represent the water color.
    • Add > Texture > Wave BSDF to create the waves. Set Scale to 100 and distortion to 0
    • Add > Texture > Noise BSDF to create the ripple. Set Scale to 300 and distortion to 4.50
    • Add > Convertor > Math to exaggerate the wave effect. Select Multiply with value of 5.
    • Add > Convertor > Math to exaggerate the ripple effect . Select Multiply with value of 2.
    • Add > Shader > Mix to combine the surface properties (glossiness and transparency). Set the Fac to 0.55
    • Add > Color > MixRGB to combine the displacement properties (wave and ripple). Set the Fac to 0.5
  • Now arrange and link the editors to acquire a node network similar to that of the figure below.
  • Navigate the 3D viewport to a location close to the water and change the viewport shading mode to Render to see how the water is rendered (it should look similar to the figure below).
  • Save the file.


my alt text
Node network of Water material



IV. Modeling vegetation patches

I this step, we distribute 3 types of species on the terrain, namely, American Linden, Weeping Willow, and Staghorn (shrubs). We use Xfrog tree models that are models are included in the sample_data folder as separate directories consisting of an object file (.obj), a material file (.mtl), and textures for barks and leaves. The distribution pattern (or the location of patches) of each specie is derived from GIS as a texture map (.png). Using these data we model vegetation in the following two steps.

  • Importing and shading a single model of each specie.

  • Spreading the species on the terrain based on the distribution textures.

    • Linden tree object is /sample_data/EA19_American_Linden/EA15.obj and the corresponding pattern is /sample_data/patch_class1.png
    • Willow tree object is /sample_data/BL15_Weeping_Willow/BL15.obj and the corresponding pattern is /sample_data/patch_class2.png
    • Staghorn shrubs object is /sample_data/SH06_Spindle/SH06_3.obj and the corresponding pattern is /sample_data/patch_class3.png


my alt text Distribution textures (top) and corresponding species (bottom). From left to right American Linden, Weeping Willow, and Staghorn.


a. Importing the vegetation models

  • Open Blender and delete the default cube object.
  • Change the render engine to Cycles Render.
  • From File > import > select Wavefront(.obj) > browse to sample_data/EA19_American_Linden folder and select EA19m.obj > press enter. The tree object should appear in the 3D view.
  • You can see that the tree object is 90 degrees rotated. To rotate it back into the vertical position:
    • Right-click on the object to select and activate it.
    • Go to Properties editor > Object (the cube icon) > in the Transform panel Rotation section, set X parameter to 0 .

b. Shading the vegetation models

Notice that while the leaves have material assigned to them but they are shown as rectangular surfaces with a black silhouette. To show the leaves properly we create a Mix Shader composed of a Transparent BSDF and a Diffuse BSDF. In this way we assign the transparent Black areas in the leaf image as transparent leaving the actual leaves as opaque. This technique is called Alpha mapping which is a computationally cheap way to create realistic trees without modeling the complex leaf geometry. The animation below shows how to create the material in Properties editor.


    Tree leaves before (left) and after (right) alpha mapping


  • Change viewport display mode to Material.
  • Go to Properties tab > Material and select Leaf.
  • Click on the X button to vacate the material slot. Note: If you click on - button you will lose the material slot that has been assigned to leaf objects.
  • Press + New button to create a new Material. Rename the Material to Leaf.
  • To create the Mix Shader:
    • From the Surface panel, Surface drop down select Mix Shader
    • Click on the radio button in the Fac parameter to open a drop-down. From the second column, select Image Texture.
    • Click on Open and navigate to the folder sample_data/EA19_American_Linden > Select EA19lef.tif .
  • To create the Transparent Shader:
    • From the Second Shader drop down select Transparent BSDF
  • To create the Diffuse Shader:
    • From the first Shader drop down select Diffuse BSDF.
    • Click on the radio button in the Color parameter to open a drop-down. From the second column, select Image Texture.
    • Click on Open and navigate to the folder sample_data/EA19_American_Linden > Select EA10lef.tif .
  • To adjust the alpha display parameters:
    • Go to Settings section and decrease the Alpha parameter in Viewport Color to 0.00.
  • Select Viewport Shading to Render to see the tree object rendered.
  • Assign one of the viewports to Node Editor to explore the material node structure.
  • Repeat the steps a and b to import and prepare Willow and Staghorn models.
  • Save the Blender file and name it tree.Blend



Alpha mapping procedure



my alt text
Node editor view of the tree material


c. Populating trees with particle systems

In this step, we use Particle Systems Modifier to populate trees on the terrain. We use texture files that are exported from Grass GIS to delineate the location of different vegetation species class. First, we bring in the trees we created in the previous step to our landscape Blender file. To do so we append the trees to a separate layer.

Appending the trees to the blender scene

  • Open landscape_example.blend
  • From 3D view bottom header Layer selector "alt text"> select the second slot located on the right side of the active layer. If you have a full keyboard, you can also toggle between layers using keyboard numbers.
  • Go to File > Append > browse and find EA_19.blend > go to Objects folder and select EA19m. The tree should be now appended and visible in the scene and outliner.
  • Now go back to layer 1 (using bottom header or keyboard number 1) and select the terrain object.

Creating a particle setting for one specie

  • Select Wireframe viewport shading mode.
  • Go to Properties editor > Modifiers tab > Add modifier > Particle_system.
  • Type Class1 in front of the Settings parameter to change the setting name.
  • Click on the far left icon in front of the Modifier to expand and view the settings.
  • Adjust the following particle settings parameters:
    • Emission section:
      • Set Emission number to 450. This is the total number of particles that will be populated on the terrain object.
      • Uncheck Even distribution.
    • Rotation section:
      • Activate Rotation.
      • Set Initial Rotation to ObjectY
    • Physics section:
      • Select the None option
    • Render section:
      • Activate the Object option.
      • Select EA19m for the Dupli Object parameter.
      • Set the Size to 1.20 and the Random Size to 0.20.
    • Textures section:
      • Press on the + button to make a new texture.
      • Rename the texture to Texture1.
      • Press the button to adjust the texture parameters in Textures tab.
  • Now you are automatically routed to the Texture tab.
    • In the image section:

      • Click on Open and browse to select sample_data/patch_class1.png . You should be able to see the Trees planted according to the texture pattern.



      Particle modifier settings (left) and particle texture settings (right)



      my alt text
      Plan view of the Linden trees distributed based on the texture


d. Replicating particle settings

Instead of making new particle systems for each specie or texture, we can create a copy of an existing particle settings and just switch the emission object and texture.

  • To make a copy of the particle system from the Linden tree for the Willows:
    • Select terrain object.
    • Add a new particle system
    • Click on the dropdown menu in front of the Settings and select Class1.
    • You will see that a new icon with number 2 appears, indicating that currently two particle systems are using this settings. Click on 2 to make it a unique setting and name it Class2.
  • To replace the texture image:
    • Now go to the textures settings and replace the texture image with patch_class2.png found in the sample_data folder
  • To replace the tree with the shrub:
    • Go to Render section > replace the object with BL_15
  • Change the Emission number to 1000 so that the shrubs are distributed more densely.
  • Clone another particle system to populate the Staghorn shrubs. Use patch_class3.png for the texture and SH06_3 as the emission object. Set the emission number to 300.


my alt text
Plan view of the Linden trees distributed based on the texture



my alt text



my alt text
Viewport rendering of select perspectives views with 32 light sample/s


⚠️ **GitHub.com Fallback** ⚠️