From 6e4625d126d10488b6bfb0899410a1065c7a0181 Mon Sep 17 00:00:00 2001 From: Yangguang Date: Wed, 26 Apr 2017 14:47:37 -0700 Subject: [PATCH 1/7] change to multi-thread loading process --- VectorVisualization/3DLIC.cpp | 117 +++++++++++++--- VectorVisualization/3DLIC.h | 11 +- VectorVisualization/GLSLShader.cpp | 14 +- VectorVisualization/GLSLShader.h | 3 + VectorVisualization/VolumeBuffer.cpp | 7 +- VectorVisualization/VolumeBuffer.h | 3 + VectorVisualization/dataset.cpp | 128 +++++++++++------- VectorVisualization/dataset.h | 47 +++++-- VectorVisualization/renderer.cpp | 17 ++- VectorVisualization/renderer.h | 6 +- VectorVisualization/shader/inc_header.glsl | 2 + VectorVisualization/shader/inc_lic.glsl | 4 +- .../shader/raycast_lic3d_fragment.glsl | 16 ++- VectorVisualization/types.h | 6 +- 14 files changed, 288 insertions(+), 93 deletions(-) diff --git a/VectorVisualization/3DLIC.cpp b/VectorVisualization/3DLIC.cpp index 90878e3..e6bf79f 100644 --- a/VectorVisualization/3DLIC.cpp +++ b/VectorVisualization/3DLIC.cpp @@ -10,6 +10,9 @@ #include #include #include +#include +#include +#include #include "texture.h" #include "illumination.h" @@ -135,13 +138,25 @@ void idle(void) //vd.getVolumeData()->newData = vd.getVolumeData()->dataSets[vd.NextTimeStep()]; //vd.createTexture("VectorData_Tex", GL_TEXTURE2_ARB, true); - if(animationMode && (renderTechnique == VOLIC_SLICING || renderTechnique == VOLIC_RAYCAST || renderTechnique == VOLIC_LICVOLUME)) + if (animationMode && (renderTechnique == VOLIC_SLICING || renderTechnique == VOLIC_RAYCAST /*|| renderTechnique == VOLIC_LICVOLUME*/)) + { vd.createTextureIterp("VectorData_Tex", GL_TEXTURE2_ARB, true); - if(animationMode && renderTechnique == VOLIC_LICVOLUME) - renderer.updateLICVolume(); - vd.checkInterpolateStage(); + vd.checkInterpolateStage(); + } + if (animationMode && renderTechnique == VOLIC_LICVOLUME) + { + licParams.interpStep++; + updateScene = true; - //renderer.setDataTex(vd.getTextureSetRef(idx)); + } + if (licParams.interpStep == licParams.interpSize) + { + renderer.setDataTex(vd.getTextureSetRef(vd.getNextTimeStep())); + renderer.renderLICVolume(); + licParams.interpStep = 0; + } + //int i = 0; + //renderer.setDataTex(vd.getTextureSetRef(vd.getNextTimeStep())); //Update Render Animation source renderer.setVolumeData(vd.getVolumeData()); @@ -394,7 +409,7 @@ void keyboard(unsigned char key, int x, int y) break; // update 3D Lic calculation case 'u': - renderer.updateLICVolume(); + //renderer.updateLICVolume(); updateScene = true; break; @@ -470,15 +485,21 @@ void keyboardSpecial(int key, int x, int y) break; case GLUT_KEY_F4: renderTechnique = VOLIC_LICVOLUME; - renderer.updateLICVolume(); + //renderer.updateLICVolume(); break; case GLUT_KEY_F5: animationMode = !animationMode; renderer.setAnimationFlag(animationMode); - if(animationMode) + if (animationMode) + { std::cout << "Playing animation!" << std::endl; + renderer.loadGLSLShader("#define VOLUME_ANIMATION"); + } else + { std::cout << "Stop animation!" << std::endl; + renderer.loadGLSLShader(); + } //renderer.updateLICVolume(); break; } @@ -673,6 +694,36 @@ void initGL(void) CHECK_FOR_OGL_ERROR(); } +void loadVecterData(VectorDataSet * vdd) +{ + wglMakeCurrent(dc, glrc_load); + std::deque& vds = vdd->getVolumeDataSet(); + std::vector & vts = vdd->getTextureSet(); + for (int i = vdd->getTimeStepBegin(); i <= vdd->getTimeStepEnd(); i++) + { + void* datap = vdd->loadTimeStep(i); + VolumeData * vdp = new VolumeData(*(vdd->getVolumeData())); + vdp->data = datap; + if (!vds.empty()) + vds.back()->newData = datap; + vds.push_back(vdp); + std::cout << "vector data set size: " << vds.size() << std::endl; + } + + //initial first volume + vdd->setVolumeDataIndex(0); + + std::unique_lock lck_load(mt_load); + load_volume_buffer = true; + cv_load.notify_one(); + + + for (int i =0; i < vds.size(); i++) + { + vts.push_back(vdd->createTextures(i, "LoadThread_Tex", GL_TEXTURE1_ARB, true)); + } +} + void init(void) { @@ -689,20 +740,22 @@ void init(void) std::cerr << "Could not load data ..." << std::endl; exit(1); } - //for (int i = vd.getTimeStepBegin(); i <= vd.getTimeStepEnd(); i++) - //{ - // void* datap = vd.loadTimeStep(vd.getCurTimeStep()); - // vd.getVolumeData()->dataSets.push_back(datap); - // vd.getNextTimeStep(); - //} + std::thread load_thread(loadVecterData, &vd); + load_thread.join(); + + auto pred = []() { + return load_volume_buffer; + }; + std::unique_lock lck_load(mt_load); + while (!pred()) + cv_load.wait(lck_load); - //vd.getVolumeData()->data = vd.getVolumeData()->dataSets[vd.getCurTimeStep()]; - //vd.getVolumeData()->newData = vd.getVolumeData()->dataSets[vd.NextTimeStep()]; - vd.getVolumeData()->data = vd.loadTimeStep(vd.getCurTimeStep()); - vd.getVolumeData()->newData = vd.loadTimeStep(vd.NextTimeStep()); + std::cout << "start initil texture" << std::endl; //vd.createTextures("VectorData_Tex", vd.getVolumeData()->dataSets.size(), GL_TEXTURE2_ARB, true); // Set Interpolation step size vd.setInterpolateSize(10); + licParams.interpSize = 10; + //vd.createTexture("VectorData_Tex", GL_TEXTURE2_ARB, true); vd.createTextureIterp("VectorData_Tex", GL_TEXTURE2_ARB, true); vd.checkInterpolateStage(); @@ -794,10 +847,33 @@ void init(void) renderer.setLICParams(&licParams); + renderer.renderLICVolume(); + renderer.updateLICVolume(); + CHECK_FOR_OGL_ERROR(); renderer.updateLightPos(); renderer.updateSlices(); } +void initMultiThread(void) +{ + //Create Multi-Thread for loading and Texture generation + dc = wglGetCurrentDC(); + glrc_main = wglCreateContext(dc); + glrc_load = wglCreateContext(dc); + BOOL error = wglShareLists(glrc_main, glrc_load); + if (error == FALSE) + { + DWORD errorCode = GetLastError(); + LPVOID lpMsgBuf; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); + MessageBox(NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION); + LocalFree(lpMsgBuf); + //Destroy the GL context and just use 1 GL context + wglDeleteContext(glrc_load); + } + wglMakeCurrent(dc, glrc_main); +} int main(int argc, char **argv) { @@ -829,9 +905,14 @@ int main(int argc, char **argv) fprintf(stderr, "GLEW error"); return 1; } + + initMultiThread(); initGL(); init(); + //std::thread load_thread(loadVecterData, &vd); + //load_thread.join(); + glutMainLoop(); return 0; diff --git a/VectorVisualization/3DLIC.h b/VectorVisualization/3DLIC.h index 243d554..342cc77 100644 --- a/VectorVisualization/3DLIC.h +++ b/VectorVisualization/3DLIC.h @@ -9,6 +9,10 @@ #include "dataSet.h" #include "parseArg.h" +HDC dc; +HGLRC glrc_main; +HGLRC glrc_load; + ParseArguments arguments; Camera cam; Renderer renderer; @@ -56,4 +60,9 @@ LICParams licParams; void display(void); void resize(int width, int height); void updateHUD(bool forceUpdate = false); -void keyboard(unsigned char key, int x, int y); \ No newline at end of file +void keyboard(unsigned char key, int x, int y); + +//Multi-thread +std::mutex mt_load; +bool load_volume_buffer = false; +std::condition_variable cv_load; \ No newline at end of file diff --git a/VectorVisualization/GLSLShader.cpp b/VectorVisualization/GLSLShader.cpp index 946f525..7f17c7f 100644 --- a/VectorVisualization/GLSLShader.cpp +++ b/VectorVisualization/GLSLShader.cpp @@ -348,7 +348,8 @@ GLSLParamsLIC::GLSLParamsLIC(void) : viewport(-1),texMax(-1),scaleVol(-1), transferAlphaOpacSampler(-1), licKernelSampler(-1),malloDiffSampler(-1), malloSpecSampler(-1),zoecklerSampler(-1), - imageFBOSampler(-1) + imageFBOSampler(-1), + interpSize(-1),interpStep(-1) { } @@ -387,6 +388,9 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) imageFBOSampler = -1; + interpSize = -1; + interpStep = -1; + glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &numUniforms); @@ -457,6 +461,14 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) { licVolumeSamplerOld = i; } + else if (strcmp(buf, "interpSize") == 0) + { + interpSize = i; + } + else if (strcmp(buf, "interpStep") == 0) + { + interpStep = i; + } else if (strcmp(buf, "scalarSampler") == 0) { scalarSampler = i; diff --git a/VectorVisualization/GLSLShader.h b/VectorVisualization/GLSLShader.h index 287e634..374064f 100644 --- a/VectorVisualization/GLSLShader.h +++ b/VectorVisualization/GLSLShader.h @@ -92,6 +92,9 @@ struct GLSLParamsLIC GLint licVolumeSamplerOld; GLint imageFBOSampler; + + GLint interpSize; + GLint interpStep; }; struct GLSLParamsBackground diff --git a/VectorVisualization/VolumeBuffer.cpp b/VectorVisualization/VolumeBuffer.cpp index d19e50b..4d41992 100644 --- a/VectorVisualization/VolumeBuffer.cpp +++ b/VectorVisualization/VolumeBuffer.cpp @@ -58,10 +58,11 @@ GLuint VolumeBuffer::create3dTexture(GLint internalformat, int w, int h, int d) void VolumeBuffer::restoreOldLayer() { - if (_tex[0].id > 0) + if (_tex[0].id > 0 && _tex[1].id > 0) { - glBindTexture(GL_TEXTURE_3D, _tex[0].id); - glCopyTexSubImage3D(_tex[1].id, 0, 0, 0, 0, 0, 0, _tex[0].width, _tex[0].height); + glCopyImageSubData(_tex[0].id, GL_TEXTURE_3D, 0, 0, 0, 0, _tex[1].id, GL_TEXTURE_3D, 0, 0, 0, 0, _tex[0].width, _tex[0].height, _tex[0].depth); + //glBindTexture(GL_TEXTURE_3D, _tex[0].id); + //glCopyTexImage3D(_tex[1].id, 0, 0, 0, 0, 0, 0, _tex[0].width, _tex[0].height); } } diff --git a/VectorVisualization/VolumeBuffer.h b/VectorVisualization/VolumeBuffer.h index 35b46c2..f3d8f63 100644 --- a/VectorVisualization/VolumeBuffer.h +++ b/VectorVisualization/VolumeBuffer.h @@ -26,6 +26,8 @@ class VolumeBuffer void setInterpolation(int size) { _interpSize = size; } + void increaseInterpoStep() { _curIntepStep++; } + void setIncreaseInterpoStep(int step) { _curIntepStep = step; } bool isAnimation() { return animationFlag; } void animationOn() { animationFlag = true; } @@ -39,6 +41,7 @@ class VolumeBuffer int _curIntepStep; GLuint _frambufferId; + // tex[0] : new tex. tex[1] : old tex. Texture * _tex; }; diff --git a/VectorVisualization/dataset.cpp b/VectorVisualization/dataset.cpp index b5d3d03..6b24356 100644 --- a/VectorVisualization/dataset.cpp +++ b/VectorVisualization/dataset.cpp @@ -25,26 +25,26 @@ VolumeData::~VolumeData(void) { std::cerr << "Volume data is to be deleted." << std::endl; - for (auto d : dataSets) { - switch (dataType) - { - case DATRAW_UCHAR: - delete[] static_cast(d); - break; - case DATRAW_USHORT: - delete[] static_cast(d); - break; - case DATRAW_FLOAT: - delete[] static_cast(d); - break; - case DATRAW_NONE: - default: - if (d) - std::cerr << "~Volume: unknown data type" << std::endl; - break; - } - d = NULL; - } + //for (auto d : dataSets) { + // switch (dataType) + // { + // case DATRAW_UCHAR: + // delete[] static_cast(d); + // break; + // case DATRAW_USHORT: + // delete[] static_cast(d); + // break; + // case DATRAW_FLOAT: + // delete[] static_cast(d); + // break; + // case DATRAW_NONE: + // default: + // if (d) + // std::cerr << "~Volume: unknown data type" << std::endl; + // break; + // } + // d = NULL; + //} data = NULL; } @@ -91,6 +91,12 @@ VectorDataSet::VectorDataSet(void) VectorDataSet::~VectorDataSet(void) { delete _vd; + while (!_volumeSet.empty()) + { + auto v = _volumeSet.front(); + _volumeSet.pop_front(); + delete v; + } } @@ -199,14 +205,17 @@ void* VectorDataSet::loadTimeStep(int timeStep) return _datFile.readRawData(timeStep); } -void VectorDataSet::checkInterpolateStage() +int VectorDataSet::checkInterpolateStage() { if (interpIndex >= InterpSize) { - _vd->data = loadTimeStep(getNextTimeStep()); - _vd->newData = loadTimeStep(NextTimeStep()); + //_vd->data = loadTimeStep(getNextTimeStep()); + //_vd->newData = loadTimeStep(NextTimeStep()); + _vd = _volumeSet.front(); + interpIndex = 0; } + return interpIndex; } @@ -365,33 +374,29 @@ void VectorDataSet::createTextureIterp(const char *texName, paddedData = NULL; } -void VectorDataSet::createTextures(const char *texName, int datasize, - GLuint texUnit, - bool floatTex) +Texture * VectorDataSet::createTextures(int index, const char *texName, GLuint texUnit, bool floatTex) { - for (int i = 0; i < datasize; i++) - { GLuint texId; void *paddedData = NULL; if (!_loaded) - return; + return nullptr; - Texture tex; + Texture * tex = new Texture; char texSetName[100]; strcpy(texSetName, texName); - strcat(texSetName, std::to_string(i).c_str()); + strcat(texSetName, std::to_string(index).c_str()); // create a texture id - if (tex.id == 0) + if (tex->id == 0) { glGenTextures(1, &texId); - tex.setTex(GL_TEXTURE_3D, texId, texSetName); + tex->setTex(GL_TEXTURE_3D, texId, texSetName); } - tex.texUnit = texUnit; - tex.width = _vd->texSize[0]; - tex.height = _vd->texSize[1]; - tex.depth = _vd->texSize[2]; + tex->texUnit = texUnit; + tex->width = _vd->texSize[0]; + tex->height = _vd->texSize[1]; + tex->depth = _vd->texSize[2]; #if FORCE_POWER_OF_TWO_TEXTURE == 1 if ((_vd->texSize[0] != _vd->size[0]) @@ -406,23 +411,24 @@ void VectorDataSet::createTextures(const char *texName, int datasize, _texSrcFmt = GL_FLOAT; _texIntFmt = GL_RGBA16F_ARB; - paddedData = fillTexDataFloat(); + paddedData = fillTexDataFloat(index); } else { _texSrcFmt = GL_UNSIGNED_BYTE; _texIntFmt = GL_RGBA; - paddedData = fillTexDataChar(); + paddedData = fillTexDataChar(index); } - tex.format = _texIntFmt; + tex->format = _texIntFmt; - glBindTexture(GL_TEXTURE_3D, tex.id); + glBindTexture(GL_TEXTURE_3D, tex->id); + CHECK_FOR_OGL_ERROR(); glTexImage3D(GL_TEXTURE_3D, 0, _texIntFmt, _vd->texSize[0], _vd->texSize[1], _vd->texSize[2], 0, GL_RGBA, _texSrcFmt, paddedData); - + CHECK_FOR_OGL_ERROR(); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -441,11 +447,12 @@ void VectorDataSet::createTextures(const char *texName, int datasize, delete[](unsigned char*)paddedData; paddedData = NULL; - _texSet.push_back(tex); - } + //_texSet.push_back(*tex); + std::cout << "texSet size: " << _texSet.size() << std::endl; + return tex; } -void* VectorDataSet::fillTexDataFloat(void) +void* VectorDataSet::fillTexDataFloat(int i) { int size = _vd->texSize[0] * _vd->texSize[1] * _vd->texSize[2]; int adr; @@ -453,8 +460,18 @@ void* VectorDataSet::fillTexDataFloat(void) float len; float maxLen = -1.0; - unsigned char *dataU = (unsigned char*)_vd->data; - float *dataF = (float*)_vd->data; + unsigned char *dataU; + float *dataF; + if (i == 0) + { + dataU = (unsigned char*)_vd->data; + dataF = (float*)_vd->data; + } + else + { + dataU = (unsigned char*)_volumeSet[i]->data; + dataF = (float*)_volumeSet[i]->data; + } float *padded = new float[4 * size]; memset(padded, 0, 4 * size * sizeof(float)); @@ -634,7 +651,7 @@ void* VectorDataSet::fillTexDataFloatInterp() return padded; } -void* VectorDataSet::fillTexDataChar(void) +void* VectorDataSet::fillTexDataChar(int i) { int size = _vd->texSize[0] * _vd->texSize[1] * _vd->texSize[2]; int adr; @@ -643,9 +660,18 @@ void* VectorDataSet::fillTexDataChar(void) float maxLen = -1.0; float *magnitude = new float[size]; - - unsigned char *dataU = (unsigned char*)_vd->data; - float *dataF = (float*)_vd->data; + unsigned char *dataU; + float *dataF; + if(i == 0) + { + dataU = (unsigned char*)_vd->data; + dataF = (float*)_vd->data; + } + else + { + dataU = (unsigned char*)_volumeSet[i]->data; + dataF = (float*)_volumeSet[i]->data; + } unsigned char *padded = new unsigned char[4 * size]; memset(padded, 0, 4 * size * sizeof(char)); diff --git a/VectorVisualization/dataset.h b/VectorVisualization/dataset.h index ac2af06..cb1e75d 100644 --- a/VectorVisualization/dataset.h +++ b/VectorVisualization/dataset.h @@ -16,6 +16,7 @@ #include "reader.h" #include "types.h" #include +#include struct VolumeData @@ -30,11 +31,32 @@ struct VolumeData scaleInv[0] = scaleInv[1] = scaleInv[2] = scaleInv[3] = 1.0f; center[0] = center[1] = center[2] = 0.0f; } + VolumeData(const VolumeData& obj) + :data(obj.data), newData(obj.newData), + dataDim(obj.dataDim),dataType(obj.dataType) + { + sliceDist[0] = obj.sliceDist[0]; + sliceDist[1] = obj.sliceDist[1]; + sliceDist[2] = obj.sliceDist[2]; + + size[0] = obj.size[0]; + size[1] = obj.size[1]; + size[2] = obj.size[2]; + + texSize[0] = obj.texSize[0]; + texSize[1] = obj.texSize[1]; + texSize[2] = obj.texSize[2]; + + extent[0] = obj.extent[0]; extent[1] = obj.extent[1]; extent[2] = obj.extent[2]; + scale[0] = obj.scale[0]; scale[1] = obj.scale[1]; scale[2] = obj.scale[2]; scale[3] = obj.scale[3]; + scaleInv[0] = obj.scaleInv[0]; scaleInv[1] = obj.scaleInv[1]; scaleInv[2] = obj.scaleInv[2]; scaleInv[3] = obj.scaleInv[3]; + center[0] = obj.center[0]; center[1] = obj.center[1]; center[2] = obj.center[2]; + } ~VolumeData(void); void *data; void *newData; - std::vector dataSets; + //std::vector dataSets; unsigned char dataDim; DataType dataType; @@ -99,7 +121,8 @@ class VectorDataSet : public DataSet void* loadTimeStep(int timeStep); VolumeData* getVolumeData(void) { return _vd; } - + std::deque& getVolumeDataSet(void) { return _volumeSet; } + std::vector& getTextureSet(void) { return _texSet; } // updates data pointer of VolumeData // the memory of the previous reference is not freed! @@ -114,7 +137,7 @@ class VectorDataSet : public DataSet GLuint texUnit = GL_TEXTURE0_ARB, bool floatTex = false); - void createTextures(const char *texName, int datasize, + Texture * createTextures(int index, const char *texName, GLuint texUnit = GL_TEXTURE0_ARB, bool floatTex = false); @@ -124,27 +147,35 @@ class VectorDataSet : public DataSet int NextTimeStep(void); int getCurTimeStep(void); - Texture* getTextureSetRef(int index) { return &(_texSet[index]); } + Texture* getTextureSetRef(int index) { return _texSet[index]; } - void checkInterpolateStage(); + int checkInterpolateStage(); void setInterpolateSize(int size) { InterpSize = size; }; + void increaseInterpIndex() { interpIndex++; } + + void setVolumeDataIndex(int i) + { + _vd = _volumeSet[i]; + } protected: private: // fill a zero padded texture with normalized vector direction // in rgb and the magnitude in a - void* fillTexDataFloat(void); + void* fillTexDataFloat(int i = 0); void* fillTexDataFloatInterp(); // fill a zero padded texture with normalized vector direction // in rgb and the magnitude in a - void* fillTexDataChar(void); + void* fillTexDataChar(int i = 0); void* fillTexDataCharInterp(); VolumeData *_vd; DatFile _datFile; + std::deque _volumeSet; + //preload sequence of texture - std::vector _texSet; + std::vector _texSet; //Interpolate step Index int interpIndex; diff --git a/VectorVisualization/renderer.cpp b/VectorVisualization/renderer.cpp index cababe7..454918c 100644 --- a/VectorVisualization/renderer.cpp +++ b/VectorVisualization/renderer.cpp @@ -993,6 +993,12 @@ void Renderer::setRenderVolParams(GLSLParamsLIC *param) if (param->numIterations > -1) glUniform1iARB(param->numIterations, _licParams->numIterations); CHECK_FOR_OGL_ERROR(); + + if (param->interpSize > -1) + glUniform1iARB(param->interpSize, _licParams->interpSize); + if (param->interpStep > -1) + glUniform1fARB(param->interpStep, float(_licParams->interpStep)/ _licParams->interpSize); + CHECK_FOR_OGL_ERROR(); } @@ -1345,10 +1351,7 @@ void Renderer::renderLICVolume(void) setRenderVolParams(&_paramLICVolume); setRenderVolTextures(&_paramLICVolume); - if (_licvolumebuffer->isAnimation()) - { - _licvolumebuffer->restoreOldLayer(); - } + CHECK_FOR_OGL_ERROR(); for (int z = 0; z < depth; z++) { @@ -1375,9 +1378,15 @@ void Renderer::renderLICVolume(void) void Renderer::updateLICVolume(void) { + _licvolumebuffer->restoreOldLayer(); renderLICVolume(); } +void Renderer::restoreLICVolume(void) +{ + _licvolumebuffer->restoreOldLayer(); +} + void Renderer::raycastLICVolume(void) { _licRaycastShader.enableShader(); diff --git a/VectorVisualization/renderer.h b/VectorVisualization/renderer.h index 08d6406..39ae73d 100644 --- a/VectorVisualization/renderer.h +++ b/VectorVisualization/renderer.h @@ -121,6 +121,10 @@ class Renderer // update3D LIC Volume void updateLICVolume(void); + // Using FBO calculate 3D LIC value and store them into a 3D Texture + void renderLICVolume(void); + // restore Old LIC Volume + void restoreLICVolume(void); void setAnimationFlag(bool flag) { _isAnimationOn = flag; } protected: @@ -154,8 +158,6 @@ class Renderer // fills the hole in the clipped cube void drawClippedPolygon(void); - // Using FBO calculate 3D LIC value and store them into a 3D Texture - void renderLICVolume(void); // Using Volume Rendering to render LIC 3D volume void raycastLICVolume(void); diff --git a/VectorVisualization/shader/inc_header.glsl b/VectorVisualization/shader/inc_header.glsl index eb8cd42..5a4c949 100644 --- a/VectorVisualization/shader/inc_header.glsl +++ b/VectorVisualization/shader/inc_header.glsl @@ -61,3 +61,5 @@ uniform sampler2D malloSpecSampler; uniform sampler2D zoecklerSampler; uniform sampler2DRect imageFBOSampler; + + diff --git a/VectorVisualization/shader/inc_lic.glsl b/VectorVisualization/shader/inc_lic.glsl index 6a60857..7cfaa28 100644 --- a/VectorVisualization/shader/inc_lic.glsl +++ b/VectorVisualization/shader/inc_lic.glsl @@ -77,9 +77,9 @@ float freqSampling(in vec3 pos, out float logEyeDist) vec4 scalarData = texture3D(scalarSampler, pos); //float scala = length(vectorData.xyz); - if (scalarData.r > 0.1 && scalarData.r < 0.3) + //if (scalarData.r > 0.1 && scalarData.r < 0.3) //if (true) - //if (vectorData.a > 0.45 && vectorData.a < 1.6) + if (vectorData.a > 0.45 && vectorData.a < 1.6) { //return texture3D(noiseSampler, pos).a return texture3D(noiseSampler, pos*gradient.z).a; diff --git a/VectorVisualization/shader/raycast_lic3d_fragment.glsl b/VectorVisualization/shader/raycast_lic3d_fragment.glsl index 577f3c2..1be46e9 100644 --- a/VectorVisualization/shader/raycast_lic3d_fragment.glsl +++ b/VectorVisualization/shader/raycast_lic3d_fragment.glsl @@ -2,6 +2,9 @@ uniform sampler3D licVolumeSampler; uniform sampler3D licVolumeSamplerOld; +uniform int interpSize; +uniform float interpStep; + void main(void) { bool outside = false; @@ -22,6 +25,7 @@ void main(void) float scalarData; vec4 volumeData; + vec4 volumeDataOld; vec4 vectorData; vec4 dest = vec4(0.0); @@ -40,7 +44,15 @@ void main(void) // lookup scalar value vectorData = texture3D(volumeSampler, pos); volumeData = texture3D(licVolumeSampler, pos); - + + volumeDataOld = texture3D(licVolumeSamplerOld, pos); + + float intensity = volumeData.r; + intensity = volumeDataOld.r*(1-interpStep) + volumeData.r * interpStep; + //volumeData = volumeDataMix; + //if(volumeData == volumeDataOld) + //intensity = interpStep; + //noise = texture3D(noiseSampler, pos); // lookup in transfer function @@ -48,7 +60,7 @@ void main(void) //src = vec4(tfData.xyz, volumeData.a); //src = vec4(noise.xyz, data.a); - src = illumLIC(volumeData.r, tfData); + src = illumLIC(intensity, tfData); //src = volumeData; // perform blending diff --git a/VectorVisualization/types.h b/VectorVisualization/types.h index b48bd77..dc44c2a 100644 --- a/VectorVisualization/types.h +++ b/VectorVisualization/types.h @@ -88,7 +88,8 @@ struct LICParams illumScale(1.0f), freqScale(1.0f), numIterations(255), stepsForward(32), stepsBackward(32), - stepSizeLIC(0.01f) + stepSizeLIC(0.01f), + interpSize(1), interpStep(0) {} float stepSizeVol; @@ -100,6 +101,9 @@ struct LICParams int stepsForward; int stepsBackward; float stepSizeLIC; + + int interpSize; + int interpStep; }; From e54d8e6396a5eb49266c94d020c49a0e7b0824f1 Mon Sep 17 00:00:00 2001 From: Yangguang Date: Tue, 23 May 2017 15:36:40 -0700 Subject: [PATCH 2/7] Add Streamline distance filtering --- VectorVisualization/3DLIC.cpp | 60 ++++++--- VectorVisualization/GLSLShader.cpp | 12 +- VectorVisualization/GLSLShader.h | 2 + VectorVisualization/VolumeBuffer.cpp | 25 +++- VectorVisualization/VolumeBuffer.h | 2 +- VectorVisualization/dataset.cpp | 39 +++--- VectorVisualization/dataset.h | 12 +- VectorVisualization/reader.cpp | 8 +- VectorVisualization/renderer.cpp | 25 +++- VectorVisualization/renderer.h | 2 + .../shader/background_fragment.glsl | 2 +- VectorVisualization/shader/inc_header.glsl | 3 + VectorVisualization/shader/inc_lic.glsl | 115 +++++++++++++++--- .../shader/lic3d_fragment.glsl | 44 ++++++- .../shader/lic3d_slicing_fragment.glsl | 6 +- .../shader/lic3d_slicingblend_fragment.glsl | 6 +- .../shader/lic3d_volume_fragment.glsl | 16 ++- .../shader/raycast_lic3d_fragment.glsl | 30 +++-- VectorVisualization/texture.h | 1 + VectorVisualization/types.h | 6 +- 20 files changed, 318 insertions(+), 98 deletions(-) diff --git a/VectorVisualization/3DLIC.cpp b/VectorVisualization/3DLIC.cpp index e6bf79f..dd5d5a8 100644 --- a/VectorVisualization/3DLIC.cpp +++ b/VectorVisualization/3DLIC.cpp @@ -141,25 +141,29 @@ void idle(void) if (animationMode && (renderTechnique == VOLIC_SLICING || renderTechnique == VOLIC_RAYCAST /*|| renderTechnique == VOLIC_LICVOLUME*/)) { vd.createTextureIterp("VectorData_Tex", GL_TEXTURE2_ARB, true); - vd.checkInterpolateStage(); + //renderer.setDataTex(vd.getTextureSetRef(vd.getNextTimeStep())); + if (vd.checkInterpolateStage()==1) + renderer.setVolumeData(vd.getVolumeData()); } if (animationMode && renderTechnique == VOLIC_LICVOLUME) { licParams.interpStep++; updateScene = true; - - } - if (licParams.interpStep == licParams.interpSize) - { - renderer.setDataTex(vd.getTextureSetRef(vd.getNextTimeStep())); - renderer.renderLICVolume(); - licParams.interpStep = 0; + if (licParams.interpStep == licParams.interpSize) + { + renderer.setDataTex(vd.getTextureSetRef(vd.getNextTimeStep())); + renderer.setNextDataTex(vd.getTextureSetRef(vd.NextTimeStep())); + //vd.createTexture("VolumeLIC_Tex", GL_TEXTURE2_ARB, true); + renderer.updateLICVolume(); + licParams.interpStep = 0; + } } + //int i = 0; //renderer.setDataTex(vd.getTextureSetRef(vd.getNextTimeStep())); //Update Render Animation source - renderer.setVolumeData(vd.getVolumeData()); + //renderer.setVolumeData(vd.getVolumeData()); // check whether to change to high res rendering if (requestHighRes && renderer.isLowResEnabled()) @@ -372,14 +376,14 @@ void keyboard(unsigned char key, int x, int y) updateHUD(); updateScene = true; break; case 'h': // frequency scaling - licParams.freqScale += 0.2f; //0.5f + licParams.freqScale += 0.1f; //0.5f updateHUD(); updateScene = true; break; case 'n': - licParams.freqScale -= 0.2f; //0.5f - if (licParams.freqScale < 0.5f) - licParams.freqScale = 0.5f; + licParams.freqScale -= 0.1f; //0.5f + if (licParams.freqScale < 0.1f) + licParams.freqScale = 0.1f; updateHUD(); updateScene = true; break; @@ -412,6 +416,10 @@ void keyboard(unsigned char key, int x, int y) //renderer.updateLICVolume(); updateScene = true; break; + case '`': + renderer.loadGLSLShader("#define STREAMLINE_DISTANCE"); + updateScene = true; + break; // clip planes case '1': @@ -475,16 +483,23 @@ void keyboardSpecial(int key, int x, int y) { case GLUT_KEY_F1: renderTechnique = VOLIC_VOLUME; + renderer.setDataTex(vd.getTextureRef()); break; case GLUT_KEY_F2: renderTechnique = VOLIC_RAYCAST; + renderer.setDataTex(vd.getTextureRef()); break; case GLUT_KEY_F3: renderTechnique = VOLIC_SLICING; + renderer.setDataTex(vd.getTextureRef()); renderer.updateSlices(); break; case GLUT_KEY_F4: renderTechnique = VOLIC_LICVOLUME; + renderer.setDataTex(vd.getTextureSetRef(vd.getCurTimeStep())); + renderer.setNextDataTex(vd.getTextureSetRef(vd.NextTimeStep())); + renderer.renderLICVolume(); + renderer.updateLICVolume(); //renderer.updateLICVolume(); break; case GLUT_KEY_F5: @@ -707,20 +722,23 @@ void loadVecterData(VectorDataSet * vdd) if (!vds.empty()) vds.back()->newData = datap; vds.push_back(vdp); - std::cout << "vector data set size: " << vds.size() << std::endl; + //std::cout << "vector data set size: " << vds.size() << std::endl; } + vds.back()->newData = vds.back()->data; //initial first volume vdd->setVolumeDataIndex(0); + vds.pop_front(); std::unique_lock lck_load(mt_load); load_volume_buffer = true; cv_load.notify_one(); - for (int i =0; i < vds.size(); i++) + for (int i = 0; i < vds.size(); i++) { - vts.push_back(vdd->createTextures(i, "LoadThread_Tex", GL_TEXTURE1_ARB, true)); + vts.push_back(vdd->createTextures(i, "LoadThread_Tex", GL_TEXTURE2_ARB, true)); + //std::cout << "create vector texture: " << vts.size() << std::endl; } } @@ -742,6 +760,7 @@ void init(void) } std::thread load_thread(loadVecterData, &vd); load_thread.join(); + //load_thread.detach(); auto pred = []() { return load_volume_buffer; @@ -836,7 +855,9 @@ void init(void) renderer.setVolumeData(vd.getVolumeData()); renderer.setLICFilter(&licFilter); - renderer.setDataTex(vd.getTextureRef()); + //renderer.setDataTex(vd.getTextureRef()); + renderer.setDataTex(vd.getTextureSetRef(vd.getCurTimeStep())); + renderer.setNextDataTex(vd.getTextureSetRef(vd.NextTimeStep())); renderer.setScalarTex(scalar.getTextureRef()); renderer.setNoiseTex(noise.getTextureRef()); renderer.setTFrgbTex(tfEdit.getTextureRGB()); @@ -847,8 +868,8 @@ void init(void) renderer.setLICParams(&licParams); - renderer.renderLICVolume(); - renderer.updateLICVolume(); + //renderer.renderLICVolume(); + //renderer.updateLICVolume(); CHECK_FOR_OGL_ERROR(); renderer.updateLightPos(); renderer.updateSlices(); @@ -910,6 +931,7 @@ int main(int argc, char **argv) initGL(); init(); + // Load a thread to calculate LIC volume //std::thread load_thread(loadVecterData, &vd); //load_thread.join(); diff --git a/VectorVisualization/GLSLShader.cpp b/VectorVisualization/GLSLShader.cpp index 7f17c7f..2cbfebc 100644 --- a/VectorVisualization/GLSLShader.cpp +++ b/VectorVisualization/GLSLShader.cpp @@ -341,7 +341,7 @@ char* GLSLShader::loadSource(char *fileName, int *size) GLSLParamsLIC::GLSLParamsLIC(void) : viewport(-1),texMax(-1),scaleVol(-1), scaleVolInv(-1),stepSize(-1),gradient(-1), licParams(-1),licKernel(-1),numIterations(-1), - alphaCorrection(-1),volumeSampler(-1),scalarSampler(-1), + alphaCorrection(-1),volumeSampler(-1), volumeSamplerNext(-1), scalarSampler(-1), licVolumeSampler(-1), licVolumeSamplerOld(-1), noiseSampler(-1),mcOffsetSampler(-1), transferRGBASampler(-1), @@ -372,8 +372,10 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) licKernel = -1; numIterations = -1; alphaCorrection = -1; + maxVectorLength = -1; volumeSampler = -1; + volumeSamplerNext = -1; scalarSampler = -1; noiseSampler = -1; mcOffsetSampler = -1; @@ -421,6 +423,10 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) { scaleVol = i; } + else if (strcmp(buf, "maxVectorLength") == 0) + { + maxVectorLength = i; + } else if (strcmp(buf, "scaleVolInv") == 0) { scaleVolInv = i; @@ -453,6 +459,10 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) { volumeSampler = i; } + else if (strcmp(buf, "volumeSamplerNext") == 0) + { + volumeSamplerNext = i; + } else if (strcmp(buf, "licVolumeSampler") == 0) { licVolumeSampler = i; diff --git a/VectorVisualization/GLSLShader.h b/VectorVisualization/GLSLShader.h index 374064f..6857854 100644 --- a/VectorVisualization/GLSLShader.h +++ b/VectorVisualization/GLSLShader.h @@ -77,8 +77,10 @@ struct GLSLParamsLIC GLint licKernel; GLint numIterations; GLint alphaCorrection; + GLint maxVectorLength; GLint volumeSampler; + GLint volumeSamplerNext; GLint scalarSampler; GLint noiseSampler; GLint mcOffsetSampler; diff --git a/VectorVisualization/VolumeBuffer.cpp b/VectorVisualization/VolumeBuffer.cpp index 4d41992..ff8a3de 100644 --- a/VectorVisualization/VolumeBuffer.cpp +++ b/VectorVisualization/VolumeBuffer.cpp @@ -1,6 +1,5 @@ #include "VolumeBuffer.h" - - +#include "types.h" VolumeBuffer::VolumeBuffer(GLint format, int width, int height, int depth, int layers) :_width(width), _height(height), _depth(depth), _maxlayers(layers), _layer(0), @@ -9,13 +8,15 @@ VolumeBuffer::VolumeBuffer(GLint format, int width, int height, int depth, int l glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT"); _frambufferId = 0; glGenFramebuffersEXT(1, &_frambufferId); - _tex = new Texture[_maxlayers]; - for (int i = 0; i<_maxlayers; i++) { + //_tex = new Texture[_maxlayers]; + for (int i = 0; i < 2; i++) { _tex[i].setTex(GL_TEXTURE_3D, create3dTexture(format, _width, _height, _depth), "LIC_Tex"); _tex[i].width = _width; _tex[i].height = _height; _tex[i].depth = _depth; } + _tex[0].texUnit = GL_TEXTURE13_ARB; + _tex[1].texUnit = GL_TEXTURE14_ARB; } @@ -61,8 +62,20 @@ void VolumeBuffer::restoreOldLayer() if (_tex[0].id > 0 && _tex[1].id > 0) { glCopyImageSubData(_tex[0].id, GL_TEXTURE_3D, 0, 0, 0, 0, _tex[1].id, GL_TEXTURE_3D, 0, 0, 0, 0, _tex[0].width, _tex[0].height, _tex[0].depth); - //glBindTexture(GL_TEXTURE_3D, _tex[0].id); - //glCopyTexImage3D(_tex[1].id, 0, 0, 0, 0, 0, 0, _tex[0].width, _tex[0].height); + + /*glBindFramebuffer(GL_FRAMEBUFFER, _frambufferId); + for (int i = 0; i < _tex[0].depth; i++) + { + glFramebufferTexture3D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, + GL_TEXTURE_3D, _tex[0].id, 0, i); + glFramebufferTexture3D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, + GL_TEXTURE_3D, _tex[1].id, 0, i); + glDrawBuffer(GL_COLOR_ATTACHMENT1); + glBlitFramebuffer(0, 0, _tex[0].width, _tex[0].height, 0, 0, _tex[0].width, _tex[0].height, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + } + glBindFramebuffer(GL_FRAMEBUFFER, 0);*/ + CHECK_FOR_OGL_ERROR(); } } diff --git a/VectorVisualization/VolumeBuffer.h b/VectorVisualization/VolumeBuffer.h index f3d8f63..0bf6809 100644 --- a/VectorVisualization/VolumeBuffer.h +++ b/VectorVisualization/VolumeBuffer.h @@ -42,6 +42,6 @@ class VolumeBuffer GLuint _frambufferId; // tex[0] : new tex. tex[1] : old tex. - Texture * _tex; + Texture _tex[2]; }; diff --git a/VectorVisualization/dataset.cpp b/VectorVisualization/dataset.cpp index 6b24356..a2c5322 100644 --- a/VectorVisualization/dataset.cpp +++ b/VectorVisualization/dataset.cpp @@ -85,6 +85,7 @@ VectorDataSet::VectorDataSet(void) _vd = new VolumeData(); interpIndex = 0; InterpSize = 1; + currentFrame = 0; } @@ -212,8 +213,9 @@ int VectorDataSet::checkInterpolateStage() //_vd->data = loadTimeStep(getNextTimeStep()); //_vd->newData = loadTimeStep(NextTimeStep()); _vd = _volumeSet.front(); - + _volumeSet.pop_front(); interpIndex = 0; + currentFrame++; } return interpIndex; } @@ -448,7 +450,7 @@ Texture * VectorDataSet::createTextures(int index, const char *texName, GLuint t paddedData = NULL; //_texSet.push_back(*tex); - std::cout << "texSet size: " << _texSet.size() << std::endl; + //std::cout << "texSet size: " << _texSet.size() << std::endl; return tex; } @@ -533,14 +535,14 @@ void* VectorDataSet::fillTexDataFloat(int i) } // adapt the range of the magnitude to [0,1] - //for (int z = 0; z<_vd->size[2]; ++z) - // for (int y = 0; y<_vd->size[1]; ++y) - // for (int x = 0; x<_vd->size[0]; ++x) - // { - // adrPacked = (z*_vd->texSize[1] + y)*_vd->texSize[0] + x; - // len = padded[4 * adrPacked + 3] / maxLen; - // padded[4 * adrPacked + 3] = (len > 1.0f) ? 1.0f : ((len < 0.0f) ? 0.0f : len); - // } + for (int z = 0; z<_vd->size[2]; ++z) + for (int y = 0; y<_vd->size[1]; ++y) + for (int x = 0; x<_vd->size[0]; ++x) + { + adrPacked = (z*_vd->texSize[1] + y)*_vd->texSize[0] + x; + len = padded[4 * adrPacked + 3] / maxLen; + padded[4 * adrPacked + 3] = (len > 1.0f) ? 1.0f : ((len < 0.0f) ? 0.0f : len); + } return padded; } @@ -553,7 +555,8 @@ void* VectorDataSet::fillTexDataFloatInterp() int adr; int adrPacked; float len; - float maxLen = -1.0; + //float maxLen = -1.0; + _vd->max_magnetic = -1.0; unsigned char *dataU = (unsigned char*)_vd->data; unsigned char *dataNextU = (unsigned char*)_vd->newData; @@ -628,8 +631,8 @@ void* VectorDataSet::fillTexDataFloatInterp() } } - if (len > maxLen) - maxLen = len; + if (len > _vd->max_magnetic) + _vd->max_magnetic = len; // store magnitude as float for higher precision padded[4 * adrPacked + 3] = len; @@ -643,7 +646,7 @@ void* VectorDataSet::fillTexDataFloatInterp() for (int x = 0; x<_vd->size[0]; ++x) { adrPacked = (z*_vd->texSize[1] + y)*_vd->texSize[0] + x; - len = padded[4 * adrPacked + 3] / maxLen; + len = padded[4 * adrPacked + 3] / _vd->max_magnetic; padded[4 * adrPacked + 3] = (len > 1.0f) ? 1.0f : ((len < 0.0f) ? 0.0f : len); } @@ -753,7 +756,7 @@ void* VectorDataSet::fillTexDataCharInterp() int adr; int adrPacked; float len; - float maxLen = -1.0; + _vd->max_magnetic = -1.0; float *magnitude = new float[size]; @@ -824,8 +827,8 @@ void* VectorDataSet::fillTexDataCharInterp() } } - if (len > maxLen) - maxLen = len; + if (len > _vd->max_magnetic) + _vd->max_magnetic = len; // store magnitude as float for higher precision magnitude[adrPacked] = len; @@ -839,7 +842,7 @@ void* VectorDataSet::fillTexDataCharInterp() for (int x = 0; x<_vd->size[0]; ++x) { adrPacked = (z*_vd->texSize[1] + y)*_vd->texSize[0] + x; - len = magnitude[adrPacked] / maxLen * UCHAR_MAX; + len = magnitude[adrPacked] / _vd->max_magnetic * UCHAR_MAX; padded[4 * adrPacked + 3] = (unsigned char)((len > 255.0f) ? 255 : ((len < 0.0f) ? 0 : len)); } diff --git a/VectorVisualization/dataset.h b/VectorVisualization/dataset.h index cb1e75d..e44c838 100644 --- a/VectorVisualization/dataset.h +++ b/VectorVisualization/dataset.h @@ -30,6 +30,7 @@ struct VolumeData scale[0] = scale[1] = scale[2] = scale[3] = 1.0f; scaleInv[0] = scaleInv[1] = scaleInv[2] = scaleInv[3] = 1.0f; center[0] = center[1] = center[2] = 0.0f; + max_magnetic = -1.0f; } VolumeData(const VolumeData& obj) :data(obj.data), newData(obj.newData), @@ -51,6 +52,8 @@ struct VolumeData scale[0] = obj.scale[0]; scale[1] = obj.scale[1]; scale[2] = obj.scale[2]; scale[3] = obj.scale[3]; scaleInv[0] = obj.scaleInv[0]; scaleInv[1] = obj.scaleInv[1]; scaleInv[2] = obj.scaleInv[2]; scaleInv[3] = obj.scaleInv[3]; center[0] = obj.center[0]; center[1] = obj.center[1]; center[2] = obj.center[2]; + + max_magnetic = obj.max_magnetic; } ~VolumeData(void); @@ -68,6 +71,7 @@ struct VolumeData float extent[3]; float scale[4]; float scaleInv[4]; + float max_magnetic; float center[3]; }; @@ -153,10 +157,9 @@ class VectorDataSet : public DataSet void setInterpolateSize(int size) { InterpSize = size; }; void increaseInterpIndex() { interpIndex++; } - void setVolumeDataIndex(int i) - { - _vd = _volumeSet[i]; - } + int getInterpIndex() { return interpIndex; } + int getInterpIndexNext() { return (interpIndex < InterpSize ) ? interpIndex + 1 : 0; } + void setVolumeDataIndex(int i) { _vd = _volumeSet[i]; } protected: private: @@ -180,6 +183,7 @@ class VectorDataSet : public DataSet //Interpolate step Index int interpIndex; int InterpSize; + int currentFrame; }; diff --git a/VectorVisualization/reader.cpp b/VectorVisualization/reader.cpp index fe2d03e..905b9f7 100644 --- a/VectorVisualization/reader.cpp +++ b/VectorVisualization/reader.cpp @@ -67,7 +67,7 @@ DatFile::DatFile(void) _sizes[0] = _sizes[1] = _sizes[2] = 0; _dists[0] = _dists[1] = _dists[2] = 1.0f; - _timestep = _timeStepBeg; + _timestep = 0; } @@ -202,7 +202,7 @@ bool DatFile::parseDatFile(char *datFileName) "(%d-%d).\n", _timeStepEnd, _timeStepBeg); return false; } - _timestep = _timeStepBeg; + _timestep = 0; } else { @@ -326,11 +326,11 @@ void DatFile::parseDataDim(char *line) int DatFile::getNextTimeStep() { - _timestep = ( _timestep == _timeStepEnd ) ? _timeStepBeg : _timestep + 1; + _timestep = ( _timestep == _timeStepEnd - _timeStepBeg) ? 0 : _timestep + 1; return _timestep; } int DatFile::NextTimeStep() { - return (_timestep == _timeStepEnd) ? _timeStepBeg : _timestep + 1; + return (_timestep == _timeStepEnd - _timeStepBeg) ? 0 : _timestep + 1; } \ No newline at end of file diff --git a/VectorVisualization/renderer.cpp b/VectorVisualization/renderer.cpp index 454918c..be11348 100644 --- a/VectorVisualization/renderer.cpp +++ b/VectorVisualization/renderer.cpp @@ -32,7 +32,7 @@ Renderer::Renderer(void) : _framebuffer(0), _depthbuffer(0), _stencilbuffer(0), _winWidth(1), _winHeight(1), _useFBO(false), _renderMode(VOLIC_RAYCAST), _vd(NULL), _licFilter(NULL), -_dataTex(NULL), _noiseTex(NULL), _licKernelTex(NULL), _scalarTex(NULL), +_dataTex(NULL), _nextDataTex(NULL), _noiseTex(NULL), _licKernelTex(NULL), _scalarTex(NULL), _lambda2Tex(NULL), _tfRGBTex(NULL), _tfAlphaOpacTex(NULL), _illumZoecklerTex(NULL), _illumMalloDiffTex(NULL), _illumMalloSpecTex(NULL), _quadric(NULL), _storeFrame(true), @@ -941,7 +941,11 @@ void Renderer::setRenderVolParams(GLSLParamsLIC *param) if (param->scaleVol > -1) glUniform4fvARB(param->scaleVol, 1, _vd->scale); if (param->scaleVolInv > -1) - glUniform4fvARB(param->scaleVol, 1, _vd->scaleInv); + glUniform4fvARB(param->scaleVolInv, 1, _vd->scaleInv); + CHECK_FOR_OGL_ERROR(); + + if (param->maxVectorLength > -1) + glUniform1fARB(param->maxVectorLength, _vd->max_magnetic); CHECK_FOR_OGL_ERROR(); if (_lowRes) @@ -1011,6 +1015,12 @@ void Renderer::setRenderVolTextures(GLSLParamsLIC *param) glUniform1iARB(param->volumeSampler, _dataTex->texUnit - GL_TEXTURE0_ARB); _dataTex->bind(); } + if (param->volumeSamplerNext > -1) + { + _nextDataTex->texUnit = GL_TEXTURE12_ARB; + glUniform1iARB(param->volumeSamplerNext, _nextDataTex->texUnit - GL_TEXTURE0_ARB); + _nextDataTex->bind(); + } if (param->licVolumeSampler > -1) { glUniform1iARB(param->licVolumeSampler, _licvolumebuffer->getCurrentLayer()->texUnit - GL_TEXTURE0_ARB); @@ -1359,6 +1369,10 @@ void Renderer::renderLICVolume(void) //render volume to 3D Texture _licvolumebuffer->drawSlice((z + 0.5f) / (float)depth); } + + _dataTex->unbind(); + _nextDataTex->unbind(); + _volumeRenderShader.disableShader(); // restore old clear color @@ -1399,13 +1413,16 @@ void Renderer::raycastLICVolume(void) setRenderVolParams(&_paramLicRaycast); setRenderVolTextures(&_paramLicRaycast); - + + CHECK_FOR_OGL_ERROR(); drawCubeFaces(); + CHECK_FOR_OGL_ERROR(); drawClippedPolygon(); CHECK_FOR_OGL_ERROR(); - + _licvolumebuffer->getCurrentLayer()->unbind(); + _licvolumebuffer->getOldLayer()->unbind(); _dataTex->unbind(); _tfRGBTex->unbind(); _tfAlphaOpacTex->unbind(); diff --git a/VectorVisualization/renderer.h b/VectorVisualization/renderer.h index 39ae73d..29082a4 100644 --- a/VectorVisualization/renderer.h +++ b/VectorVisualization/renderer.h @@ -86,6 +86,7 @@ class Renderer bool isDebugModeEnabled(void) { return _debug; } void setDataTex(Texture *tex) { _dataTex = tex; } + void setNextDataTex(Texture *tex) { _nextDataTex = tex; } void setScalarTex(Texture *tex) { _scalarTex = tex; } void setNoiseTex(Texture *tex) { _noiseTex = tex; } void setLICFilterTex(Texture *tex) { _licKernelTex = tex; } @@ -261,6 +262,7 @@ class Renderer // vector data Texture *_dataTex; + Texture *_nextDataTex; Texture *_scalarTex; Texture *_noiseTex; // LIC filter kernel diff --git a/VectorVisualization/shader/background_fragment.glsl b/VectorVisualization/shader/background_fragment.glsl index bfd5435..c183901 100644 --- a/VectorVisualization/shader/background_fragment.glsl +++ b/VectorVisualization/shader/background_fragment.glsl @@ -6,7 +6,7 @@ uniform sampler2DRect imageFBOSampler; void main(void) { - vec4 bgColor = vec4(1.0, 1.0, 1.0, 1.0); + vec4 bgColor = vec4(1.0, 1.0, 1.0, 0.0); // look up color from previous render pass vec4 dest = texture2DRect(imageFBOSampler, gl_FragCoord.xy*viewport.xy); diff --git a/VectorVisualization/shader/inc_header.glsl b/VectorVisualization/shader/inc_header.glsl index 5a4c949..87f39bb 100644 --- a/VectorVisualization/shader/inc_header.glsl +++ b/VectorVisualization/shader/inc_header.glsl @@ -41,10 +41,13 @@ uniform vec3 licKernel; // kernel step width forward (0.5/licParams.x), uniform float timeStep; +uniform float maxVectorLength; + // textures (have to be uniform) uniform sampler3D volumeSampler; +uniform sampler3D volumeSamplerNext; uniform sampler3D scalarSampler; uniform sampler3D noiseSampler; diff --git a/VectorVisualization/shader/inc_lic.glsl b/VectorVisualization/shader/inc_lic.glsl index 7cfaa28..d13f1da 100644 --- a/VectorVisualization/shader/inc_lic.glsl +++ b/VectorVisualization/shader/inc_lic.glsl @@ -63,23 +63,30 @@ vec4 freqSamplingGrad(in vec3 pos, out float logEyeDist) //vec3 objPos = pos * scaleVolInv.xyz; //vec4 tmp = noiseLookupGrad(pos, gradient.z, logEyeDist); - return texture3D(noiseSampler, pos); - //return noiseLookupGrad(pos, gradient.z, logEyeDist); + // return texture3D(noiseSampler, pos); + return noiseLookupGrad(pos, gradient.z, logEyeDist); } -float freqSampling(in vec3 pos, out float logEyeDist) +float freqSampling(in vec3 pos, out float logEyeDist, in sampler3D vectorVolume = volumeSampler) { //vec3 objPos = pos * scaleVolInv.xyz; //Use scalar data to decide noise range to be integrated - vec4 vectorData = texture3D(volumeSampler, pos); + vec4 vectorData = texture3D(vectorVolume, pos); vec4 scalarData = texture3D(scalarSampler, pos); //float scala = length(vectorData.xyz); //if (scalarData.r > 0.1 && scalarData.r < 0.3) - //if (true) - if (vectorData.a > 0.45 && vectorData.a < 1.6) + + // one example of visualize range: magnetic_field (magnitude 7.0 ~ max) + float minRange = 6.0; + float maxRange = 15.0; + //magnitude range equation + //if (vectorData.a > minRange/maxVectorLength && vectorData.a < maxRange/maxVectorLength) + // g component range equation: map to 0 ~ 1.0, 0 is 0.5 + //if (vectorData.b > ( 0.5 * minRange/maxVectorLength + 0.5) && vectorData.b < ( 0.5 * maxRange/maxVectorLength + 0.5)) + if (true) { //return texture3D(noiseSampler, pos).a return texture3D(noiseSampler, pos*gradient.z).a; @@ -93,13 +100,15 @@ float freqSampling(in vec3 pos, out float logEyeDist) #ifdef USE_NOISE_GRADIENTS vec4 singleLICstep(in vec3 licdir, in out vec3 newPos, in out vec4 step, in float kernelOffset, - in out float logEyeDist, in float dir) + in out float logEyeDist, in float dir, + in sampler3D vectorVolume = volumeSampler) { vec4 noise; #else float singleLICstep(in vec3 licdir, in out vec3 newPos, in out vec4 step, in float kernelOffset, - in out float logEyeDist, in float dir) + in out float logEyeDist, in float dir, + in sampler3D vectorVolume = volumeSampler) { float noise; #endif @@ -113,7 +122,7 @@ float singleLICstep(in vec3 licdir, in out vec3 newPos, // also correct length according to camera distance licdir *= licParams.z * (logEyeDist*0.5 + 0.3); vec3 Pos2 = newPos + licdir; - vec4 step2 = texture3D(volumeSampler, Pos2); + vec4 step2 = texture3D(vectorVolume, Pos2); vec3 licdir2 = 2.0*step2.rgb - 1.0; licdir2 *= dir; //licdir2 = step2.rgb; @@ -125,7 +134,7 @@ float singleLICstep(in vec3 licdir, in out vec3 newPos, newPos += 0.5 * (licdir + licdir2); //newPos += 0.3 * licdir; - step = texture3D(volumeSampler, newPos); + step = texture3D(vectorVolume, newPos); #ifdef TIME_DEPENDENT vectorFieldSample2 = texture3D(volumeSampler2, newPos); step = mix(timeStep, step, vectorFieldSample2); @@ -149,7 +158,7 @@ float singleLICstep(in vec3 licdir, in out vec3 newPos, // performs the LIC computation for n steps forward and backward // pos determines the starting position of the LIC // vectorFieldSample is the value of the vector field at this position -vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample) +vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample, out vec2 streamDis, out vec3 streamStart, out vec3 streaEnd, in sampler3D vectorVolume = volumeSampler) { vec3 licdir; float logEyeDist; @@ -162,7 +171,7 @@ vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample) #ifdef USE_NOISE_GRADIENTS vec4 noise; - vec4 illum = freqSamplingGrad(pos, logEyeDist); + vec4 illum = freqSamplingGrad(pos, logEyeDist, vectorVolume); #else float noise; float illum = freqSampling(pos, logEyeDist); @@ -175,15 +184,20 @@ vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample) // backward LIC vec3 newPos = pos; vec4 step = vectorFieldSample; + float streamlineL = 0.0; + float sumCross = 0.0; for (int i=0; i 0.05) - if (scalarData.g > -0.0001) - //if (scalarData.g > 0.01 && scalarData.g < 0.15) + //if (scalarData.g > 0.0001) + //if (scalarData.g > 0.31 && scalarData.g < 0.35) + if(vectorData.a > 0.5 && vectorData.a < 0.75) { // compute the LIC integral - illum = computeLIC(pos, vectorData); + vec3 streamStart; + vec3 streamEnd; + vec2 streamDis; + //illum = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd); + + vec3 center = vec3(0.0, 0.0, 0.0); + vec3 centerB = vec3(0.7, 0.7, 0.7); + //vec3 center = pos * 8; + //center = vec3(int(center.x)/8.0, int(center.y)/8.0, int(center.z)/8.0); + +#if defined(STREAMLINE_DISTANCE) + float strDis = computeStreamlineDis(pos, center); + //float strDisB = computeStreamlineDis(pos, centerB); + dis += strDis; + illum.a = cos(strDis*256) - 0.5; + if(illum.a > 0.0) + illum.a = 1.0; + //tfData = texture1D(transferRGBASampler, strDis); +#else + illum = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd); +#endif + //tfData = vec4(vectorData.rgb, 1.0); + + oldPos = pos; // scale LIC intensity illum.a *= licKernel.b * gradient.r; @@ -95,5 +128,6 @@ void main(void) } #endif + dest = clamp((1.0-dest.a)*bgColor + dest, 0.0, 1.0); // make up to white background gl_FragColor = dest; } diff --git a/VectorVisualization/shader/lic3d_slicing_fragment.glsl b/VectorVisualization/shader/lic3d_slicing_fragment.glsl index 3ecd63e..c140a21 100644 --- a/VectorVisualization/shader/lic3d_slicing_fragment.glsl +++ b/VectorVisualization/shader/lic3d_slicing_fragment.glsl @@ -46,7 +46,11 @@ void main(void) if (tfData.a > 0.05) { // compute the LIC integral - illum = computeLIC(pos, vectorData); + vec3 streamStart; + vec3 streamEnd; + vec2 streamDis; + illum = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd); + //illum = computeLIC(pos, vectorData); // scale LIC intensity illum.a *= licKernel.b * gradient.r; diff --git a/VectorVisualization/shader/lic3d_slicingblend_fragment.glsl b/VectorVisualization/shader/lic3d_slicingblend_fragment.glsl index 91fa0d3..835e2e4 100644 --- a/VectorVisualization/shader/lic3d_slicingblend_fragment.glsl +++ b/VectorVisualization/shader/lic3d_slicingblend_fragment.glsl @@ -43,7 +43,11 @@ void main(void) if (tfData.a > 0.05) { // compute the LIC integral - illum = computeLIC(pos, vectorData); + vec3 streamStart; + vec3 streamEnd; + vec2 streamDis; + illum = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd); + //illum = computeLIC(pos, vectorData); // scale LIC intensity illum.a *= licKernel.b * gradient.r; diff --git a/VectorVisualization/shader/lic3d_volume_fragment.glsl b/VectorVisualization/shader/lic3d_volume_fragment.glsl index 4a526c6..289d97b 100644 --- a/VectorVisualization/shader/lic3d_volume_fragment.glsl +++ b/VectorVisualization/shader/lic3d_volume_fragment.glsl @@ -1,4 +1,3 @@ - void main(void) { vec4 geomPos = gl_TexCoord[0]; @@ -6,14 +5,25 @@ void main(void) // lookup scalar value vec4 scalarData = texture3D(scalarSampler, pos); vec4 vectorData = texture3D(volumeSampler, pos); + vec4 vectorDataNext = texture3D(volumeSamplerNext, pos); vec4 illum = vec4(0.0, 0.0, 0.0, 1.0); //if(pos.x < 0.5 && pos.y > 0.5) { - illum.r = computeLIC(pos, vectorData).r; + vec3 streamStart; + vec3 streamEnd; + vec2 streamDis; + illum.r = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd, volumeSampler).r; // scale LIC intensity illum.r *= licKernel.b * gradient.r; - //illum = vec4(pos, 1); + + illum.g = computeLIC(pos, vectorDataNext, streamDis, streamStart, streamEnd, volumeSamplerNext).r; + // scale LIC intensity + illum.g *= licKernel.b * gradient.r; + + //if (vectorData.g == vectorDataNext.g) + //if (illum.r == illum.g) + //illum.b = 1.0; } gl_FragColor = illum; diff --git a/VectorVisualization/shader/raycast_lic3d_fragment.glsl b/VectorVisualization/shader/raycast_lic3d_fragment.glsl index 1be46e9..4d920d2 100644 --- a/VectorVisualization/shader/raycast_lic3d_fragment.glsl +++ b/VectorVisualization/shader/raycast_lic3d_fragment.glsl @@ -11,6 +11,7 @@ void main(void) vec4 data; vec4 tfData; vec4 noise; + vec4 bgColor = vec4(1.0, 1.0, 1.0, 0.0); // compute the ray starting point vec4 geomPos = gl_TexCoord[0]; @@ -45,22 +46,29 @@ void main(void) vectorData = texture3D(volumeSampler, pos); volumeData = texture3D(licVolumeSampler, pos); - volumeDataOld = texture3D(licVolumeSamplerOld, pos); + //volumeDataOld = texture3D(licVolumeSamplerOld, pos); float intensity = volumeData.r; - intensity = volumeDataOld.r*(1-interpStep) + volumeData.r * interpStep; - //volumeData = volumeDataMix; - //if(volumeData == volumeDataOld) - //intensity = interpStep; + //intensity = mix(volumeData.r, volumeData.g, interpStep); //noise = texture3D(noiseSampler, pos); // lookup in transfer function - tfData = texture1D(transferRGBASampler, vectorData.z); - - //src = vec4(tfData.xyz, volumeData.a); - //src = vec4(noise.xyz, data.a); - src = illumLIC(intensity, tfData); + //tfData = texture1D(transferRGBASampler, vectorData.z); + tfData = vec4(vectorData.rgb, 1.0); + + + #if defined(ILLUM_GRADIENT) + src = illumGradient(volumeData, tfData, pos, dir, vectorData.xyz); +#elif defined(ILLUM_MALLO) + src = illumMallo(intensity, tfData, pos, dir, vectorData.xyz); +#elif defined(ILLUM_ZOECKLER) + src = illumZoeckler(intensity, tfData, pos, dir, vectorData.xyz); +#else + // -- standard LIC -- + src = illumLIC(intensity, tfData); +#endif + //src = illumLIC(intensity, tfData); //src = volumeData; // perform blending @@ -79,7 +87,7 @@ void main(void) break; } } - + dest = clamp((1.0-dest.a)*bgColor + dest, 0.0, 1.0); gl_FragColor = dest; //gl_FragColor = vec4(texture1D(transferRGBASampler, pos.x).rgb, 0.5); } diff --git a/VectorVisualization/texture.h b/VectorVisualization/texture.h index 9ba9b24..1201f55 100644 --- a/VectorVisualization/texture.h +++ b/VectorVisualization/texture.h @@ -57,6 +57,7 @@ struct Texture { //glEnable(texTarget); glActiveTextureARB(texUnit); + glBindTexture(texTarget, 0); glBindTexture(texTarget, id); } void unbind(void) diff --git a/VectorVisualization/types.h b/VectorVisualization/types.h index dc44c2a..923d09b 100644 --- a/VectorVisualization/types.h +++ b/VectorVisualization/types.h @@ -84,10 +84,10 @@ enum MouseMode struct LICParams { - LICParams(void) : stepSizeVol(1.0f / 128.0f), gradientScale(30.0f), - illumScale(1.0f), freqScale(1.0f), + LICParams(void) : stepSizeVol(1.0f / 256.0f), gradientScale(30.0f), + illumScale(1.0f), freqScale(0.6f), numIterations(255), - stepsForward(32), stepsBackward(32), + stepsForward(48), stepsBackward(48), stepSizeLIC(0.01f), interpSize(1), interpStep(0) {} From dc957b540d32615b927c3e7cb6da305d640c376f Mon Sep 17 00:00:00 2001 From: Yangguang Date: Wed, 21 Mar 2018 18:45:53 -0700 Subject: [PATCH 3/7] update ignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 52f0df3..8b75d51 100644 --- a/.gitignore +++ b/.gitignore @@ -246,3 +246,7 @@ ModelManifest.xml /noise /VectorVisualization/snapshotOut /VectorVisualization/video +*.html +*.csv +/VectorVisualization/glew-1.11.0 +/VectorVisualization/lib From aaafe2009554f159056bfd3725c8c455a8acd3e2 Mon Sep 17 00:00:00 2001 From: Yangguang Date: Wed, 21 Mar 2018 18:51:07 -0700 Subject: [PATCH 4/7] CPU LIC, LAO, volume buffer.. Update on 21st March: CPU based LIC precomputation LAO estimation Phong shading and ambient occlusion for GPU precomputation animation LIC scattering --- VectorVisualization/3DLIC.cpp | 42 +- VectorVisualization/3DLIC.h | 6 +- VectorVisualization/CPULIC.cpp | 416 +++++++++++++++++ VectorVisualization/CPULIC.h | 52 +++ VectorVisualization/GLSLShader.cpp | 51 +- VectorVisualization/GLSLShader.h | 11 + VectorVisualization/VolumeBuffer.cpp | 68 ++- VectorVisualization/VolumeBuffer.h | 9 +- VectorVisualization/dataset.cpp | 12 +- VectorVisualization/renderer.cpp | 438 +++++++++++++++++- VectorVisualization/renderer.h | 25 + .../shader/computer_volume.glsl | 7 + VectorVisualization/shader/inc_header.glsl | 3 + VectorVisualization/shader/inc_illum.glsl | 18 +- VectorVisualization/shader/inc_lic.glsl | 185 ++++++-- .../shader/lic3d_fragment.glsl | 42 +- .../shader/lic3d_lao_fragment.glsl | 87 ++++ .../shader/lic3d_normal_fragment.glsl | 17 + .../shader/lic3d_scattering_fragment.glsl | 45 ++ .../shader/lic3d_volume_fragment.glsl | 29 +- .../shader/raycast_lic3d_fragment.glsl | 51 +- .../shader/vectorfield_fragment.glsl | 6 +- VectorVisualization/types.h | 19 +- 23 files changed, 1516 insertions(+), 123 deletions(-) create mode 100644 VectorVisualization/CPULIC.cpp create mode 100644 VectorVisualization/CPULIC.h create mode 100644 VectorVisualization/shader/computer_volume.glsl create mode 100644 VectorVisualization/shader/lic3d_lao_fragment.glsl create mode 100644 VectorVisualization/shader/lic3d_normal_fragment.glsl create mode 100644 VectorVisualization/shader/lic3d_scattering_fragment.glsl diff --git a/VectorVisualization/3DLIC.cpp b/VectorVisualization/3DLIC.cpp index dd5d5a8..398b91f 100644 --- a/VectorVisualization/3DLIC.cpp +++ b/VectorVisualization/3DLIC.cpp @@ -416,10 +416,14 @@ void keyboard(unsigned char key, int x, int y) //renderer.updateLICVolume(); updateScene = true; break; - case '`': + case '-': renderer.loadGLSLShader("#define STREAMLINE_DISTANCE"); updateScene = true; break; + case '=': + renderer.loadGLSLShader("#define AMBIENT_OCCULUSION"); + updateScene = true; + break; // clip planes case '1': @@ -499,7 +503,9 @@ void keyboardSpecial(int key, int x, int y) renderer.setDataTex(vd.getTextureSetRef(vd.getCurTimeStep())); renderer.setNextDataTex(vd.getTextureSetRef(vd.NextTimeStep())); renderer.renderLICVolume(); - renderer.updateLICVolume(); + renderer.computeVolumeNormal(); + //renderer.updateLICVolume(); + renderer.computeLAOVolume(); //renderer.updateLICVolume(); break; case GLUT_KEY_F5: @@ -517,6 +523,10 @@ void keyboardSpecial(int key, int x, int y) } //renderer.updateLICVolume(); break; + case GLUT_KEY_F6: + renderTechnique = VOLIC_SCATTER; + renderer.setDataTex(vd.getTextureRef()); + break; } renderer.setTechnique(renderTechnique); updateHUD(); @@ -629,7 +639,7 @@ void mouseMotionInteract(int x, int y) if (mouseBtnDown) { // change to low res mode immediately - //renderer.enableLowRes(true); + renderer.enableLowRes(true); //requestHighRes = false; mouseBtnDown = false; @@ -832,6 +842,18 @@ void init(void) CHECK_FOR_OGL_ERROR(); //std::cout << std::endl; + //Test of Algorithm using CPU for instance + //cpuLic = new CPULIC(256, 256, 256); + //cpuLic->setkernelData(licFilter.getFilterData()); + //cpuLic->setVectorTexture((vd.getTextureSet())[1]); + //cpuLic->getVectorTextureData(); + //cpuLic->setNoiseData(&noise); + //cpuLic->getNoiseTextureData(); + ////cpuLic->gather3DLIC(vd.getVolumeDataSet()); + //cpuLic->scatter3DLIC(vd.getVolumeDataSet()); + //cpuLic->generateTexture(); + CHECK_FOR_OGL_ERROR(); + clipPlanes[0].rotate(Quaternion_fromAngleAxis(static_cast(M_PI / 2.0), Vector3_new(0.0f, 1.0f, 0.0f))); clipPlanes[1].rotate(Quaternion_fromAngleAxis(static_cast(M_PI / 2.0), Vector3_new(-1.0f, 0.0f, 0.0f))); @@ -855,8 +877,10 @@ void init(void) renderer.setVolumeData(vd.getVolumeData()); renderer.setLICFilter(&licFilter); - //renderer.setDataTex(vd.getTextureRef()); - renderer.setDataTex(vd.getTextureSetRef(vd.getCurTimeStep())); + renderer.setDataTex(vd.getTextureRef()); + //renderer.setDataTex(cpuLic->getTextureRef()); + //renderer.setDataTex(noise.getTextureRef()); + //renderer.setDataTex(vd.getTextureSetRef(vd.getCurTimeStep())); renderer.setNextDataTex(vd.getTextureSetRef(vd.NextTimeStep())); renderer.setScalarTex(scalar.getTextureRef()); renderer.setNoiseTex(noise.getTextureRef()); @@ -867,12 +891,20 @@ void init(void) renderer.setIllumMalloSpecTex(illum.getTexMalloSpecular()); renderer.setLICParams(&licParams); + renderer.setLAOParams(&laoParams); + + //compute once noise LAO + renderer.loadGLSLShader("#define NOISE_LAO_COMPUTE"); + renderer.computeNoiseLAO(); + renderer.loadGLSLShader(); //renderer.renderLICVolume(); //renderer.updateLICVolume(); CHECK_FOR_OGL_ERROR(); renderer.updateLightPos(); renderer.updateSlices(); + + } void initMultiThread(void) diff --git a/VectorVisualization/3DLIC.h b/VectorVisualization/3DLIC.h index 342cc77..40ecad9 100644 --- a/VectorVisualization/3DLIC.h +++ b/VectorVisualization/3DLIC.h @@ -8,6 +8,7 @@ #include "fpsCounter.h" #include "dataSet.h" #include "parseArg.h" +#include "CPULIC.h" HDC dc; HGLRC glrc_main; @@ -30,6 +31,8 @@ LICFilter licFilter; OpenGLHUD hud; +CPULIC *cpuLic; + int mousePosOld[2]; // TODO: delete global variables @@ -52,10 +55,11 @@ bool useIdle = true; double lowResTimer = 0.0; -RenderTechnique renderTechnique = VOLIC_VOLUME; +RenderTechnique renderTechnique = VOLIC_RAYCAST; bool animationMode = false; MouseMode mouseMode; LICParams licParams; +LAOParams laoParams; void display(void); void resize(int width, int height); diff --git a/VectorVisualization/CPULIC.cpp b/VectorVisualization/CPULIC.cpp new file mode 100644 index 0000000..2a66585 --- /dev/null +++ b/VectorVisualization/CPULIC.cpp @@ -0,0 +1,416 @@ +#include "CPULIC.h" + +#include +#include +#include +#include + +inline int getoffset(int x, int y, int z, int* size) +{ + x = x < size[0] ? x : size[0] - 1; + y = y < size[1] ? y : size[1] - 1; + z = z < size[2] ? z : size[2] - 1; + return x * size[0] * size[1] + y * size[0] + z; +} + +CPULIC::CPULIC(int w, int h, int d) +{ + width = w; + height = h; + depth = d; + + int size = width * height * depth; + + data = new float[size]; + std::fill_n(data, size, 0); + + iterNum = 30; + stepSize = 1.0 / width; + + createFilter(); +} + + +CPULIC::~CPULIC() +{ +} + +Vector3 CPULIC::textureSample(int timestep, Vector3 pos, std::deque& vds) +{ + if (vds.size() == 0) + return Vector3_new(0,0,0); + VolumeData* vd = vds[timestep]; + int x = pos.x * vd->size[0]; + int y = pos.y * vd->size[1]; + int z = pos.z * vd->size[2]; + int offset = z * vd->size[0] * vd->size[1] + y * vd->size[0] + x; + //Vector3 dir = ((Vector3*)(vd->data))[offset]; + float* vector4 = (float*)(vtdata + offset * 4 * 4); + Vector3 res = Vector3_new(vector4[0], vector4[1], vector4[2]); + return res; +} + +inline float clip(float &n, float lower, float upper) +{ + return max(lower, min(n, upper)); +} + +Vector3 CPULIC::streamlineforward(Vector3 pos, int timestep, std::deque& vds) +{ + Vector3 dir = textureSample(timestep, pos, vds); + dir = Vector3_smult(2, dir); + dir = Vector3_sub(dir, Vector3_new(1, 1, 1)); + //std::cout << dir.x << " " << dir.y << " " << dir.z << " " << std::endl; + pos = Vector3_add(pos, Vector3_smult(stepSize, dir)); + clip(pos.x, 0, 1); + clip(pos.y, 0, 1); + clip(pos.z, 0, 1); + return pos; +} + +Vector3 CPULIC::streamlinebackward(Vector3 pos, int timestep, std::deque& vds) +{ + Vector3 dir = textureSample(timestep, pos, vds); + dir = Vector3_smult(-2, dir); + dir = Vector3_add(dir, Vector3_new(1, 1, 1)); + //if (Vector3_normalize(&dir) > 0) + //std::cout << dir.x << " " << dir.y << " " << dir.z << " " << std::endl; + pos = Vector3_sub(pos, Vector3_smult(stepSize, dir)); + return pos; +} + +float CPULIC::getNoise( int offset) +{ + unsigned char* data_value = (nsdata + offset * 4); + return data_value[3] / 256.0; +} + +float CPULIC::NoiseSample(Vector3 pos) +{ + if (noise == nullptr) + return 0; + VolumeData* nvd = noise->getVolumeData(); + float x = pos.x * nvd->size[0]; + float y = pos.y * nvd->size[1]; + float z = pos.z * nvd->size[2]; + int x0 = int(x); + int y0 = int(y); + int z0 = int(z); + float xd = x - x0; + float yd = y - y0; + float zd = z - z0; + int c000 = getoffset(x0, y0, z0, nvd->size); + int c001 = getoffset(x0, y0, z0+1, nvd->size); + int c010 = getoffset(x0, y0+1, z0, nvd->size); + int c011 = getoffset(x0, y0+1, z0+1, nvd->size); + int c100 = getoffset(x0+1, y0, z0, nvd->size); + int c101 = getoffset(x0+1, y0, z0+1, nvd->size); + int c110 = getoffset(x0+1, y0+1, z0, nvd->size); + int c111 = getoffset(x0+1, y0 + 1, z0 + 1, nvd->size); + float c00 = getNoise(c000) * (1 - xd) + getNoise(c100) * xd; + float c01 = getNoise(c001) * (1 - xd) + getNoise(c101) * xd; + float c10 = getNoise(c010) * (1 - xd) + getNoise(c110) * xd; + float c11 = getNoise(c011) * (1 - xd) + getNoise(c111) * xd; + float c0 = c00*(1 - yd) + c10*yd; + float c1 = c01*(1 - yd) + c11*yd; + float c = c0 * (1 - zd) + c1*zd; + ////int offset = z0 * nvd->size[0] * nvd->size[1] + y0 * nvd->size[0] + x0; + ////unsigned char data_value = *((unsigned char*)nvd->data + c000); + return c; + //return getNoise(c000); +} + +void CPULIC::createFilter() +{ + double stdv = 2.5; + double mean = 127.5; + double s = 2 * stdv * stdv; + double sum = 0; + for (int i = 0; i < 256; i++) + { + filter[i] = (exp(-(i - mean)* (i - mean) / s)) / sqrt(M_PI * s); + sum += filter[i]; + } + if (sum > 0.5) + for (int i = 0; i < 15; i++) + filter[i] = filter[i] * 0.5 / sum; + +} + +float CPULIC::kernel(float offset) +{ + int index = (0.5 + 0.5 * offset)*255; + return _filterData[index]*1.0/255; + //return filter[index]; +} + +bool CPULIC::outofSpace(Vector3 pos) +{ + if (pos.x < 0 || pos.y < 0 || pos.z < 0) + return true; + else if (pos.x >= 1 || pos.y >= 1 || pos.z >= 1) + return true; + else + return false; +} + +void CPULIC::gather3DLIC(std::deque& vds) +{ + for (int i = 0; i < width; i++) + { + for (int j = 0; j < height; j++) + { + for (int k = 0; k < depth; k++) + { + int index = (i * width + j) * height + k; + Vector3 pos = Vector3_new(float(i) / width, float(j) / height, float(k) / depth); + float value = 0.0; + Vector3 dir = textureSample(0, pos, vds); + + if (dir.x == 0.5 && dir.y == 0.5 && dir.z == 0.5) + { + data[index] = 0; + continue; + } + //else + /*{ + data[index] = dir.x; + continue; + }*/ + value += NoiseSample(pos) * kernel(0); + //forward + Vector3 newPos = pos; + for (int itr = 0; itr < iterNum; itr++) + { + newPos = streamlineforward(newPos, itr, vds); + if (outofSpace(newPos)) + break; + float offset = 1.0 * itr / iterNum; + value += NoiseSample(newPos) * kernel(offset); + } + //backward + newPos = pos; + for (int itr = 0; itr < iterNum; itr++) + { + newPos = streamlinebackward(newPos, itr, vds); + if (outofSpace(newPos)) + break; + float offset = -1.0 * itr / iterNum; + value += NoiseSample(newPos) * kernel(offset); + } + //if (value > 0) + // std::cout << '*'; + //else + // std::cout << '.'; + //if(Vector3_normalize(&dir) > 0) + //value = NoiseSample(pos); + //if (value > 0) + // std::cout << value << std::endl; + data[index] = value/3; + } + //std::cout << std::endl; + } + //std::cout << "------------------------------------" << std::endl; + } + return; +} + +void CPULIC::scatter3DLIC(std::deque& vds) +{ + for (int i = 0; i < width; i++) + { + for (int j = 0; j < height; j++) + { + for (int k = 0; k < depth; k++) + { + int index = (i * width + j) * height + k; + Vector3 pos = Vector3_new(float(i) / width, float(j) / height, float(k) / depth); + float value = 0.0; + Vector3 dir = textureSample(0, pos, vds); + + if (dir.x == 0.5 && dir.y == 0.5 && dir.z == 0.5) + { + continue; + } + //else + /*{ + data[index] = dir.x; + continue; + }*/ + float noise = NoiseSample(pos); + if (noise <= 0) + continue; + data[index] += noise * kernel(0); + //forward + Vector3 newPos = pos; + for (int itr = 0; itr < iterNum; itr++) + { + newPos = streamlineforward(newPos, itr, vds); + if (outofSpace(newPos)) + break; + int x = newPos.x * width; + int y = newPos.y * height; + int z = newPos.z * depth; + index = (x * width + y) * height + z; + float offset = 1.0 * (itr + 1) / iterNum; + data[index] += noise * kernel(offset); + } + //backward + newPos = pos; + for (int itr = 0; itr < iterNum; itr++) + { + newPos = streamlinebackward(newPos, itr, vds); + if (outofSpace(newPos)) + break; + int x = newPos.x * width; + int y = newPos.y * height; + int z = newPos.z * depth; + index = (x * width + y) * height + z; + float offset = -1.0 * (itr + 1) / iterNum; + data[index] += noise * kernel(offset); + } + //if (value > 0) + // std::cout << '*'; + //else + // std::cout << '.'; + //if(Vector3_normalize(&dir) > 0) + //value = NoiseSample(pos); + //if (value > 0) + // std::cout << value << std::endl; + //data[index] = value / 3; + } + //std::cout << std::endl; + } + //std::cout << "------------------------------------" << std::endl; + } + return; +} + +Texture* CPULIC::createTexture(const char *texName, GLuint texUnit, bool floatTex) +{ + GLuint texId; + void *paddedData = NULL; + + Texture * tex = new Texture; + // create a texture id + if (tex->id == 0) + { + glGenTextures(1, &texId); + tex->setTex(GL_TEXTURE_3D, texId, texName); + } + + tex->texUnit = texUnit; + tex->width = width; + tex->height = height; + tex->depth = depth; + +#if FORCE_POWER_OF_TWO_TEXTURE == 1 + if ((_vd->texSize[0] != _vd->size[0]) + || (_vd->texSize[1] != _vd->size[1]) + || (_vd->texSize[2] != _vd->size[2])) + { + fprintf(stderr, "VectorData: Dimensions are not 2^n.\n"); + } +#endif + if (floatTex) + { + _texSrcFmt = GL_FLOAT; + _texIntFmt = GL_LUMINANCE16F_ARB; + + } + else + { + _texSrcFmt = GL_UNSIGNED_BYTE; + _texIntFmt = GL_LUMINANCE; + + } + + tex->format = _texIntFmt; + + glBindTexture(GL_TEXTURE_3D, tex->id); + CHECK_FOR_OGL_ERROR(); + + glTexImage3D(GL_TEXTURE_3D, 0, _texIntFmt, width, height, depth, + 0, GL_LUMINANCE, _texSrcFmt, data); + CHECK_FOR_OGL_ERROR(); + //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + // glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + // glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + CHECK_FOR_OGL_ERROR(); + + return tex; +} + +void CPULIC::generateTexture() +{ + tex = createTexture("CPULIC_Tex", GL_TEXTURE2_ARB); +} + +void CPULIC::getNoiseTextureData() +{ + GLuint noiseTexId = noise->getTextureRef()->id; + glBindTexture(GL_TEXTURE_3D, noiseTexId); + GLint width, height, depth, internalFormat; + glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_COMPONENTS, &internalFormat); // get internal format type of GL texture + glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &width); // get width of GL texture + glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &height); // get height of GL texture + glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &depth); // get depth of GL texture + + GLint numBytes = 0; + switch (internalFormat) // determine what type GL texture has... + { + case GL_RGB: + numBytes = width * height * depth * 3; + break; + case GL_RGBA: + numBytes = width * height *depth * 4; + break; + default: // unsupported type (or you can put some code to support more formats if you need) + break; + } + + if (numBytes) + { + nsdata = (unsigned char*)malloc(numBytes); // allocate image data into RAM + glGetTexImage(GL_TEXTURE_3D, 0, internalFormat, GL_UNSIGNED_BYTE, nsdata); + } + glBindTexture(GL_TEXTURE_3D, 0); +} + +void CPULIC::getVectorTextureData() +{ + GLuint vectorTexId = tex->id; + glBindTexture(GL_TEXTURE_3D, vectorTexId); + GLint width, height, depth, internalFormat; + glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_COMPONENTS, &internalFormat); // get internal format type of GL texture + glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &width); // get width of GL texture + glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &height); // get height of GL texture + glGetTexLevelParameteriv(GL_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &depth); // get depth of GL texture + + GLint numBytes = 0; + switch (internalFormat) // determine what type GL texture has... + { + case GL_RGBA: + numBytes = width * height * depth * 4; + break; + case GL_RGBA16F_ARB: + numBytes = width * height *depth * 4 * 4; + break; + default: // unsupported type (or you can put some code to support more formats if you need) + break; + } + if (numBytes) + { + vtdata = (unsigned char*)malloc(numBytes); // allocate image data into RAM + glGetTexImage(GL_TEXTURE_3D, 0, GL_RGBA, GL_FLOAT, vtdata); + } + CHECK_FOR_OGL_ERROR(); + glBindTexture(GL_TEXTURE_3D, 0); +} diff --git a/VectorVisualization/CPULIC.h b/VectorVisualization/CPULIC.h new file mode 100644 index 0000000..bd4f3b8 --- /dev/null +++ b/VectorVisualization/CPULIC.h @@ -0,0 +1,52 @@ +#pragma once +#include "dataset.h" +#include "mmath.h" +#include "texture.h" + +class CPULIC +{ +public: + CPULIC(int w, int h, int d); + ~CPULIC(); + + void setNoiseData(NoiseDataSet* ns) { noise = ns; } + void setVectorTexture(Texture* t) { tex = t; } + void getNoiseTextureData(); + void getVectorTextureData(); + void gather3DLIC(std::deque& vds); + void scatter3DLIC(std::deque& vds); + void generateTexture(); + Texture* getTextureRef() { return tex; } + void setkernelData(unsigned char * fd) { _filterData = fd; } +private: + bool outofSpace(Vector3 pos); + + Vector3 textureSample(int timestep, Vector3 pos, std::deque& vds); + Vector3 streamlineforward(Vector3 pos, int timestep, std::deque& vds); + Vector3 streamlinebackward(Vector3 pos, int timestep, std::deque& vds); + float NoiseSample(Vector3 pos); + float kernel(float offset); + void createFilter(); + Texture* createTexture(const char *texName, GLuint texUnit, bool floatTex = true); + float getNoise(int offset); + + float* data; // 3D array for texture data + + int width; + int height; + int depth; + + int iterNum; + float stepSize; + float filter[256]; + unsigned char *_filterData; + + GLint _texIntFmt; + GLenum _texSrcFmt; + + Texture* tex; + NoiseDataSet* noise; + unsigned char* nsdata; + unsigned char* vtdata; +}; + diff --git a/VectorVisualization/GLSLShader.cpp b/VectorVisualization/GLSLShader.cpp index 2cbfebc..a301b1a 100644 --- a/VectorVisualization/GLSLShader.cpp +++ b/VectorVisualization/GLSLShader.cpp @@ -136,7 +136,7 @@ bool GLSLShader::loadShader(int countVS, char **vertexShaderNames, } versionStr = new char[128]; - snprintf(versionStr, 128, "#version 120\n"); + snprintf(versionStr, 128, "#version 430 compatibility\n"); // load vertex shader source files if (countVS > 0) @@ -342,8 +342,8 @@ GLSLParamsLIC::GLSLParamsLIC(void) : viewport(-1),texMax(-1),scaleVol(-1), scaleVolInv(-1),stepSize(-1),gradient(-1), licParams(-1),licKernel(-1),numIterations(-1), alphaCorrection(-1),volumeSampler(-1), volumeSamplerNext(-1), scalarSampler(-1), - licVolumeSampler(-1), licVolumeSamplerOld(-1), - noiseSampler(-1),mcOffsetSampler(-1), + licVolumeSampler(-1), licVolumeSamplerOld(-1), licVolumeNormalSampler(-1), + noiseSampler(-1),mcOffsetSampler(-1), noiseLAOSampler(-1), transferRGBASampler(-1), transferAlphaOpacSampler(-1), licKernelSampler(-1),malloDiffSampler(-1), @@ -373,6 +373,8 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) numIterations = -1; alphaCorrection = -1; maxVectorLength = -1; + minScalarRange = -1; + maxScalarRange = -1; volumeSampler = -1; volumeSamplerNext = -1; @@ -387,12 +389,19 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) zoecklerSampler = -1; licVolumeSampler = -1; licVolumeSamplerOld = -1; + laoVolumeSampler = -1; + licVolumeNormalSampler = -1; + noiseLAOSampler = -1; imageFBOSampler = -1; interpSize = -1; interpStep = -1; + sampleNum = -1; + pointNum = -1; + maxRayLen = -1; + glGetObjectParameterivARB(programObj, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &numUniforms); @@ -427,6 +436,14 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) { maxVectorLength = i; } + else if (strcmp(buf, "minScalarRange") == 0) + { + minScalarRange = i; + } + else if (strcmp(buf, "maxScalarRange") == 0) + { + maxScalarRange = i; + } else if (strcmp(buf, "scaleVolInv") == 0) { scaleVolInv = i; @@ -471,6 +488,18 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) { licVolumeSamplerOld = i; } + else if (strcmp(buf, "licVolumeNormalSampler") == 0) + { + licVolumeNormalSampler = i; + } + else if (strcmp(buf, "laoVolumeSampler") == 0) + { + laoVolumeSampler = i; + } + else if (strcmp(buf, "noiseLAOSampler") == 0) + { + noiseLAOSampler = i; + } else if (strcmp(buf, "interpSize") == 0) { interpSize = i; @@ -519,6 +548,22 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) { imageFBOSampler = i; } + else if (strcmp(buf, "scatterVolume") == 0) + { + volumeImage = i; + } + else if (strcmp(buf, "sampleNum") == 0) + { + sampleNum = i; + } + else if (strcmp(buf, "pointNum") == 0) + { + pointNum = i; + } + else if (strcmp(buf, "maxRayLen") == 0) + { + maxRayLen = i; + } /* else if (strcmp(buf, "") == 0) { diff --git a/VectorVisualization/GLSLShader.h b/VectorVisualization/GLSLShader.h index 6857854..3a156d2 100644 --- a/VectorVisualization/GLSLShader.h +++ b/VectorVisualization/GLSLShader.h @@ -78,6 +78,8 @@ struct GLSLParamsLIC GLint numIterations; GLint alphaCorrection; GLint maxVectorLength; + GLint minScalarRange; + GLint maxScalarRange; GLint volumeSampler; GLint volumeSamplerNext; @@ -92,11 +94,20 @@ struct GLSLParamsLIC GLint zoecklerSampler; GLint licVolumeSampler; GLint licVolumeSamplerOld; + GLint laoVolumeSampler; + GLint licVolumeNormalSampler; + GLint noiseLAOSampler; + + GLint volumeImage; GLint imageFBOSampler; GLint interpSize; GLint interpStep; + + GLint sampleNum; + GLint pointNum; + GLint maxRayLen; }; struct GLSLParamsBackground diff --git a/VectorVisualization/VolumeBuffer.cpp b/VectorVisualization/VolumeBuffer.cpp index ff8a3de..b5812ee 100644 --- a/VectorVisualization/VolumeBuffer.cpp +++ b/VectorVisualization/VolumeBuffer.cpp @@ -1,22 +1,35 @@ #include "VolumeBuffer.h" #include "types.h" -VolumeBuffer::VolumeBuffer(GLint format, int width, int height, int depth, int layers) +VolumeBuffer::VolumeBuffer(GLint format, int width, int height, int depth, int layers, bool depthFlag) :_width(width), _height(height), _depth(depth), _maxlayers(layers), _layer(0), - _interpSize(0), _curIntepStep(0), animationFlag(false) + _interpSize(0), _curIntepStep(0), animationFlag(false), _depthFlag(depthFlag) { glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)wglGetProcAddress("glGenFramebuffersEXT"); _frambufferId = 0; glGenFramebuffersEXT(1, &_frambufferId); //_tex = new Texture[_maxlayers]; - for (int i = 0; i < 2; i++) { - _tex[i].setTex(GL_TEXTURE_3D, create3dTexture(format, _width, _height, _depth), "LIC_Tex"); + for (int i = 0; i < _maxlayers; i++) { + _tex[i].setTex(GL_TEXTURE_3D, create3dTexture(format, _width, _height, _depth, GL_RGBA, GL_FLOAT), "LIC_Tex"); _tex[i].width = _width; _tex[i].height = _height; _tex[i].depth = _depth; } _tex[0].texUnit = GL_TEXTURE13_ARB; _tex[1].texUnit = GL_TEXTURE14_ARB; + + if (_depthFlag) + { + for (int i = 0; i < _maxlayers; i++) { + _depthtex[i].setTex(GL_TEXTURE_2D_ARRAY, create2darrayTexture(GL_DEPTH_COMPONENT32F, _width, _height, _depth, GL_DEPTH_COMPONENT, GL_FLOAT), "LIC_DepTex"); + _depthtex[i].width = _width; + _depthtex[i].height = _height; + _depthtex[i].depth = _depth; + } + _depthtex[0].texUnit = GL_TEXTURE15_ARB; + _depthtex[1].texUnit = GL_TEXTURE16_ARB; + + } } @@ -38,10 +51,17 @@ VolumeBuffer::~VolumeBuffer() for (int i = 0; i<_maxlayers; i++) { glDeleteTextures(1, &_tex[i].id); } + if (_depthFlag) + { + for (int i = 0; i<_maxlayers; i++) { + glDeleteTextures(1, &_depthtex[i].id); + } + delete[] _depthtex; + } delete [] _tex; } -GLuint VolumeBuffer::create3dTexture(GLint internalformat, int w, int h, int d) +GLuint VolumeBuffer::create3dTexture(GLint internalformat, int w, int h, int d, GLenum format, GLenum type) { GLuint tex; glGenTextures(1, &tex); @@ -53,7 +73,26 @@ GLuint VolumeBuffer::create3dTexture(GLint internalformat, int w, int h, int d) glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, mode); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, mode); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, mode); - glTexImage3D(GL_TEXTURE_3D, 0, internalformat, w, h, d, 0, GL_RGBA, GL_FLOAT, 0); + glTexImage3D(GL_TEXTURE_3D, 0, internalformat, w, h, d, 0, format, type, 0); + CHECK_FOR_OGL_ERROR(); + return tex; +} + +GLuint VolumeBuffer::create2darrayTexture(GLint internalformat, int w, int h, int d, GLenum format, GLenum type) +{ + GLuint tex; + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D_ARRAY, tex); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); + GLint mode = GL_REPEAT; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode); + //glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, mode); + glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, internalformat, w, h, d, 0, format, type, 0); + CHECK_FOR_OGL_ERROR(); return tex; } @@ -61,7 +100,11 @@ void VolumeBuffer::restoreOldLayer() { if (_tex[0].id > 0 && _tex[1].id > 0) { - glCopyImageSubData(_tex[0].id, GL_TEXTURE_3D, 0, 0, 0, 0, _tex[1].id, GL_TEXTURE_3D, 0, 0, 0, 0, _tex[0].width, _tex[0].height, _tex[0].depth); + glCopyImageSubData(_tex[0].id, GL_TEXTURE_3D, 0, 0, 0, 0, + _tex[1].id, GL_TEXTURE_3D, 0, 0, 0, 0, _tex[0].width, _tex[0].height, _tex[0].depth); + if(_depthFlag && _depthtex[0].id > 0 && _depthtex[1].id > 0) + glCopyImageSubData(_depthtex[0].id, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, + _depthtex[1].id, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, _depthtex[0].width, _depthtex[0].height, _depthtex[0].depth); /*glBindFramebuffer(GL_FRAMEBUFFER, _frambufferId); for (int i = 0; i < _tex[0].depth; i++) @@ -91,7 +134,11 @@ void VolumeBuffer::unbind() void VolumeBuffer::attachLayer(int layer, int zSlice) { - attachTexture(GL_TEXTURE_3D, GL_COLOR_ATTACHMENT0_EXT, _tex[layer].id, 0, zSlice); + attachTexture(GL_TEXTURE_3D, GL_COLOR_ATTACHMENT0_EXT + layer, _tex[layer].id, 0, zSlice); + + if(_depthFlag) + attachTexture(GL_TEXTURE_2D_ARRAY, GL_DEPTH_ATTACHMENT_EXT, _depthtex[layer].id, 0, zSlice); + //CHECK_FRAMEBUFFER_STATUS(); } void VolumeBuffer::attachTexture(GLenum texTarget, GLenum attachment, GLuint texId, int mipLevel, int zSlice) @@ -104,11 +151,16 @@ void VolumeBuffer::attachTexture(GLenum texTarget, GLenum attachment, GLuint tex glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D, texId, mipLevel, zSlice); } + else if (texTarget == GL_TEXTURE_2D_ARRAY) { + glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment, + texId, mipLevel, zSlice); + } else { // Default is GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, or cube faces glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, texTarget, texId, mipLevel); } + CHECK_FOR_OGL_ERROR(); } void VolumeBuffer::drawSlice(float z) diff --git a/VectorVisualization/VolumeBuffer.h b/VectorVisualization/VolumeBuffer.h index 0bf6809..b90e220 100644 --- a/VectorVisualization/VolumeBuffer.h +++ b/VectorVisualization/VolumeBuffer.h @@ -6,10 +6,11 @@ class VolumeBuffer { public: - VolumeBuffer(GLint format, int width, int height, int depth, int layers); + VolumeBuffer(GLint format, int width, int height, int depth, int layers, bool depthFlag = false); ~VolumeBuffer(); - GLuint create3dTexture(GLint internalformat, int w, int h, int d); + GLuint create3dTexture(GLint internalformat, int w, int h, int d, GLenum format, GLenum type); + GLuint create2darrayTexture(GLint internalformat, int w, int h, int d, GLenum format, GLenum type); void bind(); void unbind(); void attachLayer(int layer, int zSlice); @@ -18,6 +19,8 @@ class VolumeBuffer void restoreOldLayer(); Texture* getCurrentLayer() { return &(_tex[0]); } + Texture* getLayer(int i) { return &(_tex[i]); } + Texture* getCurrentDepthLayer() { return &(_depthtex[0]); } Texture* getOldLayer() { return &(_tex[1]); } int getDepth() { return _depth; } int getWidth() { return _width; } @@ -39,9 +42,11 @@ class VolumeBuffer bool animationFlag; int _interpSize; int _curIntepStep; + bool _depthFlag; GLuint _frambufferId; // tex[0] : new tex. tex[1] : old tex. Texture _tex[2]; + Texture _depthtex[2]; }; diff --git a/VectorVisualization/dataset.cpp b/VectorVisualization/dataset.cpp index a2c5322..28939a3 100644 --- a/VectorVisualization/dataset.cpp +++ b/VectorVisualization/dataset.cpp @@ -360,8 +360,8 @@ void VectorDataSet::createTextureIterp(const char *texName, glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - // glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - // glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + //glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + //glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); @@ -1209,7 +1209,7 @@ void NoiseDataSet::createTexture(const char *texName, GLuint texId; int size; int adr, adrPacked; - bool needPadding = false; + bool needPadding = true; float *gradients = NULL; unsigned char *packedData = NULL; unsigned char *gradTmp = NULL; @@ -1319,7 +1319,7 @@ void NoiseDataSet::createTexture(const char *texName, } else { - _texIntFmt = GL_LUMINANCE; // because of noise + _texIntFmt = GL_INTENSITY; // because of noise _texSrcFmt = GL_UNSIGNED_BYTE; if (needPadding) @@ -1356,8 +1356,8 @@ void NoiseDataSet::createTexture(const char *texName, glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - // glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - // glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + //glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + //glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT); diff --git a/VectorVisualization/renderer.cpp b/VectorVisualization/renderer.cpp index be11348..a0ebb45 100644 --- a/VectorVisualization/renderer.cpp +++ b/VectorVisualization/renderer.cpp @@ -37,7 +37,7 @@ _lambda2Tex(NULL), _tfRGBTex(NULL), _tfAlphaOpacTex(NULL), _illumZoecklerTex(NULL), _illumMalloDiffTex(NULL), _illumMalloSpecTex(NULL), _quadric(NULL), _storeFrame(true), _lowRes(false), _wireframe(false), _screenShot(false), _recording(false), _licParams(NULL), -_debug(false), _isAnimationOn(false) +_laoParams(NULL), _debug(false), _isAnimationOn(false) { _imgBufferTex0 = new Texture; @@ -49,6 +49,11 @@ _debug(false), _isAnimationOn(false) _snapshotFileName = "snapshot.png"; frames = 0; + _scatterTex = new Texture; + _scatterTex->width = 512; + _scatterTex->height = 512; + _scatterTex->depth = 512; + } @@ -82,7 +87,7 @@ Renderer::~Renderer(void) void Renderer::init(char *defines) { - float lightPos[] = { 0.0f, 0.0, 0.0f, 0.0f }; + float lightPos[] = { 0.0f, 0.0f, 0.0f, 0.0f }; _quadric = gluNewQuadric(); gluQuadricDrawStyle(_quadric, GLU_FILL); @@ -94,12 +99,25 @@ void Renderer::init(char *defines) //init volume buffer // A 3D texture buffer to store LIC value according to the vectore field - _licvolumebuffer = new VolumeBuffer(GL_RGBA16F_ARB, 512, 512, 512, 2); + bool iHasDepth = false; + _licvolumebuffer = new VolumeBuffer(GL_RGB32F, 256, 256, 256, 2, iHasDepth); + _licvolumeNormal = new VolumeBuffer(GL_RGB32F, 256, 256, 256, 1, iHasDepth); + _licLAObuffer = new VolumeBuffer(GL_R32F, 256, 256, 256, 1); + _noiseLAObuffer = new VolumeBuffer(GL_R32F, 256, 256, 256, 1); loadGLSLShader(defines); CHECK_FOR_OGL_ERROR(); glLightfv(GL_LIGHT1, GL_POSITION, lightPos); + + float ambientlight[] = { 0.8f, 0.8f, 0.8f, 1.0f}; + float diffuselight[] = { 0.8f, 0.8f, 0.8f, 1.0f }; + float specularlight[] = { 0.8f, 0.8f, 0.8f, 1.0f }; + + glLightfv(GL_LIGHT1, GL_AMBIENT, ambientlight); + glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuselight); + glLightfv(GL_LIGHT1, GL_SPECULAR, specularlight); + } @@ -190,6 +208,10 @@ void Renderer::render(bool update) case VOLIC_LICVOLUME: raycastLICVolume(); break; + case VOLIC_SCATTER: + scatterLICVolume(); + renderScatterLIC(); + break; default: std::cerr << "Renderer: Unknown render mode!" << std::endl; break; @@ -267,7 +289,6 @@ void Renderer::render(bool update) } } */ - glPushMatrix(); glTranslatef(_vd->center[0], _vd->center[1], _vd->center[2]); enableClipPlanes(); @@ -279,8 +300,11 @@ void Renderer::render(bool update) glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); for (int i = 0; i<_numClipPlanes; ++i) _clipPlanes[i].drawSlice(); + //glutWireSphere(0.5, 20, 20); + //glTranslatef(-0.5, -0.5, -0.5); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } + CHECK_FOR_OGL_ERROR(); @@ -470,7 +494,7 @@ void Renderer::renderLight(bool highlight) { int slices = 24; float axis[3]; - float ambient[4] = { 0.4f, 0.4f, 0.4f, 1.0f }; + float ambient[4] = { 0.8f, 0.8f, 0.8f, 1.0f }; float diffuse[4] = { 0.8f, 0.8f, 0.8f, 1.0f }; float specular[4] = { 0.8f, 0.8f, 0.8f, 1.0f }; @@ -809,6 +833,7 @@ void Renderer::loadGLSLShader(char *defines) char *vertexShader[] = { "shader/volic_vertex.glsl" }; char *vectorFieldFragShader[] = { "shader/vectorfield_fragment.glsl" }; char *bgFragShader[] = { "shader/background_fragment.glsl" }; + char *computeShader[] = { "shader/compute_volume.glsl" }; char *licRaycastFragShader[] = { "shader/inc_header.glsl", "shader/inc_lic.glsl", @@ -832,11 +857,24 @@ void Renderer::loadGLSLShader(char *defines) "shader/lic3d_volume_fragment.glsl", }; + char *licVolumeNormFragShader[] = { "shader/inc_header.glsl", + "shader/inc_lic.glsl", + "shader/lic3d_normal_fragment.glsl", + }; + char *raycastLICVolumeFragShader[] = { "shader/inc_header.glsl", "shader/inc_illum.glsl", "shader/raycast_lic3d_fragment.glsl", }; + char *scatterLICVolumeFragShader[] = { + "shader/inc_header.glsl", + "shader/lic3d_scattering_fragment.glsl", }; + + char *licLAOFragShader[] = { "shader/inc_header.glsl", + "shader/lic3d_lao_fragment.glsl", + }; + char *phongVertexShader[] = { "shader/phong_vertex.glsl" }; char *phongFragmentShader[] = { "shader/phong_fragment.glsl" }; @@ -908,6 +946,16 @@ void Renderer::loadGLSLShader(char *defines) << "for volumeRenderShader Shader." << std::endl; } _paramLICVolume.getMemoryLocations(_volumeRenderShader.getProgramObj(), _debug); + + if (!_volumeNormalShader.loadShader(1, reinterpret_cast(vertexShader), + 3, reinterpret_cast(licVolumeNormFragShader), + defines)) + { + std::cerr << "Renderer: Error loading Vertex and Fragment Program " + << "for volumeRenderShader Shader." << std::endl; + } + _paramLICNormVolume.getMemoryLocations(_volumeNormalShader.getProgramObj(), _debug); + if (!_licRaycastShader.loadShader(1, reinterpret_cast(vertexShader), 3, reinterpret_cast(raycastLICVolumeFragShader), defines)) @@ -917,6 +965,23 @@ void Renderer::loadGLSLShader(char *defines) } _paramLicRaycast.getMemoryLocations(_licRaycastShader.getProgramObj(), _debug); + if (!_licScatterShader.loadShader(1, reinterpret_cast(vertexShader), + 2, reinterpret_cast(scatterLICVolumeFragShader), + defines)) + { + std::cerr << "Renderer: Error loading Vertex and Fragment Program " + << "for raycastLICVolumeFragShader Shader." << std::endl; + } + _paramLicScatter.getMemoryLocations(_licScatterShader.getProgramObj(), _debug); + + if (!_laoRenderShader.loadShader(1, reinterpret_cast(vertexShader), + 2, reinterpret_cast(licLAOFragShader), + defines)) + { + std::cerr << "Renderer: Error loading Vertex and Fragment Program " + << "for raycastLICVolumeFragShader Shader." << std::endl; + } + _paramLAOVolume.getMemoryLocations(_laoRenderShader.getProgramObj(), _debug); CHECK_FOR_OGL_ERROR(); } @@ -946,6 +1011,10 @@ void Renderer::setRenderVolParams(GLSLParamsLIC *param) if (param->maxVectorLength > -1) glUniform1fARB(param->maxVectorLength, _vd->max_magnetic); + if (param->minScalarRange > -1) + glUniform1fARB(param->minScalarRange, 1.0f); + if (param->maxVectorLength > -1) + glUniform1fARB(param->maxVectorLength, 13.0f); CHECK_FOR_OGL_ERROR(); if (_lowRes) @@ -1003,8 +1072,26 @@ void Renderer::setRenderVolParams(GLSLParamsLIC *param) if (param->interpStep > -1) glUniform1fARB(param->interpStep, float(_licParams->interpStep)/ _licParams->interpSize); CHECK_FOR_OGL_ERROR(); + + // set LAO rendering parameters + if (!_laoParams) + return; + if (param->sampleNum > -1) + glUniform1iARB(param->sampleNum, _laoParams->sampleNum); + if (param->pointNum > -1) + glUniform1iARB(param->pointNum, _laoParams->pointNum); + if (param->maxRayLen > -1) + glUniform1fARB(param->maxRayLen, _laoParams->maxRayLen); + CHECK_FOR_OGL_ERROR(); } +void Renderer::setRenderVolImage(GLSLParamsLIC *param) +{ + if (param->volumeImage > -1) + { + glUniform1iARB(param->volumeImage, 3); + } +} void Renderer::setRenderVolTextures(GLSLParamsLIC *param) { @@ -1023,13 +1110,24 @@ void Renderer::setRenderVolTextures(GLSLParamsLIC *param) } if (param->licVolumeSampler > -1) { - glUniform1iARB(param->licVolumeSampler, _licvolumebuffer->getCurrentLayer()->texUnit - GL_TEXTURE0_ARB); - _licvolumebuffer->getCurrentLayer()->bind(); - }if (param->licVolumeSamplerOld > -1) + glUniform1iARB(param->licVolumeSampler, _licvolumebuffer->getLayer(0)->texUnit - GL_TEXTURE0_ARB); + _licvolumebuffer->getLayer(0)->bind(); + } + if (param->licVolumeSamplerOld > -1) { glUniform1iARB(param->licVolumeSamplerOld, _licvolumebuffer->getOldLayer()->texUnit - GL_TEXTURE0_ARB); _licvolumebuffer->getOldLayer()->bind(); } + if (param->licVolumeNormalSampler > -1) + { + glUniform1iARB(param->licVolumeNormalSampler, _licvolumebuffer->getLayer(1)->texUnit - GL_TEXTURE0_ARB); + _licvolumebuffer->getLayer(1)->bind(); + } + if (param->laoVolumeSampler > -1) + { + glUniform1iARB(param->laoVolumeSampler, _licLAObuffer->getCurrentLayer()->texUnit - GL_TEXTURE0_ARB); + _licLAObuffer->getCurrentLayer()->bind(); + } if (param->scalarSampler > -1) { glUniform1iARB(param->scalarSampler, _scalarTex->texUnit - GL_TEXTURE0_ARB); @@ -1040,6 +1138,11 @@ void Renderer::setRenderVolTextures(GLSLParamsLIC *param) glUniform1iARB(param->noiseSampler, _noiseTex->texUnit - GL_TEXTURE0_ARB); _noiseTex->bind(); } + if (param->noiseLAOSampler > -1) + { + glUniform1iARB(param->noiseLAOSampler, _noiseLAObuffer->getCurrentLayer()->texUnit - GL_TEXTURE0_ARB); + _noiseLAObuffer->getCurrentLayer()->bind(); + } if (param->mcOffsetSampler > -1) { glUniform1iARB(param->mcOffsetSampler, _mcOffsetTex->texUnit - GL_TEXTURE0_ARB); @@ -1346,7 +1449,7 @@ void Renderer::renderLICVolume(void) glPushMatrix(); glLoadIdentity(); //glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); - + //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glGetIntegerv(GL_VIEWPORT, oldViewport); glViewport(0, 0, width, height); glDisable(GL_DEPTH_TEST); @@ -1366,10 +1469,12 @@ void Renderer::renderLICVolume(void) for (int z = 0; z < depth; z++) { _licvolumebuffer->attachLayer(0, z); + _licvolumebuffer->attachLayer(1, z); + CHECK_FRAMEBUFFER_STATUS(); //render volume to 3D Texture _licvolumebuffer->drawSlice((z + 0.5f) / (float)depth); } - + CHECK_FOR_OGL_ERROR(); _dataTex->unbind(); _nextDataTex->unbind(); @@ -1392,13 +1497,220 @@ void Renderer::renderLICVolume(void) void Renderer::updateLICVolume(void) { - _licvolumebuffer->restoreOldLayer(); + //_licvolumebuffer->restoreOldLayer(); renderLICVolume(); + //loadGLSLShader("#define ILLUM_GRADIENT"); + //computeVolumeNormal(); + computeLAOVolume(); } void Renderer::restoreLICVolume(void) { - _licvolumebuffer->restoreOldLayer(); + //_licvolumebuffer->restoreOldLayer(); +} + +void Renderer::computeVolumeNormal(void) +{ + int oldViewport[4]; + float color[4]; + int depth = _licvolumeNormal->getDepth(); + int width = _licvolumeNormal->getWidth(); + int height = _licvolumeNormal->getHeight(); + GLint currentFBO = 0; + + // store current framebuffer object + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, ¤tFBO); + + _licvolumeNormal->bind(); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + //glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); + + glGetIntegerv(GL_VIEWPORT, oldViewport); + glViewport(0, 0, width, height); + glDisable(GL_DEPTH_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + glGetFloatv(GL_COLOR_CLEAR_VALUE, color); + glClearColor(0.0, 0.0, 0.0, 0.0); + + _volumeNormalShader.enableShader(); + + setRenderVolParams(&_paramLICNormVolume); + setRenderVolTextures(&_paramLICNormVolume); + + CHECK_FOR_OGL_ERROR(); + + for (int z = 0; z < depth; z++) + { + _licvolumeNormal->attachLayer(0, z); + CHECK_FRAMEBUFFER_STATUS(); + //render volume to 3D Texture + _licvolumeNormal->drawSlice((z + 0.5f) / (float)depth); + } + CHECK_FOR_OGL_ERROR(); + _dataTex->unbind(); + + _volumeNormalShader.disableShader(); + + // restore old clear color + glClearColor(color[0], color[1], color[2], color[3]); + + glViewport(oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + _licvolumeNormal->unbind(); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, currentFBO); + + CHECK_FRAMEBUFFER_STATUS(); +} + +void Renderer::computeNoiseLAO(void) +{ + int oldViewport[4]; + float color[4]; + int depth = _noiseLAObuffer->getDepth(); + int width = _noiseLAObuffer->getWidth(); + int height = _noiseLAObuffer->getHeight(); + GLint currentFBO = 0; + + // store current framebuffer object + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, ¤tFBO); + + _noiseLAObuffer->bind(); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + //glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); + + glGetIntegerv(GL_VIEWPORT, oldViewport); + glViewport(0, 0, width, height); + glDisable(GL_DEPTH_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + glGetFloatv(GL_COLOR_CLEAR_VALUE, color); + glClearColor(0.0, 0.0, 0.0, 0.0); + + _laoRenderShader.enableShader(); + + setRenderVolParams(&_paramLAOVolume); + setRenderVolTextures(&_paramLAOVolume); + if(_paramLAOVolume.licVolumeSampler > -1) + { + glUniform1iARB(_paramLAOVolume.licVolumeSampler, _noiseTex->texUnit - GL_TEXTURE0_ARB); + _noiseTex->bind(); + } + CHECK_FOR_OGL_ERROR(); + + for (int z = 0; z < depth; z++) + { + _noiseLAObuffer->attachLayer(0, z); + //render volume to 3D Texture + _noiseLAObuffer->drawSlice((z + 0.5f) / (float)depth); + } + + _noiseTex->unbind(); + _noiseLAObuffer->getCurrentLayer()->unbind(); + + _laoRenderShader.disableShader(); + + // restore old clear color + glClearColor(color[0], color[1], color[2], color[3]); + + glViewport(oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + _noiseLAObuffer->unbind(); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, currentFBO); + + CHECK_FRAMEBUFFER_STATUS(); +} + +void Renderer::computeLAOVolume(void) +{ + int oldViewport[4]; + float color[4]; + int depth = _licvolumebuffer->getDepth(); + int width = _licvolumebuffer->getWidth(); + int height = _licvolumebuffer->getHeight(); + GLint currentFBO = 0; + + // store current framebuffer object + glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, ¤tFBO); + + _licLAObuffer->bind(); + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + //glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); + + glGetIntegerv(GL_VIEWPORT, oldViewport); + glViewport(0, 0, width, height); + glDisable(GL_DEPTH_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + glGetFloatv(GL_COLOR_CLEAR_VALUE, color); + glClearColor(0.0, 0.0, 0.0, 0.0); + + _laoRenderShader.enableShader(); + + setRenderVolParams(&_paramLAOVolume); + + setRenderVolTextures(&_paramLAOVolume); + CHECK_FOR_OGL_ERROR(); + + for (int z = 0; z < depth; z++) + { + _licLAObuffer->attachLayer(0, z); + //render volume to 3D Texture + _licLAObuffer->drawSlice((z + 0.5f) / (float)depth); + } + + _dataTex->unbind(); + _nextDataTex->unbind(); + _licvolumebuffer->getCurrentLayer()->unbind(); + _licvolumebuffer->getCurrentDepthLayer()->unbind(); + + _laoRenderShader.disableShader(); + + // restore old clear color + glClearColor(color[0], color[1], color[2], color[3]); + + glViewport(oldViewport[0], oldViewport[1], oldViewport[2], oldViewport[3]); + + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + _licLAObuffer->unbind(); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, currentFBO); + + CHECK_FRAMEBUFFER_STATUS(); } void Renderer::raycastLICVolume(void) @@ -1421,6 +1733,44 @@ void Renderer::raycastLICVolume(void) CHECK_FOR_OGL_ERROR(); + _licvolumebuffer->getCurrentLayer()->unbind(); + _licvolumeNormal->getCurrentLayer()->unbind(); + _licLAObuffer->getCurrentLayer()->unbind(); + _dataTex->unbind(); + _tfRGBTex->unbind(); + _tfAlphaOpacTex->unbind(); + + _licRaycastShader.disableShader(); + + glDisable(GL_CULL_FACE); +} + +void Renderer::renderScatterLIC(void) +{ + _licRaycastShader.enableShader(); + + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glDisable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); + //glDisable(GL_BLEND); + glEnable(GL_BLEND); + + setRenderVolParams(&_paramLicRaycast); + setRenderVolTextures(&_paramLicRaycast); + + if (_paramLicRaycast.licVolumeSampler > -1) + { + glUniform1iARB(_paramLicRaycast.licVolumeSampler, _scatterTex->texUnit - GL_TEXTURE0_ARB); + _scatterTex->bind(); + } + + CHECK_FOR_OGL_ERROR(); + drawCubeFaces(); + CHECK_FOR_OGL_ERROR(); + drawClippedPolygon(); + + CHECK_FOR_OGL_ERROR(); + _licvolumebuffer->getCurrentLayer()->unbind(); _licvolumebuffer->getOldLayer()->unbind(); _dataTex->unbind(); @@ -1430,6 +1780,70 @@ void Renderer::raycastLICVolume(void) glDisable(GL_CULL_FACE); } +void Renderer::scatterLICVolume(void) +{ + int oldViewport[4]; + float color[4]; + glEnable(GL_TEXTURE_3D); + glActiveTexture(GL_TEXTURE6_ARB); + CHECK_FOR_OGL_ERROR(); + if (_scatterTex->id == 0) + { + glGenTextures(1, &(_scatterTex->id)); + glBindTexture(GL_TEXTURE_3D, _scatterTex->id); + glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA16F_ARB, _scatterTex->width, _scatterTex->height, _scatterTex->depth); + glBindTexture(GL_TEXTURE_3D, 0); + } + _scatterTex->texUnit = GL_TEXTURE6_ARB; + + //GLuint ray_shader = glCreateShader(GL_COMPUTE_SHADER); + //glShaderSource(ray_shader, 1, &the_ray_shader_string, NULL); + //glCompileShader(ray_shader); + //// check for compilation errors as per normal here + + //GLuint ray_program = glCreateProgram(); + //glAttachShader(ray_program, ray_shader); + //glLinkProgram(ray_program); + + glGetFloatv(GL_COLOR_CLEAR_VALUE, color); + glClearColor(0.0, 0.0, 0.0, 0.0); + + glBindImageTexture(3, _scatterTex->id, 0, GL_TRUE, 0, GL_READ_WRITE, GL_RGBA16F_ARB); + + _licScatterShader.enableShader(); + + setRenderVolParams(&_paramLicScatter); + setRenderVolTextures(&_paramLicScatter); + setRenderVolImage(&_paramLicScatter); + + CHECK_FOR_OGL_ERROR(); + + //glTexImage3D(GL_TEXTURE_3D, 0, GL_R8, volume_dims[0], volume_dims[1], volume_dims[2], 0, GL_RED, GL_UNSIGNED_BYTE, voxels); + + /*ShaderProgram computeVolumeShader; + computeVolumeShader.loadShader(GL_COMPUTE_SHADER, "compute_volume.glsl"); + computeVolumeShader.link(); + computeVolumeShader.use(); + computeVolumeShader.uniform("volume", 0); + glBindImageTexture(0, volume_tid, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8); + glDispatchCompute(volume_dims[0], volume_dims[1], volume_dims[2]); + glBindImageTexture(0, 0, 0, GL_FALSE, 0, GL_READ_WRITE, GL_R8); + computeVolumeShader.unUse(); + glMemoryBarrier(GL_ALL_BARRIER_BITS);*/ + + glDispatchCompute(_scatterTex->width, _scatterTex->height, _scatterTex->depth); + + CHECK_FOR_OGL_ERROR(); + _dataTex->unbind(); + _nextDataTex->unbind(); + + _licScatterShader.disableShader(); + + // restore old clear color + glClearColor(color[0], color[1], color[2], color[3]); + +} + void Renderer::renderBackground(void) { int viewport[4] = { 0, 0, _winWidth, _winHeight }; diff --git a/VectorVisualization/renderer.h b/VectorVisualization/renderer.h index 29082a4..bb6027e 100644 --- a/VectorVisualization/renderer.h +++ b/VectorVisualization/renderer.h @@ -102,6 +102,7 @@ class Renderer void switchRecording(void) { _recording = !_recording; } void setLICParams(LICParams *params) { _licParams = params; } + void setLAOParams(LAOParams *params) { _laoParams = params; } /* void setStepSize(float stepSize) { _stepSize = stepSize; } void setGradientScale(float scale) { _gradientScale = scale; } @@ -126,6 +127,10 @@ class Renderer void renderLICVolume(void); // restore Old LIC Volume void restoreLICVolume(void); + // pre-computed local ambient occulusion volume + void computeLAOVolume(void); + void computeNoiseLAO(void); + void computeVolumeNormal(void); void setAnimationFlag(bool flag) { _isAnimationOn = flag; } protected: @@ -146,6 +151,7 @@ class Renderer void setRenderVolParams(GLSLParamsLIC *param); void setRenderVolTextures(GLSLParamsLIC *param); + void setRenderVolImage(GLSLParamsLIC *param); // render only the volume void renderVolume(void); @@ -163,6 +169,10 @@ class Renderer // Using Volume Rendering to render LIC 3D volume void raycastLICVolume(void); + // Scattering LIC Value and Raycasting the volume + void scatterLICVolume(void); + void renderScatterLIC(void); + // draw a screen filling quad and display FBO content // composited with a background color void renderBackground(void); @@ -228,6 +238,9 @@ class Renderer // 3D LIC Volume Buffer VolumeBuffer * _licvolumebuffer; + VolumeBuffer * _licvolumeNormal; + VolumeBuffer * _licLAObuffer; + VolumeBuffer * _noiseLAObuffer; // GLSL shaders GLSLShader _bgShader; @@ -238,6 +251,10 @@ class Renderer GLSLShader _volumeShader; GLSLShader _volumeRenderShader; GLSLShader _licRaycastShader; + GLSLShader _laoRenderShader; + GLSLShader _volumeNormalShader; + + GLSLShader _licScatterShader; GLSLShader _phongShader; @@ -248,7 +265,10 @@ class Renderer GLSLParamsLIC _paramSliceBlend; GLSLParamsLIC _paramVolume; GLSLParamsLIC _paramLICVolume; + GLSLParamsLIC _paramLICNormVolume; GLSLParamsLIC _paramLicRaycast; + GLSLParamsLIC _paramLicScatter; + GLSLParamsLIC _paramLAOVolume; // Textures @@ -260,6 +280,10 @@ class Renderer Texture *_mcOffsetTex; + // scatter volume texture; + + Texture *_scatterTex; + // vector data Texture *_dataTex; Texture *_nextDataTex; @@ -298,6 +322,7 @@ class Renderer LICParams *_licParams; + LAOParams *_laoParams; bool _debug; }; diff --git a/VectorVisualization/shader/computer_volume.glsl b/VectorVisualization/shader/computer_volume.glsl new file mode 100644 index 0000000..395bdc8 --- /dev/null +++ b/VectorVisualization/shader/computer_volume.glsl @@ -0,0 +1,7 @@ +layout(local_size_x=1, local_size_y=1, local_size_z=1) in; +layout(r8, location = 0) uniform image3D volume; + +void main() +{ + imageStore(volume, ivec3(gl_WorkGroupID), vec4(0)); +} \ No newline at end of file diff --git a/VectorVisualization/shader/inc_header.glsl b/VectorVisualization/shader/inc_header.glsl index 87f39bb..4dbdfce 100644 --- a/VectorVisualization/shader/inc_header.glsl +++ b/VectorVisualization/shader/inc_header.glsl @@ -43,6 +43,8 @@ uniform float timeStep; uniform float maxVectorLength; + float minScalarRange = 4.0; + float maxScalarRange = 14.0; // textures (have to be uniform) @@ -50,6 +52,7 @@ uniform sampler3D volumeSampler; uniform sampler3D volumeSamplerNext; uniform sampler3D scalarSampler; uniform sampler3D noiseSampler; +uniform sampler3D noiseLAOSampler; uniform sampler2DRect mcOffsetSampler; diff --git a/VectorVisualization/shader/inc_illum.glsl b/VectorVisualization/shader/inc_illum.glsl index 247041f..2d54fcf 100644 --- a/VectorVisualization/shader/inc_illum.glsl +++ b/VectorVisualization/shader/inc_illum.glsl @@ -1,5 +1,14 @@ +vec3 sampleGrad(sampler3D tsampler, vec3 coord) +{ + const int offset = 1; + float dx = textureOffset(tsampler, coord, ivec3(offset, 0, 0)).x - textureOffset(tsampler, coord, ivec3(-offset, 0, 0)).x; + float dy = textureOffset(tsampler, coord, ivec3(0, offset, 0)).y - textureOffset(tsampler, coord, ivec3(0, -offset, 0)).y; + float dz = textureOffset(tsampler, coord, ivec3(0, 0, offset)).z - textureOffset(tsampler, coord, ivec3(0, 0, -offset)).z; + return normalize(vec3(dx, dy, dz)); +} + vec4 illumGradient(in vec4 illum, in vec4 tfData, - in vec3 pos, in vec3 dir, in vec3 tangent) + in vec3 pos, in vec3 dir, in vec3 tangent, float ao = 1.0) { vec3 diffuse; vec3 specular; @@ -26,7 +35,8 @@ vec4 illumGradient(in vec4 illum, in vec4 tfData, diffuse = diffuse.r * gl_LightSource[0].diffuse.rgb * gradient.g; // apply illumination - color.rgb = color.rgb * (diffuse + 0.3 + gl_LightSource[0].ambient.rgb) + specular; + //color.rgb = color.rgb * (diffuse + 0.3) + gl_LightSource[0].ambient.rgb * ao + specular; + color.rgb = color.rgb * (diffuse + 0.3) + vec3(0.1, 0.1, 0.1) * ao + specular; color.rgb *= gradient.g; @@ -155,12 +165,12 @@ vec4 illumZoeckler(in float illum, in vec4 tfData, -vec4 illumLIC(in float illum, in vec4 tfData) +vec4 illumLIC(in float illum, in vec4 tfData, in float ao = 1.0) { vec4 color; // result = lic intensity * color * illumination scaling - color.rgb = illum * tfData.rgb * gradient.g; + color.rgb = illum * tfData.rgb * gradient.g * ao; // alpha affected by lic intensity color.a = texture1D(transferAlphaOpacSampler, illum*1.3).a * tfData.a; diff --git a/VectorVisualization/shader/inc_lic.glsl b/VectorVisualization/shader/inc_lic.glsl index d13f1da..3c139df 100644 --- a/VectorVisualization/shader/inc_lic.glsl +++ b/VectorVisualization/shader/inc_lic.glsl @@ -55,59 +55,99 @@ float noiseLookup(in vec3 objPos, in float freqScale, out float logEyeDist) return mix(noise1, noise2, freqMeasure.z); } - // preserve same spatial frequencies of the noise with respect to // the image plane -vec4 freqSamplingGrad(in vec3 pos, out float logEyeDist) +vec4 freqSamplingGrad(in vec3 pos, in int level, out float logEyeDist, in sampler3D vectorVolume = volumeSampler) { - //vec3 objPos = pos * scaleVolInv.xyz; + vec4 vectorData = texture3D(vectorVolume, pos); - //vec4 tmp = noiseLookupGrad(pos, gradient.z, logEyeDist); - // return texture3D(noiseSampler, pos); - return noiseLookupGrad(pos, gradient.z, logEyeDist); + //float minRange = 0.0; + //float maxRange = 30.0; + //magnitude range equation + if (vectorData.a > minScalarRange / maxVectorLength && vectorData.a < maxScalarRange / maxVectorLength) + { + //return texture3D(noiseSampler, pos).a + vec4 res = texture3D(noiseSampler, pos*gradient.z); + if (level > 0) + return res.a > 0.0 ? texture3D(noiseSampler, pos*level*gradient.z) : vec4(0.0); + else + return res; + //return noiseLookup(pos, gradient.z, logEyeDist); + } + else + return vec4(0.0); + //return noiseLookupGrad(pos, gradient.z, logEyeDist); } -float freqSampling(in vec3 pos, out float logEyeDist, in sampler3D vectorVolume = volumeSampler) +float freqSampling(in vec3 pos, in int level, out float logEyeDist, in sampler3D vectorVolume = volumeSampler) { //vec3 objPos = pos * scaleVolInv.xyz; //Use scalar data to decide noise range to be integrated vec4 vectorData = texture3D(vectorVolume, pos); - vec4 scalarData = texture3D(scalarSampler, pos); + //vec4 scalarData = texture3D(scalarSampler, pos); //float scala = length(vectorData.xyz); //if (scalarData.r > 0.1 && scalarData.r < 0.3) // one example of visualize range: magnetic_field (magnitude 7.0 ~ max) - float minRange = 6.0; - float maxRange = 15.0; + //float minRange = 2.0; + //float maxRange = 30.0; //magnitude range equation - //if (vectorData.a > minRange/maxVectorLength && vectorData.a < maxRange/maxVectorLength) + //minScalarRange = 1.0; + //maxScalarRange = 13.0; + if (vectorData.a > minScalarRange /maxVectorLength && vectorData.a < maxScalarRange /maxVectorLength) // g component range equation: map to 0 ~ 1.0, 0 is 0.5 //if (vectorData.b > ( 0.5 * minRange/maxVectorLength + 0.5) && vectorData.b < ( 0.5 * maxRange/maxVectorLength + 0.5)) - if (true) + //if (true) { //return texture3D(noiseSampler, pos).a - return texture3D(noiseSampler, pos*gradient.z).a; + float res = texture3D(noiseSampler, pos*gradient.z).a; + if(level > 0) + return res > 0.0 ? texture3D(noiseSampler, pos*level*gradient.z).a : 0.0; + else + return res; //return noiseLookup(pos, gradient.z, logEyeDist); } else return 0; } +float noiseLAOSampling(in vec3 pos, in int level, in sampler3D vectorVolume = volumeSampler) +{ + //Use scalar data to decide noise range to be integrated + vec4 vectorData = texture3D(vectorVolume, pos); + + // one example of visualize range: magnetic_field (magnitude 7.0 ~ max) + //float minRange = 2.0; + //float maxRange = 30.0; + //magnitude range equation + if (vectorData.a > minScalarRange / maxVectorLength && vectorData.a < maxScalarRange / maxVectorLength) + { + //return texture3D(noiseSampler, pos).a + float res = texture3D(noiseLAOSampler, pos*gradient.z).r; + if (level > 0) + return res > 0.0 ? texture3D(noiseLAOSampler, pos*level*gradient.z).r : 0.0; + else + return res; + //return noiseLookup(pos, gradient.z, logEyeDist); + } + else + return 0; +} #ifdef USE_NOISE_GRADIENTS -vec4 singleLICstep(in vec3 licdir, in out vec3 newPos, +vec4 singleLICstep(in vec3 licdir, in out vec3 newPos, in int level, in out vec4 step, in float kernelOffset, - in out float logEyeDist, in float dir, + in out float logEyeDist, in float dir, in out float ao, in sampler3D vectorVolume = volumeSampler) { vec4 noise; #else -float singleLICstep(in vec3 licdir, in out vec3 newPos, +float singleLICstep(in vec3 licdir, in out vec3 newPos, in int level, in out vec4 step, in float kernelOffset, - in out float logEyeDist, in float dir, + in out float logEyeDist, in float dir, in out float ao, in sampler3D vectorVolume = volumeSampler) { float noise; @@ -141,14 +181,18 @@ float singleLICstep(in vec3 licdir, in out vec3 newPos, #endif #ifdef USE_NOISE_GRADIENTS - noise = freqSamplingGrad(newPos, logEyeDist); + noise = freqSamplingGrad(newPos, level, logEyeDist); //noise = vec4(texture3D(noiseSampler, newPos).a); #else - noise = freqSampling(newPos, logEyeDist); + noise = freqSampling(newPos, level, logEyeDist); #endif // determine weighting noise *= texture1D(licKernelSampler, kernelOffset).r; +#ifdef AMBIENT_OCCULUSION + ao += noiseLAOSampling(newPos, level) * texture1D(licKernelSampler, kernelOffset).r; +#endif + return noise; } @@ -158,28 +202,39 @@ float singleLICstep(in vec3 licdir, in out vec3 newPos, // performs the LIC computation for n steps forward and backward // pos determines the starting position of the LIC // vectorFieldSample is the value of the vector field at this position -vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample, out vec2 streamDis, out vec3 streamStart, out vec3 streaEnd, in sampler3D vectorVolume = volumeSampler) +vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample, + out vec2 streamDis, out vec3 streamStart, + out vec3 streaEnd, + in sampler3D vectorVolume = volumeSampler) { vec3 licdir; float logEyeDist; float kernelOffset = 0.5; + float ao = 1.0; #ifdef TIME_DEPENDENT vec4 vectorFieldSample2; #endif - + // decide which noise sampling level will use for this lic computation + int level = 0; + //if (pos.z > 0.5) + // level = 2; + //else + // level = 1; + // perform first lookup - #ifdef USE_NOISE_GRADIENTS vec4 noise; - vec4 illum = freqSamplingGrad(pos, logEyeDist, vectorVolume); + vec4 illum = freqSamplingGrad(pos,level, logEyeDist); #else float noise; - float illum = freqSampling(pos, logEyeDist); + float illum = freqSampling(pos, level, logEyeDist); #endif // weight sample with lic kernel at position 0 illum *= texture1D(licKernelSampler, 0.5).r; - +#ifdef AMBIENT_OCCULUSION + ao = noiseLAOSampling(pos, level) * texture1D(licKernelSampler, 0.5).r; +#endif float dir = -1; // backward LIC vec3 newPos = pos; @@ -192,8 +247,8 @@ vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample, out vec2 streamDis, out //licdir = step.rgb; kernelOffset -= licKernel.y; vec3 oldPos = newPos; - illum += singleLICstep(licdir, newPos, step, - kernelOffset, logEyeDist, dir, vectorVolume); + illum += singleLICstep(licdir, newPos, level, step, + kernelOffset, logEyeDist, dir, ao, vectorVolume); streamlineL += length(newPos - oldPos); sumCross += length(cross(oldPos, newPos)); } @@ -209,8 +264,8 @@ vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample, out vec2 streamDis, out //licdir = step.rgb; kernelOffset += licKernel.x; vec3 oldPos = newPos; - illum += singleLICstep(licdir, newPos, step, - kernelOffset, logEyeDist, dir, vectorVolume); + illum += singleLICstep(licdir, newPos, level, step, + kernelOffset, logEyeDist, dir, ao, vectorVolume); streamlineL += length(newPos - oldPos); sumCross += length(cross(newPos, oldPos)); } @@ -219,6 +274,78 @@ vec4 computeLIC(in vec3 pos, in vec4 vectorFieldSample, out vec2 streamDis, out return vec4(illum); } +vec4 computeLICwithAO(in vec3 pos, in vec4 vectorFieldSample, + out vec2 streamDis, out vec3 streamStart, + out vec3 streaEnd, in out float ao, + in sampler3D vectorVolume = volumeSampler) +{ + vec3 licdir; + float logEyeDist; + float kernelOffset = 0.5; +#ifdef TIME_DEPENDENT + vec4 vectorFieldSample2; +#endif + // decide which noise sampling level will use for this lic computation + int level = 0; + //if (pos.z > 0.5) + // level = 2; + //else + // level = 1; + + // perform first lookup +#ifdef USE_NOISE_GRADIENTS + vec4 noise; + vec4 illum = freqSamplingGrad(pos, level, logEyeDist); +#else + float noise; + float illum = freqSampling(pos, level, logEyeDist); +#endif + //return vec4(illum); + + // weight sample with lic kernel at position 0 + illum *= texture1D(licKernelSampler, 0.5).r; +#ifdef AMBIENT_OCCULUSION + ao = noiseLAOSampling(pos, level) * texture1D(licKernelSampler, 0.5).r; +#endif + float dir = -1; + // backward LIC + vec3 newPos = pos; + vec4 step = vectorFieldSample; + float streamlineL = 0.0; + float sumCross = 0.0; + for (int i = 0; i 0.05) - //if (scalarData.g > 0.0001) - //if (scalarData.g > 0.31 && scalarData.g < 0.35) + +#if defined(STREAMLINE_DISTANCE) if(vectorData.a > 0.5 && vectorData.a < 0.75) +#else + if (scalarData.g > -0.01) +#endif { // compute the LIC integral vec3 streamStart; @@ -83,17 +82,20 @@ void main(void) #if defined(STREAMLINE_DISTANCE) float strDis = computeStreamlineDis(pos, center); - //float strDisB = computeStreamlineDis(pos, centerB); dis += strDis; illum.a = cos(strDis*256) - 0.5; if(illum.a > 0.0) illum.a = 1.0; - //tfData = texture1D(transferRGBASampler, strDis); #else - illum = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd); + ao = 1.0; + //illum = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd); + illum = computeLICwithAO(pos, vectorData, streamDis, streamStart, streamEnd, ao); #endif //tfData = vec4(vectorData.rgb, 1.0); - + //ao *= licKernel.b * 15; + ao = texture3D(noiseLAOSampler, pos).r; + //ao = texture3D(noiseSampler, pos).a; + oldPos = pos; // scale LIC intensity @@ -103,15 +105,27 @@ void main(void) // zoeckler/mallo/gradient/no illum #if defined(ILLUM_GRADIENT) src = illumGradient(illum, tfData, pos, dir, vectorData.xyz); + //src = vec4(normalize(illum.rgb), 1.0); #elif defined(ILLUM_MALLO) src = illumMallo(illum.a, tfData, pos, dir, vectorData.xyz); -#elif defined(ILLUM_ZOECKLER) +#elif defined(ILLUM_ZOECKLER) src = illumZoeckler(illum.a, tfData, pos, dir, vectorData.xyz); +#elif defined(AMBIENT_OCCULUSION) + + //src = illumLIC(intensity.a, tfData, ao); + tfData = vec4(1.0, 1.0, 1.0, 1.0); + //src = vec4(tfData * (ao)); + if (ao > 0.0) + src = vec4(tfData.rgb * (1-ao), ao); + else + src = vec4(tfData.rgb * (1 - ao), 0.0); + //ao = clamp(1-ao, 0.0, 1.0); + //src = illumGradient(illum, tfData, pos, dir, vectorData.xyz, ao); #else // -- standard LIC -- src = illumLIC(illum.a, tfData); #endif - + //src = vec4(normalize(vectorData.rgb), illum.a); // perform blending src.rgb *= src.a; dest = clamp((1.0-dest.a)*src + dest, 0.0, 1.0); diff --git a/VectorVisualization/shader/lic3d_lao_fragment.glsl b/VectorVisualization/shader/lic3d_lao_fragment.glsl new file mode 100644 index 0000000..4fafa7e --- /dev/null +++ b/VectorVisualization/shader/lic3d_lao_fragment.glsl @@ -0,0 +1,87 @@ +uniform sampler3D licVolumeSampler; +uniform int sampleNum; +uniform int pointNum; +uniform float maxRayLen; + +const float PAI = 3.1415926; + +float rand(vec2 co) +{ + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); +} + +vec3 genPointonSphere(float theta, float u) +{ + float x = sqrt(1 - u*u) * cos(theta); + float y = sqrt(1 - u*u) * sin(theta); + float z = u; + + return vec3(x, y, z); +} + +vec3 randomSphericalDistr(int i, int itrsPerAngle) +{ + int cur_angle = i / itrsPerAngle; + int cur_itr = i % itrsPerAngle; + float theta = rand(vec2(cur_angle, cur_itr)) * 2 * PAI; + float u = 2 * rand(vec2(cur_itr, cur_angle)) - 1; + return genPointonSphere(theta, u); +} + +vec3 uniformSphericalDistr(int i, int angles, int itrsPerAngle) +{ + int idx_angle = i / itrsPerAngle; + int idx_itrs = i % itrsPerAngle; + float theta = 2 * PAI * (idx_angle + 0.5) / angles; + float u = (idx_itrs + 0.5) / itrsPerAngle; + return genPointonSphere(theta, u); +} + +void main(void) +{ + vec4 geomPos = gl_TexCoord[0]; + vec3 pos = geomPos.xyz * scaleVol.xyz; + // lookup scalar value + vec4 illum = vec4(0.0, 0.0, 0.0, 1.0); + + float laoStepSize = maxRayLen * 1.0 / sampleNum; + float aoKsum = 0.0; + int angleNum = 12; + int itrPerAngle = pointNum / angleNum; +#if defined(NOISE_LAO_COMPUTE) + vec4 vectorData = texture3D(volumeSampler, pos); + //if (vectorData.a > minScalarRange / maxVectorLength && vectorData.a < maxScalarRange / maxVectorLength) + { +#endif + for (int i = 0; i < pointNum; i++) + { + //vec3 pointRay = uniformSphericalDistr(i, angleNum, itrPerAngle); + vec3 pointRay = randomSphericalDistr(i, itrPerAngle); + vec3 pointStart = pos; + float alphaAcu = 0; + for (int k = 0; k < sampleNum; k++) + { + vec3 pointPos = pointStart + pointRay*laoStepSize; + // if noise data, intensity is in a, licvolume intensity is in r +#if defined(NOISE_LAO_COMPUTE) + float intensity = texture3D(licVolumeSampler, pointPos).a; +#else + float intensity = texture3D(licVolumeSampler, pointPos).r; +#endif + float alpha = texture1D(transferAlphaOpacSampler, intensity*1.3).a; + alphaAcu = alphaAcu*(1 - alpha) + alpha; + if (alphaAcu >= 0.995) + break; + } + aoKsum += alphaAcu; + //aoKsum = alphaAcu / (i + 1) + aoKsum*(1.0 - 1.0 / (i + 1)); + } + if (pointNum > 0) + aoKsum /= pointNum; + illum.rgb = vec3(aoKsum); +#if defined(NOISE_LAO_COMPUTE) + } +#endif + gl_FragColor = illum; + //gl_FragColor = vec4(pos, 1); +} \ No newline at end of file diff --git a/VectorVisualization/shader/lic3d_normal_fragment.glsl b/VectorVisualization/shader/lic3d_normal_fragment.glsl new file mode 100644 index 0000000..8e0c510 --- /dev/null +++ b/VectorVisualization/shader/lic3d_normal_fragment.glsl @@ -0,0 +1,17 @@ +#define USE_NOISE_GRADIENTS + +void main(void) +{ + vec4 geomPos = gl_TexCoord[0]; + vec3 pos = geomPos.xyz * scaleVol.xyz; + // lookup vector value + vec4 vectorData = texture3D(volumeSampler, pos); + vec4 illum = vec4(0.0); + vec3 streamStart; + vec3 streamEnd; + vec2 streamDis; + vec4 res = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd).rgba; + illum.rgb = res.rgb; + illum.a = 1.0; + gl_FragColor = illum; +} \ No newline at end of file diff --git a/VectorVisualization/shader/lic3d_scattering_fragment.glsl b/VectorVisualization/shader/lic3d_scattering_fragment.glsl new file mode 100644 index 0000000..0180849 --- /dev/null +++ b/VectorVisualization/shader/lic3d_scattering_fragment.glsl @@ -0,0 +1,45 @@ +#extension GL_ARB_shader_image_size : enable + +uniform layout(binding=3, rgba16f) image3D scatterVolume; + +vec3 nextStreamline(in vec3 pos) +{ + vec4 k1 = texture3D(volumeSampler, pos); + vec4 k2 = texture3D(volumeSampler, pos + 0.5 * stepSize * k1.xyz); + vec4 k3 = texture3D(volumeSampler, pos + 0.5 * stepSize * k2.xyz); + vec4 k4 = texture3D(volumeSampler, pos + stepSize * k3.xyz); + + return pos + stepSize / 6 * (k1.xyz + 2 * k2.xyz + 2 * k3.xyz + k4.xyz); +} + +void main(void) +{ +/* + vec4 geomPos = gl_TexCoord[0]; + vec3 pos = geomPos.xyz * scaleVol.xyz; + // lookup scalar value + vec4 scalarData = texture3D(scalarSampler, pos); + vec4 vectorData = texture3D(volumeSampler, pos); + vec4 vectorDataNext = texture3D(volumeSamplerNext, pos); + vec4 illum = vec4(0.0, 0.0, 0.0, 1.0); + + // scattering current point value to streamline + // forward + vec3 originPos = pos; + int numIntegrate = 10; + ivec3 size = imageSize(scatterVolume); + //int x = gl_VertexID % size.x; + //int y = ( gl_VertexID % (size.x * size.y)) / size.x; + //int z = gl_VertexID / (size.x * size.y); + //ivec3 i = ivec3(x, y , z); + //originPos = vec3(x/256.0, y/256.0, z/256.0); + for(int itr = 0; itr < numIntegrate; itr++) + { + originPos = nextStreamline(originPos); + vec4 weightValue = 1.5 * texture3D(noiseSampler, pos*gradient.z); + imageStore(scatterVolume, ivec3(pos*size), weightValue ); + } +*/ + + //gl_FragColor = illum; +} \ No newline at end of file diff --git a/VectorVisualization/shader/lic3d_volume_fragment.glsl b/VectorVisualization/shader/lic3d_volume_fragment.glsl index 289d97b..f463756 100644 --- a/VectorVisualization/shader/lic3d_volume_fragment.glsl +++ b/VectorVisualization/shader/lic3d_volume_fragment.glsl @@ -1,31 +1,38 @@ +#if defined(ILLUM_GRADIENT) +# define USE_NOISE_GRADIENTS +#endif + +layout(location = 0) out vec4 out_scalar; +layout(location = 1) out vec4 out_normal; + void main(void) { vec4 geomPos = gl_TexCoord[0]; vec3 pos = geomPos.xyz * scaleVol.xyz; // lookup scalar value - vec4 scalarData = texture3D(scalarSampler, pos); + //vec4 scalarData = texture3D(scalarSampler, pos); vec4 vectorData = texture3D(volumeSampler, pos); - vec4 vectorDataNext = texture3D(volumeSamplerNext, pos); - vec4 illum = vec4(0.0, 0.0, 0.0, 1.0); - + //vec4 vectorDataNext = texture3D(volumeSamplerNext, pos); + vec4 illum = vec4(0.0); //if(pos.x < 0.5 && pos.y > 0.5) - { vec3 streamStart; vec3 streamEnd; vec2 streamDis; - illum.r = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd, volumeSampler).r; + vec4 res = computeLIC(pos, vectorData, streamDis, streamStart, streamEnd); + illum = vec4(res.a * licKernel.b * gradient.r); + illum.a = 1.0; + // scale LIC intensity - illum.r *= licKernel.b * gradient.r; - illum.g = computeLIC(pos, vectorDataNext, streamDis, streamStart, streamEnd, volumeSamplerNext).r; + //illum.g = computeLIC(pos, vectorDataNext, streamDis, streamStart, streamEnd, volumeSamplerNext).r; // scale LIC intensity - illum.g *= licKernel.b * gradient.r; + //illum.g *= licKernel.b * gradient.r; //if (vectorData.g == vectorDataNext.g) //if (illum.r == illum.g) //illum.b = 1.0; - } - gl_FragColor = illum; + out_scalar = illum; + out_normal = vec4(normalize(res.rgb), 0.0); //gl_FragColor = vec4(pos, 1); } \ No newline at end of file diff --git a/VectorVisualization/shader/raycast_lic3d_fragment.glsl b/VectorVisualization/shader/raycast_lic3d_fragment.glsl index 4d920d2..a721138 100644 --- a/VectorVisualization/shader/raycast_lic3d_fragment.glsl +++ b/VectorVisualization/shader/raycast_lic3d_fragment.glsl @@ -1,6 +1,8 @@ uniform sampler3D licVolumeSampler; -uniform sampler3D licVolumeSamplerOld; +uniform sampler3D licVolumeNormal; +uniform sampler3D laoVolumeSampler; +uniform sampler3D licVolumeNormalSampler; uniform int interpSize; uniform float interpStep; @@ -26,17 +28,13 @@ void main(void) float scalarData; vec4 volumeData; - vec4 volumeDataOld; vec4 vectorData; + vec4 normalData; + float ao = 0.0; vec4 dest = vec4(0.0); vec4 src; - //dest = texture3D(licVolumeSampler, pos); - - // move one step forward - //pos += dir * stepSize; - for (int j=0; (!outside && (j= 0.5) @@ -45,28 +43,38 @@ void main(void) // lookup scalar value vectorData = texture3D(volumeSampler, pos); volumeData = texture3D(licVolumeSampler, pos); + normalData = texture3D(licVolumeNormalSampler, pos); - //volumeDataOld = texture3D(licVolumeSamplerOld, pos); + vec4 intensity = vec4(normalData.rgb, volumeData.r); - float intensity = volumeData.r; - //intensity = mix(volumeData.r, volumeData.g, interpStep); - - //noise = texture3D(noiseSampler, pos); + //float intensity = normalData.r ; + //volumeData.r *= licKernel.b * gradient.r; // lookup in transfer function //tfData = texture1D(transferRGBASampler, vectorData.z); +#if defined(AMBIENT_OCCULUSION) + ao = texture3D(laoVolumeSampler, pos).r; +#endif + //tfData = vec4(0.0, 1.0, 0.0, 1.0); tfData = vec4(vectorData.rgb, 1.0); - - - #if defined(ILLUM_GRADIENT) - src = illumGradient(volumeData, tfData, pos, dir, vectorData.xyz); +#if defined(ILLUM_GRADIENT) + //intensity = vec4(normalize(intensity.rgb), intensity.a); + //src = illumGradient(intensity, tfData, pos, dir, vectorData.xyz); + src = vec4(normalize(intensity.rgb), 1.0); #elif defined(ILLUM_MALLO) - src = illumMallo(intensity, tfData, pos, dir, vectorData.xyz); + src = illumMallo(intensity.a, tfData, pos, dir, vectorData.xyz); #elif defined(ILLUM_ZOECKLER) - src = illumZoeckler(intensity, tfData, pos, dir, vectorData.xyz); + src = illumZoeckler(intensity.a, tfData, pos, dir, vectorData.xyz); +#elif defined(AMBIENT_OCCULUSION) + //src = illumLIC(intensity.a, tfData, ao); + tfData = vec4(1.0, 1.0, 1.0, 1.0); + if(ao > 0.0) + src = vec4(tfData.rgb * (1 - ao), ao); + else + src = vec4(tfData.rgb * (1 - ao), 0.0); #else // -- standard LIC -- - src = illumLIC(intensity, tfData); + src = illumLIC(intensity.a, tfData); #endif //src = illumLIC(intensity, tfData); //src = volumeData; @@ -75,12 +83,9 @@ void main(void) src.rgb *= src.a; dest = clamp((1.0-dest.a)*src + dest, 0.0, 1.0); - // early ray termination with high opacity - // ... - // move one step forward pos += dir * stepSize; - + // early ray termination with high opacity // terminate loop if outside volume outside = any(bvec4(clamp(pos.xyz, vec3(0.0), texMax.xyz) - pos.xyz, dest.a > 0.95)); if (outside) diff --git a/VectorVisualization/shader/vectorfield_fragment.glsl b/VectorVisualization/shader/vectorfield_fragment.glsl index 26c491c..38700eb 100644 --- a/VectorVisualization/shader/vectorfield_fragment.glsl +++ b/VectorVisualization/shader/vectorfield_fragment.glsl @@ -71,13 +71,13 @@ void main(void) // lookup scalar value vectorData = texture3D(volumeSampler, pos); noise = texture3D(noiseSampler, pos); - scalarData = vectorData.a; + scalarData = vectorData.r; // lookup in transfer function data = texture1D(transferRGBASampler, scalarData); - src = vec4(vectorData.xyz, data.a); - //src = vec4(noise.xyz, data.a); + //src = vec4(vectorData.xyz, data.a); + src = vec4(data.xyz, vectorData.r); // perform blending src.rgb *= src.a; diff --git a/VectorVisualization/types.h b/VectorVisualization/types.h index 923d09b..be75bd6 100644 --- a/VectorVisualization/types.h +++ b/VectorVisualization/types.h @@ -68,6 +68,7 @@ enum RenderTechnique //VOLIC_DEPTH_PEEL_MULTI VOLIC_LICVOLUME, VOLIC_VOLUMEANI, + VOLIC_SCATTER, }; enum MouseMode @@ -85,11 +86,12 @@ enum MouseMode struct LICParams { LICParams(void) : stepSizeVol(1.0f / 256.0f), gradientScale(30.0f), - illumScale(1.0f), freqScale(0.6f), + illumScale(1.0f), freqScale(1.0f), numIterations(255), stepsForward(48), stepsBackward(48), stepSizeLIC(0.01f), - interpSize(1), interpStep(0) + interpSize(1), interpStep(0), + minScalarRange(0.0), maxScalarRange(1.0) {} float stepSizeVol; @@ -104,6 +106,19 @@ struct LICParams int interpSize; int interpStep; + + float minScalarRange; + float maxScalarRange; +}; + +struct LAOParams +{ + LAOParams(void) : sampleNum(6), pointNum(48), maxRayLen(0.1) + {} + + int sampleNum; + int pointNum; + float maxRayLen; }; From e64cf058dcd01b300ca2e447ed3022a06b94b2a8 Mon Sep 17 00:00:00 2001 From: Yangguang Date: Wed, 21 Mar 2018 18:51:43 -0700 Subject: [PATCH 5/7] configure update --- .../VectorVisualization.vcxproj | 6 ++++++ .../VectorVisualization.vcxproj.filters | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/VectorVisualization/VectorVisualization.vcxproj b/VectorVisualization/VectorVisualization.vcxproj index 9aa293e..e0efe53 100644 --- a/VectorVisualization/VectorVisualization.vcxproj +++ b/VectorVisualization/VectorVisualization.vcxproj @@ -124,6 +124,7 @@ + @@ -148,6 +149,7 @@ + @@ -171,10 +173,14 @@ + + + + diff --git a/VectorVisualization/VectorVisualization.vcxproj.filters b/VectorVisualization/VectorVisualization.vcxproj.filters index 98a7947..24011c0 100644 --- a/VectorVisualization/VectorVisualization.vcxproj.filters +++ b/VectorVisualization/VectorVisualization.vcxproj.filters @@ -93,6 +93,9 @@ Source Files\graphics + + Source Files\graphics + @@ -161,6 +164,9 @@ Source Files\graphics + + Source Files\graphics + @@ -202,6 +208,18 @@ Source Files\shaders + + Source Files\shaders + + + Source Files\shaders + + + Source Files\shaders + + + Source Files\shaders + From cf63f067a43501aa5504ef45113ad225a2aa79a3 Mon Sep 17 00:00:00 2001 From: Yangguang Date: Wed, 2 May 2018 19:43:33 -0700 Subject: [PATCH 6/7] Add vector reference data and CPU LIC --- VectorVisualization/3DLIC.cpp | 33 +- VectorVisualization/3DLIC.h | 1 + VectorVisualization/CPULIC.cpp | 2 +- VectorVisualization/GLSLShader.cpp | 8 +- VectorVisualization/GLSLShader.h | 1 + VectorVisualization/dataset.cpp | 11 +- .../glew-1.11.0/doc/advanced.html | 67 +- .../glew-1.11.0/doc/basic.html | 28 +- .../glew-1.11.0/doc/build.html | 33 +- .../glew-1.11.0/doc/credits.html | 55 +- VectorVisualization/glew-1.11.0/doc/glew.html | 1166 ++++++++------- VectorVisualization/glew-1.11.0/doc/glew.txt | 1 + .../glew-1.11.0/doc/glxew.html | 118 +- .../glew-1.11.0/doc/index.html | 57 +- .../glew-1.11.0/doc/install.html | 28 +- VectorVisualization/glew-1.11.0/doc/log.html | 135 +- .../glew-1.11.0/doc/wglew.html | 28 +- .../glew-1.11.0/include/GL/glew.h | 1279 ++++++++++++++++- .../glew-1.11.0/include/GL/glxew.h | 74 +- .../glew-1.11.0/include/GL/wglew.h | 45 +- VectorVisualization/lib/glew32.dll | Bin 391680 -> 370176 bytes VectorVisualization/lib/glew32.lib | Bin 587190 -> 621984 bytes VectorVisualization/lib/glew32s.lib | Bin 2130434 -> 2263484 bytes VectorVisualization/reader.cpp | 9 +- VectorVisualization/renderer.cpp | 10 +- VectorVisualization/renderer.h | 2 + VectorVisualization/shader/inc_header.glsl | 5 +- VectorVisualization/shader/inc_illum.glsl | 71 +- VectorVisualization/shader/inc_lic.glsl | 122 +- .../shader/lic3d_fragment.glsl | 62 +- .../shader/lic3d_lao_fragment.glsl | 114 +- .../shader/raycast_lic3d_fragment.glsl | 73 +- VectorVisualization/types.h | 4 +- 33 files changed, 2563 insertions(+), 1079 deletions(-) diff --git a/VectorVisualization/3DLIC.cpp b/VectorVisualization/3DLIC.cpp index 398b91f..db73e0c 100644 --- a/VectorVisualization/3DLIC.cpp +++ b/VectorVisualization/3DLIC.cpp @@ -104,6 +104,7 @@ void display(void) //double timetest = timer(); renderer.render(updateScene || updateSceneCont); + //std::cout << "cost for render" << timetest - timer() << std::endl; //updateScene = true; @@ -121,9 +122,11 @@ void display(void) snprintf(fpsStr, 10, "%2.2f", fpsCounter.getFPS()); hud.DrawHUD(fpsStr, 420, 2); //hud.DrawHUD(); + //if(updateScene) + // std::cout << fpsCounter << std::endl; CHECK_FOR_OGL_ERROR(); - + //updateScene = false; glutSwapBuffers(); fpsCounter.frameFinished(); } @@ -291,6 +294,8 @@ void keyboard(unsigned char key, int x, int y) hud.SetVisible(!hud.IsVisible()); break; case 'r': + renderer.loadGLSLShader("#define NOISE_LAO_COMPUTE"); + renderer.computeNoiseLAO(); renderer.loadGLSLShader(); updateScene = true; break; @@ -483,6 +488,7 @@ void keyboard(unsigned char key, int x, int y) void keyboardSpecial(int key, int x, int y) { + double begint, ent; switch (key) { case GLUT_KEY_F1: @@ -500,13 +506,15 @@ void keyboardSpecial(int key, int x, int y) break; case GLUT_KEY_F4: renderTechnique = VOLIC_LICVOLUME; - renderer.setDataTex(vd.getTextureSetRef(vd.getCurTimeStep())); - renderer.setNextDataTex(vd.getTextureSetRef(vd.NextTimeStep())); + renderer.setDataTex(vd.getTextureRef()); + //begint = timer(); renderer.renderLICVolume(); renderer.computeVolumeNormal(); //renderer.updateLICVolume(); renderer.computeLAOVolume(); //renderer.updateLICVolume(); + //ent = timer(); + //std::cout<<"pre-computed LIC: "<< ent-begint << std::endl; break; case GLUT_KEY_F5: animationMode = !animationMode; @@ -796,13 +804,22 @@ void init(void) std::cout << std::endl; // load secondary scalar volume data - if (!scalar.loadData("..\\data\\outputraw\\out_64_0_temperature.dat")) + if (!scalar.loadData("..\\data\\327output\\out_64_0_temperature.dat")) { std::cerr << "Could not load data ..." << std::endl; exit(1); } scalar.createTexture("Scalar_Tex", GL_TEXTURE4_ARB); + //load secondary vector data + if (!vector.loadData("..\\data\\327output\\out_64_0_vorticity.dat")) + { + std::cerr << "Could not load data ..." << std::endl; + exit(1); + } + vector.getVolumeData()->data = vector.loadTimeStep(0); + vector.createTexture("Vector_Tex", GL_TEXTURE6_ARB, true); + // load LIC filter kernel if (!licFilter.loadData(arguments.getLicFilterFileName())) { @@ -843,16 +860,19 @@ void init(void) //std::cout << std::endl; //Test of Algorithm using CPU for instance + //double begint = timer(); //cpuLic = new CPULIC(256, 256, 256); //cpuLic->setkernelData(licFilter.getFilterData()); - //cpuLic->setVectorTexture((vd.getTextureSet())[1]); + //cpuLic->setVectorTexture(vd.getTextureRef()); //cpuLic->getVectorTextureData(); //cpuLic->setNoiseData(&noise); //cpuLic->getNoiseTextureData(); ////cpuLic->gather3DLIC(vd.getVolumeDataSet()); //cpuLic->scatter3DLIC(vd.getVolumeDataSet()); + //double endt = timer(); //cpuLic->generateTexture(); - CHECK_FOR_OGL_ERROR(); + //CHECK_FOR_OGL_ERROR(); + //std::cout << "CPU LIC:" << endt - begint << std::endl; clipPlanes[0].rotate(Quaternion_fromAngleAxis(static_cast(M_PI / 2.0), Vector3_new(0.0f, 1.0f, 0.0f))); clipPlanes[1].rotate(Quaternion_fromAngleAxis(static_cast(M_PI / 2.0), Vector3_new(-1.0f, 0.0f, 0.0f))); @@ -883,6 +903,7 @@ void init(void) //renderer.setDataTex(vd.getTextureSetRef(vd.getCurTimeStep())); renderer.setNextDataTex(vd.getTextureSetRef(vd.NextTimeStep())); renderer.setScalarTex(scalar.getTextureRef()); + renderer.setVectorTex(vector.getTextureRef()); renderer.setNoiseTex(noise.getTextureRef()); renderer.setTFrgbTex(tfEdit.getTextureRGB()); renderer.setTFalphaOpacTex(tfEdit.getTextureAlphaOpac()); diff --git a/VectorVisualization/3DLIC.h b/VectorVisualization/3DLIC.h index 40ecad9..1c44923 100644 --- a/VectorVisualization/3DLIC.h +++ b/VectorVisualization/3DLIC.h @@ -25,6 +25,7 @@ Transform light; VectorDataSet vd; VolumeDataSet scalar; // load second dimension scalar data +VectorDataSet vector; NoiseDataSet noise; Illumination illum; LICFilter licFilter; diff --git a/VectorVisualization/CPULIC.cpp b/VectorVisualization/CPULIC.cpp index 2a66585..89e7684 100644 --- a/VectorVisualization/CPULIC.cpp +++ b/VectorVisualization/CPULIC.cpp @@ -24,7 +24,7 @@ CPULIC::CPULIC(int w, int h, int d) data = new float[size]; std::fill_n(data, size, 0); - iterNum = 30; + iterNum = 1; stepSize = 1.0 / width; createFilter(); diff --git a/VectorVisualization/GLSLShader.cpp b/VectorVisualization/GLSLShader.cpp index a301b1a..9ff62c5 100644 --- a/VectorVisualization/GLSLShader.cpp +++ b/VectorVisualization/GLSLShader.cpp @@ -341,7 +341,8 @@ char* GLSLShader::loadSource(char *fileName, int *size) GLSLParamsLIC::GLSLParamsLIC(void) : viewport(-1),texMax(-1),scaleVol(-1), scaleVolInv(-1),stepSize(-1),gradient(-1), licParams(-1),licKernel(-1),numIterations(-1), - alphaCorrection(-1),volumeSampler(-1), volumeSamplerNext(-1), scalarSampler(-1), + alphaCorrection(-1),volumeSampler(-1), volumeSamplerNext(-1), + scalarSampler(-1),vectorSampler(-1), licVolumeSampler(-1), licVolumeSamplerOld(-1), licVolumeNormalSampler(-1), noiseSampler(-1),mcOffsetSampler(-1), noiseLAOSampler(-1), transferRGBASampler(-1), @@ -379,6 +380,7 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) volumeSampler = -1; volumeSamplerNext = -1; scalarSampler = -1; + vectorSampler = -1; noiseSampler = -1; mcOffsetSampler = -1; transferRGBASampler = -1; @@ -512,6 +514,10 @@ void GLSLParamsLIC::getMemoryLocations(GLhandleARB programObj, bool printList) { scalarSampler = i; } + else if (strcmp(buf, "vectorSampler") == 0) + { + vectorSampler = i; + } else if (strcmp(buf, "noiseSampler") == 0) { noiseSampler = i; diff --git a/VectorVisualization/GLSLShader.h b/VectorVisualization/GLSLShader.h index 3a156d2..ba0701c 100644 --- a/VectorVisualization/GLSLShader.h +++ b/VectorVisualization/GLSLShader.h @@ -84,6 +84,7 @@ struct GLSLParamsLIC GLint volumeSampler; GLint volumeSamplerNext; GLint scalarSampler; + GLint vectorSampler; GLint noiseSampler; GLint mcOffsetSampler; GLint transferRGBASampler; diff --git a/VectorVisualization/dataset.cpp b/VectorVisualization/dataset.cpp index 28939a3..497fc9d 100644 --- a/VectorVisualization/dataset.cpp +++ b/VectorVisualization/dataset.cpp @@ -525,8 +525,8 @@ void* VectorDataSet::fillTexDataFloat(int i) } } - if (len > maxLen) - maxLen = len; + if (len > _vd->max_magnetic) + _vd->max_magnetic = len; // store magnitude as float for higher precision padded[4 * adrPacked + 3] = len; @@ -970,7 +970,7 @@ void VolumeDataSet::createTexture(const char *texName, int size; int adr; int adrPacked; - bool needPadding = false; + bool needPadding = true; void *paddedData = _vd->data; if (!_loaded) @@ -1018,7 +1018,8 @@ void VolumeDataSet::createTexture(const char *texName, size = _vd->texSize[0] * _vd->texSize[1] * _vd->texSize[2]; - + float maxt = -1000.0; + float mint = 1000.0; if (needPadding) { if (_vd->dataType == DATRAW_UCHAR) @@ -1048,7 +1049,7 @@ void VolumeDataSet::createTexture(const char *texName, adrPacked = (z*_vd->texSize[1] + y)*_vd->texSize[0] + x; adr = (z*_vd->size[1] + y)*_vd->size[0] + x; ((float*)paddedData)[adrPacked] = - ((float*)_vd->data)[adr]; + (((float*)_vd->data)[adr] + 1.0) / 2.0; } } } diff --git a/VectorVisualization/glew-1.11.0/doc/advanced.html b/VectorVisualization/glew-1.11.0/doc/advanced.html index f53383d..b4c98bb 100644 --- a/VectorVisualization/glew-1.11.0/doc/advanced.html +++ b/VectorVisualization/glew-1.11.0/doc/advanced.html @@ -1,7 +1,7 @@ - GLEW: The OpenGL Extension Wrangler Library @@ -47,7 +46,7 @@ - + @@ -58,11 +57,15 @@ - - - - + + + + + + + +
Latest Release: 1.11.0
Latest Release: 2.2.0

GLEW Logo

Building
Installation
Source Generation
Credits & Copyright
Change Log
Project Page
Mailing Lists
Bug Tracker

GitHub
Issues
Pull Requests
Authors
Licensing

SourceForge Page

@@ -72,13 +75,12 @@ - +
Last Update: 08-11-14
Last Update: 07-24-16
- OpenGL Logo - SourceForge Logo + OpenGL Logo
+ GitHub Logo
+ Travis Logo
+ SourceForge Logo
@@ -206,45 +208,6 @@

Custom Code Generation

WGL_NV_float_buffer

-

Multiple Rendering Contexts (GLEW MX)

- -

Starting with release 1.2.0, thread-safe support for multiple -rendering contexts, possibly with different capabilities, is -available. Since this is not required by most users, it is not added -to the binary releases to maintain compatibility between different -versions. To include multi-context support, you have to do the -following:

-
    -
  1. Compile and use GLEW with the GLEW_MX preprocessor token -defined.
  2. -
  3. For each rendering context, create a GLEWContext object -that will be available as long as the rendering context exists.
  4. -
  5. Define a macro or function called glewGetContext() that -returns a pointer to the GLEWContext object associated with -the rendering context from which OpenGL/WGL/GLX calls are issued. This -dispatch mechanism is primitive, but generic. -
  6. Make sure that you call glewInit() after creating the -GLEWContext object in each rendering context. Note, that the -GLEWContext pointer returned by glewGetContext() has -to reside in global or thread-local memory. -
- -

Note that according to the MSDN -WGL documentation, you have to initialize the entry points for -every rendering context that use pixel formats with different -capabilities For example, the pixel formats provided by the generic -software OpenGL implementation by Microsoft vs. the hardware -accelerated pixel formats have different capabilities. GLEW by -default ignores this requirement, and does not define per-context -entry points (you can however do this using the steps described -above). Assuming a global namespace for the entry points works in -most situations, because typically all hardware accelerated pixel -formats provide the same entry points and capabilities. This means -that unless you use the multi-context version of GLEW, you need to -call glewInit() only once in your program, or more precisely, -once per process.

-

Separate Namespace

diff --git a/VectorVisualization/glew-1.11.0/doc/basic.html b/VectorVisualization/glew-1.11.0/doc/basic.html index 4ed1684..4acb9b6 100644 --- a/VectorVisualization/glew-1.11.0/doc/basic.html +++ b/VectorVisualization/glew-1.11.0/doc/basic.html @@ -1,7 +1,7 @@ - GLEW: The OpenGL Extension Wrangler Library @@ -47,7 +46,7 @@ - + @@ -58,11 +57,15 @@ - - - - + + + + + + + +
Latest Release: 1.11.0
Latest Release: 2.2.0

GLEW Logo

Building
Installation
Source Generation
Credits & Copyright
Change Log
Project Page
Mailing Lists
Bug Tracker

GitHub
Issues
Pull Requests
Authors
Licensing

SourceForge Page

@@ -72,13 +75,12 @@ - +
Last Update: 08-11-14
Last Update: 07-24-16
- OpenGL Logo - SourceForge Logo + OpenGL Logo
+ GitHub Logo
+ Travis Logo
+ SourceForge Logo
diff --git a/VectorVisualization/glew-1.11.0/doc/build.html b/VectorVisualization/glew-1.11.0/doc/build.html index 72513d4..1bf90a2 100644 --- a/VectorVisualization/glew-1.11.0/doc/build.html +++ b/VectorVisualization/glew-1.11.0/doc/build.html @@ -1,7 +1,7 @@ - GLEW: The OpenGL Extension Wrangler Library @@ -47,7 +46,7 @@ - + @@ -58,11 +57,15 @@ - - - - + + + + + + + +
Latest Release: 1.11.0
Latest Release: 2.2.0

GLEW Logo

Building
Installation
Source Generation
Credits & Copyright
Change Log
Project Page
Mailing Lists
Bug Tracker

GitHub
Issues
Pull Requests
Authors
Licensing

SourceForge Page

@@ -72,13 +75,12 @@ - +
Last Update: 08-11-14
Last Update: 07-24-16
- OpenGL Logo - SourceForge Logo + OpenGL Logo
+ GitHub Logo
+ Travis Logo
+ SourceForge Logo
@@ -138,10 +140,11 @@

Requirements

  • wget
  • GNU sed
  • gcc compiler
  • +
  • git
  • -Ubuntu:
    sudo apt-get install libXmu-dev libXi-dev libgl-dev dos2unix
    -Fedora:
    sudo yum install libXmu-devel libXi-devel libGL-devel dos2unix
    +Ubuntu:
    sudo apt-get install libXmu-dev libXi-dev libgl-dev dos2unix git wget
    +Fedora:
    sudo yum install libXmu-devel libXi-devel libGL-devel dos2unix git wget
    diff --git a/VectorVisualization/glew-1.11.0/doc/credits.html b/VectorVisualization/glew-1.11.0/doc/credits.html index fbd3d3e..dd7e25d 100644 --- a/VectorVisualization/glew-1.11.0/doc/credits.html +++ b/VectorVisualization/glew-1.11.0/doc/credits.html @@ -1,7 +1,7 @@ - GLEW: The OpenGL Extension Wrangler Library @@ -47,7 +46,7 @@ - + @@ -58,11 +57,15 @@ - - - - + + + + + + + +
    Latest Release: 1.11.0
    Latest Release: 2.2.0

    GLEW Logo

    Building
    Installation
    Source Generation
    Credits & Copyright
    Change Log
    Project Page
    Mailing Lists
    Bug Tracker

    GitHub
    Issues
    Pull Requests
    Authors
    Licensing

    SourceForge Page

    @@ -72,13 +75,12 @@ - +
    Last Update: 08-11-14
    Last Update: 07-24-16
    - OpenGL Logo - SourceForge Logo + OpenGL Logo
    + GitHub Logo
    + Travis Logo
    + SourceForge Logo
    @@ -94,31 +96,8 @@

    The OpenGL Extension Wrangler Library

    -

    Credits

    - -

    -GLEW was developed by Milan -Ikits and Marcelo -Magallon. They also perform occasional maintainance to make sure -that GLEW stays in mint condition. Aaron Lefohn, Joe Kniss, and Chris -Wyman were the first users and also assisted with the design and -debugging process. The acronym GLEW originates from Aaron Lefohn. -Pasi Kärkkäinen identified and fixed several problems with -GLX and SDL. Nate Robins created the wglinfo utility, to -which modifications were made by Michael Wimmer. -

    - -

    Copyright

    - -

    -GLEW is originally derived from the EXTGL project by Lev Povalahev. -The source code is licensed under the Modified BSD -License, the Mesa 3-D License (MIT -License), and the Khronos License (MIT -License). The automatic code generation scripts are released under -the GNU GPL. -

    +

    +Author, copyright and licensing information on github.

    diff --git a/VectorVisualization/glew-1.11.0/doc/glew.html b/VectorVisualization/glew-1.11.0/doc/glew.html index 04fcb38..0e75551 100644 --- a/VectorVisualization/glew-1.11.0/doc/glew.html +++ b/VectorVisualization/glew-1.11.0/doc/glew.html @@ -1,7 +1,7 @@ - GLEW: The OpenGL Extension Wrangler Library @@ -47,7 +46,7 @@ - + @@ -58,11 +57,15 @@ - - - - + + + + + + + +
    Latest Release: 1.11.0
    Latest Release: 2.2.0

    GLEW Logo

    Building
    Installation
    Source Generation
    Credits & Copyright
    Change Log
    Project Page
    Mailing Lists
    Bug Tracker

    GitHub
    Issues
    Pull Requests
    Authors
    Licensing

    SourceForge Page

    @@ -72,13 +75,12 @@ - +
    Last Update: 08-11-14
    Last Update: 07-24-16
    - OpenGL Logo - SourceForge Logo + OpenGL Logo
    + GitHub Logo
    + Travis Logo
    + SourceForge Logo
    @@ -118,547 +120,603 @@

    Supported OpenGL Extensions

    18 AMD_sample_positions 19 AMD_seamless_cubemap_per_texture 20 AMD_shader_atomic_counter_ops -21 AMD_shader_stencil_export -22 AMD_shader_stencil_value_export -23 AMD_shader_trinary_minmax -24 AMD_sparse_texture -25 AMD_stencil_operation_extended -26 AMD_texture_texture4 -27 AMD_transform_feedback3_lines_triangles -28 AMD_transform_feedback4 -29 AMD_vertex_shader_layer -30 AMD_vertex_shader_tessellator -31 AMD_vertex_shader_viewport_index -
    -32 ANGLE_depth_texture -33 ANGLE_framebuffer_blit -34 ANGLE_framebuffer_multisample -35 ANGLE_instanced_arrays -36 ANGLE_pack_reverse_row_order -37 ANGLE_program_binary -38 ANGLE_texture_compression_dxt1 -39 ANGLE_texture_compression_dxt3 -40 ANGLE_texture_compression_dxt5 -41 ANGLE_texture_usage -42 ANGLE_timer_query -43 ANGLE_translated_shader_source -
    -44 APPLE_aux_depth_stencil -45 APPLE_client_storage -46 APPLE_element_array -47 APPLE_fence -48 APPLE_float_pixels -49 APPLE_flush_buffer_range -50 APPLE_object_purgeable -51 APPLE_pixel_buffer -52 APPLE_rgb_422 -53 APPLE_row_bytes -54 APPLE_specular_vector -55 APPLE_texture_range -56 APPLE_transform_hint -57 APPLE_vertex_array_object -58 APPLE_vertex_array_range -59 APPLE_vertex_program_evaluators -60 APPLE_ycbcr_422 -
    -61 ARB_ES2_compatibility -62 ARB_ES3_1_compatibility -63 ARB_ES3_compatibility -64 ARB_arrays_of_arrays -65 ARB_base_instance -66 ARB_bindless_texture -67 ARB_blend_func_extended -68 ARB_buffer_storage -69 ARB_cl_event -70 ARB_clear_buffer_object -71 ARB_clear_texture -72 ARB_clip_control -73 ARB_color_buffer_float -74 ARB_compatibility -75 ARB_compressed_texture_pixel_storage -76 ARB_compute_shader -77 ARB_compute_variable_group_size -78 ARB_conditional_render_inverted -79 ARB_conservative_depth -80 ARB_copy_buffer -81 ARB_copy_image -82 ARB_cull_distance -83 ARB_debug_output -84 ARB_depth_buffer_float -85 ARB_depth_clamp -86 ARB_depth_texture -87 ARB_derivative_control -88 ARB_direct_state_access -89 ARB_draw_buffers -90 ARB_draw_buffers_blend -91 ARB_draw_elements_base_vertex -92 ARB_draw_indirect -93 ARB_draw_instanced -94 ARB_enhanced_layouts -95 ARB_explicit_attrib_location -96 ARB_explicit_uniform_location -97 ARB_fragment_coord_conventions -98 ARB_fragment_layer_viewport -99 ARB_fragment_program -100 ARB_fragment_program_shadow -101 ARB_fragment_shader -102 ARB_framebuffer_no_attachments -103 ARB_framebuffer_object -104 ARB_framebuffer_sRGB -105 ARB_geometry_shader4 -106 ARB_get_program_binary -107 ARB_get_texture_sub_image -108 ARB_gpu_shader5 -109 ARB_gpu_shader_fp64 -110 ARB_half_float_pixel -111 ARB_half_float_vertex -112 ARB_imaging -113 ARB_indirect_parameters -114 ARB_instanced_arrays -115 ARB_internalformat_query -116 ARB_internalformat_query2 -117 ARB_invalidate_subdata -118 ARB_map_buffer_alignment -119 ARB_map_buffer_range -120 ARB_matrix_palette -121 ARB_multi_bind -122 ARB_multi_draw_indirect -123 ARB_multisample -124 ARB_multitexture -125 ARB_occlusion_query -126 ARB_occlusion_query2 -127 ARB_pipeline_statistics_query -128 ARB_pixel_buffer_object -129 ARB_point_parameters -130 ARB_point_sprite -131 ARB_program_interface_query -132 ARB_provoking_vertex -133 ARB_query_buffer_object -134 ARB_robust_buffer_access_behavior -135 ARB_robustness -136 ARB_robustness_application_isolation -137 ARB_robustness_share_group_isolation -138 ARB_sample_shading -139 ARB_sampler_objects -140 ARB_seamless_cube_map -141 ARB_seamless_cubemap_per_texture -142 ARB_separate_shader_objects -143 ARB_shader_atomic_counters -144 ARB_shader_bit_encoding -145 ARB_shader_draw_parameters -146 ARB_shader_group_vote -147 ARB_shader_image_load_store -148 ARB_shader_image_size -149 ARB_shader_objects -150 ARB_shader_precision -151 ARB_shader_stencil_export -152 ARB_shader_storage_buffer_object -153 ARB_shader_subroutine -154 ARB_shader_texture_image_samples -155 ARB_shader_texture_lod -156 ARB_shading_language_100 -157 ARB_shading_language_420pack -158 ARB_shading_language_include -159 ARB_shading_language_packing -160 ARB_shadow -161 ARB_shadow_ambient -162 ARB_sparse_buffer -163 ARB_sparse_texture -164 ARB_stencil_texturing -165 ARB_sync -166 ARB_tessellation_shader -167 ARB_texture_barrier -168 ARB_texture_border_clamp -169 ARB_texture_buffer_object -170 ARB_texture_buffer_object_rgb32 -171 ARB_texture_buffer_range -172 ARB_texture_compression -173 ARB_texture_compression_bptc -174 ARB_texture_compression_rgtc -175 ARB_texture_cube_map -176 ARB_texture_cube_map_array -177 ARB_texture_env_add -178 ARB_texture_env_combine -179 ARB_texture_env_crossbar -180 ARB_texture_env_dot3 -181 ARB_texture_float -182 ARB_texture_gather -183 ARB_texture_mirror_clamp_to_edge -184 ARB_texture_mirrored_repeat -185 ARB_texture_multisample -186 ARB_texture_non_power_of_two -187 ARB_texture_query_levels -188 ARB_texture_query_lod -189 ARB_texture_rectangle -190 ARB_texture_rg -191 ARB_texture_rgb10_a2ui -192 ARB_texture_stencil8 -193 ARB_texture_storage -194 ARB_texture_storage_multisample -195 ARB_texture_swizzle -196 ARB_texture_view -197 ARB_timer_query -198 ARB_transform_feedback2 -199 ARB_transform_feedback3 -200 ARB_transform_feedback_instanced -201 ARB_transform_feedback_overflow_query -202 ARB_transpose_matrix -203 ARB_uniform_buffer_object -204 ARB_vertex_array_bgra -205 ARB_vertex_array_object -206 ARB_vertex_attrib_64bit -207 ARB_vertex_attrib_binding -208 ARB_vertex_blend -209 ARB_vertex_buffer_object -210 ARB_vertex_program -211 ARB_vertex_shader -212 ARB_vertex_type_10f_11f_11f_rev -213 ARB_vertex_type_2_10_10_10_rev -214 ARB_viewport_array -215 ARB_window_pos -
    -216 ATIX_point_sprites -217 ATIX_texture_env_combine3 -218 ATIX_texture_env_route -219 ATIX_vertex_shader_output_point_size -
    -220 ATI_draw_buffers -221 ATI_element_array -222 ATI_envmap_bumpmap -223 ATI_fragment_shader -224 ATI_map_object_buffer -225 ATI_meminfo -226 ATI_pn_triangles -227 ATI_separate_stencil -228 ATI_shader_texture_lod -229 ATI_text_fragment_shader -230 ATI_texture_compression_3dc -231 ATI_texture_env_combine3 -232 ATI_texture_float -233 ATI_texture_mirror_once -234 ATI_vertex_array_object -235 ATI_vertex_attrib_array_object -236 ATI_vertex_streams -
    -237 EXT_422_pixels -238 EXT_Cg_shader -239 EXT_abgr -240 EXT_bgra -241 EXT_bindable_uniform -242 EXT_blend_color -243 EXT_blend_equation_separate -244 EXT_blend_func_separate -245 EXT_blend_logic_op -246 EXT_blend_minmax -247 EXT_blend_subtract -248 EXT_clip_volume_hint -249 EXT_cmyka -250 EXT_color_subtable -251 EXT_compiled_vertex_array -252 EXT_convolution -253 EXT_coordinate_frame -254 EXT_copy_texture -255 EXT_cull_vertex -256 EXT_debug_label -257 EXT_debug_marker -258 EXT_depth_bounds_test -259 EXT_direct_state_access -260 EXT_draw_buffers2 -261 EXT_draw_instanced -262 EXT_draw_range_elements -263 EXT_fog_coord -264 EXT_fragment_lighting -265 EXT_framebuffer_blit -266 EXT_framebuffer_multisample -267 EXT_framebuffer_multisample_blit_scaled -268 EXT_framebuffer_object -269 EXT_framebuffer_sRGB -270 EXT_geometry_shader4 -271 EXT_gpu_program_parameters -272 EXT_gpu_shader4 -273 EXT_histogram -274 EXT_index_array_formats -275 EXT_index_func -276 EXT_index_material -277 EXT_index_texture -278 EXT_light_texture -279 EXT_misc_attribute -280 EXT_multi_draw_arrays -281 EXT_multisample -282 EXT_packed_depth_stencil -283 EXT_packed_float -284 EXT_packed_pixels -285 EXT_paletted_texture -286 EXT_pixel_buffer_object -287 EXT_pixel_transform -288 EXT_pixel_transform_color_table -289 EXT_point_parameters -290 EXT_polygon_offset -291 EXT_provoking_vertex -292 EXT_rescale_normal -293 EXT_scene_marker -294 EXT_secondary_color -295 EXT_separate_shader_objects -296 EXT_separate_specular_color -297 EXT_shader_image_load_formatted -298 EXT_shader_image_load_store -299 EXT_shader_integer_mix -300 EXT_shadow_funcs -301 EXT_shared_texture_palette -302 EXT_stencil_clear_tag -303 EXT_stencil_two_side -304 EXT_stencil_wrap -305 EXT_subtexture -306 EXT_texture -307 EXT_texture3D -308 EXT_texture_array -309 EXT_texture_buffer_object -310 EXT_texture_compression_dxt1 -311 EXT_texture_compression_latc -312 EXT_texture_compression_rgtc -313 EXT_texture_compression_s3tc -314 EXT_texture_cube_map -315 EXT_texture_edge_clamp -316 EXT_texture_env -317 EXT_texture_env_add -318 EXT_texture_env_combine -319 EXT_texture_env_dot3 -320 EXT_texture_filter_anisotropic -321 EXT_texture_integer -322 EXT_texture_lod_bias -323 EXT_texture_mirror_clamp -324 EXT_texture_object -325 EXT_texture_perturb_normal -326 EXT_texture_rectangle -327 EXT_texture_sRGB -328 EXT_texture_sRGB_decode -329 EXT_texture_shared_exponent -330 EXT_texture_snorm -331 EXT_texture_swizzle -332 EXT_timer_query -333 EXT_transform_feedback -334 EXT_vertex_array -335 EXT_vertex_array_bgra -336 EXT_vertex_attrib_64bit -337 EXT_vertex_shader -338 EXT_vertex_weighting -339 EXT_x11_sync_object -
    -340 GREMEDY_frame_terminator -341 GREMEDY_string_marker -
    -342 HP_convolution_border_modes -343 HP_image_transform -344 HP_occlusion_test -345 HP_texture_lighting -
    -346 IBM_cull_vertex -347 IBM_multimode_draw_arrays -348 IBM_rasterpos_clip -349 IBM_static_data -350 IBM_texture_mirrored_repeat -351 IBM_vertex_array_lists -
    -352 INGR_color_clamp -353 INGR_interlace_read -
    -354 INTEL_fragment_shader_ordering -355 INTEL_map_texture -356 INTEL_parallel_arrays -357 INTEL_performance_query -358 INTEL_texture_scissor -
    -359 KHR_blend_equation_advanced -360 KHR_blend_equation_advanced_coherent -361 KHR_context_flush_control -362 KHR_debug -363 KHR_robust_buffer_access_behavior -364 KHR_robustness -365 KHR_texture_compression_astc_hdr -366 KHR_texture_compression_astc_ldr -
    -367 KTX_buffer_region -
    -368 MESAX_texture_stack -
    -369 MESA_pack_invert -370 MESA_resize_buffers -371 MESA_window_pos -372 MESA_ycbcr_texture -
    -373 NVX_conditional_render -374 NVX_gpu_memory_info -
    -375 NV_bindless_multi_draw_indirect -376 NV_bindless_multi_draw_indirect_count -377 NV_bindless_texture -378 NV_blend_equation_advanced -379 NV_blend_equation_advanced_coherent -380 NV_blend_square -381 NV_compute_program5 -382 NV_conditional_render -383 NV_copy_depth_to_color -384 NV_copy_image -385 NV_deep_texture3D -386 NV_depth_buffer_float -387 NV_depth_clamp -388 NV_depth_range_unclamped -389 NV_draw_texture -390 NV_evaluators -391 NV_explicit_multisample -392 NV_fence -393 NV_float_buffer -394 NV_fog_distance -395 NV_fragment_program -396 NV_fragment_program2 -397 NV_fragment_program4 -398 NV_fragment_program_option -399 NV_framebuffer_multisample_coverage -400 NV_geometry_program4 -401 NV_geometry_shader4 -402 NV_gpu_program4 -403 NV_gpu_program5 -404 NV_gpu_program5_mem_extended -405 NV_gpu_program_fp64 -406 NV_gpu_shader5 -407 NV_half_float -408 NV_light_max_exponent -409 NV_multisample_coverage -410 NV_multisample_filter_hint -411 NV_occlusion_query -412 NV_packed_depth_stencil -413 NV_parameter_buffer_object -414 NV_parameter_buffer_object2 -415 NV_path_rendering -416 NV_pixel_data_range -417 NV_point_sprite -418 NV_present_video -419 NV_primitive_restart -420 NV_register_combiners -421 NV_register_combiners2 -422 NV_shader_atomic_counters -423 NV_shader_atomic_float -424 NV_shader_atomic_int64 -425 NV_shader_buffer_load -426 NV_shader_storage_buffer_object -427 NV_shader_thread_group -428 NV_shader_thread_shuffle -429 NV_tessellation_program5 -430 NV_texgen_emboss -431 NV_texgen_reflection -432 NV_texture_barrier -433 NV_texture_compression_vtc -434 NV_texture_env_combine4 -435 NV_texture_expand_normal -436 NV_texture_multisample -437 NV_texture_rectangle -438 NV_texture_shader -439 NV_texture_shader2 -440 NV_texture_shader3 -441 NV_transform_feedback -442 NV_transform_feedback2 -443 NV_vdpau_interop -444 NV_vertex_array_range -445 NV_vertex_array_range2 -446 NV_vertex_attrib_integer_64bit -447 NV_vertex_buffer_unified_memory -448 NV_vertex_program -449 NV_vertex_program1_1 -450 NV_vertex_program2 -451 NV_vertex_program2_option -452 NV_vertex_program3 -453 NV_vertex_program4 -454 NV_video_capture -
    -455 OES_byte_coordinates -456 OES_compressed_paletted_texture -457 OES_read_format -458 OES_single_precision -
    -459 OML_interlace -460 OML_resample -461 OML_subsample -
    -462 PGI_misc_hints -463 PGI_vertex_hints -
    -464 REGAL_ES1_0_compatibility -465 REGAL_ES1_1_compatibility -466 REGAL_enable -467 REGAL_error_string -468 REGAL_extension_query -469 REGAL_log -470 REGAL_proc_address -
    -471 REND_screen_coordinates -
    -472 S3_s3tc -
    -473 SGIS_color_range -474 SGIS_detail_texture -475 SGIS_fog_function -476 SGIS_generate_mipmap -477 SGIS_multisample -478 SGIS_pixel_texture -479 SGIS_point_line_texgen -480 SGIS_sharpen_texture -481 SGIS_texture4D -482 SGIS_texture_border_clamp -483 SGIS_texture_edge_clamp -484 SGIS_texture_filter4 -485 SGIS_texture_lod -486 SGIS_texture_select -
    -487 SGIX_async -488 SGIX_async_histogram -489 SGIX_async_pixel -490 SGIX_blend_alpha_minmax -491 SGIX_clipmap -492 SGIX_convolution_accuracy -493 SGIX_depth_texture -494 SGIX_flush_raster -495 SGIX_fog_offset -496 SGIX_fog_texture -497 SGIX_fragment_specular_lighting -498 SGIX_framezoom -499 SGIX_interlace -500 SGIX_ir_instrument1 -501 SGIX_list_priority -502 SGIX_pixel_texture -503 SGIX_pixel_texture_bits -504 SGIX_reference_plane -505 SGIX_resample -506 SGIX_shadow -507 SGIX_shadow_ambient -508 SGIX_sprite -509 SGIX_tag_sample_buffer -510 SGIX_texture_add_env -511 SGIX_texture_coordinate_clamp -512 SGIX_texture_lod_bias -513 SGIX_texture_multi_buffer -514 SGIX_texture_range -515 SGIX_texture_scale_bias -516 SGIX_vertex_preclip -517 SGIX_vertex_preclip_hint -518 SGIX_ycrcb -
    -519 SGI_color_matrix -520 SGI_color_table -521 SGI_texture_color_table -
    -522 SUNX_constant_data -
    -523 SUN_convolution_border_modes -524 SUN_global_alpha -525 SUN_mesh_array -526 SUN_read_video_pixels -527 SUN_slice_accum -528 SUN_triangle_list -529 SUN_vertex -
    -530 WIN_phong_shading -531 WIN_specular_fog -532 WIN_swap_hint +21 AMD_shader_explicit_vertex_parameter +22 AMD_shader_stencil_export +23 AMD_shader_stencil_value_export +24 AMD_shader_trinary_minmax +25 AMD_sparse_texture +26 AMD_stencil_operation_extended +27 AMD_texture_texture4 +28 AMD_transform_feedback3_lines_triangles +29 AMD_transform_feedback4 +30 AMD_vertex_shader_layer +31 AMD_vertex_shader_tessellator +32 AMD_vertex_shader_viewport_index +
    +33 ANGLE_depth_texture +34 ANGLE_framebuffer_blit +35 ANGLE_framebuffer_multisample +36 ANGLE_instanced_arrays +37 ANGLE_pack_reverse_row_order +38 ANGLE_program_binary +39 ANGLE_texture_compression_dxt1 +40 ANGLE_texture_compression_dxt3 +41 ANGLE_texture_compression_dxt5 +42 ANGLE_texture_usage +43 ANGLE_timer_query +44 ANGLE_translated_shader_source +
    +45 APPLE_aux_depth_stencil +46 APPLE_client_storage +47 APPLE_element_array +48 APPLE_fence +49 APPLE_float_pixels +50 APPLE_flush_buffer_range +51 APPLE_object_purgeable +52 APPLE_pixel_buffer +53 APPLE_rgb_422 +54 APPLE_row_bytes +55 APPLE_specular_vector +56 APPLE_texture_range +57 APPLE_transform_hint +58 APPLE_vertex_array_object +59 APPLE_vertex_array_range +60 APPLE_vertex_program_evaluators +61 APPLE_ycbcr_422 +
    +62 ARB_ES2_compatibility +63 ARB_ES3_1_compatibility +64 ARB_ES3_2_compatibility +65 ARB_ES3_compatibility +66 ARB_arrays_of_arrays +67 ARB_base_instance +68 ARB_bindless_texture +69 ARB_blend_func_extended +70 ARB_buffer_storage +71 ARB_cl_event +72 ARB_clear_buffer_object +73 ARB_clear_texture +74 ARB_clip_control +75 ARB_color_buffer_float +76 ARB_compatibility +77 ARB_compressed_texture_pixel_storage +78 ARB_compute_shader +79 ARB_compute_variable_group_size +80 ARB_conditional_render_inverted +81 ARB_conservative_depth +82 ARB_copy_buffer +83 ARB_copy_image +84 ARB_cull_distance +85 ARB_debug_output +86 ARB_depth_buffer_float +87 ARB_depth_clamp +88 ARB_depth_texture +89 ARB_derivative_control +90 ARB_direct_state_access +91 ARB_draw_buffers +92 ARB_draw_buffers_blend +93 ARB_draw_elements_base_vertex +94 ARB_draw_indirect +95 ARB_draw_instanced +96 ARB_enhanced_layouts +97 ARB_explicit_attrib_location +98 ARB_explicit_uniform_location +99 ARB_fragment_coord_conventions +100 ARB_fragment_layer_viewport +101 ARB_fragment_program +102 ARB_fragment_program_shadow +103 ARB_fragment_shader +104 ARB_fragment_shader_interlock +105 ARB_framebuffer_no_attachments +106 ARB_framebuffer_object +107 ARB_framebuffer_sRGB +108 ARB_geometry_shader4 +109 ARB_get_program_binary +110 ARB_get_texture_sub_image +111 ARB_gl_spirv +112 ARB_gpu_shader5 +113 ARB_gpu_shader_fp64 +114 ARB_gpu_shader_int64 +115 ARB_half_float_pixel +116 ARB_half_float_vertex +117 ARB_imaging +118 ARB_indirect_parameters +119 ARB_instanced_arrays +120 ARB_internalformat_query +121 ARB_internalformat_query2 +122 ARB_invalidate_subdata +123 ARB_map_buffer_alignment +124 ARB_map_buffer_range +125 ARB_matrix_palette +126 ARB_multi_bind +127 ARB_multi_draw_indirect +128 ARB_multisample +129 ARB_multitexture +130 ARB_occlusion_query +131 ARB_occlusion_query2 +132 ARB_parallel_shader_compile +133 ARB_pipeline_statistics_query +134 ARB_pixel_buffer_object +135 ARB_point_parameters +136 ARB_point_sprite +137 ARB_post_depth_coverage +138 ARB_program_interface_query +139 ARB_provoking_vertex +140 ARB_query_buffer_object +141 ARB_robust_buffer_access_behavior +142 ARB_robustness +143 ARB_robustness_application_isolation +144 ARB_robustness_share_group_isolation +145 ARB_sample_locations +146 ARB_sample_shading +147 ARB_sampler_objects +148 ARB_seamless_cube_map +149 ARB_seamless_cubemap_per_texture +150 ARB_separate_shader_objects +151 ARB_shader_atomic_counter_ops +152 ARB_shader_atomic_counters +153 ARB_shader_ballot +154 ARB_shader_bit_encoding +155 ARB_shader_clock +156 ARB_shader_draw_parameters +157 ARB_shader_group_vote +158 ARB_shader_image_load_store +159 ARB_shader_image_size +160 ARB_shader_objects +161 ARB_shader_precision +162 ARB_shader_stencil_export +163 ARB_shader_storage_buffer_object +164 ARB_shader_subroutine +165 ARB_shader_texture_image_samples +166 ARB_shader_texture_lod +167 ARB_shader_viewport_layer_array +168 ARB_shading_language_100 +169 ARB_shading_language_420pack +170 ARB_shading_language_include +171 ARB_shading_language_packing +172 ARB_shadow +173 ARB_shadow_ambient +174 ARB_sparse_buffer +175 ARB_sparse_texture +176 ARB_sparse_texture2 +177 ARB_sparse_texture_clamp +178 ARB_stencil_texturing +179 ARB_sync +180 ARB_tessellation_shader +181 ARB_texture_barrier +182 ARB_texture_border_clamp +183 ARB_texture_buffer_object +184 ARB_texture_buffer_object_rgb32 +185 ARB_texture_buffer_range +186 ARB_texture_compression +187 ARB_texture_compression_bptc +188 ARB_texture_compression_rgtc +189 ARB_texture_cube_map +190 ARB_texture_cube_map_array +191 ARB_texture_env_add +192 ARB_texture_env_combine +193 ARB_texture_env_crossbar +194 ARB_texture_env_dot3 +195 ARB_texture_filter_minmax +196 ARB_texture_float +197 ARB_texture_gather +198 ARB_texture_mirror_clamp_to_edge +199 ARB_texture_mirrored_repeat +200 ARB_texture_multisample +201 ARB_texture_non_power_of_two +202 ARB_texture_query_levels +203 ARB_texture_query_lod +204 ARB_texture_rectangle +205 ARB_texture_rg +206 ARB_texture_rgb10_a2ui +207 ARB_texture_stencil8 +208 ARB_texture_storage +209 ARB_texture_storage_multisample +210 ARB_texture_swizzle +211 ARB_texture_view +212 ARB_timer_query +213 ARB_transform_feedback2 +214 ARB_transform_feedback3 +215 ARB_transform_feedback_instanced +216 ARB_transform_feedback_overflow_query +217 ARB_transpose_matrix +218 ARB_uniform_buffer_object +219 ARB_vertex_array_bgra +220 ARB_vertex_array_object +221 ARB_vertex_attrib_64bit +222 ARB_vertex_attrib_binding +223 ARB_vertex_blend +224 ARB_vertex_buffer_object +225 ARB_vertex_program +226 ARB_vertex_shader +227 ARB_vertex_type_10f_11f_11f_rev +228 ARB_vertex_type_2_10_10_10_rev +229 ARB_viewport_array +230 ARB_window_pos +
    +231 ATIX_point_sprites +232 ATIX_texture_env_combine3 +233 ATIX_texture_env_route +234 ATIX_vertex_shader_output_point_size +
    +235 ATI_draw_buffers +236 ATI_element_array +237 ATI_envmap_bumpmap +238 ATI_fragment_shader +239 ATI_map_object_buffer +240 ATI_meminfo +241 ATI_pn_triangles +242 ATI_separate_stencil +243 ATI_shader_texture_lod +244 ATI_text_fragment_shader +245 ATI_texture_compression_3dc +246 ATI_texture_env_combine3 +247 ATI_texture_float +248 ATI_texture_mirror_once +249 ATI_vertex_array_object +250 ATI_vertex_attrib_array_object +251 ATI_vertex_streams +
    +252 EGL_NV_robustness_video_memory_purge +
    +253 EXT_422_pixels +254 EXT_Cg_shader +255 EXT_abgr +256 EXT_bgra +257 EXT_bindable_uniform +258 EXT_blend_color +259 EXT_blend_equation_separate +260 EXT_blend_func_separate +261 EXT_blend_logic_op +262 EXT_blend_minmax +263 EXT_blend_subtract +264 EXT_clip_volume_hint +265 EXT_cmyka +266 EXT_color_subtable +267 EXT_compiled_vertex_array +268 EXT_convolution +269 EXT_coordinate_frame +270 EXT_copy_texture +271 EXT_cull_vertex +272 EXT_debug_label +273 EXT_debug_marker +274 EXT_depth_bounds_test +275 EXT_direct_state_access +276 EXT_draw_buffers2 +277 EXT_draw_instanced +278 EXT_draw_range_elements +279 EXT_fog_coord +280 EXT_fragment_lighting +281 EXT_framebuffer_blit +282 EXT_framebuffer_multisample +283 EXT_framebuffer_multisample_blit_scaled +284 EXT_framebuffer_object +285 EXT_framebuffer_sRGB +286 EXT_geometry_shader4 +287 EXT_gpu_program_parameters +288 EXT_gpu_shader4 +289 EXT_histogram +290 EXT_index_array_formats +291 EXT_index_func +292 EXT_index_material +293 EXT_index_texture +294 EXT_light_texture +295 EXT_misc_attribute +296 EXT_multi_draw_arrays +297 EXT_multisample +298 EXT_packed_depth_stencil +299 EXT_packed_float +300 EXT_packed_pixels +301 EXT_paletted_texture +302 EXT_pixel_buffer_object +303 EXT_pixel_transform +304 EXT_pixel_transform_color_table +305 EXT_point_parameters +306 EXT_polygon_offset +307 EXT_polygon_offset_clamp +308 EXT_post_depth_coverage +309 EXT_provoking_vertex +310 EXT_raster_multisample +311 EXT_rescale_normal +312 EXT_scene_marker +313 EXT_secondary_color +314 EXT_separate_shader_objects +315 EXT_separate_specular_color +316 EXT_shader_image_load_formatted +317 EXT_shader_image_load_store +318 EXT_shader_integer_mix +319 EXT_shadow_funcs +320 EXT_shared_texture_palette +321 EXT_sparse_texture2 +322 EXT_stencil_clear_tag +323 EXT_stencil_two_side +324 EXT_stencil_wrap +325 EXT_subtexture +326 EXT_texture +327 EXT_texture3D +328 EXT_texture_array +329 EXT_texture_buffer_object +330 EXT_texture_compression_dxt1 +331 EXT_texture_compression_latc +332 EXT_texture_compression_rgtc +333 EXT_texture_compression_s3tc +334 EXT_texture_cube_map +335 EXT_texture_edge_clamp +336 EXT_texture_env +337 EXT_texture_env_add +338 EXT_texture_env_combine +339 EXT_texture_env_dot3 +340 EXT_texture_filter_anisotropic +341 EXT_texture_filter_minmax +342 EXT_texture_integer +343 EXT_texture_lod_bias +344 EXT_texture_mirror_clamp +345 EXT_texture_object +346 EXT_texture_perturb_normal +347 EXT_texture_rectangle +348 EXT_texture_sRGB +349 EXT_texture_sRGB_decode +350 EXT_texture_shared_exponent +351 EXT_texture_snorm +352 EXT_texture_swizzle +353 EXT_timer_query +354 EXT_transform_feedback +355 EXT_vertex_array +356 EXT_vertex_array_bgra +357 EXT_vertex_attrib_64bit +358 EXT_vertex_shader +359 EXT_vertex_weighting +360 EXT_window_rectangles +361 EXT_x11_sync_object +
    +362 GREMEDY_frame_terminator +363 GREMEDY_string_marker +
    +364 HP_convolution_border_modes +365 HP_image_transform +366 HP_occlusion_test +367 HP_texture_lighting +
    +368 IBM_cull_vertex +369 IBM_multimode_draw_arrays +370 IBM_rasterpos_clip +371 IBM_static_data +372 IBM_texture_mirrored_repeat +373 IBM_vertex_array_lists +
    +374 INGR_color_clamp +375 INGR_interlace_read +
    +376 INTEL_conservative_rasterization +377 INTEL_fragment_shader_ordering +378 INTEL_framebuffer_CMAA +379 INTEL_map_texture +380 INTEL_parallel_arrays +381 INTEL_performance_query +382 INTEL_texture_scissor +
    +383 KHR_blend_equation_advanced +384 KHR_blend_equation_advanced_coherent +385 KHR_context_flush_control +386 KHR_debug +387 KHR_no_error +388 KHR_robust_buffer_access_behavior +389 KHR_robustness +390 KHR_texture_compression_astc_hdr +391 KHR_texture_compression_astc_ldr +392 KHR_texture_compression_astc_sliced_3d +
    +393 KTX_buffer_region +
    +394 MESAX_texture_stack +
    +395 MESA_pack_invert +396 MESA_resize_buffers +397 MESA_shader_integer_functions +398 MESA_window_pos +399 MESA_ycbcr_texture +
    +400 NVX_blend_equation_advanced_multi_draw_buffers +401 NVX_conditional_render +402 NVX_gpu_memory_info +403 NVX_linked_gpu_multicast +
    +404 NV_bindless_multi_draw_indirect +405 NV_bindless_multi_draw_indirect_count +406 NV_bindless_texture +407 NV_blend_equation_advanced +408 NV_blend_equation_advanced_coherent +409 NV_blend_square +410 NV_clip_space_w_scaling +411 NV_command_list +412 NV_compute_program5 +413 NV_conditional_render +414 NV_conservative_raster +415 NV_conservative_raster_dilate +416 NV_conservative_raster_pre_snap_triangles +417 NV_copy_depth_to_color +418 NV_copy_image +419 NV_deep_texture3D +420 NV_depth_buffer_float +421 NV_depth_clamp +422 NV_depth_range_unclamped +423 NV_draw_texture +424 NV_draw_vulkan_image +425 NV_evaluators +426 NV_explicit_multisample +427 NV_fence +428 NV_fill_rectangle +429 NV_float_buffer +430 NV_fog_distance +431 NV_fragment_coverage_to_color +432 NV_fragment_program +433 NV_fragment_program2 +434 NV_fragment_program4 +435 NV_fragment_program_option +436 NV_fragment_shader_interlock +437 NV_framebuffer_mixed_samples +438 NV_framebuffer_multisample_coverage +439 NV_geometry_program4 +440 NV_geometry_shader4 +441 NV_geometry_shader_passthrough +442 NV_gpu_multicast +443 NV_gpu_program4 +444 NV_gpu_program5 +445 NV_gpu_program5_mem_extended +446 NV_gpu_program_fp64 +447 NV_gpu_shader5 +448 NV_half_float +449 NV_internalformat_sample_query +450 NV_light_max_exponent +451 NV_multisample_coverage +452 NV_multisample_filter_hint +453 NV_occlusion_query +454 NV_packed_depth_stencil +455 NV_parameter_buffer_object +456 NV_parameter_buffer_object2 +457 NV_path_rendering +458 NV_path_rendering_shared_edge +459 NV_pixel_data_range +460 NV_point_sprite +461 NV_present_video +462 NV_primitive_restart +463 NV_register_combiners +464 NV_register_combiners2 +465 NV_robustness_video_memory_purge +466 NV_sample_locations +467 NV_sample_mask_override_coverage +468 NV_shader_atomic_counters +469 NV_shader_atomic_float +470 NV_shader_atomic_float64 +471 NV_shader_atomic_fp16_vector +472 NV_shader_atomic_int64 +473 NV_shader_buffer_load +474 NV_shader_storage_buffer_object +475 NV_shader_thread_group +476 NV_shader_thread_shuffle +477 NV_stereo_view_rendering +478 NV_tessellation_program5 +479 NV_texgen_emboss +480 NV_texgen_reflection +481 NV_texture_barrier +482 NV_texture_compression_vtc +483 NV_texture_env_combine4 +484 NV_texture_expand_normal +485 NV_texture_multisample +486 NV_texture_rectangle +487 NV_texture_shader +488 NV_texture_shader2 +489 NV_texture_shader3 +490 NV_transform_feedback +491 NV_transform_feedback2 +492 NV_uniform_buffer_unified_memory +493 NV_vdpau_interop +494 NV_vertex_array_range +495 NV_vertex_array_range2 +496 NV_vertex_attrib_integer_64bit +497 NV_vertex_buffer_unified_memory +498 NV_vertex_program +499 NV_vertex_program1_1 +500 NV_vertex_program2 +501 NV_vertex_program2_option +502 NV_vertex_program3 +503 NV_vertex_program4 +504 NV_video_capture +505 NV_viewport_array2 +506 NV_viewport_swizzle +
    +507 OES_byte_coordinates +508 OES_compressed_paletted_texture +509 OES_read_format +510 OES_single_precision +
    +511 OML_interlace +512 OML_resample +513 OML_subsample +
    +514 OVR_multiview +515 OVR_multiview2 +
    +516 PGI_misc_hints +517 PGI_vertex_hints +
    +518 REGAL_ES1_0_compatibility +519 REGAL_ES1_1_compatibility +520 REGAL_enable +521 REGAL_error_string +522 REGAL_extension_query +523 REGAL_log +524 REGAL_proc_address +
    +525 REND_screen_coordinates +
    +526 S3_s3tc +
    +527 SGIS_color_range +528 SGIS_detail_texture +529 SGIS_fog_function +530 SGIS_generate_mipmap +531 SGIS_multisample +532 SGIS_pixel_texture +533 SGIS_point_line_texgen +534 SGIS_sharpen_texture +535 SGIS_texture4D +536 SGIS_texture_border_clamp +537 SGIS_texture_edge_clamp +538 SGIS_texture_filter4 +539 SGIS_texture_lod +540 SGIS_texture_select +
    +541 SGIX_async +542 SGIX_async_histogram +543 SGIX_async_pixel +544 SGIX_blend_alpha_minmax +545 SGIX_clipmap +546 SGIX_convolution_accuracy +547 SGIX_depth_texture +548 SGIX_flush_raster +549 SGIX_fog_offset +550 SGIX_fog_texture +551 SGIX_fragment_specular_lighting +552 SGIX_framezoom +553 SGIX_interlace +554 SGIX_ir_instrument1 +555 SGIX_list_priority +556 SGIX_pixel_texture +557 SGIX_pixel_texture_bits +558 SGIX_reference_plane +559 SGIX_resample +560 SGIX_shadow +561 SGIX_shadow_ambient +562 SGIX_sprite +563 SGIX_tag_sample_buffer +564 SGIX_texture_add_env +565 SGIX_texture_coordinate_clamp +566 SGIX_texture_lod_bias +567 SGIX_texture_multi_buffer +568 SGIX_texture_range +569 SGIX_texture_scale_bias +570 SGIX_vertex_preclip +571 SGIX_vertex_preclip_hint +572 SGIX_ycrcb +
    +573 SGI_color_matrix +574 SGI_color_table +575 SGI_texture_color_table +
    +576 SUNX_constant_data +
    +577 SUN_convolution_border_modes +578 SUN_global_alpha +579 SUN_mesh_array +580 SUN_read_video_pixels +581 SUN_slice_accum +582 SUN_triangle_list +583 SUN_vertex +
    +584 WIN_phong_shading +585 WIN_specular_fog +586 WIN_swap_hint diff --git a/VectorVisualization/glew-1.11.0/doc/glew.txt b/VectorVisualization/glew-1.11.0/doc/glew.txt index 31a31d3..67b4aff 100644 --- a/VectorVisualization/glew-1.11.0/doc/glew.txt +++ b/VectorVisualization/glew-1.11.0/doc/glew.txt @@ -1,4 +1,5 @@ The OpenGL Extension Wrangler Library +Copyright (C) 2008-2016, Nigel Stewart Copyright (C) 2002-2008, Milan Ikits Copyright (C) 2002-2008, Marcelo E. Magallon Copyright (C) 2002, Lev Povalahev diff --git a/VectorVisualization/glew-1.11.0/doc/glxew.html b/VectorVisualization/glew-1.11.0/doc/glxew.html index d7df9c6..4e5d617 100644 --- a/VectorVisualization/glew-1.11.0/doc/glxew.html +++ b/VectorVisualization/glew-1.11.0/doc/glxew.html @@ -1,7 +1,7 @@ - GLEW: The OpenGL Extension Wrangler Library @@ -47,7 +46,7 @@ - + @@ -58,11 +57,15 @@ - - - - + + + + + + + +
    Latest Release: 1.11.0
    Latest Release: 2.2.0

    GLEW Logo

    Building
    Installation
    Source Generation
    Credits & Copyright
    Change Log
    Project Page
    Mailing Lists
    Bug Tracker

    GitHub
    Issues
    Pull Requests
    Authors
    Licensing

    SourceForge Page

    @@ -72,13 +75,12 @@ - +
    Last Update: 08-11-14
    Last Update: 07-24-16
    - OpenGL Logo - SourceForge Logo + OpenGL Logo
    + GitHub Logo
    + Travis Logo
    + SourceForge Logo
    @@ -122,58 +124,60 @@

    Supported GLX Extensions

    19 EXT_fbconfig_packed_float 20 EXT_framebuffer_sRGB 21 EXT_import_context -22 EXT_scene_marker -23 EXT_stereo_tree -24 EXT_swap_control -25 EXT_swap_control_tear -26 EXT_texture_from_pixmap -27 EXT_visual_info -28 EXT_visual_rating +22 EXT_libglvnd +23 EXT_scene_marker +24 EXT_stereo_tree +25 EXT_swap_control +26 EXT_swap_control_tear +27 EXT_texture_from_pixmap +28 EXT_visual_info +29 EXT_visual_rating
    -29 INTEL_swap_event +30 INTEL_swap_event
    -30 MESA_agp_offset -31 MESA_copy_sub_buffer -32 MESA_pixmap_colormap -33 MESA_query_renderer -34 MESA_release_buffers -35 MESA_set_3dfx_mode -36 MESA_swap_control +31 MESA_agp_offset +32 MESA_copy_sub_buffer +33 MESA_pixmap_colormap +34 MESA_query_renderer +35 MESA_release_buffers +36 MESA_set_3dfx_mode +37 MESA_swap_control
    -37 NV_copy_buffer -38 NV_copy_image -39 NV_delay_before_swap -40 NV_float_buffer -41 NV_multisample_coverage -42 NV_present_video -43 NV_swap_group -44 NV_vertex_array_range -45 NV_video_capture -46 NV_video_out +38 NV_copy_buffer +39 NV_copy_image +40 NV_delay_before_swap +41 NV_float_buffer +42 NV_multisample_coverage +43 NV_present_video +44 NV_robustness_video_memory_purge +45 NV_swap_group +46 NV_vertex_array_range +47 NV_video_capture +48 NV_video_out
    -47 OML_swap_method -48 OML_sync_control +49 OML_swap_method +50 OML_sync_control
    -49 SGIS_blended_overlay -50 SGIS_color_range -51 SGIS_multisample -52 SGIS_shared_multisample +51 SGIS_blended_overlay +52 SGIS_color_range +53 SGIS_multisample +54 SGIS_shared_multisample
    -53 SGIX_fbconfig -54 SGIX_hyperpipe -55 SGIX_pbuffer -56 SGIX_swap_barrier -57 SGIX_swap_group -58 SGIX_video_resize -59 SGIX_visual_select_group +55 SGIX_fbconfig +56 SGIX_hyperpipe +57 SGIX_pbuffer +58 SGIX_swap_barrier +59 SGIX_swap_group +60 SGIX_video_resize +61 SGIX_visual_select_group
    -60 SGI_cushion -61 SGI_make_current_read -62 SGI_swap_control -63 SGI_video_sync +62 SGI_cushion +63 SGI_make_current_read +64 SGI_swap_control +65 SGI_video_sync
    -64 SUN_get_transparent_index -65 SUN_video_resize +66 SUN_get_transparent_index +67 SUN_video_resize diff --git a/VectorVisualization/glew-1.11.0/doc/index.html b/VectorVisualization/glew-1.11.0/doc/index.html index d4e591c..6f61c2f 100644 --- a/VectorVisualization/glew-1.11.0/doc/index.html +++ b/VectorVisualization/glew-1.11.0/doc/index.html @@ -1,7 +1,7 @@ - GLEW: The OpenGL Extension Wrangler Library @@ -47,7 +46,7 @@ - + @@ -58,11 +57,15 @@ - - - - + + + + + + + +
    Latest Release: 1.11.0
    Latest Release: 2.2.0

    GLEW Logo

    Building
    Installation
    Source Generation
    Credits & Copyright
    Change Log
    Project Page
    Mailing Lists
    Bug Tracker

    GitHub
    Issues
    Pull Requests
    Authors
    Licensing

    SourceForge Page

    @@ -72,13 +75,12 @@ - +
    Last Update: 08-11-14
    Last Update: 07-24-16
    - OpenGL Logo - SourceForge Logo + OpenGL Logo
    + GitHub Logo
    + Travis Logo
    + SourceForge Logo
    @@ -109,7 +111,7 @@

    Downloads

    GLEW is distributed as source and precompiled binaries.
    The latest release is -1.11.0[08-11-14]: +2.2.0[07-24-16]:

    @@ -123,8 +125,8 @@

    Downloads

    Source -ZIP |  -TGZ +ZIP |  +TGZ @@ -132,7 +134,7 @@

    Downloads

    Binaries -Windows 32-bit and 64-bit +Windows 32-bit and 64-bit @@ -147,23 +149,11 @@

    Downloads

    • github
      git clone https://github.com/nigels-com/glew.git glew
       
    • -
    • Sourceforge
      -git clone git://git.code.sf.net/p/glew/code glew
       
    • -
    - -

    -

    -Unsupported snapshots are also available: -

    -

    Supported Extensions

    -The latest release contains support for OpenGL 4.4 and the following extensions: +The latest release contains support for OpenGL 4.5, compatibility and forward-compatible contexts and the following extensions: