Black Spots on surface singularities
- Lingua principale
- Python
- Stelle
- 93.8k
- Fork
- 7.7k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
## 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)
```
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);
}
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend, computer-graphics
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 65/100