mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Address PR comments
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
local transforms = asset.require("scene/solarsystem/sun/transforms")
|
||||
local sun = asset.require("scene/solarsystem/sun/sun")
|
||||
local M_PI = 3.141592657
|
||||
|
||||
local kernels = asset.syncedResource({
|
||||
Name = "Dawn Kernels",
|
||||
@@ -88,7 +87,7 @@ local DawnPosition = {
|
||||
-- Rotation for model version 2
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { M_PI/2.0, 0.0, M_PI/2.0 }
|
||||
Rotation = { math.pi/2.0, 0.0, math.pi/2.0 }
|
||||
}
|
||||
},
|
||||
GUI = {
|
||||
@@ -209,7 +208,7 @@ local DawnFramingCamera2 = {
|
||||
},
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { 0, M_PI/2.0, 0 }
|
||||
Rotation = { 0, math.pi/2.0, 0 }
|
||||
}
|
||||
},
|
||||
GUI = {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
local sun = asset.require("scene/solarsystem/sun/sun")
|
||||
local sunTransforms = asset.require("scene/solarsystem/sun/transforms")
|
||||
local transforms = asset.require("./67p")
|
||||
local M_PI = 3.141592657
|
||||
|
||||
local models = asset.syncedResource({
|
||||
Name = "Rosetta Models",
|
||||
@@ -101,7 +100,7 @@ local Rosetta = {
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { 0.0, M_PI/2.0, 0.0 }
|
||||
Rotation = { 0.0, math.pi/2.0, 0.0 }
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
@@ -153,7 +152,7 @@ local Philae = {
|
||||
Transform = {
|
||||
Rotation = {
|
||||
Type = "StaticRotation",
|
||||
Rotation = { 0.0, M_PI/2.0, 0.0 }
|
||||
Rotation = { 0.0, math.pi/2.0, 0.0 }
|
||||
}
|
||||
},
|
||||
Renderable = {
|
||||
|
||||
@@ -71,36 +71,36 @@ public:
|
||||
* depending on where in the render cycle you are. Especially after the Deferred
|
||||
* Caster Tasks.
|
||||
*
|
||||
* \return GLuint identifier of the currently NOT used pingPongTexture
|
||||
* \return identifier of the currently NOT used pingPongTexture
|
||||
*/
|
||||
GLuint additionalColorTexture1();
|
||||
GLuint additionalColorTexture1() const;
|
||||
|
||||
/**
|
||||
* Gives access to the exitColorTexture. This texture is available for all RenderBins.
|
||||
* However, it cannot be used at the same time as the Raycaster Tasks. The size of the
|
||||
* texture is the resolution of the viewport.
|
||||
*
|
||||
* \return GLuint identifier of the exitColorTexture
|
||||
* \return identifier of the exitColorTexture
|
||||
*/
|
||||
GLuint additionalColorTexture2();
|
||||
GLuint additionalColorTexture2() const;
|
||||
|
||||
/**
|
||||
* Gives access to the fxaaTexture. This texture is available for all RenderBins.
|
||||
* However, it cannot be used at the same time as the FXAA Task. The size of the
|
||||
* texture is the resolution of the viewport.
|
||||
*
|
||||
* \return GLuint identifier of the fxaaTexture
|
||||
* \return identifier of the fxaaTexture
|
||||
*/
|
||||
GLuint additionalColorTexture3();
|
||||
GLuint additionalColorTexture3() const;
|
||||
|
||||
/**
|
||||
* Gives access to the exitDepthTexture. This texture is available for all RenderBins.
|
||||
* However, it cannot be used at the same time as the Raycaster Tasks. The size of the
|
||||
* texture is the resolution of the viewport.
|
||||
*
|
||||
* \return GLuint identifier of the exitDepthTexture
|
||||
* \return identifier of the exitDepthTexture
|
||||
*/
|
||||
GLuint additionalDepthTexture();
|
||||
GLuint additionalDepthTexture() const;
|
||||
|
||||
//=============================//
|
||||
//===== Access G-buffer =====//
|
||||
@@ -111,36 +111,36 @@ public:
|
||||
* the majority of rendering the scene and might be already in use. Use CAUTION when
|
||||
* using this function. The size of the texture is the resolution of the viewport.
|
||||
*
|
||||
* \return GLuint identifier of the color texture of the G-buffer
|
||||
* \return identifier of the color texture of the G-buffer
|
||||
*/
|
||||
GLuint gBufferColorTexture();
|
||||
GLuint gBufferColorTexture() const;
|
||||
|
||||
/**
|
||||
* Gives access to the position texture of the G-buffer. NOTE: This texture is used for
|
||||
* the majority of rendering the scene and might be already in use. Use CAUTION when
|
||||
* using this function. The size of the texture is the resolution of the viewport.
|
||||
*
|
||||
* \return GLuint identifier of the position texture of the G-buffer
|
||||
* \return identifier of the position texture of the G-buffer
|
||||
*/
|
||||
GLuint gBufferPositionTexture();
|
||||
GLuint gBufferPositionTexture() const;
|
||||
|
||||
/**
|
||||
* Gives access to the normal texture of the G-buffer. NOTE: This texture is used for
|
||||
* the majority of rendering the scene and might be already in use. Use CAUTION when
|
||||
* using this function. The size of the texture is the resolution of the viewport.
|
||||
*
|
||||
* \return GLuint identifier of the normal texture of the G-buffer
|
||||
* \return identifier of the normal texture of the G-buffer
|
||||
*/
|
||||
GLuint gBufferNormalTexture();
|
||||
GLuint gBufferNormalTexture() const;
|
||||
|
||||
/**
|
||||
* Gives access to the depth texture of the G-buffer. NOTE: This texture is used for
|
||||
* the majority of rendering the scene and might be already in use. Use CAUTION when
|
||||
* using this function. The size of the texture is the resolution of the viewport.
|
||||
*
|
||||
* \return GLuint identifier of the depth texture of the G-buffer
|
||||
* \return identifier of the depth texture of the G-buffer
|
||||
*/
|
||||
GLuint gBufferDepthTexture();
|
||||
GLuint gBufferDepthTexture() const;
|
||||
|
||||
void initialize();
|
||||
void deinitialize();
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
RenderEngine();
|
||||
virtual ~RenderEngine() override;
|
||||
|
||||
FramebufferRenderer* renderer();
|
||||
const FramebufferRenderer& renderer() const;
|
||||
|
||||
void initialize();
|
||||
void initializeGL();
|
||||
|
||||
@@ -586,7 +586,7 @@ void RenderableModel::initializeGL() {
|
||||
GL_FLOAT,
|
||||
GL_FALSE,
|
||||
4 * sizeof(GLfloat),
|
||||
(void*)(2 * sizeof(GLfloat))
|
||||
reinterpret_cast<void*>(2 * sizeof(GLfloat))
|
||||
);
|
||||
|
||||
// Generate textures and the frame buffer
|
||||
@@ -597,25 +597,25 @@ void RenderableModel::initializeGL() {
|
||||
glFramebufferTexture(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
global::renderEngine->renderer()->additionalColorTexture1(),
|
||||
global::renderEngine->renderer().additionalColorTexture1(),
|
||||
0
|
||||
);
|
||||
glFramebufferTexture(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT1,
|
||||
global::renderEngine->renderer()->additionalColorTexture2(),
|
||||
global::renderEngine->renderer().additionalColorTexture2(),
|
||||
0
|
||||
);
|
||||
glFramebufferTexture(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT2,
|
||||
global::renderEngine->renderer()->additionalColorTexture3(),
|
||||
global::renderEngine->renderer().additionalColorTexture3(),
|
||||
0
|
||||
);
|
||||
glFramebufferTexture(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_DEPTH_ATTACHMENT,
|
||||
global::renderEngine->renderer()->additionalDepthTexture(),
|
||||
global::renderEngine->renderer().additionalDepthTexture(),
|
||||
0
|
||||
);
|
||||
|
||||
@@ -772,17 +772,17 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
}
|
||||
|
||||
// Only render two pass if the model is in any way transparent
|
||||
bool shouldRenderTwise = false;
|
||||
bool shouldRenderTwice = false;
|
||||
const float o = opacity();
|
||||
if ((o >= 0.f && o < 1.f) || _geometry->isTransparent()) {
|
||||
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
|
||||
shouldRenderTwise = true;
|
||||
shouldRenderTwice = true;
|
||||
}
|
||||
else {
|
||||
setRenderBin(_originalRenderBin);
|
||||
}
|
||||
|
||||
if (!shouldRenderTwise) {
|
||||
if (!shouldRenderTwice) {
|
||||
// Reset manual depth test
|
||||
_program->setUniform(
|
||||
_uniformCache.performManualDepthTest,
|
||||
@@ -801,7 +801,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
glFramebufferTexture(
|
||||
GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
global::renderEngine->renderer()->additionalColorTexture1(),
|
||||
global::renderEngine->renderer().additionalColorTexture1(),
|
||||
0
|
||||
);
|
||||
// Check status
|
||||
@@ -826,7 +826,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
gBufferDepthTextureUnit.activate();
|
||||
glBindTexture(
|
||||
GL_TEXTURE_2D,
|
||||
global::renderEngine->renderer()->gBufferDepthTexture()
|
||||
global::renderEngine->renderer().gBufferDepthTexture()
|
||||
);
|
||||
_program->setUniform(
|
||||
_uniformCache.gBufferDepthTexture,
|
||||
@@ -863,7 +863,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
colorTextureUnit.activate();
|
||||
glBindTexture(
|
||||
GL_TEXTURE_2D,
|
||||
global::renderEngine->renderer()->additionalColorTexture1()
|
||||
global::renderEngine->renderer().additionalColorTexture1()
|
||||
);
|
||||
_quadProgram->setUniform(_uniformOpacityCache.colorTexture, colorTextureUnit);
|
||||
|
||||
@@ -871,7 +871,7 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
depthTextureUnit.activate();
|
||||
glBindTexture(
|
||||
GL_TEXTURE_2D,
|
||||
global::renderEngine->renderer()->additionalDepthTexture()
|
||||
global::renderEngine->renderer().additionalDepthTexture()
|
||||
);
|
||||
_quadProgram->setUniform(_uniformOpacityCache.depthTexture, depthTextureUnit);
|
||||
|
||||
@@ -886,10 +886,10 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
glm::ivec4 viewport = glm::ivec4(vp[0], vp[1], vp[2], vp[3]);
|
||||
_quadProgram->setUniform(
|
||||
_uniformOpacityCache.viewport,
|
||||
static_cast<float>(viewport[0]),
|
||||
static_cast<float>(viewport[1]),
|
||||
static_cast<float>(viewport[2]),
|
||||
static_cast<float>(viewport[3])
|
||||
viewport[0],
|
||||
viewport[1],
|
||||
viewport[2],
|
||||
viewport[3]
|
||||
);
|
||||
|
||||
// Draw
|
||||
|
||||
@@ -117,9 +117,9 @@ private:
|
||||
properties::PropertyOwner _lightSourcePropertyOwner;
|
||||
|
||||
// Framebuffer and screen space quad
|
||||
GLuint _framebuffer;
|
||||
GLuint _quadVao;
|
||||
GLuint _quadVbo;
|
||||
GLuint _framebuffer = 0;
|
||||
GLuint _quadVao = 0;
|
||||
GLuint _quadVbo = 0;
|
||||
|
||||
// Opacity program
|
||||
ghoul::opengl::ProgramObject* _quadProgram = nullptr;
|
||||
|
||||
@@ -32,7 +32,7 @@ uniform float opacity = 1.0;
|
||||
uniform sampler2D colorTexture;
|
||||
uniform sampler2D depthTexture;
|
||||
|
||||
uniform vec4 viewport;
|
||||
uniform ivec4 viewport;
|
||||
uniform vec2 resolution;
|
||||
|
||||
Fragment getFragment() {
|
||||
|
||||
@@ -90,47 +90,47 @@ namespace openspace {
|
||||
//============================//
|
||||
//===== Reuse textures =====//
|
||||
//============================//
|
||||
// Gives access to the currently NOT used pingPongTexture
|
||||
GLuint FramebufferRenderer::additionalColorTexture1() {
|
||||
GLuint FramebufferRenderer::additionalColorTexture1() const {
|
||||
// Gives access to the currently NOT used pingPongTexture
|
||||
int unusedPingPongIndex = _pingPongIndex == 0 ? 1 : 0;
|
||||
return _pingPongBuffers.colorTexture[unusedPingPongIndex];
|
||||
}
|
||||
|
||||
// Gives access to the exitColorTexture
|
||||
GLuint FramebufferRenderer::additionalColorTexture2() {
|
||||
GLuint FramebufferRenderer::additionalColorTexture2() const {
|
||||
// Gives access to the exitColorTexture
|
||||
return _exitColorTexture;
|
||||
}
|
||||
|
||||
// Gives access to the fxaaTexture
|
||||
GLuint FramebufferRenderer::additionalColorTexture3() {
|
||||
GLuint FramebufferRenderer::additionalColorTexture3() const {
|
||||
// Gives access to the fxaaTexture
|
||||
return _fxaaBuffers.fxaaTexture;
|
||||
}
|
||||
|
||||
// Gives access to the exitDepthTexture
|
||||
GLuint FramebufferRenderer::additionalDepthTexture() {
|
||||
GLuint FramebufferRenderer::additionalDepthTexture() const {
|
||||
// Gives access to the exitDepthTexture
|
||||
return _exitDepthTexture;
|
||||
}
|
||||
|
||||
//=============================//
|
||||
//===== Access G-buffer =====//
|
||||
//=============================//
|
||||
// / Gives access to the color texture of the G-buffer
|
||||
GLuint FramebufferRenderer::gBufferColorTexture() {
|
||||
GLuint FramebufferRenderer::gBufferColorTexture() const {
|
||||
// Gives access to the color texture of the G-buffer
|
||||
return _gBuffers.colorTexture;
|
||||
}
|
||||
|
||||
// Gives access to the position texture of the G-buffer
|
||||
GLuint FramebufferRenderer::gBufferPositionTexture() {
|
||||
GLuint FramebufferRenderer::gBufferPositionTexture() const {
|
||||
// Gives access to the position texture of the G-buffer
|
||||
return _gBuffers.positionTexture;
|
||||
}
|
||||
|
||||
// Gives access to the normal texture of the G-buffer
|
||||
GLuint FramebufferRenderer::gBufferNormalTexture() {
|
||||
GLuint FramebufferRenderer::gBufferNormalTexture() const {
|
||||
// Gives access to the normal texture of the G-buffer
|
||||
return _gBuffers.normalTexture;
|
||||
}
|
||||
|
||||
// Gives access to the depth texture of the G-buffer
|
||||
GLuint FramebufferRenderer::gBufferDepthTexture() {
|
||||
GLuint FramebufferRenderer::gBufferDepthTexture() const {
|
||||
// Gives access to the depth texture of the G-buffer
|
||||
return _gBuffers.depthTexture;
|
||||
}
|
||||
|
||||
|
||||
@@ -413,8 +413,8 @@ RenderEngine::RenderEngine()
|
||||
|
||||
RenderEngine::~RenderEngine() {}
|
||||
|
||||
FramebufferRenderer* RenderEngine::renderer() {
|
||||
return &_renderer;
|
||||
const FramebufferRenderer& RenderEngine::renderer() const {
|
||||
return _renderer;
|
||||
}
|
||||
|
||||
void RenderEngine::initialize() {
|
||||
|
||||
Reference in New Issue
Block a user