mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0029519: Visualization, TKOpenGl - fallback to Graphic3d_TOSM_FACET from Gouraud/Phong when nodal normals are undefined
This commit is contained in:
parent
dc89236fee
commit
db5d29de1c
@ -1521,6 +1521,15 @@ Multiple changes have been applied to lights management within TKV3d and TKOpenG
|
||||
Dedicated classes only hides visibility of unrelated light properties depending on its type.
|
||||
* Calling V3d_Viewer::UpdateLights() is no more required after modifying light sources properties (color, position, etc.).
|
||||
|
||||
@subsection upgrade_730_shadingmodels Shading Models
|
||||
|
||||
*Graphic3d_AspectFillArea3d* has been extended by a new property ::ShadingModel(), which previously has been defined globally for entire View.
|
||||
|
||||
Previously, triangle array without normal vertex attributes was implicitly considered as unshaded,
|
||||
but now such array will be shaded using *Graphic3d_TOSM_FACET* model (e.g. by computing per-triangle normals).
|
||||
Therefore, *Graphic3d_TOSM_UNLIT* should be explicitly specified for disabling shading or triangles array.
|
||||
Alternatively, material without reflectance properties can be used for disabling shading as before.
|
||||
|
||||
@subsection upgrade_730_tkopengl Custom low-level OpenGL elements
|
||||
|
||||
The following API changes should be considered while porting custom OpenGl_Element objects:
|
||||
|
@ -733,11 +733,6 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
myIsVboInit = Standard_True;
|
||||
}
|
||||
|
||||
const Standard_Boolean hasColorAttrib = !myVboAttribs.IsNull()
|
||||
&& myVboAttribs->HasColorAttribute();
|
||||
const Graphic3d_TypeOfShadingModel aShadingModel = aCtx->ShaderManager()->ChooseShadingModel (anAspectFace->ShadingModel(),
|
||||
!myVboAttribs.IsNull() && myVboAttribs->HasNormalAttribute());
|
||||
|
||||
// Temporarily disable environment mapping
|
||||
Handle(OpenGl_TextureSet) aTextureBack;
|
||||
bool toDrawArray = true;
|
||||
@ -758,14 +753,19 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
}
|
||||
}
|
||||
|
||||
Graphic3d_TypeOfShadingModel aShadingModel = Graphic3d_TOSM_UNLIT;
|
||||
if (toDrawArray)
|
||||
{
|
||||
const bool toHilight = theWorkspace->ToHighlight();
|
||||
const Standard_Boolean hasVertColor = hasColorAttrib && !toHilight;
|
||||
const bool hasColorAttrib = !myVboAttribs.IsNull()
|
||||
&& myVboAttribs->HasColorAttribute();
|
||||
const bool toHilight = theWorkspace->ToHighlight();
|
||||
const bool hasVertColor = hasColorAttrib && !toHilight;
|
||||
const bool hasVertNorm = !myVboAttribs.IsNull() && myVboAttribs->HasNormalAttribute();
|
||||
switch (myDrawMode)
|
||||
{
|
||||
case GL_POINTS:
|
||||
{
|
||||
aShadingModel = aCtx->ShaderManager()->ChooseMarkerShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
|
||||
const Handle(OpenGl_TextureSet)& aSpriteNormRes = anAspectMarker->SpriteRes (aCtx);
|
||||
const OpenGl_PointSprite* aSpriteNorm = !aSpriteNormRes.IsNull() ? dynamic_cast<const OpenGl_PointSprite*> (aSpriteNormRes->First().get()) : NULL;
|
||||
if (aSpriteNorm != NULL
|
||||
@ -786,6 +786,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
case GL_LINES:
|
||||
case GL_LINE_STRIP:
|
||||
{
|
||||
aShadingModel = aCtx->ShaderManager()->ChooseLineShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
|
||||
aCtx->ShaderManager()->BindLineProgram (NULL,
|
||||
anAspectLine->Aspect()->Type(),
|
||||
aShadingModel,
|
||||
@ -795,6 +796,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
}
|
||||
default:
|
||||
{
|
||||
aShadingModel = aCtx->ShaderManager()->ChooseFaceShadingModel (anAspectFace->ShadingModel(), hasVertNorm);
|
||||
const Handle(OpenGl_TextureSet)& aTextures = aCtx->ActiveTextures();
|
||||
const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
|
||||
aCtx->ShaderManager()->BindFaceProgram (aTextures,
|
||||
|
@ -316,9 +316,10 @@ public:
|
||||
return myContext == theCtx;
|
||||
}
|
||||
|
||||
//! Choose Shading Model.
|
||||
Graphic3d_TypeOfShadingModel ChooseShadingModel (Graphic3d_TypeOfShadingModel theCustomModel,
|
||||
bool theHasNodalNormals) const
|
||||
//! Choose Shading Model for filled primitives.
|
||||
//! Fallbacks to FACET model if there are no normal attributes.
|
||||
Graphic3d_TypeOfShadingModel ChooseFaceShadingModel (Graphic3d_TypeOfShadingModel theCustomModel,
|
||||
bool theHasNodalNormals) const
|
||||
{
|
||||
if (!myContext->ColorMask())
|
||||
{
|
||||
@ -330,13 +331,42 @@ public:
|
||||
case Graphic3d_TOSM_DEFAULT:
|
||||
case Graphic3d_TOSM_UNLIT:
|
||||
case Graphic3d_TOSM_FACET:
|
||||
break;
|
||||
return aModel;
|
||||
case Graphic3d_TOSM_VERTEX:
|
||||
case Graphic3d_TOSM_FRAGMENT:
|
||||
aModel = theHasNodalNormals ? aModel : Graphic3d_TOSM_UNLIT;
|
||||
break;
|
||||
return theHasNodalNormals ? aModel : Graphic3d_TOSM_FACET;
|
||||
}
|
||||
return aModel;
|
||||
return Graphic3d_TOSM_UNLIT;
|
||||
}
|
||||
|
||||
//! Choose Shading Model for line primitives.
|
||||
//! Fallbacks to UNLIT model if there are no normal attributes.
|
||||
Graphic3d_TypeOfShadingModel ChooseLineShadingModel (Graphic3d_TypeOfShadingModel theCustomModel,
|
||||
bool theHasNodalNormals) const
|
||||
{
|
||||
if (!myContext->ColorMask())
|
||||
{
|
||||
return Graphic3d_TOSM_UNLIT;
|
||||
}
|
||||
Graphic3d_TypeOfShadingModel aModel = theCustomModel != Graphic3d_TOSM_DEFAULT ? theCustomModel : myShadingModel;
|
||||
switch (aModel)
|
||||
{
|
||||
case Graphic3d_TOSM_DEFAULT:
|
||||
case Graphic3d_TOSM_UNLIT:
|
||||
case Graphic3d_TOSM_FACET:
|
||||
return Graphic3d_TOSM_UNLIT;
|
||||
case Graphic3d_TOSM_VERTEX:
|
||||
case Graphic3d_TOSM_FRAGMENT:
|
||||
return theHasNodalNormals ? aModel : Graphic3d_TOSM_UNLIT;
|
||||
}
|
||||
return Graphic3d_TOSM_UNLIT;
|
||||
}
|
||||
|
||||
//! Choose Shading Model for Marker primitives.
|
||||
Graphic3d_TypeOfShadingModel ChooseMarkerShadingModel (Graphic3d_TypeOfShadingModel theCustomModel,
|
||||
bool theHasNodalNormals) const
|
||||
{
|
||||
return ChooseLineShadingModel (theCustomModel, theHasNodalNormals);
|
||||
}
|
||||
|
||||
//! Returns default Shading Model.
|
||||
|
Loading…
x
Reference in New Issue
Block a user