Skip to content

Trajectory renderer: fixed in errorneous modulo calculation in shader

Christoph Fischer requested to merge devel_issue_288 into master

Closes #288 (closed) Closes #289 (closed)

Some tube segments were incomplete when computing trajectories, see the images in the issues. The cause of the issues seem to be some weird behavior when calculating mod on integers in GLSL shaders. The introduced intMod function computes the modulo properly based on integers. While typically mod should be able to handle this as well, when the second argument is an uniform input, unexpected results are returned. Probably uniforms are handled separately, causing the compiler to somehow link the mod call to mod(float,float) or something similar.

uniform int numObsPerTrajectory;

if (numObsPerTrajectory == 37)  --> resolves to True

if (mod(37, numObsPerTrajectory) == 0) --> resolves to False
if (mod(numObsPerTrajectory, 37) == 0) --> resolves to True
Edited by Christoph Fischer

Merge request reports