Skip to content

Visual troubleshooting

Dmitry V. Sokolov edited this page Feb 29, 2016 · 17 revisions

Permanently under construction

This page is not meant to be a FAQ section; instead I show here several examples of bugs me and my students were able to fix without looking into the source code, solely by observing things in the images.

Triangle rasterization: line sweeping

Frequent bug: while sorting by y-coordinate, the vertices are sorted, but the data coming with the vertices is not.

Gouraud shading, forgot to sort intensities

Z-buffer, forgot to sort z coordinates

Horizontal sort of two vertices splitting the triangle

Here are two examples of rounding errors creating holes in/between triangles:

Bad y interpolation while sweeping the line:

The vertices were not casted to int prior to filling:

Bad data parsing

Forgot to decrement indices of vertices (remember in wavefront obj indices are starting from 1, not 0)

Few broken reads of texture coordinates, notice that all the fan of triangles incident to a vertex is messy, thus the vertex is broken:

All "v", "vt" and "vn" lines are read in the same array, thus effectively killing any sense in the model. Very roundish shape of the rendering gives the idea about "vn" confused with "v". Prior to the bugfix and after:

Clone this wiki locally