refactor abuffer and add msaa support. volumes temporarily disabled.

This commit is contained in:
Emil Axelsson
2016-02-02 11:30:27 +01:00
parent 4f7ab5321f
commit d4ff8119d1
79 changed files with 2354 additions and 3106 deletions

View File

@@ -0,0 +1,110 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* 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 __ABUFFERRENDERER_H__
#define __ABUFFERRENDERER_H__
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/glm.h>
#include <ghoul/misc/dictionary.h>
#include <string>
#include <vector>
#include <map>
#include <openspace/rendering/volume.h>
#include <openspace/rendering/renderer.h>
namespace ghoul {
namespace filesystem {
class File;
}
namespace opengl {
class ProgramObject;
class Texture;
}
}
namespace openspace {
class RenderableVolume;
class Camera;
class Scene;
class ABufferRenderer : public Renderer {
public:
ABufferRenderer();
virtual ~ABufferRenderer();
void initialize() override;
void deinitialize() override;
void setCamera(Camera* camera) override;
void setScene(Scene* scene) override;
void setResolution(glm::ivec2 res) override;
void update();
void render(float blackoutFactor, bool doPerformanceMeasurements) override;
/**
* Update render data
* Responsible for calling renderEngine::setRenderData
*/
virtual void updateRendererData() override;
private:
void clear();
void updateResolution();
ghoul::Dictionary createResolveDictionary();
ghoul::opengl::ProgramObject* createResolveProgram(const ghoul::Dictionary& dict);
Camera* _camera;
Scene* _scene;
glm::ivec2 _resolution;
bool _dirtyResolution;
ghoul::opengl::ProgramObject* _resolveProgram;
/**
* When a volume is attached or detached from the scene graph,
* the resolve program needs to be recompiled.
* The #volumes vector keeps track of which volumes that can
* be rendered using the current resolve program.
*/
std::vector<Volume*> _volumes;
GLuint _screenQuad;
GLuint _anchorPointerTexture;
GLuint _anchorPointerTextureInitializer;
GLuint _atomicCounterBuffer;
GLuint _fragmentBuffer;
GLuint _fragmentTexture;
ghoul::Dictionary _rendererData;
}; // ABufferRenderer
} // openspace
#endif // __RENDERER_H__

View File

@@ -0,0 +1,84 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* 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 __FRAMEBUFFERRENDERER_H__
#define __FRAMEBUFFERRENDERER_H__
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/glm.h>
#include <string>
#include <vector>
#include <map>
#include <openspace/rendering/volume.h>
#include <openspace/rendering/renderer.h>
namespace ghoul {
class Dictionary;
namespace filesystem {
class File;
}
namespace opengl {
class ProgramObject;
class Texture;
}
}
namespace openspace {
class RenderableVolume;
class Camera;
class Scene;
class FramebufferRenderer : public Renderer {
public:
FramebufferRenderer();
virtual ~FramebufferRenderer();
void initialize() override;
void deinitialize() override;
void setCamera(Camera* camera) override;
void setScene(Scene* scene) override;
void setResolution(glm::ivec2 res) override;
void update() override;
void render(float blackoutFactor, bool doPerformanceMeasurements) override;
/**
* Update render data
* Responsible for calling renderEngine::setRenderData
*/
virtual void updateRendererData() override;
private:
Camera* _camera;
Scene* _scene;
glm::vec2 _resolution;
}; // FramebufferRenderer
} // openspace
#endif // __FRAMEBUFFERRENDERER_H__

View File

@@ -29,9 +29,11 @@
#include <openspace/properties/scalarproperty.h>
#include <openspace/util/powerscaledscalar.h>
#include <openspace/util/updatestructures.h>
#include <openspace/rendering/volume.h>
#include <ghoul/opengl/programobject.h>
// Forward declare to minimize dependencies
namespace ghoul {
namespace opengl {
@@ -67,6 +69,7 @@ public:
virtual void render(const RenderData& data) = 0;
virtual void update(const UpdateData& data);
virtual std::vector<Volume*> volumesToRender(const RenderData& data) const;
bool isVisible() const;

View File

@@ -34,7 +34,10 @@ namespace ghoul {
namespace fontrendering {
class Font;
}
namespace opengl {
class ProgramObject;
}
class Dictionary;
class SharedMemory;
}
@@ -44,17 +47,14 @@ namespace openspace {
class Camera;
class SyncBuffer;
class Scene;
class ABuffer;
class ABufferVisualizer;
class Renderer;
class ScreenLog;
class RenderEngine {
public:
enum class ABufferImplementation {
FrameBuffer = 0,
SingleLinked,
Fixed,
Dynamic,
enum class RendererImplementation {
Framebuffer = 0,
ABuffer,
Invalid
};
@@ -69,8 +69,8 @@ public:
Scene* scene();
Camera* camera() const;
ABuffer* aBuffer() const;
ABufferImplementation aBufferImplementation() const;
Renderer* renderer() const;
RendererImplementation rendererImplementation() const;
// sgct wrapped functions
bool initializeGL();
@@ -80,8 +80,6 @@ public:
void postDraw();
void takeScreenshot();
void toggleVisualizeABuffer(bool b);
void toggleInfoText(bool b);
void setPerformanceMeasurements(bool performanceMeasurements);
@@ -94,21 +92,40 @@ public:
void setGlobalBlackOutFactor(float factor);
void setDisableRenderingOnMaster(bool enabled);
ghoul::opengl::ProgramObject* buildRenderProgram(
std::string name,
std::string vsPath,
std::string fsPath,
const ghoul::Dictionary& dictionary = ghoul::Dictionary());
ghoul::opengl::ProgramObject* buildRenderProgram(
std::string name,
std::string vsPath,
std::string fsPath,
std::string csPath,
const ghoul::Dictionary& dictionary = ghoul::Dictionary());
void removeRenderProgram(ghoul::opengl::ProgramObject* program);
void setRendererFromString(const std::string& method);
/**
* Let's the renderer update the data to be brought into the rendererer programs
* as a 'rendererData' variable in the dictionary.
*/
void setRendererData(const ghoul::Dictionary& renderer);
/**
* Returns the Lua library that contains all Lua functions available to affect the
* rendering. The functions contained are
* - openspace::luascriptfunctions::printImage
* - openspace::luascriptfunctions::visualizeABuffer
* \return The Lua library that contains all Lua functions available to affect the
* rendering
* rendering.
*/
static scripting::ScriptEngine::LuaLibrary luaLibrary();
// This is a temporary method to change the origin of the coordinate system ---abock
void changeViewPoint(std::string origin);
//temporaray fade functionality
// Temporary fade functionality
void startFading(int direction, float fadeDuration);
// This is temporary until a proper screenspace solution is found ---abock
@@ -119,38 +136,37 @@ public:
} _onScreenInformation;
private:
ABufferImplementation aBufferFromString(const std::string& impl);
void setRenderer(Renderer* renderer);
RendererImplementation rendererFromString(const std::string& method);
void storePerformanceMeasurements();
void renderInformation();
void renderScreenLog();
Camera* _mainCamera;
Scene* _sceneGraph;
ABuffer* _abuffer;
ABufferImplementation _abufferImplementation;
Renderer* _renderer;
RendererImplementation _rendererImplementation;
ghoul::Dictionary _rendererData;
ScreenLog* _log;
bool _showInfo;
bool _showScreenLog;
bool _showLog;
bool _takeScreenshot;
bool _doPerformanceMeasurements;
ghoul::SharedMemory* _performanceMemory;
void generateGlslConfig();
float _globalBlackOutFactor;
float _fadeDuration;
float _currentFadeTime;
int _fadeDirection;
// bool _sgctRenderStatisticsVisible;
std::vector<ghoul::opengl::ProgramObject*> _programs;
ghoul::fontrendering::Font* _fontInfo = nullptr;
ghoul::fontrendering::Font* _fontDate = nullptr;
ghoul::fontrendering::Font* _fontLog = nullptr;
bool _visualizeABuffer;
ABufferVisualizer* _visualizer;
bool _disableMasterRendering = false;
};

View File

@@ -0,0 +1,73 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2015 *
* *
* 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 __RENDERER_H__
#define __RENDERER_H__
#include <ghoul/opengl/ghoul_gl.h>
#include <ghoul/glm.h>
#include <string>
#include <vector>
#include <map>
namespace ghoul {
class Dictionary;
namespace filesystem {
class File;
}
namespace opengl {
class ProgramObject;
class Texture;
}
}
namespace openspace {
class RenderableVolume;
class Camera;
class Scene;
class Renderer {
public:
virtual void initialize() = 0;
virtual void deinitialize() = 0;
virtual void setCamera(Camera* camera) = 0;
virtual void setScene(Scene* scene) = 0;
virtual void setResolution(glm::ivec2 res) = 0;
virtual void update() = 0;
virtual void render(float blackoutFactor, bool doPerformanceMeasurements) = 0;
/**
* Update render data
* Responsible for calling renderEngine::setRenderData
*/
virtual void updateRendererData() = 0;
}; // Renderer
} // openspace
#endif // __RENDERER_H__

View File

@@ -0,0 +1,132 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2016 *
* *
* 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 __VOLUME_H__
#define __VOLUME_H__
#include <string>
#include <vector>
namespace ghoul {
namespace opengl {
class Texture;
class ProgramObject;
}
}
namespace openspace {
class Volume {
public:
/**
* Constructor
*/
Volume() {};
/**
* Destructor
*/
virtual ~Volume() {};
/**
* Render the volume's entry points (front face of the bounding geometry)
*/
//virtual void renderEntryPoints(const RenderData& data, ghoul::opengl::ProgramObject* program) = 0;
/**
* Render the volume's exit points (back face of the bounding geometry)
*/
//virtual void renderExitPoints(const RenderData& data, ghoul::opengl::ProgramObject* program) = 0;
/**
* Prepare the volume for the ABuffer's resolve step.
* Make sure textures are up to date, bind them to texture units, set program uniforms etc.
*/
//virtual void preRayCast(ghoul::opengl::ProgramObject* program) {};
/**
* Clean up for the volume after the ABuffer's resolve step.
* Make sure texture units are deinitialized, etc.
*/
//virtual void postRayCast(ghoul::opengl::ProgramObject* program) {};
/**
* Return a path to a file with the uniforms, per-vertex variables, functions etc
* required to transform the vertices of the bounding geometry to view space.
* It could also set other vertex out variables for the fragment shader to access.
*
* The shader preprocessor will have acceess to
* A #{namespace} variable (unique per helper file)
*
* Should define the function:
* vec4 getVertex()
*/
//virtual std::string getBoundsVsPath() = 0;
/*
* Return a path to a file with the functions, uniforms and fragment shader in variables
* required to generate the fragment color and depth.
*
* Should define the function:
* Fragment getFragment()
*
* The shader preprocessor will have acceess to
* A #{namespace} variable (unique per helper file)
*/
//virtual std::string getBoundsFsPath() = 0;
/**
* Return a path to a file with all the uniforms, functions etc
* required to perform ray casting through this volume.
*
* The header should define the following two functions:
* vec4 sampler#{id}(vec3 samplePos, vec3 dir, float occludingAlpha, inout float maxStepSize)
* (return color of sample)
* float stepSize#{id}(vec3 samplePos, vec3 dir)
* (return the preferred step size at this sample position)
*
* The shader preprocessor will have acceess to
* An #{id} variable (unique per volume)
* A #{namespace} variable (unique per helper file)
*/
//virtual std::string getRayCastPath() = 0;
/**
* Return a path to a glsl file with helper functions required for the
* transformation and raycast steps.
* This file will be included once per shader program generated,
* regardless of how many volumes say they require the file.
* Ideal to avoid redefinitions of helper functions.
*
* The shader preprocessor will have access to the #{namespace} variable (unique per helper file)
* which should be a prefix to all symbols defined by the helper
*/
//virtual std::string getHelperPath() = 0;
}; // Volume
} // openspace
#endif // __VOLUME_H__