Skip to content

Commit

Permalink
Merge pull request #1728 from ghutchis/default-render-options
Browse files Browse the repository at this point in the history
Turn off default depth blur, shadows, edge for speed
  • Loading branch information
ghutchis authored Oct 15, 2024
2 parents 818c059 + 77f4d4e commit 91472d4
Showing 1 changed file with 40 additions and 38 deletions.
78 changes: 40 additions & 38 deletions avogadro/rendering/solidpipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include "solidpipeline.h"

#include "avogadrogl.h"
#include "shader.h"
#include "camera.h"
#include "shader.h"
#include "shaderprogram.h"

#include "solid_vs.h"
Expand Down Expand Up @@ -57,12 +57,8 @@ class SolidPipeline::Private
};

static const GLfloat s_fullscreenQuad[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 0.0f,
};

void initializeFramebuffer(GLuint* outFBO, GLuint* texRGB, GLuint* texDepth)
Expand All @@ -88,10 +84,11 @@ void initializeFramebuffer(GLuint* outFBO, GLuint* texRGB, GLuint* texDepth)
}

SolidPipeline::SolidPipeline()
: m_pixelRatio(1.0f), m_aoEnabled(true), m_dofEnabled(true), m_aoStrength(1.0f),
m_fogStrength(1.0f), m_fogPosition(1.0), m_fogEnabled(true), m_edEnabled(true),
m_edStrength(1.0f), m_width(0), m_height(0), m_dofStrength(1.0f),
m_dofPosition(1.0), m_backgroundColor(0,0,0,0), d(new Private)
: m_pixelRatio(1.0f), m_aoEnabled(false), m_dofEnabled(false),
m_aoStrength(1.0f), m_fogStrength(1.0f), m_fogPosition(1.0),
m_fogEnabled(true), m_edEnabled(false), m_edStrength(1.0f), m_width(0),
m_height(0), m_dofStrength(1.0f), m_dofPosition(1.0),
m_backgroundColor(0, 0, 0, 0), d(new Private)
{
}

Expand Down Expand Up @@ -157,43 +154,48 @@ void SolidPipeline::end()
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDrawBuffer(GL_BACK);
}
d->attachStage(d->firstStageShaders, "inRGBTex", d->renderTexture, "inDepthTex",
d->depthTexture, m_width, m_height);
d->firstStageShaders.setUniformValue("inAoEnabled", m_aoEnabled ? 1.0f : 0.0f);
d->firstStageShaders.setUniformValue("inDofEnabled", m_dofEnabled ? 1.0f : 0.0f);
d->firstStageShaders.setUniformValue("inDofStrength", m_dofEnabled ? (m_dofStrength * 100.0f) : 0.0f);
d->firstStageShaders.setUniformValue("inDofPosition", ((m_dofPosition) /10.0f));
d->attachStage(d->firstStageShaders, "inRGBTex", d->renderTexture,
"inDepthTex", d->depthTexture, m_width, m_height);
d->firstStageShaders.setUniformValue("inAoEnabled",
m_aoEnabled ? 1.0f : 0.0f);
d->firstStageShaders.setUniformValue("inDofEnabled",
m_dofEnabled ? 1.0f : 0.0f);
d->firstStageShaders.setUniformValue(
"inDofStrength", m_dofEnabled ? (m_dofStrength * 100.0f) : 0.0f);
d->firstStageShaders.setUniformValue("inDofPosition",
((m_dofPosition) / 10.0f));
d->firstStageShaders.setUniformValue("inAoStrength", m_aoStrength);
d->firstStageShaders.setUniformValue("inEdStrength", m_edStrength);
d->firstStageShaders.setUniformValue("inFogEnabled", m_fogEnabled ? 1.0f : 0.0f);
d->firstStageShaders.setUniformValue("inFogStrength", m_fogEnabled ? m_fogStrength : 0.0f);
d->firstStageShaders.setUniformValue("inFogEnabled",
m_fogEnabled ? 1.0f : 0.0f);
d->firstStageShaders.setUniformValue("inFogStrength",
m_fogEnabled ? m_fogStrength : 0.0f);
d->firstStageShaders.setUniformValue("inFogPosition", m_fogPosition);
d->firstStageShaders.setUniformValue("fogR", (m_backgroundColor[0])/255.0f);
d->firstStageShaders.setUniformValue("fogG", (m_backgroundColor[1])/255.0f);
d->firstStageShaders.setUniformValue("fogB", (m_backgroundColor[2])/255.0f);
d->firstStageShaders.setUniformValue("fogR", (m_backgroundColor[0]) / 255.0f);
d->firstStageShaders.setUniformValue("fogG", (m_backgroundColor[1]) / 255.0f);
d->firstStageShaders.setUniformValue("fogB", (m_backgroundColor[2]) / 255.0f);
glDrawArrays(GL_TRIANGLES, 0, 6);
glDisableVertexAttribArray(0);
}

void SolidPipeline::adjustOffset(const Camera& cam) {

// The numbers used in calculations are random.
// They help define an offset with the projection-matrix
// to make the fog dynamic as the molecule moves away
// from the camera or come closer.
Eigen::Matrix4f projectView = cam.projection().matrix();
void SolidPipeline::adjustOffset(const Camera& cam)
{

float project = ((((5000 + projectView(2,3) * 1000)/6) + 55) * 100);
// The numbers used in calculations are random.
// They help define an offset with the projection-matrix
// to make the fog dynamic as the molecule moves away
// from the camera or come closer.
Eigen::Matrix4f projectView = cam.projection().matrix();

float offSet = 0.000102337 * pow(project,2) - 3.84689 * project + 36182.2;
if(project >= 21018.106 && project<21595.588){
offSet = 2.63129 * project - 54768.4;
}
else if(project >= 21595.588 ){
offSet = 9.952 * project - 212865;
}
d->firstStageShaders.setUniformValue("uoffset", offSet);
float project = ((((5000 + projectView(2, 3) * 1000) / 6) + 55) * 100);

float offSet = 0.000102337 * pow(project, 2) - 3.84689 * project + 36182.2;
if (project >= 21018.106 && project < 21595.588) {
offSet = 2.63129 * project - 54768.4;
} else if (project >= 21595.588) {
offSet = 9.952 * project - 212865;
}
d->firstStageShaders.setUniformValue("uoffset", offSet);
}

void SolidPipeline::resize(int width, int height)
Expand Down

0 comments on commit 91472d4

Please sign in to comment.