mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added option for disabling lighting (#311)
This commit is contained in:
@@ -93,7 +93,6 @@ static const char light_AmbientDiffuse_inl[] =
|
||||
" return vec4(ambient + diffuse, srcFragColor.a); \n"
|
||||
"} \n";
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -103,7 +102,6 @@ cvf::String CommonShaderSources::light_AmbientDiffuse()
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Static helper to configure polygon offset render state from enum
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -395,6 +393,7 @@ ScalarMapperEffectGenerator::ScalarMapperEffectGenerator(const cvf::ScalarMapper
|
||||
m_opacityLevel = 1.0f;
|
||||
m_faceCulling = FC_NONE;
|
||||
m_enableDepthWrite = true;
|
||||
m_disableLighting = false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -407,8 +406,16 @@ void ScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::Effect* eff
|
||||
cvf::ShaderProgramGenerator gen("ScalarMapperEffectGenerator", cvf::ShaderSourceProvider::instance());
|
||||
gen.addVertexCode(cvf::ShaderSourceRepository::vs_Standard);
|
||||
gen.addFragmentCode(cvf::ShaderSourceRepository::src_Texture);
|
||||
gen.addFragmentCode(CommonShaderSources::light_AmbientDiffuse());
|
||||
gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard);
|
||||
|
||||
if (m_disableLighting)
|
||||
{
|
||||
gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit);
|
||||
}
|
||||
else
|
||||
{
|
||||
gen.addFragmentCode(CommonShaderSources::light_AmbientDiffuse());
|
||||
gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard);
|
||||
}
|
||||
|
||||
cvf::ref<cvf::ShaderProgram> prog = gen.generate();
|
||||
eff->setShaderProgram(prog.p());
|
||||
@@ -447,6 +454,7 @@ void ScalarMapperEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* e
|
||||
|
||||
cvf::ref<cvf::RenderStateLighting_FF> lighting = new cvf::RenderStateLighting_FF;
|
||||
lighting->enableTwoSided(true);
|
||||
lighting->enable(!m_disableLighting);
|
||||
eff->setRenderState(lighting.p());
|
||||
|
||||
// Result mapping texture
|
||||
@@ -534,7 +542,8 @@ bool ScalarMapperEffectGenerator::isEqual(const EffectGenerator* other) const
|
||||
&& m_opacityLevel == otherTextureResultEffect->m_opacityLevel
|
||||
&& m_undefinedColor == otherTextureResultEffect->m_undefinedColor
|
||||
&& m_faceCulling == otherTextureResultEffect->m_faceCulling
|
||||
&& m_enableDepthWrite == otherTextureResultEffect->m_enableDepthWrite)
|
||||
&& m_enableDepthWrite == otherTextureResultEffect->m_enableDepthWrite
|
||||
&& m_disableLighting == otherTextureResultEffect->m_disableLighting)
|
||||
{
|
||||
cvf::ref<cvf::TextureImage> texImg2 = new cvf::TextureImage;
|
||||
otherTextureResultEffect->m_scalarMapper->updateTexture(texImg2.p());
|
||||
@@ -557,6 +566,7 @@ EffectGenerator* ScalarMapperEffectGenerator::copy() const
|
||||
scEffGen->m_undefinedColor = m_undefinedColor;
|
||||
scEffGen->m_faceCulling = m_faceCulling;
|
||||
scEffGen->m_enableDepthWrite = m_enableDepthWrite;
|
||||
scEffGen->m_disableLighting = m_disableLighting;
|
||||
|
||||
return scEffGen;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,8 @@ public:
|
||||
void setOpacityLevel(float opacity) { m_opacityLevel = cvf::Math::clamp(opacity, 0.0f , 1.0f ); }
|
||||
void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; }
|
||||
void setFaceCulling(FaceCulling faceCulling) { m_faceCulling = faceCulling; }
|
||||
void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; }
|
||||
void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; }
|
||||
void disableLighting(bool disable) { m_disableLighting = disable; }
|
||||
|
||||
public:
|
||||
static cvf::ref<cvf::TextureImage> addAlphaAndUndefStripes(const cvf::TextureImage* texImg, const cvf::Color3f& undefScalarColor, float opacityLevel);
|
||||
@@ -185,6 +186,7 @@ private:
|
||||
cvf::Color3f m_undefinedColor;
|
||||
FaceCulling m_faceCulling;
|
||||
bool m_enableDepthWrite;
|
||||
bool m_disableLighting;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user