Skip to content

Black Spots on surface singularities #2452

@SalekDev

Description

@SalekDev

Bug

I found this bug when creating single colored Disk3D objects. Despite constructing it with some arbitrary color with default parameters the disk appears completely black:

dsk1 = Disk3D(v_range=[PI, 1.5 * PI], radius=bevel, color=GREY)
Image

The shader being used is the default for an arbitrary Surface object.
shaders/surface/vert.glsl:

#version 330

in vec3 point;
in vec3 d_normal_point;
in vec4 rgba;

out vec4 v_color;

#INSERT emit_gl_Position.glsl
#INSERT get_unit_normal.glsl
#INSERT finalize_color.glsl

const float EPSILON = 1e-10;

void main(){
    emit_gl_Position(point);
    vec3 unit_normal = normalize(d_normal_point - point);
    v_color = finalize_color(rgba, point, unit_normal);
}

This issue is similar to #2324 because I figured that when one increases the uv resolution from the default of (2,100) for disks to, say, (10,100) the black spot concentrates near the center where normalize(d_normal_point - point) fails. Using a higher u resolution with the following check confirms this:

void main(){
    emit_gl_Position(point);
    vec3 unit_normal = d_normal_point - point;
    float len = length(unit_normal);
    if (len == 0) {
        v_color = vec4(0,0,0,1);
        return;
    } else {
        unit_normal = normalize(d_normal_point - point);
    }
    v_color = finalize_color(rgba, point, unit_normal);
}
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions