Skip to content

Instantly share code, notes, and snippets.

@jaisonoh
Last active July 16, 2018 11:56
Show Gist options
  • Save jaisonoh/d0de23fb28694d801fe794ffd58a7f7b to your computer and use it in GitHub Desktop.
Save jaisonoh/d0de23fb28694d801fe794ffd58a7f7b to your computer and use it in GitHub Desktop.
simple gradient
#include "Debug"
void main() {
// Load a reference image
ref<Debug> debug;
std::vector<float4> _ref = debug->getRefimg(film);
// Calculate
float4* _refDxErr = new float4[xSize * ySize];
float4* _refDyErr = new float4[xSize * ySize];
for (int i = 0; i < xSize * ySize; ++i) {
int x = i % xSize;
int y = i / xSize;
_refDx[i].x = (x != xSize - 1) ? _ref[i + 1].x - _ref[i].x : 0.f;
_refDx[i].y = (x != xSize - 1) ? _ref[i + 1].y - _ref[i].y : 0.f;
_refDx[i].z = (x != xSize - 1) ? _ref[i + 1].z - _ref[i].z : 0.f;
_refDy[i].x = (y != ySize - 1) ? _ref[i + xSize].x - _ref[i].x : 0.f;
_refDy[i].y = (y != ySize - 1) ? _ref[i + xSize].y - _ref[i].y : 0.f;
_refDy[i].z = (y != ySize - 1) ? _ref[i + xSize].z - _ref[i].z : 0.f;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment