diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index 3171aad530..bcde980d5c 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -49,6 +49,7 @@ CellEdgeEffectGenerator::CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeSc m_cullBackfaces = caf::FC_NONE; m_opacityLevel = 1.0f; m_defaultCellColor = cvf::Color3f(cvf::Color3::WHITE); + m_disableLighting = false; } //-------------------------------------------------------------------------------------------------- @@ -82,6 +83,7 @@ bool CellEdgeEffectGenerator::isEqual(const EffectGenerator* other) const && m_opacityLevel == otherCellFaceEffectGenerator->m_opacityLevel && m_undefinedColor == otherCellFaceEffectGenerator->m_undefinedColor && m_defaultCellColor == otherCellFaceEffectGenerator->m_defaultCellColor + && m_disableLighting == otherCellFaceEffectGenerator->m_disableLighting ) { cvf::ref texImg2 = new cvf::TextureImage; @@ -121,6 +123,7 @@ caf::EffectGenerator* CellEdgeEffectGenerator::copy() const newEffect->setFaceCulling(m_cullBackfaces); newEffect->setUndefinedColor(m_undefinedColor); newEffect->setDefaultCellColor(m_defaultCellColor); + newEffect->disableLighting(m_disableLighting); return newEffect; } @@ -179,8 +182,16 @@ void CellEdgeEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) } } - shaderGen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse()); - shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + if (m_disableLighting) + { + shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit); + } + else + { + shaderGen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse()); + shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + } + cvf::ref prog = shaderGen.generate(); eff->setShaderProgram(prog.p()); diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.h b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.h index 967cc0de12..52f6b1d8e7 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.h +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.h @@ -110,6 +110,7 @@ public: void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; } void setFaceCulling(caf::FaceCulling faceCulling) { m_cullBackfaces = faceCulling; } void setDefaultCellColor(cvf::Color3f color) { m_defaultCellColor = color; } + void disableLighting(bool disable) { m_disableLighting = disable; } protected: virtual bool isEqual( const EffectGenerator* other ) const; @@ -130,5 +131,6 @@ private: caf::FaceCulling m_cullBackfaces; cvf::Color3f m_undefinedColor; cvf::Color3f m_defaultCellColor; + bool m_disableLighting; }; diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp index 8c10c8d39b..ee2cd498f3 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp @@ -39,28 +39,28 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivScalarMapperUtils::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling) +void RivScalarMapperUtils::applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting) { CVF_ASSERT(part && textureCoords && mapper); cvf::DrawableGeo* dg = dynamic_cast(part->drawable()); if (dg) dg->setTextureCoordArray(textureCoords); - cvf::ref scalarEffect = RivScalarMapperUtils::createScalarMapperEffect(mapper, opacityLevel, faceCulling); + cvf::ref scalarEffect = RivScalarMapperUtils::createScalarMapperEffect(mapper, opacityLevel, faceCulling, disableLighting); part->setEffect(scalarEffect.p()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivScalarMapperUtils::applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling) +void RivScalarMapperUtils::applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting) { CVF_ASSERT(part && textureCoords && mapper); cvf::DrawableGeo* dg = dynamic_cast(part->drawable()); if (dg) dg->setTextureCoordArray(textureCoords); - cvf::ref scalarEffect = RivScalarMapperUtils::createTernaryScalarMapperEffect(mapper, opacityLevel, faceCulling); + cvf::ref scalarEffect = RivScalarMapperUtils::createTernaryScalarMapperEffect(mapper, opacityLevel, faceCulling, disableLighting); part->setEffect(scalarEffect.p()); } @@ -75,7 +75,8 @@ cvf::ref RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe RimCellEdgeResultSlot* cellEdgeResultSlot, float opacityLevel, cvf::Color3f defaultColor, - caf::FaceCulling faceCulling) + caf::FaceCulling faceCulling, + bool disableLighting) { CellEdgeEffectGenerator cellFaceEffectGen(cellEdgeResultSlot->legendConfig()->scalarMapper()); @@ -99,6 +100,7 @@ cvf::ref RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe cellFaceEffectGen.setOpacityLevel(opacityLevel); cellFaceEffectGen.setDefaultCellColor(defaultColor); cellFaceEffectGen.setFaceCulling(faceCulling); + cellFaceEffectGen.disableLighting(disableLighting); cvf::ref eff = cellFaceEffectGen.generateEffect(); return eff; @@ -107,7 +109,7 @@ cvf::ref RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling) +cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting) { CVF_ASSERT(mapper); @@ -115,6 +117,7 @@ cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf:: caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset); scalarEffgen.setOpacityLevel(opacityLevel); scalarEffgen.setFaceCulling(faceCulling); + scalarEffgen.disableLighting(disableLighting); cvf::ref scalarEffect = scalarEffgen.generateEffect(); @@ -124,7 +127,7 @@ cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf:: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivScalarMapperUtils::createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling) +cvf::ref RivScalarMapperUtils::createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting) { CVF_ASSERT(mapper); @@ -132,6 +135,7 @@ cvf::ref RivScalarMapperUtils::createTernaryScalarMapperEffect(cons RivTernaryScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset); scalarEffgen.setOpacityLevel(opacityLevel); scalarEffgen.setFaceCulling(faceCulling); + scalarEffgen.disableLighting(disableLighting); cvf::ref scalarEffect = scalarEffgen.generateEffect(); return scalarEffect; diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.h b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.h index 64bd98dcee..6ba08cf078 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.h +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.h @@ -43,8 +43,8 @@ class RimCellEdgeResultSlot; class RivScalarMapperUtils { public: - static void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling); - static void applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling); + static void applyTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting); + static void applyTernaryTextureResultsToPart(cvf::Part* part, cvf::Vec2fArray* textureCoords, const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting); static cvf::ref createCellEdgeEffect(cvf::DrawableGeo* dg, const cvf::StructGridQuadToCellFaceMapper* quadToCellFaceMapper, @@ -54,10 +54,11 @@ public: RimCellEdgeResultSlot* cellEdgeResultSlot, float opacityLevel, cvf::Color3f defaultColor, - caf::FaceCulling faceCulling); + caf::FaceCulling faceCulling, + bool disableLighting); private: - static cvf::ref createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling); - static cvf::ref createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling); + static cvf::ref createScalarMapperEffect(const cvf::ScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting); + static cvf::ref createTernaryScalarMapperEffect(const RivTernaryScalarMapper* mapper, float opacityLevel, caf::FaceCulling faceCulling, bool disableLighting); }; diff --git a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp index 60b7630413..d80e67bc5b 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp @@ -54,6 +54,7 @@ RivTernaryScalarMapperEffectGenerator::RivTernaryScalarMapperEffectGenerator(con m_opacityLevel = 1.0f; m_faceCulling = caf::FC_NONE; m_enableDepthWrite = true; + m_disableLighting = false; } //-------------------------------------------------------------------------------------------------- @@ -66,8 +67,16 @@ void RivTernaryScalarMapperEffectGenerator::updateForShaderBasedRendering(cvf::E cvf::ShaderProgramGenerator gen("ScalarMapperMeshEffectGenerator", cvf::ShaderSourceProvider::instance()); gen.addVertexCode(cvf::ShaderSourceRepository::vs_Standard); gen.addFragmentCode(cvf::ShaderSourceRepository::src_Texture); - gen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse()); - gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + + if (m_disableLighting) + { + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit); + } + else + { + gen.addFragmentCode(caf::CommonShaderSources::light_AmbientDiffuse()); + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + } cvf::ref prog = gen.generate(); eff->setShaderProgram(prog.p()); @@ -104,6 +113,7 @@ void RivTernaryScalarMapperEffectGenerator::updateForFixedFunctionRendering(cvf: cvf::ref lighting = new cvf::RenderStateLighting_FF; lighting->enableTwoSided(true); + lighting->enable(!m_disableLighting); eff->setRenderState(lighting.p()); // Result mapping texture @@ -189,7 +199,8 @@ bool RivTernaryScalarMapperEffectGenerator::isEqual(const EffectGenerator* other && 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 texImg2 = new cvf::TextureImage; otherTextureResultEffect->m_scalarMapper->updateTexture(texImg2.p(), m_opacityLevel); @@ -212,6 +223,7 @@ caf::EffectGenerator* RivTernaryScalarMapperEffectGenerator::copy() const scEffGen->m_undefinedColor = m_undefinedColor; scEffGen->m_faceCulling = m_faceCulling; scEffGen->m_enableDepthWrite = m_enableDepthWrite; + scEffGen->m_disableLighting = m_disableLighting; return scEffGen; } diff --git a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.h b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.h index d45121421b..0e00ea2973 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.h +++ b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.h @@ -42,6 +42,7 @@ public: void setUndefinedColor(cvf::Color3f color) { m_undefinedColor = color; } void setFaceCulling(caf::FaceCulling faceCulling) { m_faceCulling = faceCulling; } void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; } + void disableLighting(bool disable) { m_disableLighting = disable; } public: @@ -65,5 +66,6 @@ private: cvf::Color3f m_undefinedColor; caf::FaceCulling m_faceCulling; bool m_enableDepthWrite; + bool m_disableLighting; }; diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp index e5049e0d8d..642c24b4e1 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp @@ -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 prog = gen.generate(); eff->setShaderProgram(prog.p()); @@ -447,6 +454,7 @@ void ScalarMapperEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* e cvf::ref 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 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; } diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h index 9d79c9d5c4..56adcf3849 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h @@ -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 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; };