Marlon Banta

How to Create Grayscale Heightmaps for 3D Textures

Blog Post created by Marlon Banta Employee on Nov 6, 2018

In a previous blog post I discussed the new 3D Textures functionality that was added to SOLIDWORKS 2019 ( see How to Use 3D Texture  in SOLIDWORKS ) . One thing that was discussed in that blog post was the fact that though you can use any type of image for 3D textures, what works best are greyscale heightmap images. With this in mind I wanted to share with you a post that was originally presented during the beta program for SOLIDWORKS 2019. This post explores one way that you can create greyscale heightmap images. Again thanks to my colleague Xiao Liu for his help producing this post and the video (https://youtu.be/z_jh_PrZzOs).

 

There are many software packages that can be utilized to generate grayscale heightmaps. Here we will use Blender, which is a free and open source 3D creation suite, to create grayscale heightmaps. An example will be described step-by-step to illustrate the generation process of a grayscle heightmap image.

 

Please note that this blog is not an advertisement for Blender and the DS SOLIDWORKS Co. doesn’t have any collaborations with Blender. However, I am very grateful to the Blender’s team for providing such a useful free tool. If you use Blender you may consider making a donation to Blender’s development fund.

 

The Outline for how to create the grayscale heightmaps:

 

  1. Generate a SOLIDWORKS solid body and save it as STL file
  2. Import the STL file into Blender
  3. Adjust the location of the 3D model in the Blender
  4. Adjust the orientation and location of the camera
  5. Generate grayscale heightmap using the node editor
  6. Generate a 3D model

 

 

Generate a 3D polyhedron model (Image 1) in SOLIDWORKS.

 

To have a proper orientation of the model after importing it into Blender, the bottom surface of the polyhedron should be located on the front plane in the SOLIDWORKS part file. Note that the 3D model needs to be saved as STL format or other formats which can be imported into Blender. Image 2 shows the resultant grayscale heightmap of this polyhedron.

 

Image1.png

Image 1. A SOLIDWORKS body

Image2.png

Image 2. A height map of of the SOLIDWORKS body

 

Importing the 3D model into Blender

 

Open Blender and follow the following steps:

File >> Import >> Stl(.stl) >> Change the directory to where the 3D body has been saved

Image3.png

Image 3. Process for import STL file into Blender

 

Adjusting the location of the 3D model in the Blender

 

  1. Right-click the 3D model and press Shift+Ctrl+Alt+C key to show the coordinates of the polyhedron’s geometric center
  2. Left-click the graphics area and press N key to open Transform window
  3. Move the geometric center of the model to the origin by adjusting Rotation and Location as shown in the following image

Image4.png

Image 4. The settings for relocated model

 

Relocate and setup the camera

 

  1. Left-click the camera in Outline and move the camera above the polyhedron model by changing the value of location and location (step 2 in the following image)
  2. Press 0 key to obtain the field of view of the camera (step 3)
  3. Click the Data tab and choose Orthographic for the lens and adjust the value for Orthographic Scale (step 4)
  4. Adjust the values in the Clipping to ensure the camera to capture the view of the entire model (step 5)

Note that with orthographic lens objects always appear at their actual size, regardless of distance. This means that parallel lines appear parallel and do not converge. For clipping interval, only objects within the limits are visible. Thus, users need to adjust the value of Clipping Start and End to have the entire model in the clipping interval.

5. Click the Render tab and Set the Resolution (The resolution of the final heightmap) as shown in step 6

Note that for the models with simple geometry appearance, the resolution of 512 x 512 pixels will be fine enough. For a model with many details, a heigher resolution setting is more suitable. However, a heigher resolution grayscale heightmap image will raise the computational cost of 3D texture generation.

Image5.png

Image 5. Process to setup the camera

 

Generate a grayscale heightmap using Node Editor

 

  1. Expand the bottom window and change the editor type to Node Editor
  2. Click the Composing and enable the Use Nodes
  3. Add Normalized node and Invert color node and link them
  4. Expand the Color Management in the Scence and change Display Device from sRGB to None
  5. Press F12 key, then the heightmap of mesh model will be generated as shown in Image 7.

Image6.png

Image 6. Node editor setting

Image7.png

Image 7. Height map for 3D model

 

 

Again, please watch the following video to see a demonstration of generating a grayschale heightmap for 3D Texture in SOLIDWORKS 2019:

 

 

https://youtu.be/z_jh_PrZzOs

 

Thank you,

-Xiao Liu

-Marlon Banta

Outcomes