Section Analysis / Profile Cutout – from the bottom up

Animatable 3D shader to render a mesh from the bottom up like a 3D printer.

Good as a basic start, I recommend to change it for your specific use.

Shader parameters:

  • Y Cutoff – the topmost global Y position to render pixels at.
  • Cap Color – the color of the generated top face.

 

*Made with AI help*, tested in Godot 4.7, completely free for any kind of use.

Shader code
shader_type spatial;
render_mode cull_disabled;

uniform float y_cutoff = 0.0;
uniform vec3 cap_color : source_color = vec3(0.0, 1.0, 0.0);

varying float world_y;

void vertex() {
    world_y = (MODEL_MATRIX * vec4(VERTEX, 1.0)).y;
}

void fragment() {
    if (world_y > y_cutoff) {
        discard;
    }

    if (!FRONT_FACING) {
        ALBEDO = vec3(0.0);
        EMISSION = cap_color;
    } else {
        ALBEDO = vec3(1.0);
    }
}
Live Preview
Tags
3d printing, artistic, cut, CUTOFF, cutout, profile, section, section analysis
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

guest

0 Comments
Oldest
Newest Most Voted