1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0024450: TKOpenGl - Fixed pipeline materials update optimization does not distinguish front/back faces

This commit is contained in:
kgv 2013-12-10 12:44:10 +04:00 committed by abv
parent 0794c042bd
commit 0adbd30f1d
5 changed files with 209 additions and 322 deletions

View File

@ -27,6 +27,7 @@
#include <OpenGl_Context.hxx> #include <OpenGl_Context.hxx>
#include <OpenGl_ShaderManager.hxx> #include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx> #include <OpenGl_ShaderProgram.hxx>
#include <OpenGl_Workspace.hxx>
IMPLEMENT_STANDARD_HANDLE (OpenGl_ShaderManager, Standard_Transient) IMPLEMENT_STANDARD_HANDLE (OpenGl_ShaderManager, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderManager, Standard_Transient) IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderManager, Standard_Transient)
@ -260,7 +261,7 @@ public:
OpenGl_Vec4 Parameters; OpenGl_Vec4 Parameters;
//! Returns packed (serialized) representation of light source properties //! Returns packed (serialized) representation of light source properties
const OpenGl_Vec4* Packed() { return reinterpret_cast<OpenGl_Vec4*> (this); } const OpenGl_Vec4* Packed() const { return reinterpret_cast<const OpenGl_Vec4*> (this); }
static Standard_Integer NbOfVec4() { return 4; } static Standard_Integer NbOfVec4() { return 4; }
}; };
@ -274,7 +275,7 @@ public:
Standard_Integer IsHeadlight; Standard_Integer IsHeadlight;
//! Returns packed (serialized) representation of light source type //! Returns packed (serialized) representation of light source type
const OpenGl_Vec2i* Packed() { return reinterpret_cast<OpenGl_Vec2i*> (this); } const OpenGl_Vec2i* Packed() const { return reinterpret_cast<const OpenGl_Vec2i*> (this); }
static Standard_Integer NbOfVec2i() { return 1; } static Standard_Integer NbOfVec2i() { return 1; }
}; };
@ -621,8 +622,7 @@ static void PushAspectFace (const Handle(OpenGl_Context)& theCtx,
theProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE), theProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE),
theAspect->DistinguishingMode()); theAspect->DistinguishingMode());
const float aDefSpecCol[4] = {1.0f, 1.0f, 1.0f, 1.0f}; OpenGl_Material aParams;
OpenGl_Vec4 aParams[5];
for (Standard_Integer anIndex = 0; anIndex < 2; ++anIndex) for (Standard_Integer anIndex = 0; anIndex < 2; ++anIndex)
{ {
const GLint aLoc = theProgram->GetStateLocation (anIndex == 0 const GLint aLoc = theProgram->GetStateLocation (anIndex == 0
@ -633,35 +633,9 @@ static void PushAspectFace (const Handle(OpenGl_Context)& theCtx,
continue; continue;
} }
const OPENGL_SURF_PROP& aProps = (anIndex == 0) ? theAspect->IntFront() : theAspect->IntBack(); aParams.Init (anIndex == 0 ? theAspect->IntFront() : theAspect->IntBack());
const float* aSrcEms = aProps.isphysic ? aProps.emscol.rgb : aProps.matcol.rgb; theProgram->SetUniform (theCtx, aLoc, OpenGl_Material::NbOfVec4(),
const OpenGl_Vec4 anEmission (aSrcEms[0] * aProps.emsv, aParams.Packed());
aSrcEms[1] * aProps.emsv,
aSrcEms[2] * aProps.emsv,
1.0f);
const float* aSrcAmb = aProps.isphysic ? aProps.ambcol.rgb : aProps.matcol.rgb;
const OpenGl_Vec4 anAmbient (aSrcAmb[0] * aProps.amb,
aSrcAmb[1] * aProps.amb,
aSrcAmb[2] * aProps.amb,
1.0f);
const float* aSrcDif = aProps.isphysic ? aProps.difcol.rgb : aProps.matcol.rgb;
const OpenGl_Vec4 aDiffuse (aSrcDif[0] * aProps.diff,
aSrcDif[1] * aProps.diff,
aSrcDif[2] * aProps.diff,
1.0f);
const float* aSrcSpe = aProps.isphysic ? aProps.speccol.rgb : aDefSpecCol;
const OpenGl_Vec4 aSpecular (aSrcSpe[0] * aProps.spec,
aSrcSpe[1] * aProps.spec,
aSrcSpe[2] * aProps.spec,
1.0f);
aParams[0] = anEmission;
aParams[1] = anAmbient;
aParams[2] = aDiffuse;
aParams[3] = aSpecular;
aParams[4].x() = aProps.shine;
aParams[4].y() = aProps.trans;
theProgram->SetUniform (theCtx, aLoc, 5, aParams);
} }
} }

View File

@ -17,7 +17,6 @@
// purpose or non-infringement. Please see the License for the specific terms // purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License. // and conditions governing the rights and limitations under the License.
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
@ -48,7 +47,8 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,OpenGl_Window)
namespace namespace
{ {
static const TEL_COLOUR myDefaultHighlightColor = { { 1.F, 1.F, 1.F, 1.F } }; static const TEL_COLOUR THE_WHITE_COLOR = { { 1.0f, 1.0f, 1.0f, 1.0f } };
static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f);
static const OpenGl_AspectLine myDefaultAspectLine; static const OpenGl_AspectLine myDefaultAspectLine;
static const OpenGl_AspectFace myDefaultAspectFace; static const OpenGl_AspectFace myDefaultAspectFace;
@ -70,6 +70,72 @@ namespace
}; };
// =======================================================================
// function : Init
// purpose :
// =======================================================================
void OpenGl_Material::Init (const OPENGL_SURF_PROP& theProp)
{
// ambient component
if (theProp.color_mask & OPENGL_AMBIENT_MASK)
{
const float* aSrcAmb = theProp.isphysic ? theProp.ambcol.rgb : theProp.matcol.rgb;
Ambient = OpenGl_Vec4 (aSrcAmb[0] * theProp.amb,
aSrcAmb[1] * theProp.amb,
aSrcAmb[2] * theProp.amb,
1.0f);
}
else
{
Ambient = THE_BLACK_COLOR;
}
// diffusion component
if (theProp.color_mask & OPENGL_DIFFUSE_MASK)
{
const float* aSrcDif = theProp.isphysic ? theProp.difcol.rgb : theProp.matcol.rgb;
Diffuse = OpenGl_Vec4 (aSrcDif[0] * theProp.diff,
aSrcDif[1] * theProp.diff,
aSrcDif[2] * theProp.diff,
1.0f);
}
else
{
Diffuse = THE_BLACK_COLOR;
}
// specular component
if (theProp.color_mask & OPENGL_SPECULAR_MASK)
{
const float* aSrcSpe = theProp.isphysic ? theProp.speccol.rgb : THE_WHITE_COLOR.rgb;
Specular = OpenGl_Vec4 (aSrcSpe[0] * theProp.spec,
aSrcSpe[1] * theProp.spec,
aSrcSpe[2] * theProp.spec,
1.0f);
}
else
{
Specular = THE_BLACK_COLOR;
}
// emission component
if (theProp.color_mask & OPENGL_EMISSIVE_MASK)
{
const float* aSrcEms = theProp.isphysic ? theProp.emscol.rgb : theProp.matcol.rgb;
Emission = OpenGl_Vec4 (aSrcEms[0] * theProp.emsv,
aSrcEms[1] * theProp.emsv,
aSrcEms[2] * theProp.emsv,
1.0f);
}
else
{
Emission = THE_BLACK_COLOR;
}
ChangeShine() = theProp.shine;
ChangeTransparency() = theProp.trans;
}
// ======================================================================= // =======================================================================
// function : OpenGl_Workspace // function : OpenGl_Workspace
// purpose : // purpose :
@ -81,7 +147,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay,
const Handle(OpenGl_Context)& theShareCtx) const Handle(OpenGl_Context)& theShareCtx)
: OpenGl_Window (theDisplay, theCWindow, theGContext, theCaps, theShareCtx), : OpenGl_Window (theDisplay, theCWindow, theGContext, theCaps, theShareCtx),
NamedStatus (0), NamedStatus (0),
HighlightColor (&myDefaultHighlightColor), HighlightColor (&THE_WHITE_COLOR),
// //
myIsTransientOpen (Standard_False), myIsTransientOpen (Standard_False),
myRetainMode (Standard_False), myRetainMode (Standard_False),
@ -195,7 +261,7 @@ void OpenGl_Workspace::UseTransparency (const Standard_Boolean theFlag)
void OpenGl_Workspace::ResetAppliedAspect() void OpenGl_Workspace::ResetAppliedAspect()
{ {
NamedStatus = !myTextureBound.IsNull() ? OPENGL_NS_TEXTURE : 0; NamedStatus = !myTextureBound.IsNull() ? OPENGL_NS_TEXTURE : 0;
HighlightColor = &myDefaultHighlightColor; HighlightColor = &THE_WHITE_COLOR;
AspectLine_set = &myDefaultAspectLine; AspectLine_set = &myDefaultAspectLine;
AspectLine_applied = NULL; AspectLine_applied = NULL;
AspectFace_set = &myDefaultAspectFace; AspectFace_set = &myDefaultAspectFace;

View File

@ -60,6 +60,7 @@
#endif #endif
#include <OpenGl_TextParam.hxx> #include <OpenGl_TextParam.hxx>
#include <OpenGl_RenderFilter.hxx> #include <OpenGl_RenderFilter.hxx>
#include <OpenGl_Vec.hxx>
#include <Handle_OpenGl_View.hxx> #include <Handle_OpenGl_View.hxx>
#include <Handle_OpenGl_Texture.hxx> #include <Handle_OpenGl_Texture.hxx>
@ -72,6 +73,31 @@ class OpenGl_Structure;
class OpenGl_Element; class OpenGl_Element;
class Image_PixMap; class Image_PixMap;
//! OpenGL material definition
struct OpenGl_Material
{
OpenGl_Vec4 Ambient; //!< ambient reflection coefficient
OpenGl_Vec4 Diffuse; //!< diffuse reflection coefficient
OpenGl_Vec4 Specular; //!< glossy reflection coefficient
OpenGl_Vec4 Emission; //!< material emission
OpenGl_Vec4 Params; //!< extra packed parameters
Standard_ShortReal Shine() const { return Params.x(); }
Standard_ShortReal& ChangeShine() { return Params.x(); }
Standard_ShortReal Transparency() const { return Params.y(); }
Standard_ShortReal& ChangeTransparency() { return Params.y(); }
//! Initialize material
void Init (const OPENGL_SURF_PROP& theProps);
//! Returns packed (serialized) representation of material properties
const OpenGl_Vec4* Packed() const { return reinterpret_cast<const OpenGl_Vec4*> (this); }
static Standard_Integer NbOfVec4() { return 5; }
};
//! Represents window with GL context. //! Represents window with GL context.
//! Provides methods to render primitives and maintain GL state. //! Provides methods to render primitives and maintain GL state.
class OpenGl_Workspace : public OpenGl_Window class OpenGl_Workspace : public OpenGl_Window
@ -217,7 +243,7 @@ protected:
const Aspect_CLayer2d& theCOverLayer, const Aspect_CLayer2d& theCOverLayer,
const int theToSwap); const int theToSwap);
void UpdateMaterial (const int flag); void updateMaterial (const int theFlag);
void setTextureParams (Handle(OpenGl_Texture)& theTexture, void setTextureParams (Handle(OpenGl_Texture)& theTexture,
const Handle(Graphic3d_TextureParams)& theParams); const Handle(Graphic3d_TextureParams)& theParams);
@ -417,6 +443,10 @@ protected: //! @name fields related to status
const OpenGl_Matrix* ViewMatrix_applied; const OpenGl_Matrix* ViewMatrix_applied;
const OpenGl_Matrix* StructureMatrix_applied; const OpenGl_Matrix* StructureMatrix_applied;
OpenGl_Material myMatFront; //!< current front material state (cached to reduce GL context updates)
OpenGl_Material myMatBack; //!< current back material state
OpenGl_Material myMatTmp; //!< temporary variable
//! Model matrix with applied structure transformations //! Model matrix with applied structure transformations
OpenGl_Matrix myModelViewMatrix; OpenGl_Matrix myModelViewMatrix;

View File

@ -71,7 +71,7 @@ static void TelUpdatePolygonOffsets( const TEL_POFFSET_PARAM *pdata )
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
void OpenGl_Workspace::UpdateMaterial( const int flag ) void OpenGl_Workspace::updateMaterial (const int theFlag)
{ {
// Case of hidden line // Case of hidden line
if (AspectFace_set->InteriorStyle() == Aspect_IS_HIDDENLINE) if (AspectFace_set->InteriorStyle() == Aspect_IS_HIDDENLINE)
@ -85,32 +85,46 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
return; return;
} }
const OPENGL_SURF_PROP *prop = NULL; const OPENGL_SURF_PROP* aProps = &AspectFace_set->IntFront();
GLenum face = 0; GLenum aFace = GL_FRONT_AND_BACK;
if ( flag == TEL_FRONT_MATERIAL ) if (theFlag == TEL_BACK_MATERIAL)
{ {
prop = &AspectFace_set->IntFront(); aFace = GL_BACK;
face = GL_FRONT_AND_BACK; aProps = &AspectFace_set->IntBack();
}
else if (AspectFace_set->DistinguishingMode() == TOn
&& !(NamedStatus & OPENGL_NS_RESMAT))
{
aFace = GL_FRONT;
}
myMatTmp.Init (*aProps);
// handling transparency
if (NamedStatus & OPENGL_NS_2NDPASSDO)
{
// second pass
myMatTmp.Diffuse.a() = aProps->env_reflexion;
} }
else else
{ {
prop = &AspectFace_set->IntBack(); if (aProps->env_reflexion != 0.0f)
face = GL_BACK; {
// if the material reflects the environment scene, the second pass is needed
NamedStatus |= OPENGL_NS_2NDPASSNEED;
} }
// Handling transparency if (myUseTransparency && aProps->trans != 1.0f)
if ( (NamedStatus & OPENGL_NS_2NDPASSDO) == 0 )
{ {
if ( myUseTransparency && prop->trans != 1.0F ) // render transparent
{ myMatTmp.Diffuse.a() = aProps->trans;
// Render transparent
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable (GL_BLEND); glEnable (GL_BLEND);
glDepthMask (GL_FALSE); glDepthMask (GL_FALSE);
} }
else else
{ {
// Render opaque // render opaque
if ((NamedStatus & OPENGL_NS_ANTIALIASING) == 0) if ((NamedStatus & OPENGL_NS_ANTIALIASING) == 0)
{ {
glBlendFunc (GL_ONE, GL_ZERO); glBlendFunc (GL_ONE, GL_ZERO);
@ -120,271 +134,74 @@ void OpenGl_Workspace::UpdateMaterial( const int flag )
} }
} }
// Obtaining reflection mode flags to update GL material properties // do not update material properties in case of zero reflection mode,
const unsigned int aReflectionMode = prop->color_mask; // because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() anyway.
if (aProps->color_mask == 0)
{
return;
}
// Do not update material properties in case of zero reflection mode, // reset material
// because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray()
// anyway.
if ( !aReflectionMode ) return;
static float mAmb[4];
static float mDiff[4];
static float mSpec[4];
static float mEmsv[4];
static float mShin;
static const float defspeccol[4] = { 1.F, 1.F, 1.F, 1.F };
// Reset material
if (NamedStatus & OPENGL_NS_RESMAT) if (NamedStatus & OPENGL_NS_RESMAT)
{ {
// Ambient component glMaterialfv (aFace, GL_AMBIENT, myMatTmp.Ambient.GetData());
if( aReflectionMode & OPENGL_AMBIENT_MASK ) glMaterialfv (aFace, GL_DIFFUSE, myMatTmp.Diffuse.GetData());
{ glMaterialfv (aFace, GL_SPECULAR, myMatTmp.Specular.GetData());
const float *c = prop->isphysic? prop->ambcol.rgb : prop->matcol.rgb; glMaterialfv (aFace, GL_EMISSION, myMatTmp.Emission.GetData());
glMaterialf (aFace, GL_SHININESS, myMatTmp.Shine());
mAmb[0] = prop->amb * c[0]; if (theFlag == TEL_FRONT_MATERIAL)
mAmb[1] = prop->amb * c[1]; {
mAmb[2] = prop->amb * c[2]; myMatFront = myMatTmp;
myMatBack = myMatTmp;
} }
else else
{ {
mAmb[0] = 0.F; myMatBack = myMatTmp;
mAmb[1] = 0.F;
mAmb[2] = 0.F;
} }
mAmb[3] = 1.F;
// Diffusion component
if( aReflectionMode & OPENGL_DIFFUSE_MASK )
{
const float *c = prop->isphysic? prop->difcol.rgb : prop->matcol.rgb;
mDiff[0] = prop->diff * c[0];
mDiff[1] = prop->diff * c[1];
mDiff[2] = prop->diff * c[2];
}
else
{
mDiff[0] = 0.F;
mDiff[1] = 0.F;
mDiff[2] = 0.F;
}
mDiff[3] = 1.F;
if (NamedStatus & OPENGL_NS_2NDPASSDO)
{
mDiff[3] = prop->env_reflexion;
}
else
{
if (myUseTransparency) mDiff[3] = prop->trans;
// If the material reflects the environment scene, the second pass is needed
if (prop->env_reflexion != 0.0) NamedStatus |= OPENGL_NS_2NDPASSNEED;
}
// Specular component
if( aReflectionMode & OPENGL_SPECULAR_MASK )
{
const float *c = prop->isphysic? prop->speccol.rgb : defspeccol;
mSpec[0] = prop->spec * c[0];
mSpec[1] = prop->spec * c[1];
mSpec[2] = prop->spec * c[2];
}
else {
mSpec[0] = 0.F;
mSpec[1] = 0.F;
mSpec[2] = 0.F;
}
mSpec[3] = 1.F;
// Emissive component
if( aReflectionMode & OPENGL_EMISSIVE_MASK )
{
const float *c = prop->isphysic? prop->emscol.rgb : prop->matcol.rgb;
mEmsv[0] = prop->emsv * c[0];
mEmsv[1] = prop->emsv * c[1];
mEmsv[2] = prop->emsv * c[2];
}
else {
mEmsv[0] = 0.F;
mEmsv[1] = 0.F;
mEmsv[2] = 0.F;
}
mEmsv[3] = 1.F;
/* Coeficient de brillance */
mShin = prop->shine;
glMaterialfv(face, GL_AMBIENT, mAmb );
glMaterialfv(face, GL_DIFFUSE, mDiff );
glMaterialfv(face, GL_SPECULAR, mSpec);
glMaterialfv(face, GL_EMISSION, mEmsv);
glMaterialf(face, GL_SHININESS, mShin);
NamedStatus &= ~OPENGL_NS_RESMAT; NamedStatus &= ~OPENGL_NS_RESMAT;
return;
} }
// Set Material Optimize // reduce updates
else OpenGl_Material& anOld = (theFlag == TEL_FRONT_MATERIAL)
{ ? myMatFront
// Ambient component : myMatBack;
if( aReflectionMode & OPENGL_AMBIENT_MASK )
{
const float *c = prop->isphysic? prop->ambcol.rgb : prop->matcol.rgb;
if (mAmb[0] != prop->amb * c[0] || if (myMatTmp.Ambient.r() != anOld.Ambient.r()
mAmb[1] != prop->amb * c[1] || || myMatTmp.Ambient.g() != anOld.Ambient.g()
mAmb[2] != prop->amb * c[2] ) || myMatTmp.Ambient.b() != anOld.Ambient.b())
{ {
mAmb[0] = prop->amb * c[0]; glMaterialfv (aFace, GL_AMBIENT, myMatTmp.Ambient.GetData());
mAmb[1] = prop->amb * c[1];
mAmb[2] = prop->amb * c[2];
mAmb[3] = 1.F;
glMaterialfv(face, GL_AMBIENT, mAmb);
} }
} if (myMatTmp.Diffuse.r() != anOld.Diffuse.r()
else || myMatTmp.Diffuse.g() != anOld.Diffuse.g()
|| myMatTmp.Diffuse.b() != anOld.Diffuse.b()
|| fabs (myMatTmp.Diffuse.a() - anOld.Diffuse.a()) > 0.01f)
{ {
if ( mAmb[0] != 0.F || mAmb[1] != 0.F || mAmb[2] != 0.F ) glMaterialfv (aFace, GL_DIFFUSE, myMatTmp.Diffuse.GetData());
}
if (myMatTmp.Specular.r() != anOld.Specular.r()
|| myMatTmp.Specular.g() != anOld.Specular.g()
|| myMatTmp.Specular.b() != anOld.Specular.b())
{ {
mAmb[0] = 0.F; glMaterialfv (aFace, GL_SPECULAR, myMatTmp.Specular.GetData());
mAmb[1] = 0.F;
mAmb[2] = 0.F;
mAmb[3] = 1.F;
glMaterialfv(face, GL_AMBIENT, mAmb);
} }
} if (myMatTmp.Emission.r() != anOld.Emission.r()
|| myMatTmp.Emission.g() != anOld.Emission.g()
// Diffusion component || myMatTmp.Emission.b() != anOld.Emission.b())
if( aReflectionMode & OPENGL_DIFFUSE_MASK )
{ {
const float *c = prop->isphysic? prop->difcol.rgb : prop->matcol.rgb; glMaterialfv (aFace, GL_EMISSION, myMatTmp.Emission.GetData());
}
if (mDiff[0] != prop->diff * c[0] || if (myMatTmp.Shine() != anOld.Shine())
mDiff[1] != prop->diff * c[1] ||
mDiff[2] != prop->diff * c[2] ||
mDiff[3] != ((NamedStatus & OPENGL_NS_2NDPASSDO)? prop->env_reflexion : (myUseTransparency? prop->trans : 1.0F)))
{ {
mDiff[0] = prop->diff * c[0]; glMaterialf (aFace, GL_SHININESS, myMatTmp.Shine());
mDiff[1] = prop->diff * c[1]; }
mDiff[2] = prop->diff * c[2]; anOld = myMatTmp;
mDiff[3] = 1.F; if (aFace == GL_FRONT_AND_BACK)
if (NamedStatus & OPENGL_NS_2NDPASSDO)
{ {
mDiff[3] = prop->env_reflexion; myMatBack = myMatTmp;
}
else
{
if (myUseTransparency) mDiff[3] = prop->trans;
// If the material reflects the environment scene, the second pass is needed
if (prop->env_reflexion != 0.0) NamedStatus |= OPENGL_NS_2NDPASSNEED;
}
glMaterialfv(face, GL_DIFFUSE, mDiff );
}
}
else
{
Tfloat newDiff3 = 1.F;
if (NamedStatus & OPENGL_NS_2NDPASSDO)
{
newDiff3 = prop->env_reflexion;
}
else
{
if (myUseTransparency) newDiff3 = prop->trans;
// If the material reflects the environment scene, the second pass is needed
if (prop->env_reflexion != 0.0) NamedStatus |= OPENGL_NS_2NDPASSNEED;
}
/* OCC19915: Even if diffuse reflectance is disabled,
still trying to update the current transparency if it
differs from the previous value */
if ( mDiff[0] != 0.F || mDiff[1] != 0.F || mDiff[2] != 0.F || fabs(mDiff[3] - newDiff3) > 0.01F )
{
mDiff[0] = 0.F;
mDiff[1] = 0.F;
mDiff[2] = 0.F;
mDiff[3] = newDiff3;
glMaterialfv(face, GL_DIFFUSE, mDiff);
}
}
// Specular component
if( aReflectionMode & OPENGL_SPECULAR_MASK )
{
const float *c = prop->isphysic? prop->speccol.rgb : defspeccol;
if (mSpec[0] != prop->spec * c[0] ||
mSpec[1] != prop->spec * c[1] ||
mSpec[2] != prop->spec * c[2])
{
mSpec[0] = prop->spec * c[0];
mSpec[1] = prop->spec * c[1];
mSpec[2] = prop->spec * c[2];
mSpec[3] = 1.F;
glMaterialfv(face, GL_SPECULAR, mSpec);
}
}
else
{
if ( mSpec[0] != 0.F || mSpec[1] != 0.F || mSpec[2] != 0.F )
{
mSpec[0] = 0.F;
mSpec[1] = 0.F;
mSpec[2] = 0.F;
mSpec[3] = 1.F;
glMaterialfv(face, GL_SPECULAR, mSpec);
}
}
// Emissive component
if( aReflectionMode & OPENGL_EMISSIVE_MASK )
{
const float *c = prop->isphysic? prop->emscol.rgb : prop->matcol.rgb;
if (mEmsv[0] != prop->emsv * c[0] ||
mEmsv[1] != prop->emsv * c[1] ||
mEmsv[2] != prop->emsv * c[2])
{
mEmsv[0] = prop->emsv * c[0];
mEmsv[1] = prop->emsv * c[1];
mEmsv[2] = prop->emsv * c[2];
mEmsv[3] = 1.F;
glMaterialfv(face, GL_EMISSION, mEmsv);
}
}
else
{
if ( mEmsv[0] != 0.F || mEmsv[1] != 0.F || mEmsv[2] != 0.F )
{
mEmsv[0] = 0.F;
mEmsv[1] = 0.F;
mEmsv[2] = 0.F;
mEmsv[3] = 1.F;
glMaterialfv(face, GL_EMISSION, mEmsv);
}
}
// Shining coefficient
if( mShin != prop->shine )
{
mShin = prop->shine;
glMaterialf(face, GL_SHININESS, mShin);
}
} }
} }
@ -536,7 +353,7 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th
glDisable (GL_POLYGON_STIPPLE); glDisable (GL_POLYGON_STIPPLE);
break; break;
} }
case Aspect_IS_POINT: //szvgl - no corresponding enumeration item Aspect_IS_POINT // = 5 case Aspect_IS_POINT:
{ {
glPolygonMode (GL_FRONT_AND_BACK, GL_POINT); glPolygonMode (GL_FRONT_AND_BACK, GL_POINT);
break; break;
@ -594,10 +411,10 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th
} }
} }
UpdateMaterial (TEL_FRONT_MATERIAL); updateMaterial (TEL_FRONT_MATERIAL);
if (AspectFace_set->DistinguishingMode() == TOn) if (AspectFace_set->DistinguishingMode() == TOn)
{ {
UpdateMaterial (TEL_BACK_MATERIAL); updateMaterial (TEL_BACK_MATERIAL);
} }
if ((NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0) if ((NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0)

View File

@ -21,17 +21,17 @@ uniform vec4 occFrontMaterial[5];
uniform vec4 occBackMaterial[5]; uniform vec4 occBackMaterial[5];
// front material properties accessors // front material properties accessors
vec4 occFrontMaterial_Emission(void) { return occFrontMaterial[0]; } vec4 occFrontMaterial_Ambient(void) { return occFrontMaterial[0]; }
vec4 occFrontMaterial_Ambient(void) { return occFrontMaterial[1]; } vec4 occFrontMaterial_Diffuse(void) { return occFrontMaterial[1]; }
vec4 occFrontMaterial_Diffuse(void) { return occFrontMaterial[2]; } vec4 occFrontMaterial_Specular(void) { return occFrontMaterial[2]; }
vec4 occFrontMaterial_Specular(void) { return occFrontMaterial[3]; } vec4 occFrontMaterial_Emission(void) { return occFrontMaterial[3]; }
float occFrontMaterial_Shininess(void) { return occFrontMaterial[4].x; } float occFrontMaterial_Shininess(void) { return occFrontMaterial[4].x; }
float occFrontMaterial_Transparency(void) { return occFrontMaterial[4].y; } float occFrontMaterial_Transparency(void) { return occFrontMaterial[4].y; }
// back material properties accessors // back material properties accessors
vec4 occBackMaterial_Emission(void) { return occBackMaterial[0]; } vec4 occBackMaterial_Ambient(void) { return occBackMaterial[0]; }
vec4 occBackMaterial_Ambient(void) { return occBackMaterial[1]; } vec4 occBackMaterial_Diffuse(void) { return occBackMaterial[1]; }
vec4 occBackMaterial_Diffuse(void) { return occBackMaterial[2]; } vec4 occBackMaterial_Specular(void) { return occBackMaterial[2]; }
vec4 occBackMaterial_Specular(void) { return occBackMaterial[3]; } vec4 occBackMaterial_Emission(void) { return occBackMaterial[3]; }
float occBackMaterial_Shininess(void) { return occBackMaterial[4].x; } float occBackMaterial_Shininess(void) { return occBackMaterial[4].x; }
float occBackMaterial_Transparency(void) { return occBackMaterial[4].y; } float occBackMaterial_Transparency(void) { return occBackMaterial[4].y; }