diff --git a/sphericalenvmapping/sphericalenvmapping.cpp b/sphericalenvmapping/sphericalenvmapping.cpp index 373dcdfd..14dd9a34 100644 --- a/sphericalenvmapping/sphericalenvmapping.cpp +++ b/sphericalenvmapping/sphericalenvmapping.cpp @@ -450,17 +450,9 @@ public: #endif } - void changeMatCapIndex(uint32_t delta) + void changeMatCapIndex(int32_t delta) { - uboVS.texIndex += delta; - if (uboVS.texIndex < 0) - { - uboVS.texIndex = textures.matCapArray.layerCount-1; - } - if (uboVS.texIndex >= textures.matCapArray.layerCount) - { - uboVS.texIndex = 0; - } + uboVS.texIndex = (uboVS.texIndex + delta + textures.matCapArray.layerCount) % textures.matCapArray.layerCount; updateUniformBuffers(); }