How the base_thickness Parameter Affects 3D Model Structure in mcp_3d_relief

The base_thickness parameter controls the vertical depth of the solid base plate and side walls in generated STL files, positioning the relief geometry above the XY-plane by the specified amount while creating the foundation geometry at negative Z-coordinates.

The mcp_3d_relief repository by bigchx converts 2D images into 3D printable relief models through a depth-map-based mesh generation pipeline. Understanding how this specific parameter influences the final mesh geometry is essential for optimizing print stability, material usage, and overall object height.

Geometry Generation Pipeline

When processing an image, the system first converts it into a grayscale depth map representing surface heights. The generate_stl() function in relief.py then constructs the mesh through three distinct geometric operations that utilize the base_thickness value to define the model's foundation.

Vertex Height Calculation

The relief surface heights are calculated independently of the base thickness, using the model_thickness parameter to scale the depth map values:

vertices[y, x] = (depth_map[y, x] / 255.0) * model_thickness

This operation, found at line 65 of relief.py, establishes the topographic variation of the relief itself. The resulting vertex heights determine the artistic surface features, but do not influence the model's position relative to the build plate.

Base Plate Construction

The bottom faces of the model are generated at a constant Z-coordinate of -base_thickness, creating the solid foundation beneath the relief:

write_facet(f, [x0, y0, -base_thickness], ...)

According to the source code in relief.py (lines 76-78 and 82-84), these triangular facets form the flat underside of the STL file. Because these coordinates are negative, the entire relief structure sits elevated above the XY-plane by exactly the base_thickness amount.

Side Wall Generation

Vertical walls are constructed along the four borders of the image, connecting the base plate to the relief edges. These walls extend from -base_thickness up to the height of the first row or column of vertices:

write_facet(f, [x0, y0, -base_thickness], ...)

The implementation in relief.py (lines 106-112, 117-123, 128-134, and 139-145) generates these facets to enclose the perimeter, ensuring a watertight mesh suitable for 3D printing.

Physical Impact on Final 3D Prints

Adjusting the base_thickness value produces three measurable effects on the printed object structure:

  • Increases overall model height: The total Z-height equals base_thickness plus the maximum relief height derived from model_thickness. Raising the base thickness value positions the entire relief further from the build plate.
  • Creates sturdier foundations: Thicker base plates provide structural support for large surface area reliefs or delicate topographic features, reducing warping and improving adhesion during printing.
  • Adds material volume: Larger values increase the solid material in the STL file, directly impacting print time and filament or resin consumption.

Configuration Interfaces

The parameter is exposed through both command-line and web API interfaces, forwarding the same value into the relief() function which calls generate_stl().

Command-Line Interface

The relief.py script accepts --base_thickness via argparse (lines 90-95), with a default value of 2.0 millimeters:


# Default 2.0 mm base

python relief.py input.jpg

# Thicker 5 mm foundation for large prints

python relief.py input.jpg --base_thickness 5.0

# Minimal 0.5 mm base for small, efficient prints

python relief.py input.jpg --base_thickness 0.5

FastAPI Endpoint

When using the web server defined in server.py, the parameter is accepted as a form field at lines 28-29:

@app.post("/convert")
...
    base_thickness: float = Form(2.0),

Example API usage with Python requests:

import requests

files = {'image_path': open('portrait.png', 'rb')}
data = {
    'model_width': 60,
    'model_thickness': 6,
    'base_thickness': 3.0,  # 3 mm solid foundation

    'detail_level': 1.2,
}
resp = requests.post('http://localhost:8000/convert', data=data, files=files)
print(resp.json())

Summary

  • The base_thickness parameter in mcp_3d_relief defines the Z-coordinate of the model's underside, set at -base_thickness in the generated STL mesh.
  • It affects the foundation depth and side walls only, not the relative heights of the relief topography calculated from the depth map.
  • The implementation spans relief.py (core geometry generation at lines 65, 76-84, and 106-145) and server.py (API parameter handling at lines 28-29).
  • Default value is 2.0 millimeters, accessible via both CLI (--base_thickness) and FastAPI form fields.
  • Increasing the value improves print stability for large models but consumes more material and increases total print height.

Frequently Asked Questions

What is the default base_thickness value in mcp_3d_relief?

The default value is 2.0 millimeters. This is defined in the FastAPI endpoint at lines 28-29 of server.py and applies to both the web interface and CLI usage unless explicitly overridden.

How does base_thickness differ from model_thickness?

While base_thickness controls the solid foundation depth at negative Z-coordinates, model_thickness scales the grayscale depth map values to determine the relief's topographic variation. The model_thickness parameter affects the artistic height of surface features, whereas base_thickness affects the structural foundation and print bed offset.

Where exactly is base_thickness applied in the STL generation?

The parameter is used in relief.py within the generate_stl() function to set the Z-coordinate for bottom facets (lines 76-84) and anchor the vertical side walls (lines 106-145). Every bottom vertex uses -base_thickness as its Z-value, creating the solid plate beneath the relief geometry.

Can base_thickness be set to values below 1.0 mm?

Yes, the parameter accepts any float value. The examples in the source code demonstrate settings as low as 0.5 millimeters for minimal material usage, though extremely thin bases may compromise structural stability for large or complex relief models.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →