Using Blender to create Heightmap from a 3D model

Post Reply
g19fanatic
Posts: 5
Joined: Thu May 07, 2015 12:14 pm

Using Blender to create Heightmap from a 3D model

Post by g19fanatic » Thu May 07, 2015 6:33 pm

I've been interested in a 3D CAM workflow for quite some time. I believe I've found my work-chain and I'd like to share it with others.

It goes like this:
  • Create Model (Blender)
    Create Heightmap (Blender, this is what I'm going to go over in this post)
    Create GCode (dmap2gcode from scorchworks)
    Execute GCode (UGS -> grbl)
While reading through Blender's Manual, I stumbled across its "Compositor" "Nodes" and all of the crazy things you can do with Blender. One of those pages, Input Nodes -> Render Layer Node, showed something I was looking for. A way to generate a heightmap from a 3D model without having to do the gradients or painting myself. This led to many searches and finally this stackexchange page that gave me an answer.

Between these two pages, I put together a blender file that will allow me to drop in a model (.stl's are easily imported into blender from any other CAD program) and return a greyscale heightmap. I no longer need to paint some gray-scale gradients to get what I'm looking for. Just model it like I do everything else.
Attachments
3D_CAM.zip
(108.93 KiB) Downloaded 104 times
Last edited by g19fanatic on Thu May 07, 2015 7:58 pm, edited 1 time in total.

Brian Stone
Posts: 295
Joined: Tue Oct 21, 2014 1:52 am
Location: Seattle, WA

Re: Using Blender to create Heightmap from a 3D model

Post by Brian Stone » Thu May 07, 2015 7:11 pm

There's no need to generate a heightmap from mesh data if you already have the mesh. Just save the model as an STL file, if it's not already, then build the toolpaths with any number of CAM programs. Or, with BlenderCAM, you can generate simple toolpaths inside Blender itself.
Shapeoko 2 #7353
1500x1000mm Shapeoko/X-Carve Hybrid, Nema-23's, Belt-Driven Z-Axis /w ACME Screw, Dewalt 611, Soundproof Enclosure
[Fusion 360 | Illustrator] -> Universal G-Code Sender

g19fanatic
Posts: 5
Joined: Thu May 07, 2015 12:14 pm

Re: Using Blender to create Heightmap from a 3D model

Post by g19fanatic » Thu May 07, 2015 7:35 pm

Brian Stone wrote:There's no need to generate a heightmap from mesh data if you already have the mesh. Just save the model as an STL file, if it's not already, then build the toolpaths with any number of CAM programs.
Could you point me to some open source/free CAM tools that will do 3D cam from a .stl file?
My understanding was that most 3D cam was done with heightmaps. A .stl isn't a heightmap.

Hans
Posts: 290
Joined: Tue Dec 25, 2012 5:19 am
Location: Connecticut, USA

Re: Using Blender to create Heightmap from a 3D model

Post by Hans » Thu May 07, 2015 7:40 pm

This sounds pretty cool. One thing that's helpful about converting to grayscale is that you can recreate it as a thin relief easily, whereas just creating toolpaths over a 3D model can only make the model in its original height. I think the biggest benefit would be post-processing in something like Photoshop to run some sort of HDR filter. Say you have a model of a bunch of grapes, and you're milling a .2" deep bas-relief of it. The difference in height from one grape to the next will be so slight, it'll be hard to get any sense of depth and roundness on the grapes. Hopefully there's some sort of filter that would make the individual grapes have greater depth range when milled.
Shapeoko #1,123

g19fanatic
Posts: 5
Joined: Thu May 07, 2015 12:14 pm

Re: Using Blender to create Heightmap from a 3D model

Post by g19fanatic » Thu May 07, 2015 8:06 pm

Hans wrote:Hopefully there's some sort of filter that would make the individual grapes have greater depth range when milled.
Though I've been an avid Blender Modeler for quite some time, I'm just learning Blender's Node system and how to better utlize it for my needs.
There are a ton of different Node Types available with many different capabilities.

This is just scratching the surface...

Brian Stone
Posts: 295
Joined: Tue Oct 21, 2014 1:52 am
Location: Seattle, WA

Re: Using Blender to create Heightmap from a 3D model

Post by Brian Stone » Thu May 07, 2015 8:13 pm

g19fanatic wrote: Could you point me to some open source/free CAM tools that will do 3D cam from a .stl file?
My understanding was that most 3D cam was done with heightmaps. A .stl isn't a heightmap.
To be technically correct, you're describing 2.5D milling not 3D. 3D CAM can't be done with a heightmap, because a heightmap only represents displacement perpendicular to one plane. The Shapeoko is only capable of 2.5D milling. But, yes, it's very common to use heightmaps to generate 2.5D toolpaths. It's also common to use vector graphics (SVG) and mesh data.

BlenderCAM is free and it does work well enough to generate parallel and contour toolpaths for triangle meshes. It's also still a work in progress, so don't expect it to do everything you want. I've used it to do some test engravings in styrofoam with good results, but haven't tried it for a "real" job yet. Take a look at the BlenderCAM gallery to get an idea of what it's capable of with a little practice and effort.

I've heard good things about FreeMill, but haven't tried it myself. It's capable of reading STL files. There are many other options out there. Check out the wiki's CAM Software page for a list.

I'm going to back off a bit from my previous sentiment... I don't really want to turn you away from the idea of converting a 3D mesh to a heightmap, because it does have merit. I can think of a couple of reasons why one would want to do this. For instance, a heightmap is easily modified and blended with other heightmaps to create compound surfaces that would otherwise be difficult to generate in Blender or another 3D modeling program. Heightmaps can also be "locally scaled", meaning that dimming selected pixels produces a scale transform just in that area without affecting the rest of the model, which is an operation that can sometimes be difficult to perform in modeling programs.
Shapeoko 2 #7353
1500x1000mm Shapeoko/X-Carve Hybrid, Nema-23's, Belt-Driven Z-Axis /w ACME Screw, Dewalt 611, Soundproof Enclosure
[Fusion 360 | Illustrator] -> Universal G-Code Sender

Hans
Posts: 290
Joined: Tue Dec 25, 2012 5:19 am
Location: Connecticut, USA

Re: Using Blender to create Heightmap from a 3D model

Post by Hans » Thu May 07, 2015 8:58 pm

Brian Stone wrote:To be technically correct, you're describing 2.5D milling not 3D. 3D CAM can't be done with a heightmap, because a heightmap only represents displacement perpendicular to one plane.
For the record, 2.5D milling just means that the machine can't perform ramp or arc moves involving the Z axis. It doesn't mean that there are overhangs, etc. The Shapeoko does 3D milling just fine, albeit with really slow Z acceleration on the S1 and S2. I use MasterCAM to generate 3D toolpaths based on heightmaps, no problem.
Shapeoko #1,123

Brian Stone
Posts: 295
Joined: Tue Oct 21, 2014 1:52 am
Location: Seattle, WA

Re: Using Blender to create Heightmap from a 3D model

Post by Brian Stone » Thu May 07, 2015 9:25 pm

Hans wrote:
Brian Stone wrote:To be technically correct, you're describing 2.5D milling not 3D. 3D CAM can't be done with a heightmap, because a heightmap only represents displacement perpendicular to one plane.
For the record, 2.5D milling just means that the machine can't perform ramp or arc moves involving the Z axis.
That's 2D milling. 2.5D milling can, indeed, involve ramps and variable Z-axis control. Think of 2.5D milling as a contour map or a height map.

2D Milling: Toolpath control of the Z-axis is limited to a static height on a 2D plane. Every X and Y-axis coordinate have the same Z-axis coordinate. (Example: A circle.)

2.5D Milling: Toolpath control of the Z-axis is variable but limited to 2D functional control only, relative to the XY plane. There is exactly one Z-axis coordinate for every X and Y axis coordinate. (Example: A hemisphere.)

3D Milling: Toolpath control of the Z-axis is unlimited and has as much freedom as the X and Y axis control. EVery X and Y-axis coordinate may have more than one Z-axis coordinate. (Example: A full sphere.)


And on that note, I think this underscores the silliness of even defining these different types of milling. It causes confusion, and doesn't really solve a problem. No one needs to know that a milling operation is 2.5D or 3D or 2D or whatever to generate a practical tool path for a particular machine. All you need to know is how many degrees of freedom the machine has, and what axes do you have to work with, and you can build a set of setup operations and toolpaths for that machine for regardless of how many dimensions the part has.
Shapeoko 2 #7353
1500x1000mm Shapeoko/X-Carve Hybrid, Nema-23's, Belt-Driven Z-Axis /w ACME Screw, Dewalt 611, Soundproof Enclosure
[Fusion 360 | Illustrator] -> Universal G-Code Sender

g19fanatic
Posts: 5
Joined: Thu May 07, 2015 12:14 pm

Re: Using Blender to create Heightmap from a 3D model

Post by g19fanatic » Sat May 09, 2015 2:16 pm

Brian Stone wrote: That's 2D milling. 2.5D milling can, indeed, involve ramps and variable Z-axis control. Think of 2.5D milling as a contour map or a height map.

2D Milling: Toolpath control of the Z-axis is limited to a static height on a 2D plane. Every X and Y-axis coordinate have the same Z-axis coordinate. (Example: A circle.)

2.5D Milling: Toolpath control of the Z-axis is variable but limited to 2D functional control only, relative to the XY plane. There is exactly one Z-axis coordinate for every X and Y axis coordinate. (Example: A hemisphere.)

3D Milling: Toolpath control of the Z-axis is unlimited and has as much freedom as the X and Y axis control. EVery X and Y-axis coordinate may have more than one Z-axis coordinate. (Example: A full sphere.)
You see I've always understood 2D milling to be essentially stencil cutting, 2.5D Milling to be flat cuts at different heights (one z height per plane) and 3D cutting to be contours and the such.

Being able to cut a full sphere requires more axes of rotation but isn't 2.5D cutting, its still 3D cutting just within a specific scope of what you're machine is able to do. The hemisphere that most CNC routers will be able to cut is a 3 dimension object hence 3D milling.

Being able to mill a hemisphere is 3D milling. Most machines are limited to 3 axes which means they aren't able to fully cut a sphere without additional work (keying the cut and flipping it to do the other side) but most standard 3 axes machines can cut 3D.

Regardless if this talk is silly or not, most (lay)people will still refer to 2D,2.D,or 3D 'vocabulary' versus the number of axes and setup of the CNC machine.

cvoinescu
Posts: 4442
Joined: Thu Jul 19, 2012 6:50 pm
Location: Camberley, UK
Contact:

Re: Using Blender to create Heightmap from a 3D model

Post by cvoinescu » Sat May 09, 2015 2:32 pm

With g19fanatic on this one.

On a 3-axis milling machine, doing all the milling with the workpiece in one position (no turning to mill the back or the sides), if you can model the cut with a single 2D file it's 2D milling; if you need a number of 2D files, each one for a given Z height, it's 2.5D milling; and if you need a 3D model, it's 3D milling. It says nothing about the ability to do overhangs/undercuts, nor about machining the back of the piece.
Proud owner of ShapeOko #709, eShapeOko #0, and of store.amberspyglass.co.uk

Post Reply