mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Experimental support for offsetting NNCs when drawing
Utilize polygon offset in conjunction with disabling of depth writes to layer drawing of NNs on top of other fault drawing.
This commit is contained in:
parent
6d1db22cd8
commit
0100038db0
@ -45,6 +45,7 @@
|
|||||||
#include "cvfPrimitiveSetIndexedUInt.h"
|
#include "cvfPrimitiveSetIndexedUInt.h"
|
||||||
#include "cvfPrimitiveSetDirect.h"
|
#include "cvfPrimitiveSetDirect.h"
|
||||||
#include "RivGridPartMgr.h"
|
#include "RivGridPartMgr.h"
|
||||||
|
#include "cvfRenderStateDepth.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -223,6 +224,10 @@ void RivFaultPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, RimResultS
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RivFaultPartMgr::generatePartGeometry()
|
void RivFaultPartMgr::generatePartGeometry()
|
||||||
{
|
{
|
||||||
|
const int priFaultGeo = 1;
|
||||||
|
const int priNncGeo = 2;
|
||||||
|
const int priMesh = 3;
|
||||||
|
|
||||||
bool useBufferObjects = true;
|
bool useBufferObjects = true;
|
||||||
// Surface geometry
|
// Surface geometry
|
||||||
{
|
{
|
||||||
@ -246,6 +251,7 @@ void RivFaultPartMgr::generatePartGeometry()
|
|||||||
|
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
part->setEnableMask(faultBit);
|
part->setEnableMask(faultBit);
|
||||||
|
part->setPriority(priFaultGeo);
|
||||||
|
|
||||||
m_nativeFaultFaces = part;
|
m_nativeFaultFaces = part;
|
||||||
}
|
}
|
||||||
@ -267,6 +273,7 @@ void RivFaultPartMgr::generatePartGeometry()
|
|||||||
|
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
part->setEnableMask(meshFaultBit);
|
part->setEnableMask(meshFaultBit);
|
||||||
|
part->setPriority(priMesh);
|
||||||
|
|
||||||
m_nativeFaultGridLines = part;
|
m_nativeFaultGridLines = part;
|
||||||
}
|
}
|
||||||
@ -295,6 +302,7 @@ void RivFaultPartMgr::generatePartGeometry()
|
|||||||
|
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
part->setEnableMask(faultBit);
|
part->setEnableMask(faultBit);
|
||||||
|
part->setPriority(priFaultGeo);
|
||||||
|
|
||||||
m_oppositeFaultFaces = part;
|
m_oppositeFaultFaces = part;
|
||||||
}
|
}
|
||||||
@ -316,6 +324,7 @@ void RivFaultPartMgr::generatePartGeometry()
|
|||||||
|
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
part->setEnableMask(meshFaultBit);
|
part->setEnableMask(meshFaultBit);
|
||||||
|
part->setPriority(priMesh);
|
||||||
|
|
||||||
m_oppositeFaultGridLines = part;
|
m_oppositeFaultGridLines = part;
|
||||||
}
|
}
|
||||||
@ -342,6 +351,7 @@ void RivFaultPartMgr::generatePartGeometry()
|
|||||||
|
|
||||||
part->updateBoundingBox();
|
part->updateBoundingBox();
|
||||||
part->setEnableMask(faultBit);
|
part->setEnableMask(faultBit);
|
||||||
|
part->setPriority(priNncGeo);
|
||||||
|
|
||||||
m_NNCFaces = part;
|
m_NNCFaces = part;
|
||||||
}
|
}
|
||||||
@ -407,8 +417,19 @@ void RivFaultPartMgr::updatePartEffect()
|
|||||||
nncColor.g() += (1.0 - nncColor.g()) * 0.2;
|
nncColor.g() += (1.0 - nncColor.g()) * 0.2;
|
||||||
nncColor.g() += (1.0 - nncColor.b()) * 0.2;
|
nncColor.g() += (1.0 - nncColor.b()) * 0.2;
|
||||||
|
|
||||||
caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_NONE);
|
cvf::ref<cvf::Effect> nncEffect;
|
||||||
cvf::ref<cvf::Effect> nncEffect = nncEffgen.generateEffect();
|
|
||||||
|
if (m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces)
|
||||||
|
{
|
||||||
|
caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_NEG_LARGE);
|
||||||
|
nncEffgen.enableDepthWrite(false);
|
||||||
|
nncEffect = nncEffgen.generateEffect();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
caf::SurfaceEffectGenerator nncEffgen(nncColor, caf::PO_1);
|
||||||
|
nncEffect = nncEffgen.generateEffect();
|
||||||
|
}
|
||||||
|
|
||||||
if (m_NNCFaces.notNull())
|
if (m_NNCFaces.notNull())
|
||||||
{
|
{
|
||||||
@ -434,6 +455,9 @@ void RivFaultPartMgr::updatePartEffect()
|
|||||||
|
|
||||||
if (m_opacityLevel < 1.0f)
|
if (m_opacityLevel < 1.0f)
|
||||||
{
|
{
|
||||||
|
// Must be fixed since currently fault drawing relies on internal priorities of the parts
|
||||||
|
CVF_FAIL_MSG("Not implemented");
|
||||||
|
|
||||||
// Set priority to make sure this transparent geometry are rendered last
|
// Set priority to make sure this transparent geometry are rendered last
|
||||||
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setPriority(100);
|
if (m_nativeFaultFaces.notNull()) m_nativeFaultFaces->setPriority(100);
|
||||||
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setPriority(100);
|
if (m_oppositeFaultFaces.notNull()) m_oppositeFaultFaces->setPriority(100);
|
||||||
|
@ -116,13 +116,12 @@ static cvf::ref<cvf::RenderStatePolygonOffset> CreateAngConfigurePolygonOffsetRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
rs->enableFillMode(true);
|
rs->enableFillMode(true);
|
||||||
rs->setFactor(1.0f);
|
|
||||||
|
|
||||||
switch (polygonOffset)
|
switch (polygonOffset)
|
||||||
{
|
{
|
||||||
case PO_1: rs->setUnits(1.0f); break;
|
case PO_1: rs->setFactor(1.0f); rs->setUnits(1.0f); break;
|
||||||
case PO_2: rs->setUnits(2.0f); break;
|
case PO_2: rs->setFactor(2.0f); rs->setUnits(2.0f); break;
|
||||||
case PO_3: rs->setUnits(3.0f); break;
|
case PO_NEG_LARGE: rs->setFactor(-1.0f); rs->setUnits(-30.0f); break;
|
||||||
default:
|
default:
|
||||||
CVF_FAIL_MSG("Unhandled polygon offset enum");
|
CVF_FAIL_MSG("Unhandled polygon offset enum");
|
||||||
}
|
}
|
||||||
@ -239,6 +238,7 @@ SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color4f& color, Polygo
|
|||||||
m_color = color;
|
m_color = color;
|
||||||
m_polygonOffset = polygonOffset;
|
m_polygonOffset = polygonOffset;
|
||||||
m_cullBackfaces = FC_NONE;
|
m_cullBackfaces = FC_NONE;
|
||||||
|
m_enableDepthWrite = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -249,6 +249,7 @@ SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color3f& color, Polygo
|
|||||||
m_color = cvf::Color4f(color, 1.0f);
|
m_color = cvf::Color4f(color, 1.0f);
|
||||||
m_polygonOffset = polygonOffset;
|
m_polygonOffset = polygonOffset;
|
||||||
m_cullBackfaces = FC_NONE;
|
m_cullBackfaces = FC_NONE;
|
||||||
|
m_enableDepthWrite = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -331,6 +332,13 @@ void SurfaceEffectGenerator::updateCommonEffect(cvf::Effect* effect) const
|
|||||||
|
|
||||||
effect->setRenderState(faceCulling.p());
|
effect->setRenderState(faceCulling.p());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_enableDepthWrite)
|
||||||
|
{
|
||||||
|
cvf::ref<cvf::RenderStateDepth> depth = new cvf::RenderStateDepth;
|
||||||
|
depth->enableDepthWrite(false);
|
||||||
|
effect->setRenderState(depth.p());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -344,6 +352,7 @@ bool SurfaceEffectGenerator::isEqual(const EffectGenerator* other) const
|
|||||||
{
|
{
|
||||||
if (m_color == otherSurfaceEffect->m_color
|
if (m_color == otherSurfaceEffect->m_color
|
||||||
&& m_polygonOffset == otherSurfaceEffect->m_polygonOffset
|
&& m_polygonOffset == otherSurfaceEffect->m_polygonOffset
|
||||||
|
&& m_enableDepthWrite == otherSurfaceEffect->m_enableDepthWrite
|
||||||
&& m_cullBackfaces == otherSurfaceEffect->m_cullBackfaces)
|
&& m_cullBackfaces == otherSurfaceEffect->m_cullBackfaces)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -360,6 +369,7 @@ EffectGenerator* SurfaceEffectGenerator::copy() const
|
|||||||
{
|
{
|
||||||
SurfaceEffectGenerator* effGen = new SurfaceEffectGenerator(m_color, m_polygonOffset);
|
SurfaceEffectGenerator* effGen = new SurfaceEffectGenerator(m_color, m_polygonOffset);
|
||||||
effGen->m_cullBackfaces = m_cullBackfaces;
|
effGen->m_cullBackfaces = m_cullBackfaces;
|
||||||
|
effGen->m_enableDepthWrite = m_enableDepthWrite;
|
||||||
return effGen;
|
return effGen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,10 +58,10 @@ public:
|
|||||||
// Enumerates different levels of polygon offsetting
|
// Enumerates different levels of polygon offsetting
|
||||||
enum PolygonOffset
|
enum PolygonOffset
|
||||||
{
|
{
|
||||||
PO_NONE = 0, // No polygon offset
|
PO_NONE, // No polygon offset
|
||||||
PO_1 = 1, // 'Normal' polygon offset, equal to configurePolygonPositiveOffset(), ie factor=unit=1.0
|
PO_1, // 'Normal' positive polygon offset, equal to configurePolygonPositiveOffset(), ie factor=unit=1.0
|
||||||
PO_2 = 2, // More offset
|
PO_2, // More positive offset
|
||||||
PO_3 = 3 // Even more offset
|
PO_NEG_LARGE // Currently, a large negative offset
|
||||||
};
|
};
|
||||||
|
|
||||||
// Enumerates face culling
|
// Enumerates face culling
|
||||||
@ -125,6 +125,7 @@ public:
|
|||||||
SurfaceEffectGenerator(const cvf::Color3f& color, PolygonOffset polygonOffset);
|
SurfaceEffectGenerator(const cvf::Color3f& color, PolygonOffset polygonOffset);
|
||||||
|
|
||||||
void setCullBackfaces(FaceCulling cullBackFaces) { m_cullBackfaces = cullBackFaces; }
|
void setCullBackfaces(FaceCulling cullBackFaces) { m_cullBackfaces = cullBackFaces; }
|
||||||
|
void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool isEqual(const EffectGenerator* other) const;
|
virtual bool isEqual(const EffectGenerator* other) const;
|
||||||
@ -140,7 +141,7 @@ private:
|
|||||||
cvf::Color4f m_color;
|
cvf::Color4f m_color;
|
||||||
PolygonOffset m_polygonOffset;
|
PolygonOffset m_polygonOffset;
|
||||||
FaceCulling m_cullBackfaces;
|
FaceCulling m_cullBackfaces;
|
||||||
|
bool m_enableDepthWrite;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user