Flare and Volumes in scenegraph

- Added new volumeraycaster classes
- Fixed many small warnings in OpenSpace
- Linked to updated Ghoul and Openspace-data

- TODO cleanup in volumeraycaster classes
- TODO Add an advanced volumeraycaster class to use during development
This commit is contained in:
Jonas Strandstedt
2014-04-14 16:41:57 -04:00
parent b63978438d
commit 30bda3fc97
30 changed files with 1252 additions and 290 deletions

View File

@@ -0,0 +1,45 @@
#ifndef RENDERABLEVOLUME_H
#define RENDERABLEVOLUME_H
// open space includes
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/volumeraycaster.h>
// ghoul includes
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/io/rawvolumereader.h>
namespace openspace {
class RenderableVolume: public Renderable {
public:
// constructors & destructor
RenderableVolume(const ghoul::Dictionary& dictionary);
~RenderableVolume();
bool initialize();
bool deinitialize();
virtual void render(const Camera *camera, const psc& thisPosition);
virtual void update();
protected:
ghoul::RawVolumeReader::ReadHints readHints(const ghoul::Dictionary& dictionary);
std::string findPath(const std::string& path, const std::string& relativePath);
private:
// texture
std::string _volumePath;
// Object
VolumeRaycaster *_rayCaster;
ghoul::RawVolumeReader::ReadHints _hints;
bool _programUpdateOnSave;
};
} // namespace openspace
#endif

View File

@@ -22,39 +22,21 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef VOLUMERAYCASTER_H
#define VOLUMERAYCASTER_H
#ifndef __VOLUMERAYCASTER_H__
#define __VOLUMERAYCASTER_H__
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/framebufferobject.h>
#include <ghoul/opengl/texture.h>
#include <sgct.h>
#include <ghoul/misc/dictionary.h>
namespace openspace {
using namespace ghoul::opengl;
class VolumeRaycaster {
public:
VolumeRaycaster();
~VolumeRaycaster();
void initialize();
void render();
private:
void setupTwopassRaycaster();
void setupSinglepassRaycaster();
void renderWithTwopassRaycaster(glm::mat4 modelViewProjectionMatrix);
void renderWithSinglepassRaycaster(glm::mat4 modelViewProjectionMatrix);
FramebufferObject* _fbo;
Texture* _backTexture;
Texture* _frontTexture;
Texture* _volume;
ProgramObject *_fboProgram, *_twopassProgram, *_singlepassProgram;
sgct_utils::SGCTBox* _boundingBox;
GLuint _screenQuad, _cubeCenterVBO;
VolumeRaycaster() = default;
VolumeRaycaster(const ghoul::Dictionary& dictionary);
virtual ~VolumeRaycaster();
virtual bool initialize() = 0;
virtual void render(const glm::mat4& modelViewProjection) = 0;
};
} // namespace openspace

View File

@@ -0,0 +1,82 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __VOLUMERAYCASTERCL_H__
#define __VOLUMERAYCASTERCL_H__
#include <openspace/rendering/volumeraycaster.h>
#include <openspace/engine/openspaceengine.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/framebufferobject.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/io/rawvolumereader.h>
#include <ghoul/filesystem/file.h>
#include <sgct.h>
#include <memory>
#include <mutex>
namespace openspace {
class VolumeRaycasterCL: public VolumeRaycaster {
public:
VolumeRaycasterCL(const ghoul::Dictionary& dictionary);
~VolumeRaycasterCL();
bool initialize();
void render(const glm::mat4& modelViewProjection);
private:
std::string _filename;
ghoul::RawVolumeReader::ReadHints _hints;
float _stepSize;
ghoul::opengl::FramebufferObject* _fbo;
ghoul::opengl::Texture* _backTexture;
ghoul::opengl::Texture* _frontTexture;
ghoul::opengl::Texture* _volume;
ghoul::opengl::Texture* _output;
ghoul::opengl::ProgramObject *_fboProgram;
ghoul::opengl::ProgramObject *_quadProgram;
sgct_utils::SGCTBox* _boundingBox;
GLuint _screenQuad;
ghoul::opencl::CLContext _context;
ghoul::opencl::CLCommandQueue _commands;
ghoul::opencl::CLProgram _program;
ghoul::opencl::CLKernel _kernel;
cl_mem _clBackTexture, _clFrontTexture, _clVolume, _clOutput;
std::string _kernelPath;
ghoul::filesystem::File* _kernelSourceFile;
bool _kernelUpdateOnSave;
std::mutex _kernelMutex;
void _safeKernelCompilation();
};
} // namespace openspace
#endif // VOLUMERAYCASTER_H

View File

@@ -0,0 +1,76 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __VOLUMERAYCASTERGL_H__
#define __VOLUMERAYCASTERGL_H__
#include <openspace/rendering/volumeraycaster.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/framebufferobject.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/filesystem/file.h>
#include <ghoul/io/rawvolumereader.h>
#include <sgct.h>
#include <memory>
namespace openspace {
using namespace ghoul::opengl;
class VolumeRaycasterGL: public VolumeRaycaster {
public:
VolumeRaycasterGL(const ghoul::Dictionary& dictionary);
~VolumeRaycasterGL();
bool initialize();
void render(const glm::mat4& modelViewProjection);
private:
std::string _filename;
ghoul::RawVolumeReader::ReadHints _hints;
float _stepSize;
FramebufferObject* _fbo;
Texture* _backTexture;
Texture* _frontTexture;
Texture* _volume;
ProgramObject *_fboProgram, *_twopassProgram;
sgct_utils::SGCTBox* _boundingBox;
GLuint _screenQuad;
std::mutex _shaderMutex;
std::string _vshaderpath;
std::string _fshaderpath;
ghoul::filesystem::File* _vertexSourceFile;
ghoul::filesystem::File* _fragmentSourceFile;
void _safeShaderCompilation();
};
} // namespace openspace
#endif // VOLUMERAYCASTER_H

View File

@@ -0,0 +1,61 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __VOLUMERAYCASTERSINGLEPASS_H__
#define __VOLUMERAYCASTERSINGLEPASS_H__
#include <openspace/rendering/volumeraycaster.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/framebufferobject.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/io/rawvolumereader.h>
#include <sgct.h>
namespace openspace {
using namespace ghoul::opengl;
class VolumeRaycasterSinglePass: public VolumeRaycaster {
public:
VolumeRaycasterSinglePass(const ghoul::Dictionary& dictionary);
~VolumeRaycasterSinglePass();
bool initialize();
void render(const glm::mat4& modelViewProjection);
private:
std::string _filename;
ghoul::RawVolumeReader::ReadHints _hints;
//float _stepSize;
Texture* _volume;
ProgramObject *_singlepassProgram;
sgct_utils::SGCTBox* _boundingBox;
GLuint _cubeCenterVBO;
};
} // namespace openspace
#endif // VOLUMERAYCASTER_H