Renaming and reordering variables
Fixing bug that was because the webgl texture sampler uses inverted y-axis
Refactoring
Refactoring and deleting unused code