3b1b / 3b1b/manim

Black Spots on surface singularities

Đang mở
#2,452 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
93.8k
Fork
7.7k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

## 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:
```python
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`:
```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:

```glsl
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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

The bug is in the shader code for surface singularities, specifically in `shaders/surface/vert.glsl`. The issue occurs when `d_normal_point - point` has zero length, causing normalization to fail. Start by examining the `Disk3D` class and its normal calculation. Modify the shader to handle the zero-length case, as shown in the issue description. Test by creating a `Disk3D` with a single color and checking the rendered output.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend, computer-graphics
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
65/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.