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. No made up situations, real renderings, real student pain is shown. The description of bugs is kept to a bare minimum, these images speak for themselves.

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:

Specular map

Frequent bug, anything elevated to the zero power equals to one:

Texturing

This one needs a circular permutation of barycentric coordinates in the uv-interpolation:

The texture needs to be vertically flipped:

While visually ressembling to the above one, this one is completely different (why?). Here the student used xy pixel coordinates (instead of uv) to fetch a color from the texture :

Lighting

Light direction (instead of view direction) was used for backface culling. Prior and after bugfix.

Broken normal map reading, before and after. [0,255]^3 RGB were brought to XYZ living in [0,2]^3 and not [-1,1]^3.

Clone this wiki locally