Change the rounded blade tip to a nicer bullet tip in the Style Editor

Today I created a nice adjustable bullet shaped blade tip for the Style Editor 3D render SDFs code using ChatGpt. Would be nice if we could get the current rounded tip updated with this one.

Screenshot 2025-06-18 at 16.47.46

Here is a reference code:

// Signed distance for capped cylinder
float sdCappedCylinder(vec3 p, float h, float r) {
    vec2 d = abs(vec2(length(p.xz), p.y)) - vec2(r, h);
    return min(max(d.x,d.y), 0.0) + length(max(d,0.0));
}

// Bullet tip with smooth quarter-ellipse profile
float radiusProfileSmooth(float y, float h, float rBase, float a, float b) {
    float t = clamp(y / h, 0.0, 1.0);

    float profile = pow(1.0 - pow(t, a), b);  // always convex if a,b ≥ 1
    return rBase * profile;
}

float sdBulletTip(vec3 p, float h, float rBase, float a, float b) {
    if (p.y < 0.0) return 1000.0;

    float y = clamp(p.y, 0.0, h);
    float r = radiusProfileSmooth(y, h, rBase, a, b);
    float q = length(p.xz);

    return q - r + max(0.0, y - h);
}

// Scene SDF combining cylinder + bullet tip on top
float map(vec3 p) {
    float cylH = 0.5;
    float cylR = 0.2;
    float tipH = 0.5;  // tip height

    float d1 = sdCappedCylinder(p, cylH, cylR);

    vec3 pt = p;
    pt.y -= cylH;

    float a = 2.5;  // tip taper steepness
    float b = 0.6;  // roundness near tip

    float d2 = sdBulletTip(pt, tipH, cylR, a, b);

    return min(d1, d2);
}

Adjust these numbers to change the shape of the tip:

float tipH = 0.5;  // tip height
float a = 2.5;  // tip taper steepness
float b = 0.6;  // roundness near tip

Nice!

I’ll have to measure how expensive this is. pow() can be kind of slow. If it’s expensive, we should only do this when the graflex model is on.

1 Like

Here is a simpler approach, it has a slightly less smooth connection to the blade cylinder though (you can see a shaded seam connection line if look from the distance):

Screenshot 2025-06-18 at 23.09.01

// Signed distance for capped cylinder
float sdCappedCylinder(vec3 p, float h, float r) {
    vec2 d = abs(vec2(length(p.xz), p.y)) - vec2(r, h);
    return min(max(d.x,d.y), 0.0) + length(max(d,0.0));
}

// Bullet tip with smooth quarter-ellipse profile
float sdBulletTip(vec3 p, float h, float rBase) {
    if (p.y < 0.0) return 1000.0;  // No shape below y=0
    float y = clamp(p.y, 0.0, h);
    float q = length(p.xz);
    float ny = y / h;
    float radius = rBase * sqrt(1.0 - ny*ny);
    return q - radius + max(0.0, y - h);
}

// Scene SDF combining cylinder + bullet tip on top
float map(vec3 p) {
    float cylH = 0.5;
    float cylR = 0.2;
    float bulletH = 0.45;
    float bulletR = cylR;

    float d_cyl = sdCappedCylinder(p, cylH, cylR);

    vec3 p_bullet = p;
    p_bullet.y -= cylH;

    float d_bullet = sdBulletTip(p_bullet, bulletH, bulletR);

    return min(d_cyl, d_bullet);
}

Esthetically, I like the first one better, but I think my one bullet-tipped blade looks more like the second one actually… :slight_smile: