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:
- Generate a SOLIDWORKS solid body and save it as STL file
- Import the STL file into Blender
- Adjust the location of the 3D model in the Blender
- Adjust the orientation and location of the camera
- Generate grayscale heightmap using the node editor
- 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.
Image 1. A SOLIDWORKS body
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
Image 3. Process for import STL file into Blender
Adjusting the location of the 3D model in the Blender
- Right-click the 3D model and press Shift+Ctrl+Alt+C key to show the coordinates of the polyhedron’s geometric center
- Left-click the graphics area and press N key to open Transform window
- Move the geometric center of the model to the origin by adjusting Rotation and Location as shown in the following image
Image 4. The settings for relocated model
Relocate and setup the camera
- 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)
- Press 0 key to obtain the field of view of the camera (step 3)
- Click the Data tab and choose Orthographic for the lens and adjust the value for Orthographic Scale (step 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.
Image 5. Process to setup the camera
Generate a grayscale heightmap using Node Editor
- Expand the bottom window and change the editor type to Node Editor
- Click the Composing and enable the Use Nodes
- Add Normalized node and Invert color node and link them
- Expand the Color Management in the Scence and change Display Device from sRGB to None
- Press F12 key, then the heightmap of mesh model will be generated as shown in Image 7.
Image 6. Node editor setting
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: