Skip to content

Commit

Permalink
fog strength added
Browse files Browse the repository at this point in the history
Signed-off-by: Perminder <[email protected]>
  • Loading branch information
perminder-17 committed Jun 5, 2024
1 parent 0022a5c commit 6b7ef22
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion avogadro/rendering/solid_first_fs.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ uniform float inAoEnabled;
uniform float inFogEnabled;
// Shadow strength for SSAO
uniform float inAoStrength;
// Fog strength
uniform float inFogStrength;
// 1.0 if enabled, 0.0 if disabled
uniform float inEdStrength;
// Rendering surface dimensions, in pixels
Expand Down Expand Up @@ -79,7 +81,7 @@ vec4 applyFog(vec2 texCoord) {
vec4 finalColor = mix(
texture2D(inRGBTex, texCoord),
vec4(vec3(fogR, fogG, fogB), 1.),
pow(texture2D(inDepthTex, texCoord.xy).r, offset)
pow(texture2D(inDepthTex, texCoord.xy).r + inFogStrength, offset)
);
return finalColor;
}
Expand Down
6 changes: 4 additions & 2 deletions avogadro/rendering/solidpipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void initializeFramebuffer(GLuint* outFBO, GLuint* texRGB, GLuint* texDepth)
}

SolidPipeline::SolidPipeline()
: m_pixelRatio(1.0f), m_aoEnabled(true), m_aoStrength(1.0f),
m_fogEnabled(true), m_edEnabled(true), m_edStrength(1.0f),
: m_pixelRatio(1.0f), m_aoEnabled(true), m_aoStrength(1.0f),
m_fogStrength(1.0f), m_fogEnabled(true), m_edEnabled(true), m_edStrength(1.0f),
m_width(0), m_height(0), d(new Private), m_backgroundColor(0,0,0,0)
{
}
Expand Down Expand Up @@ -160,6 +160,7 @@ void SolidPipeline::end()
d->depthTexture, m_width, m_height);
d->firstStageShaders.setUniformValue("inAoEnabled", m_aoEnabled ? 1.0f : 0.0f);
d->firstStageShaders.setUniformValue("inAoStrength", m_aoStrength);
d->firstStageShaders.setUniformValue("inFogStrength", ((m_fogStrength / 100.0f)- 0.01f));
d->firstStageShaders.setUniformValue("inEdStrength", m_edStrength);
d->firstStageShaders.setUniformValue("inFogEnabled", m_fogEnabled ? 1.0f : 0.0f);
d->firstStageShaders.setUniformValue("fogR", (m_backgroundColor[0])/255.0f);
Expand All @@ -170,6 +171,7 @@ void SolidPipeline::end()
glDisableVertexAttribArray(0);
}

// TODO: More precise calculations needed
void SolidPipeline::adjustOffset(const Camera& cam) {
// Get the model-view matrix from the camera
Eigen::Matrix4f modelView = cam.modelView().matrix();
Expand Down
7 changes: 7 additions & 0 deletions avogadro/rendering/solidpipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class SolidPipeline
float getAoStrength() { return m_aoStrength; }
void setAoStrength(float strength) { m_aoStrength = strength; }

/**
* @brief Get or set shadow strength for Ambient Occlusion.
*/
float getFogStrength() { return m_fogStrength; }
void setFogStrength(float strength) { m_fogStrength = strength; }

/**
* @brief Get or set whether Edge Detection is enabled.
*/
Expand All @@ -96,6 +102,7 @@ class SolidPipeline
Eigen::Affine3f modelView;
bool m_fogEnabled;
float m_aoStrength;
float m_fogStrength;
bool m_edEnabled;
float m_edStrength;
int m_width;
Expand Down

0 comments on commit 6b7ef22

Please sign in to comment.