mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-26 05:58:48 -05:00
Added deferred rendering support files. Fixed Volume rendering in framebufferrender.
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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 __OPENSPACE_CORE___DEFERREDCASTER___H
|
||||
#define __OPENSPACE_CORE___DEFERREDCASTER___H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
namespace ghoul {
|
||||
namespace opengl {
|
||||
class Texture;
|
||||
class ProgramObject;
|
||||
}
|
||||
}
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct RenderData;
|
||||
struct RaycastData;
|
||||
|
||||
class Deferredcaster {
|
||||
public:
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~Deferredcaster() {};
|
||||
|
||||
/**
|
||||
* 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(const RaycastData& data, 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(const RaycastData& data, ghoul::opengl::ProgramObject& program) {};
|
||||
|
||||
/**
|
||||
* Return a path the file to use as vertex shader
|
||||
*
|
||||
* The shader preprocessor will have acceess to
|
||||
* A #{namespace} variable (unique per helper file)
|
||||
*/
|
||||
virtual std::string getBoundsVsPath() const = 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() const = 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 sample#{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() const = 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() const = 0;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___DEFERREDCASTER___H__
|
||||
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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 __OPENSPACE_CORE___DEFERREDCASTERLISTENER___H__
|
||||
#define __OPENSPACE_CORE___DEFERREDCASTERLISTENER___H__
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Deferredcaster;
|
||||
|
||||
class DeferredcasterListener {
|
||||
public:
|
||||
virtual void deferredcastersChanged(Deferredcaster& deferredcaster, bool attached) = 0;
|
||||
};
|
||||
|
||||
} // openspace
|
||||
|
||||
|
||||
#endif // __OPENSPACE_CORE___DEFERREDCASTERLISTENER___H__
|
||||
@@ -0,0 +1,54 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2017 *
|
||||
* *
|
||||
* 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 __OPENSPACE_CORE___DEFERREDCASTERMANAGER___H__
|
||||
#define __OPENSPACE_CORE___DEFERREDCASTERMANAGER___H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class Deferredcaster;
|
||||
class DeferredcasterListener;
|
||||
|
||||
class DeferredcasterManager {
|
||||
public:
|
||||
DeferredcasterManager();
|
||||
~DeferredcasterManager();
|
||||
void attachDeferredcaster(Deferredcaster& deferredcaster);
|
||||
void detachDeferredcaster(Deferredcaster& deferredcaster);
|
||||
bool isAttached(Deferredcaster& deferredcaster);
|
||||
const std::vector<Deferredcaster*>& deferredcasters();
|
||||
|
||||
void addListener(DeferredcasterListener& listener);
|
||||
void removeListener(DeferredcasterListener& listener);
|
||||
private:
|
||||
std::vector<Deferredcaster*> _deferredcasters;
|
||||
std::vector<DeferredcasterListener*> _listeners;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
|
||||
#endif // __OPENSPACE_CORE___DEFERREDCASTERMANAGER___H__
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include <openspace/rendering/deferredcasterlistener.h>
|
||||
#include <openspace/rendering/raycasterlistener.h>
|
||||
#include <openspace/rendering/renderer.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
@@ -54,7 +55,7 @@ class RenderableVolume;
|
||||
class Camera;
|
||||
class Scene;
|
||||
|
||||
class FramebufferRenderer : public Renderer, public RaycasterListener {
|
||||
class FramebufferRenderer : public Renderer, public RaycasterListener, public DeferredcasterListener {
|
||||
public:
|
||||
FramebufferRenderer();
|
||||
virtual ~FramebufferRenderer();
|
||||
@@ -64,6 +65,7 @@ public:
|
||||
|
||||
void updateResolution();
|
||||
void updateRaycastData();
|
||||
void updateDeferredcastData();
|
||||
|
||||
void setCamera(Camera* camera) override;
|
||||
void setScene(Scene* scene) override;
|
||||
@@ -80,6 +82,8 @@ public:
|
||||
virtual void updateRendererData() override;
|
||||
|
||||
virtual void raycastersChanged(VolumeRaycaster& raycaster, bool attached) override;
|
||||
virtual void deferredcastersChanged(Deferredcaster& deferredcaster, bool attached) override;
|
||||
|
||||
private:
|
||||
|
||||
std::map<VolumeRaycaster*, RaycastData> _raycastData;
|
||||
@@ -87,6 +91,9 @@ private:
|
||||
std::map<VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>> _raycastPrograms;
|
||||
std::map<VolumeRaycaster*, std::unique_ptr<ghoul::opengl::ProgramObject>> _insideRaycastPrograms;
|
||||
|
||||
std::map<Deferredcaster*, DeferredcastData> _deferredcastData;
|
||||
std::map<Deferredcaster*, std::unique_ptr<ghoul::opengl::ProgramObject>> _deferredcastPrograms;
|
||||
|
||||
std::unique_ptr<ghoul::opengl::ProgramObject> _resolveProgram;
|
||||
|
||||
GLuint _screenQuad;
|
||||
@@ -98,6 +105,7 @@ private:
|
||||
GLuint _exitDepthTexture;
|
||||
GLuint _exitFramebuffer;
|
||||
|
||||
bool _dirtyDeferredcastData;
|
||||
bool _dirtyRaycastData;
|
||||
bool _dirtyResolution;
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ class SyncBuffer;
|
||||
|
||||
class Scene;
|
||||
class Renderer;
|
||||
class DeferredcasterManager;
|
||||
class RaycasterManager;
|
||||
class ScreenLog;
|
||||
class ScreenSpaceRenderable;
|
||||
@@ -90,6 +91,7 @@ public:
|
||||
Renderer* renderer() const;
|
||||
RendererImplementation rendererImplementation() const;
|
||||
RaycasterManager& raycasterManager();
|
||||
DeferredcasterManager& deferredcasterManager();
|
||||
|
||||
// sgct wrapped functions
|
||||
|
||||
@@ -184,6 +186,7 @@ private:
|
||||
Camera* _mainCamera;
|
||||
Scene* _sceneGraph;
|
||||
RaycasterManager* _raycasterManager;
|
||||
DeferredcasterManager* _deferredcasterManager;
|
||||
|
||||
properties::BoolProperty _performanceMeasurements;
|
||||
std::unique_ptr<performance::PerformanceManager> _performanceManager;
|
||||
|
||||
Reference in New Issue
Block a user