mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0029097: Visualization - allow picking Graphic3d_TypeOfShadingModel per-object
Graphic3d_AspectFillArea3d has been extended by new property ::ShadingModel(), which is set to Graphic3d_TOSM_DEFAULT by default. The new API allows assigning Shading Model to specific Primitive Array groups instead of entire Viewer, which was the only possibility before. Graphic3d_TypeOfShadingModel has been extended with Graphic3d_TOSM_DEFAULT value meaining that Shading Model defined as default for the Viewer should be used. Graphic3d_TOSM_NONE has been renamed to Graphic3d_TOSM_UNLIT. Documentation of Shading Models has been improved by more details. V3d_TypeOfShadingModel enumeration has been merged into Graphic3d_TypeOfShadingModel avoiding duplicated definitions and confusion. Old values has been left for compatibility with old code and can be marked deprecated in future. Draw Harness command vaspects has been extended by new argument -setShadingModel for testing Shading Models assigned to entire objects. OpenGl_SetOfShaderPrograms now holds an array of Shading Models. OpenGl_ShaderManager interface has been modified and now requires enumeration as input in several places where Boolean flags have been used previously (methods ::BindFaceProgram(), ::BindLineProgram(), ::BindMarkerProgram()). OpenGl_Workspace now defines default (undefined) OpenGl_AspectFace as Graphic3d_TOSM_UNLIT to simplify indication of primitive groups with undefined Fill Area aspects, and so that Graphic3d_TOSM_UNLIT set as default Shading Model will not make artifacts on Lines and Markers. AIS_Manipulator::Axis::Compute() - added missing initialization of Fill Area aspects (leading to undefined behavior).
This commit is contained in:
parent
8bf738e673
commit
dc89236fee
@ -1521,6 +1521,11 @@ 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_tkopengl Custom low-level OpenGL elements
|
||||
|
||||
The following API changes should be considered while porting custom OpenGl_Element objects:
|
||||
* OpenGl_ShaderManager::BindFaceProgram(), ::BindLineProgram(), ::BindMarkerProgram() now takes enumeration arguments instead of Boolean flags.
|
||||
|
||||
@subsection upgrade_730_BOPAlgo_Section Changes in BOPAlgo_Section
|
||||
|
||||
The public method *BuildSection()* in the class *BOPAlgo_Section* has became protected. The methods *Perform()* or *PerformWithFiller()* should be called for construction of the result of SECTION operation.
|
||||
|
@ -1178,8 +1178,11 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
|
||||
{
|
||||
myHighlightTranslator->Clear();
|
||||
}
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightTranslator);
|
||||
aGroup->AddPrimitiveArray (myTriangleArray);
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightTranslator);
|
||||
aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (myTriangleArray);
|
||||
}
|
||||
}
|
||||
|
||||
if (myHasScaling)
|
||||
@ -1199,8 +1202,11 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
|
||||
{
|
||||
myHighlightScaler->Clear();
|
||||
}
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightScaler);
|
||||
aGroup->AddPrimitiveArray (myCube.Array());
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightScaler);
|
||||
aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (myCube.Array());
|
||||
}
|
||||
}
|
||||
|
||||
if (myHasRotation)
|
||||
@ -1219,7 +1225,10 @@ void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& t
|
||||
{
|
||||
myHighlightRotator->Clear();
|
||||
}
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightRotator);
|
||||
Prs3d_Root::CurrentGroup (myHighlightRotator)->AddPrimitiveArray (myCircle.Array());
|
||||
{
|
||||
Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightRotator);
|
||||
aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
|
||||
aGroup->AddPrimitiveArray (myCircle.Array());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d()
|
||||
myBackInteriorColor (Quantity_NOC_CYAN1),
|
||||
myEdgeColor (Quantity_NOC_WHITE),
|
||||
myInteriorStyle (Aspect_IS_EMPTY),
|
||||
myShadingModel (Graphic3d_TOSM_DEFAULT),
|
||||
myEdgeType (Aspect_TOL_SOLID),
|
||||
myEdgeWidth (1.0f),
|
||||
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
||||
@ -54,6 +55,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorSty
|
||||
myBackInteriorColor (theInteriorColor),
|
||||
myEdgeColor (theEdgeColor),
|
||||
myInteriorStyle (theInteriorStyle),
|
||||
myShadingModel (Graphic3d_TOSM_DEFAULT),
|
||||
myEdgeType (theEdgeLineType),
|
||||
myEdgeWidth ((float )theEdgeLineWidth),
|
||||
myHatchStyle (Handle(Graphic3d_HatchStyle)()),
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
#include <Graphic3d_TextureMap.hxx>
|
||||
#include <Graphic3d_TextureSet.hxx>
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
@ -77,6 +78,12 @@ public:
|
||||
//! Modifies the interior type used for rendering
|
||||
void SetInteriorStyle (const Aspect_InteriorStyle theStyle) { myInteriorStyle = theStyle; }
|
||||
|
||||
//! Returns shading model (Graphic3d_TOSM_DEFAULT by default, which means that Shading Model set as default for entire Viewer will be used)
|
||||
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
|
||||
|
||||
//! Sets shading model
|
||||
void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel) { myShadingModel = theShadingModel; }
|
||||
|
||||
//! Return interior color.
|
||||
const Quantity_Color& InteriorColor() const { return myInteriorColor.GetRGB(); }
|
||||
|
||||
@ -337,6 +344,7 @@ protected:
|
||||
Quantity_ColorRGBA myBackInteriorColor;
|
||||
Quantity_ColorRGBA myEdgeColor;
|
||||
Aspect_InteriorStyle myInteriorStyle;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
Aspect_TypeOfLine myEdgeType;
|
||||
Standard_ShortReal myEdgeWidth;
|
||||
Handle(Graphic3d_HatchStyle) myHatchStyle;
|
||||
|
@ -38,6 +38,7 @@ Graphic3d_CView::Graphic3d_CView (const Handle(Graphic3d_StructureManager)& theM
|
||||
myIsInComputedMode (Standard_False),
|
||||
myIsActive (Standard_False),
|
||||
myIsRemoved (Standard_False),
|
||||
myShadingModel (Graphic3d_TOSM_FRAGMENT),
|
||||
myVisualization (Graphic3d_TOV_WIREFRAME)
|
||||
{
|
||||
myId = myStructureManager->Identification (this);
|
||||
@ -1088,3 +1089,17 @@ void Graphic3d_CView::CopySettings (const Handle(Graphic3d_CView)& theOther)
|
||||
SetLights (theOther->Lights());
|
||||
SetClipPlanes (theOther->ClipPlanes());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetShadingModel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Graphic3d_CView::SetShadingModel (Graphic3d_TypeOfShadingModel theModel)
|
||||
{
|
||||
if (theModel == Graphic3d_TOSM_DEFAULT)
|
||||
{
|
||||
throw Standard_ProgramError ("Graphic3d_CView::SetShadingModel() - attempt to set invalid Shading Model!");
|
||||
}
|
||||
|
||||
myShadingModel = theModel;
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ DEFINE_STANDARD_HANDLE (Graphic3d_CView, Graphic3d_DataStructureManager)
|
||||
//! computed (HLR or "view-dependent") structures.
|
||||
class Graphic3d_CView : public Graphic3d_DataStructureManager
|
||||
{
|
||||
friend class Graphic3d_StructureManager;
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_CView, Graphic3d_DataStructureManager)
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
@ -89,6 +91,13 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
//! Returns default Shading Model of the view; Graphic3d_TOSM_FRAGMENT by default.
|
||||
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
|
||||
|
||||
//! Sets default Shading Model of the view.
|
||||
//! Will throw an exception on attempt to set Graphic3d_TOSM_DEFAULT.
|
||||
Standard_EXPORT void SetShadingModel (Graphic3d_TypeOfShadingModel theModel);
|
||||
|
||||
//! Returns visualization type of the view.
|
||||
Graphic3d_TypeOfVisualization VisualizationType() const { return myVisualization; }
|
||||
|
||||
@ -152,8 +161,6 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
friend class Graphic3d_StructureManager;
|
||||
|
||||
//! Is it possible to display the structure in the view?
|
||||
Standard_EXPORT Graphic3d_TypeOfAnswer acceptDisplay (const Graphic3d_TypeOfStructure theStructType) const;
|
||||
|
||||
@ -390,12 +397,6 @@ public:
|
||||
//! Enables or disables frustum culling optimization.
|
||||
virtual void SetCullingEnabled (const Standard_Boolean theIsEnabled) = 0;
|
||||
|
||||
//! Returns shading model of the view.
|
||||
virtual Graphic3d_TypeOfShadingModel ShadingModel() const = 0;
|
||||
|
||||
//! Sets shading model of the view.
|
||||
virtual void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel) = 0;
|
||||
|
||||
//! Return backfacing model used for the view.
|
||||
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const = 0;
|
||||
|
||||
@ -465,11 +466,9 @@ protected:
|
||||
Standard_Boolean myIsInComputedMode;
|
||||
Standard_Boolean myIsActive;
|
||||
Standard_Boolean myIsRemoved;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
Graphic3d_TypeOfVisualization myVisualization;
|
||||
|
||||
private:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(Graphic3d_CView,Graphic3d_DataStructureManager)
|
||||
};
|
||||
|
||||
#endif // _Graphic3d_CView_HeaderFile
|
||||
|
@ -17,17 +17,41 @@
|
||||
#ifndef _Graphic3d_TypeOfShadingModel_HeaderFile
|
||||
#define _Graphic3d_TypeOfShadingModel_HeaderFile
|
||||
|
||||
//! Definition of the rendering (colour shading) model
|
||||
//! Graphic3d_TOSM_NONE No lighting, only white ambient light
|
||||
//! Graphic3d_TOSM_FACET No interpolation, constant shading (Flat Shading)
|
||||
//! Graphic3d_TOSM_VERTEX Interpolation of color based on normals (Gouraud Shading)
|
||||
//! Graphic3d_TOSM_FRAGMENT Interpolation of color based on normals (Phong Shading)
|
||||
//! Definition of the color shading model.
|
||||
enum Graphic3d_TypeOfShadingModel
|
||||
{
|
||||
Graphic3d_TOSM_NONE,
|
||||
//! Use Shading Model, specified as default for entire Viewer.
|
||||
Graphic3d_TOSM_DEFAULT = -1,
|
||||
|
||||
//! Unlit Shading (or shadeless), lighting is ignored and facet is fully filled by its material color.
|
||||
//! This model is useful for artificial/auxiliary objects, not intended to be lit,
|
||||
//! or for objects with pre-calculated lighting information (e.g. captured by camera).
|
||||
Graphic3d_TOSM_UNLIT = 0,
|
||||
|
||||
//! Flat Shading, calculated per-facet basing on facet normal.
|
||||
//! This model is useful for mesh element analysis.
|
||||
//! Note that unlike Graphic3d_TOSM_VERTEX/Graphic3d_TOSM_FRAGMENT,
|
||||
//! this shading model does NOT require normals to be defined within vertex attributes.
|
||||
Graphic3d_TOSM_FACET,
|
||||
|
||||
//! Gouraud Shading, calculated per-vertex basing on nodal normal, and then color is interpolated across fragments.
|
||||
//! This shading model was default within Fixed-Function Pipeline of old OpenGL (and Direct3d);
|
||||
//! still can be used as alternative to Graphic3d_TOSM_FRAGMENT for better performance on low-poly (and middle-poly) models
|
||||
//! (per-fragment shading is more optimal for considerably high-poly models, since expensive shading is not computed for discarded fragments).
|
||||
//! Shading model requires normals to be defined within vertex attributes.
|
||||
Graphic3d_TOSM_VERTEX,
|
||||
Graphic3d_TOSM_FRAGMENT
|
||||
|
||||
//! Phong Shading, calculated per-fragment basing on nodal normal, so that normal is interpolated across fragments.
|
||||
//! This is a main shading model nowadays, providing the best image quality.
|
||||
//! Shading model requires normals to be defined within vertex attributes.
|
||||
Graphic3d_TOSM_FRAGMENT,
|
||||
|
||||
// obsolete aliases
|
||||
Graphic3d_TOSM_NONE = Graphic3d_TOSM_UNLIT,
|
||||
V3d_COLOR = Graphic3d_TOSM_NONE,
|
||||
V3d_FLAT = Graphic3d_TOSM_FACET,
|
||||
V3d_GOURAUD = Graphic3d_TOSM_VERTEX,
|
||||
V3d_PHONG = Graphic3d_TOSM_FRAGMENT
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -64,8 +64,9 @@ OpenGl_AspectFace::OpenGl_AspectFace()
|
||||
: myAspect (new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_WHITE,
|
||||
Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0,
|
||||
THE_DEFAULT_MATERIAL, THE_DEFAULT_MATERIAL)),
|
||||
myIsNoLighting (false)
|
||||
myShadingModel (Graphic3d_TOSM_UNLIT)
|
||||
{
|
||||
myAspect->SetShadingModel (myShadingModel);
|
||||
myAspect->SetHatchStyle (Handle(Graphic3d_HatchStyle)());
|
||||
}
|
||||
|
||||
@ -74,7 +75,7 @@ OpenGl_AspectFace::OpenGl_AspectFace()
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
OpenGl_AspectFace::OpenGl_AspectFace (const Handle(Graphic3d_AspectFillArea3d)& theAspect)
|
||||
: myIsNoLighting (false)
|
||||
: myShadingModel (Graphic3d_TOSM_DEFAULT)
|
||||
{
|
||||
SetAspect (theAspect);
|
||||
}
|
||||
@ -88,10 +89,13 @@ void OpenGl_AspectFace::SetAspect (const Handle(Graphic3d_AspectFillArea3d)& the
|
||||
myAspect = theAspect;
|
||||
|
||||
const Graphic3d_MaterialAspect& aMat = theAspect->FrontMaterial();
|
||||
myIsNoLighting = !aMat.ReflectionMode (Graphic3d_TOR_AMBIENT)
|
||||
&& !aMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)
|
||||
&& !aMat.ReflectionMode (Graphic3d_TOR_SPECULAR)
|
||||
&& !aMat.ReflectionMode (Graphic3d_TOR_EMISSION);
|
||||
myShadingModel = theAspect->ShadingModel() != Graphic3d_TOSM_UNLIT
|
||||
&& (aMat.ReflectionMode (Graphic3d_TOR_AMBIENT)
|
||||
|| aMat.ReflectionMode (Graphic3d_TOR_DIFFUSE)
|
||||
|| aMat.ReflectionMode (Graphic3d_TOR_SPECULAR)
|
||||
|| aMat.ReflectionMode (Graphic3d_TOR_EMISSION))
|
||||
? theAspect->ShadingModel()
|
||||
: Graphic3d_TOSM_UNLIT;
|
||||
|
||||
myAspectEdge.Aspect()->SetColor (theAspect->EdgeColor());
|
||||
myAspectEdge.Aspect()->SetType (theAspect->EdgeLineType());
|
||||
|
@ -49,13 +49,13 @@ public:
|
||||
//! @return edge aspect.
|
||||
const OpenGl_AspectLine* AspectEdge() const { return &myAspectEdge; }
|
||||
|
||||
//! Returns true if lighting should be disabled.
|
||||
bool IsNoLighting() const { return myIsNoLighting; }
|
||||
//! Returns Shading Model.
|
||||
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
|
||||
|
||||
//! Set if lighting should be disabled or not.
|
||||
void SetNoLighting (bool theValue) { myIsNoLighting = theValue; }
|
||||
void SetNoLighting() { myShadingModel = Graphic3d_TOSM_UNLIT; }
|
||||
|
||||
//! Returne textures map.
|
||||
//! Returns textures map.
|
||||
const Handle(OpenGl_TextureSet)& TextureSet (const Handle(OpenGl_Context)& theCtx) const
|
||||
{
|
||||
if (!myResources.IsTextureReady())
|
||||
@ -138,7 +138,7 @@ protected:
|
||||
|
||||
Handle(Graphic3d_AspectFillArea3d) myAspect;
|
||||
OpenGl_AspectLine myAspectEdge;
|
||||
bool myIsNoLighting;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -3193,7 +3193,7 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
|
||||
|
||||
// do not update material properties in case of zero reflection mode,
|
||||
// because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() anyway.
|
||||
if (theAspect->IsNoLighting())
|
||||
if (theAspect->ShadingModel() == Graphic3d_TOSM_UNLIT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -459,8 +459,8 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4& theEdgeCo
|
||||
if (aGlContext->core20fwd != NULL)
|
||||
{
|
||||
aGlContext->ShaderManager()->BindLineProgram (NULL,
|
||||
anAspect->Aspect()->Type() != Aspect_TOL_SOLID,
|
||||
Standard_False,
|
||||
anAspect->Aspect()->Type(),
|
||||
Graphic3d_TOSM_UNLIT,
|
||||
Standard_False,
|
||||
anAspect->ShaderProgramRes (aGlContext));
|
||||
}
|
||||
@ -735,10 +735,8 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
|
||||
const Standard_Boolean hasColorAttrib = !myVboAttribs.IsNull()
|
||||
&& myVboAttribs->HasColorAttribute();
|
||||
const Standard_Boolean isLightOn = !anAspectFace->IsNoLighting()
|
||||
&& !myVboAttribs.IsNull()
|
||||
&& myVboAttribs->HasNormalAttribute()
|
||||
&& aCtx->ColorMask();
|
||||
const Graphic3d_TypeOfShadingModel aShadingModel = aCtx->ShaderManager()->ChooseShadingModel (anAspectFace->ShadingModel(),
|
||||
!myVboAttribs.IsNull() && myVboAttribs->HasNormalAttribute());
|
||||
|
||||
// Temporarily disable environment mapping
|
||||
Handle(OpenGl_TextureSet) aTextureBack;
|
||||
@ -777,11 +775,11 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
? anAspectMarker->SpriteHighlightRes (aCtx)
|
||||
: aSpriteNormRes;
|
||||
aCtx->BindTextures (aSprite);
|
||||
aCtx->ShaderManager()->BindMarkerProgram (aSprite, isLightOn, hasVertColor, anAspectMarker->ShaderProgramRes (aCtx));
|
||||
aCtx->ShaderManager()->BindMarkerProgram (aSprite, aShadingModel, hasVertColor, anAspectMarker->ShaderProgramRes (aCtx));
|
||||
}
|
||||
else
|
||||
{
|
||||
aCtx->ShaderManager()->BindMarkerProgram (Handle(OpenGl_TextureSet)(), isLightOn, hasVertColor, anAspectMarker->ShaderProgramRes (aCtx));
|
||||
aCtx->ShaderManager()->BindMarkerProgram (Handle(OpenGl_TextureSet)(), aShadingModel, hasVertColor, anAspectMarker->ShaderProgramRes (aCtx));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -789,8 +787,8 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
case GL_LINE_STRIP:
|
||||
{
|
||||
aCtx->ShaderManager()->BindLineProgram (NULL,
|
||||
anAspectLine->Aspect()->Type() != Aspect_TOL_SOLID,
|
||||
isLightOn,
|
||||
anAspectLine->Aspect()->Type(),
|
||||
aShadingModel,
|
||||
hasVertColor,
|
||||
anAspectLine->ShaderProgramRes (aCtx));
|
||||
break;
|
||||
@ -798,14 +796,9 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
default:
|
||||
{
|
||||
const Handle(OpenGl_TextureSet)& aTextures = aCtx->ActiveTextures();
|
||||
const Standard_Boolean isLightOnFace = isLightOn
|
||||
&& (aTextures.IsNull()
|
||||
|| aTextures->IsEmpty()
|
||||
|| aTextures->First().IsNull()
|
||||
|| aTextures->First()->Sampler()->Parameters()->IsModulate());
|
||||
const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
|
||||
aCtx->ShaderManager()->BindFaceProgram (aTextures,
|
||||
isLightOnFace,
|
||||
aShadingModel,
|
||||
hasVertColor,
|
||||
toEnableEnvMap,
|
||||
anAspectFace->ShaderProgramRes (aCtx));
|
||||
@ -818,7 +811,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
|
||||
if (aCtx->ActiveProgram().IsNull()
|
||||
&& aCtx->core11 != NULL)
|
||||
{
|
||||
if (!isLightOn)
|
||||
if (aShadingModel == Graphic3d_TOSM_UNLIT)
|
||||
{
|
||||
glDisable (GL_LIGHTING);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef _OpenGl_SetOfShaderPrograms_HeaderFile
|
||||
#define _OpenGl_SetOfShaderPrograms_HeaderFile
|
||||
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <OpenGl_ShaderProgram.hxx>
|
||||
|
||||
@ -38,23 +39,21 @@ enum OpenGl_ProgramOptions
|
||||
//! Alias to programs array of predefined length
|
||||
class OpenGl_SetOfShaderPrograms : public Standard_Transient
|
||||
{
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Empty constructor
|
||||
OpenGl_SetOfShaderPrograms() {}
|
||||
|
||||
//! Access program by index
|
||||
Handle(OpenGl_ShaderProgram)& ChangeValue (const Standard_Integer theIndex) { return myPrograms[theIndex]; }
|
||||
Handle(OpenGl_ShaderProgram)& ChangeValue (Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
Standard_Integer theProgramBits)
|
||||
{
|
||||
return myPrograms[theShadingModel][theProgramBits];
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Handle(OpenGl_ShaderProgram) myPrograms[OpenGl_PO_NB]; //!< programs array
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTI_INLINE(OpenGl_SetOfShaderPrograms,Standard_Transient)
|
||||
|
||||
Handle(OpenGl_ShaderProgram) myPrograms[Graphic3d_TypeOfShadingModel_NB][OpenGl_PO_NB]; //!< programs array
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(OpenGl_SetOfShaderPrograms, Standard_Transient)
|
||||
|
@ -32,15 +32,6 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_ShaderManager,Standard_Transient)
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Suffixes identifying shading model.
|
||||
static const char THE_SHADINGMODEL_KEY_LETTERS[Graphic3d_TypeOfShadingModel_NB] =
|
||||
{
|
||||
'c', // Graphic3d_TOSM_NONE
|
||||
'f', // Graphic3d_TOSM_FACET
|
||||
'g', // Graphic3d_TOSM_VERTEX
|
||||
'p' // Graphic3d_TOSM_FRAGMENT
|
||||
};
|
||||
|
||||
//! Number specifying maximum number of light sources to prepare a GLSL program with unrolled loop.
|
||||
const Standard_Integer THE_NB_UNROLLED_LIGHTS_MAX = 32;
|
||||
|
||||
@ -357,6 +348,7 @@ const char THE_FRAG_CLIP_PLANES_2[] =
|
||||
OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext)
|
||||
: myFfpProgram (new OpenGl_ShaderProgramFFP()),
|
||||
myShadingModel (Graphic3d_TOSM_VERTEX),
|
||||
myUnlitPrograms (new OpenGl_SetOfShaderPrograms()),
|
||||
myContext (theContext),
|
||||
myHasLocalOrigin (Standard_False),
|
||||
myLastView (NULL)
|
||||
@ -381,7 +373,7 @@ void OpenGl_ShaderManager::clear()
|
||||
{
|
||||
myProgramList.Clear();
|
||||
myLightPrograms.Nullify();
|
||||
myFlatPrograms = OpenGl_SetOfShaderPrograms();
|
||||
myUnlitPrograms = new OpenGl_SetOfShaderPrograms();
|
||||
myMapOfLightPrograms.Clear();
|
||||
myFontProgram.Nullify();
|
||||
myBlitProgram.Nullify();
|
||||
@ -491,26 +483,22 @@ Standard_Boolean OpenGl_ShaderManager::IsEmpty() const
|
||||
void OpenGl_ShaderManager::switchLightPrograms()
|
||||
{
|
||||
const Handle(Graphic3d_LightSet)& aLights = myLightSourceState.LightSources();
|
||||
TCollection_AsciiString aKey;
|
||||
if (!aLights.IsNull())
|
||||
if (aLights.IsNull())
|
||||
{
|
||||
aKey = THE_SHADINGMODEL_KEY_LETTERS[myShadingModel];
|
||||
aKey += "_";
|
||||
if (aLights->NbEnabled() <= THE_NB_UNROLLED_LIGHTS_MAX)
|
||||
{
|
||||
aKey += aLights->KeyEnabledLong();
|
||||
}
|
||||
else
|
||||
{
|
||||
const Standard_Integer aMaxLimit = roundUpMaxLightSources (aLights->NbEnabled());
|
||||
aKey += aLights->KeyEnabledShort();
|
||||
aKey += aMaxLimit;
|
||||
}
|
||||
myLightPrograms = myUnlitPrograms;
|
||||
return;
|
||||
}
|
||||
|
||||
TCollection_AsciiString aKey ("l_");
|
||||
if (aLights->NbEnabled() <= THE_NB_UNROLLED_LIGHTS_MAX)
|
||||
{
|
||||
aKey += aLights->KeyEnabledLong();
|
||||
}
|
||||
else
|
||||
{
|
||||
aKey = THE_SHADINGMODEL_KEY_LETTERS[Graphic3d_TOSM_NONE];
|
||||
aKey += "_";
|
||||
const Standard_Integer aMaxLimit = roundUpMaxLightSources (aLights->NbEnabled());
|
||||
aKey += aLights->KeyEnabledShort();
|
||||
aKey += aMaxLimit;
|
||||
}
|
||||
|
||||
if (!myMapOfLightPrograms.Find (aKey, myLightPrograms))
|
||||
@ -546,6 +534,11 @@ void OpenGl_ShaderManager::UpdateLightSourceState()
|
||||
// =======================================================================
|
||||
void OpenGl_ShaderManager::SetShadingModel (const Graphic3d_TypeOfShadingModel theModel)
|
||||
{
|
||||
if (theModel == Graphic3d_TOSM_DEFAULT)
|
||||
{
|
||||
throw Standard_ProgramError ("OpenGl_ShaderManager::SetShadingModel() - attempt to set invalid Shading Model!");
|
||||
}
|
||||
|
||||
myShadingModel = theModel;
|
||||
switchLightPrograms();
|
||||
}
|
||||
@ -1419,11 +1412,11 @@ namespace
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : prepareStdProgramFlat
|
||||
// function : prepareStdProgramUnlit
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFlat (Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
const Standard_Integer theBits)
|
||||
Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
const Standard_Integer theBits)
|
||||
{
|
||||
Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
|
||||
TCollection_AsciiString aSrcVert, aSrcVertExtraOut, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha;
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
#include <Graphic3d_StereoMode.hxx>
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <NCollection_Sequence.hxx>
|
||||
@ -84,7 +83,7 @@ public:
|
||||
|
||||
//! Bind program for filled primitives rendering
|
||||
Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
|
||||
const Standard_Boolean theToLightOn,
|
||||
const Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
const Standard_Boolean theHasVertColor,
|
||||
const Standard_Boolean theEnableEnvMap,
|
||||
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
|
||||
@ -95,15 +94,19 @@ public:
|
||||
return bindProgramWithState (theCustomProgram);
|
||||
}
|
||||
|
||||
const Graphic3d_TypeOfShadingModel aShadeModelOnFace = theShadingModel != Graphic3d_TOSM_UNLIT
|
||||
&& (theTextures.IsNull() || theTextures->IsModulate())
|
||||
? theShadingModel
|
||||
: Graphic3d_TOSM_UNLIT;
|
||||
const Standard_Integer aBits = getProgramBits (theTextures, theHasVertColor, theEnableEnvMap);
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theToLightOn, aBits);
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (aShadeModelOnFace, aBits);
|
||||
return bindProgramWithState (aProgram);
|
||||
}
|
||||
|
||||
//! Bind program for line rendering
|
||||
Standard_Boolean BindLineProgram (const Handle(OpenGl_TextureSet)& theTextures,
|
||||
const Standard_Boolean theStipple,
|
||||
const Standard_Boolean theToLightOn,
|
||||
const Aspect_TypeOfLine theLineType,
|
||||
const Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
const Standard_Boolean theHasVertColor,
|
||||
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
|
||||
{
|
||||
@ -114,18 +117,18 @@ public:
|
||||
}
|
||||
|
||||
Standard_Integer aBits = getProgramBits (theTextures, theHasVertColor);
|
||||
if (theStipple)
|
||||
if (theLineType != Aspect_TOL_SOLID)
|
||||
{
|
||||
aBits |= OpenGl_PO_StippleLine;
|
||||
}
|
||||
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theToLightOn, aBits);
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
|
||||
return bindProgramWithState (aProgram);
|
||||
}
|
||||
|
||||
//! Bind program for point rendering
|
||||
Standard_Boolean BindMarkerProgram (const Handle(OpenGl_TextureSet)& theTextures,
|
||||
const Standard_Boolean theToLightOn,
|
||||
const Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
const Standard_Boolean theHasVertColor,
|
||||
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
|
||||
{
|
||||
@ -136,7 +139,7 @@ public:
|
||||
}
|
||||
|
||||
const Standard_Integer aBits = getProgramBits (theTextures, theHasVertColor) | OpenGl_PO_Point;
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theToLightOn, aBits);
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
|
||||
return bindProgramWithState (aProgram);
|
||||
}
|
||||
|
||||
@ -313,6 +316,32 @@ public:
|
||||
return myContext == theCtx;
|
||||
}
|
||||
|
||||
//! Choose Shading Model.
|
||||
Graphic3d_TypeOfShadingModel ChooseShadingModel (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:
|
||||
break;
|
||||
case Graphic3d_TOSM_VERTEX:
|
||||
case Graphic3d_TOSM_FRAGMENT:
|
||||
aModel = theHasNodalNormals ? aModel : Graphic3d_TOSM_UNLIT;
|
||||
break;
|
||||
}
|
||||
return aModel;
|
||||
}
|
||||
|
||||
//! Returns default Shading Model.
|
||||
Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
|
||||
|
||||
//! Sets shading model.
|
||||
Standard_EXPORT void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel);
|
||||
|
||||
@ -377,25 +406,26 @@ protected:
|
||||
}
|
||||
|
||||
//! Prepare standard GLSL program.
|
||||
Handle(OpenGl_ShaderProgram)& getStdProgram (const Standard_Boolean theToLightOn,
|
||||
const Standard_Integer theBits)
|
||||
Handle(OpenGl_ShaderProgram)& getStdProgram (Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
Standard_Integer theBits)
|
||||
{
|
||||
// If environment map is enabled lighting calculations are
|
||||
// not needed (in accordance with default OCCT behaviour)
|
||||
if (theToLightOn && (theBits & OpenGl_PO_TextureEnv) == 0)
|
||||
if (theShadingModel == Graphic3d_TOSM_UNLIT
|
||||
|| (theBits & OpenGl_PO_TextureEnv) != 0)
|
||||
{
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = myLightPrograms->ChangeValue (theBits);
|
||||
// If environment map is enabled lighting calculations are
|
||||
// not needed (in accordance with default OCCT behavior)
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = myUnlitPrograms->ChangeValue (Graphic3d_TOSM_UNLIT, theBits);
|
||||
if (aProgram.IsNull())
|
||||
{
|
||||
prepareStdProgramLight (aProgram, theBits);
|
||||
prepareStdProgramUnlit (aProgram, theBits);
|
||||
}
|
||||
return aProgram;
|
||||
}
|
||||
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = myFlatPrograms.ChangeValue (theBits);
|
||||
Handle(OpenGl_ShaderProgram)& aProgram = myLightPrograms->ChangeValue (theShadingModel, theBits);
|
||||
if (aProgram.IsNull())
|
||||
{
|
||||
prepareStdProgramFlat (aProgram, theBits);
|
||||
prepareStdProgramLight (aProgram, theShadingModel, theBits);
|
||||
}
|
||||
return aProgram;
|
||||
}
|
||||
@ -416,18 +446,20 @@ protected:
|
||||
Standard_EXPORT Standard_Boolean prepareStdProgramOitCompositing (const Standard_Boolean theMsaa);
|
||||
|
||||
//! Prepare standard GLSL program without lighting.
|
||||
Standard_EXPORT Standard_Boolean prepareStdProgramFlat (Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
const Standard_Integer theBits);
|
||||
Standard_EXPORT Standard_Boolean prepareStdProgramUnlit (Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
const Standard_Integer theBits);
|
||||
|
||||
//! Prepare standard GLSL program with lighting.
|
||||
Standard_Boolean prepareStdProgramLight (Handle(OpenGl_ShaderProgram)& theProgram,
|
||||
const Standard_Integer theBits)
|
||||
Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
Standard_Integer theBits)
|
||||
{
|
||||
switch (myShadingModel)
|
||||
switch (theShadingModel)
|
||||
{
|
||||
case Graphic3d_TOSM_NONE: return prepareStdProgramFlat (theProgram, theBits);
|
||||
case Graphic3d_TOSM_UNLIT: return prepareStdProgramUnlit (theProgram, theBits);
|
||||
case Graphic3d_TOSM_FACET: return prepareStdProgramPhong (theProgram, theBits, true);
|
||||
case Graphic3d_TOSM_VERTEX: return prepareStdProgramGouraud(theProgram, theBits);
|
||||
case Graphic3d_TOSM_DEFAULT:
|
||||
case Graphic3d_TOSM_FRAGMENT: return prepareStdProgramPhong (theProgram, theBits, false);
|
||||
}
|
||||
return false;
|
||||
@ -501,11 +533,11 @@ protected:
|
||||
Graphic3d_TypeOfShadingModel myShadingModel; //!< lighting shading model
|
||||
OpenGl_ShaderProgramList myProgramList; //!< The list of shader programs
|
||||
Handle(OpenGl_SetOfShaderPrograms) myLightPrograms; //!< pointer to active lighting programs matrix
|
||||
OpenGl_SetOfShaderPrograms myFlatPrograms; //!< programs matrix without lighting
|
||||
Handle(OpenGl_SetOfShaderPrograms) myUnlitPrograms; //!< programs matrix without lighting
|
||||
Handle(OpenGl_ShaderProgram) myFontProgram; //!< standard program for textured text
|
||||
Handle(OpenGl_ShaderProgram) myBlitProgram; //!< standard program for FBO blit emulation
|
||||
Handle(OpenGl_ShaderProgram) myOitCompositingProgram[2]; //!< standard program for OIT compositing (default and MSAA).
|
||||
OpenGl_MapOfShaderPrograms myMapOfLightPrograms; //!< map of lighting programs depending on shading model and lights configuration
|
||||
OpenGl_MapOfShaderPrograms myMapOfLightPrograms; //!< map of lighting programs depending on lights configuration
|
||||
|
||||
Handle(OpenGl_ShaderProgram) myStereoPrograms[Graphic3d_StereoMode_NB]; //!< standard stereo programs
|
||||
|
||||
|
@ -758,7 +758,7 @@ void OpenGl_Text::drawRect (const Handle(OpenGl_Context)& theCtx,
|
||||
}
|
||||
|
||||
// bind flat program
|
||||
theCtx->ShaderManager()->BindFaceProgram (Handle(OpenGl_TextureSet)(), Standard_False, Standard_False, Standard_False, Handle(OpenGl_ShaderProgram)());
|
||||
theCtx->ShaderManager()->BindFaceProgram (Handle(OpenGl_TextureSet)(), Graphic3d_TOSM_UNLIT, Standard_False, Standard_False, Handle(OpenGl_ShaderProgram)());
|
||||
|
||||
#if !defined(GL_ES_VERSION_2_0)
|
||||
if (theCtx->core11 != NULL
|
||||
|
@ -14,4 +14,17 @@
|
||||
|
||||
#include <OpenGl_TextureSet.hxx>
|
||||
|
||||
#include <OpenGl_Texture.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_TextureSet, Standard_Transient)
|
||||
|
||||
// =======================================================================
|
||||
// function : IsModulate
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool OpenGl_TextureSet::IsModulate() const
|
||||
{
|
||||
return myTextures.IsEmpty()
|
||||
|| myTextures.First().IsNull()
|
||||
|| myTextures.First()->Sampler()->Parameters()->IsModulate();
|
||||
}
|
||||
|
@ -81,6 +81,10 @@ public:
|
||||
//! Return the texture at specified position within [0, Size()) range.
|
||||
Handle(OpenGl_Texture)& ChangeValue (Standard_Integer theIndex) { return myTextures.ChangeValue (theIndex); }
|
||||
|
||||
//! Return TRUE if texture color modulation has been enabled for the first texture
|
||||
//! or if texture is not set at all.
|
||||
Standard_EXPORT bool IsModulate() const;
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_Array1<Handle(OpenGl_Texture)> myTextures;
|
||||
|
@ -55,7 +55,6 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
|
||||
myCaps (theCaps),
|
||||
myWasRedrawnGL (Standard_False),
|
||||
myCulling (Standard_True),
|
||||
myShadingModel (Graphic3d_TOSM_FACET),
|
||||
myBackfacing (Graphic3d_TOBM_AUTOMATIC),
|
||||
myBgColor (Quantity_NOC_BLACK),
|
||||
myCamera (new Graphic3d_Camera()),
|
||||
|
@ -255,12 +255,6 @@ public:
|
||||
//! Enables or disables frustum culling optimization.
|
||||
virtual void SetCullingEnabled (const Standard_Boolean theIsEnabled) Standard_OVERRIDE { myCulling = theIsEnabled; }
|
||||
|
||||
//! Returns shading model of the view.
|
||||
virtual Graphic3d_TypeOfShadingModel ShadingModel() const Standard_OVERRIDE { return myShadingModel; }
|
||||
|
||||
//! Sets shading model of the view.
|
||||
virtual void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel) Standard_OVERRIDE { myShadingModel = theModel; }
|
||||
|
||||
//! Return backfacing model used for the view.
|
||||
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const Standard_OVERRIDE { return myBackfacing; }
|
||||
|
||||
@ -472,7 +466,6 @@ protected:
|
||||
Standard_Boolean myWasRedrawnGL;
|
||||
|
||||
Standard_Boolean myCulling;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
Graphic3d_TypeOfBackfacingModel myBackfacing;
|
||||
Quantity_ColorRGBA myBgColor;
|
||||
Handle(Graphic3d_SequenceOfHClipPlane) myClipPlanes;
|
||||
|
@ -2475,7 +2475,7 @@ Standard_Boolean OpenGl_View::updateRaytraceLightSources (const OpenGl_Mat4& the
|
||||
{
|
||||
std::vector<Handle(Graphic3d_CLight)> aLightSources;
|
||||
myRaytraceGeometry.Ambient = BVH_Vec4f (0.f, 0.f, 0.f, 0.f);
|
||||
if (myShadingModel != Graphic3d_TOSM_NONE
|
||||
if (myShadingModel != Graphic3d_TOSM_UNLIT
|
||||
&& !myLights.IsNull())
|
||||
{
|
||||
const Graphic3d_Vec4& anAmbient = myLights->AmbientColor();
|
||||
|
@ -889,7 +889,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
||||
myBVHSelector.CacheClipPtsProjections();
|
||||
|
||||
const Handle(OpenGl_ShaderManager)& aManager = aContext->ShaderManager();
|
||||
const Handle(Graphic3d_LightSet)& aLights = myShadingModel == Graphic3d_TOSM_NONE ? myNoShadingLight : myLights;
|
||||
const Handle(Graphic3d_LightSet)& aLights = myShadingModel == Graphic3d_TOSM_UNLIT ? myNoShadingLight : myLights;
|
||||
Standard_Size aLightsRevision = 0;
|
||||
if (!aLights.IsNull())
|
||||
{
|
||||
@ -977,7 +977,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
|
||||
if (aContext->core11 != NULL)
|
||||
{
|
||||
aContext->core11->glShadeModel (myShadingModel == Graphic3d_TOSM_FACET
|
||||
|| myShadingModel == Graphic3d_TOSM_NONE ? GL_FLAT : GL_SMOOTH);
|
||||
|| myShadingModel == Graphic3d_TOSM_UNLIT ? GL_FLAT : GL_SMOOTH);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -362,10 +362,11 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
|
||||
if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
|
||||
{
|
||||
// copy all values including line edge aspect
|
||||
*myAspectFaceHl.Aspect().operator->() = *myAspectFaceSet->Aspect();
|
||||
*myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
|
||||
myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
|
||||
myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
|
||||
myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
|
||||
myAspectFaceHl.SetNoLighting (true);
|
||||
myAspectFaceHl.SetNoLighting();
|
||||
myAspectFaceSet = &myAspectFaceHl;
|
||||
}
|
||||
else
|
||||
|
@ -1278,3 +1278,33 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetShadingModel
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool Prs3d_Drawer::SetShadingModel (Graphic3d_TypeOfShadingModel theModel,
|
||||
bool theToOverrideDefaults)
|
||||
{
|
||||
bool isUpdateNeeded = false;
|
||||
|
||||
if (theToOverrideDefaults
|
||||
&& !myHasOwnShadingAspect)
|
||||
{
|
||||
isUpdateNeeded = true;
|
||||
myShadingAspect = new Prs3d_ShadingAspect();
|
||||
myHasOwnShadingAspect = true;
|
||||
if (!myLink.IsNull())
|
||||
{
|
||||
*myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
|
||||
if (!myShadingAspect.IsNull()
|
||||
&& myHasOwnShadingAspect)
|
||||
{
|
||||
myShadingAspect->Aspect()->SetShadingModel (theModel);
|
||||
}
|
||||
|
||||
return isUpdateNeeded;
|
||||
}
|
||||
|
@ -847,6 +847,10 @@ public:
|
||||
const Graphic3d_GroupAspect theAspect,
|
||||
const bool theToOverrideDefaults = false);
|
||||
|
||||
//! Sets Shading Model type for the shading aspect.
|
||||
Standard_EXPORT bool SetShadingModel (Graphic3d_TypeOfShadingModel theModel,
|
||||
bool theToOverrideDefaults = false);
|
||||
|
||||
protected:
|
||||
|
||||
Handle(Prs3d_Drawer) myLink;
|
||||
|
@ -17,18 +17,8 @@
|
||||
#ifndef _V3d_TypeOfShadingModel_HeaderFile
|
||||
#define _V3d_TypeOfShadingModel_HeaderFile
|
||||
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
|
||||
//! Defines the type of shading for the graphic object:
|
||||
//! - V3d_COLOR: simple surface color (Graphic3d_TOM_NONE),
|
||||
//! - V3d_FLAT: flat shading (Graphic3d_TOM_FACET),
|
||||
//! - V3d_GOURAUD: Gouraud shading (Graphic3d_TOM_VERTEX),
|
||||
//! - V3d_PHONG: Phong shading (Graphic3d_TOM_FRAGMENT).
|
||||
enum V3d_TypeOfShadingModel
|
||||
{
|
||||
V3d_COLOR,
|
||||
V3d_FLAT,
|
||||
V3d_GOURAUD,
|
||||
V3d_PHONG
|
||||
};
|
||||
typedef Graphic3d_TypeOfShadingModel V3d_TypeOfShadingModel;
|
||||
|
||||
#endif // _V3d_TypeOfShadingModel_HeaderFile
|
||||
|
@ -525,9 +525,9 @@ void V3d_View::SetAxis (const Standard_Real theX, const Standard_Real theY, co
|
||||
//function : SetShadingModel
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void V3d_View::SetShadingModel (const V3d_TypeOfShadingModel theShadingModel)
|
||||
void V3d_View::SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel)
|
||||
{
|
||||
myView->SetShadingModel (static_cast<Graphic3d_TypeOfShadingModel> (theShadingModel));
|
||||
myView->SetShadingModel (theShadingModel);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -2218,9 +2218,9 @@ Standard_Real V3d_View::Twist() const
|
||||
//function : ShadingModel
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
V3d_TypeOfShadingModel V3d_View::ShadingModel() const
|
||||
Graphic3d_TypeOfShadingModel V3d_View::ShadingModel() const
|
||||
{
|
||||
return static_cast<V3d_TypeOfShadingModel> (myView->ShadingModel());
|
||||
return myView->ShadingModel();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <Graphic3d_GraduatedTrihedron.hxx>
|
||||
#include <Graphic3d_RenderingParams.hxx>
|
||||
#include <Graphic3d_SequenceOfHClipPlane.hxx>
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
|
||||
#include <Image_PixMap.hxx>
|
||||
@ -63,7 +64,6 @@
|
||||
|
||||
#include <V3d_TypeOfBackfacingModel.hxx>
|
||||
#include <V3d_TypeOfOrientation.hxx>
|
||||
#include <V3d_TypeOfShadingModel.hxx>
|
||||
#include <V3d_TypeOfView.hxx>
|
||||
#include <V3d_TypeOfVisualization.hxx>
|
||||
#include <V3d_Viewer.hxx>
|
||||
@ -230,7 +230,7 @@ public:
|
||||
const Standard_Real Vx, const Standard_Real Vy, const Standard_Real Vz);
|
||||
|
||||
//! Defines the shading model for the visualization. Various models are available.
|
||||
Standard_EXPORT void SetShadingModel (const V3d_TypeOfShadingModel theShadingModel);
|
||||
Standard_EXPORT void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel);
|
||||
|
||||
//! Sets the environment texture to use. No environment texture by default.
|
||||
Standard_EXPORT void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTexture);
|
||||
@ -673,7 +673,7 @@ public:
|
||||
Standard_EXPORT Standard_Real Twist() const;
|
||||
|
||||
//! Returns the current shading model.
|
||||
Standard_EXPORT V3d_TypeOfShadingModel ShadingModel() const;
|
||||
Standard_EXPORT Graphic3d_TypeOfShadingModel ShadingModel() const;
|
||||
|
||||
Standard_EXPORT Handle(Graphic3d_TextureEnv) TextureEnv() const;
|
||||
|
||||
|
@ -46,7 +46,7 @@ V3d_Viewer::V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver)
|
||||
myViewSize (1000.0),
|
||||
myViewProj (V3d_XposYnegZpos),
|
||||
myVisualization (V3d_ZBUFFER),
|
||||
myShadingModel (V3d_GOURAUD),
|
||||
myShadingModel (Graphic3d_TOSM_VERTEX),
|
||||
myDefaultTypeOfView (V3d_ORTHOGRAPHIC),
|
||||
myComputedMode (Standard_True),
|
||||
myDefaultComputedMode (Standard_False),
|
||||
@ -68,13 +68,13 @@ V3d_Viewer::V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver)
|
||||
V3d_Viewer::V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver,
|
||||
const Standard_ExtString ,
|
||||
const Standard_CString ,
|
||||
const Standard_Real theViewSize,
|
||||
const V3d_TypeOfOrientation theViewProj,
|
||||
const Quantity_Color& theViewBackground,
|
||||
const V3d_TypeOfVisualization theVisualization,
|
||||
const V3d_TypeOfShadingModel theShadingModel,
|
||||
const Standard_Boolean theComputedMode,
|
||||
const Standard_Boolean theDefaultComputedMode)
|
||||
const Standard_Real theViewSize,
|
||||
const V3d_TypeOfOrientation theViewProj,
|
||||
const Quantity_Color& theViewBackground,
|
||||
const V3d_TypeOfVisualization theVisualization,
|
||||
const Graphic3d_TypeOfShadingModel theShadingModel,
|
||||
const Standard_Boolean theComputedMode,
|
||||
const Standard_Boolean theDefaultComputedMode)
|
||||
: myDriver (theDriver),
|
||||
myStructureManager (new Graphic3d_StructureManager (theDriver)),
|
||||
myZLayerGenId (1, IntegerLast()),
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <Graphic3d_StructureManager.hxx>
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_ZLayerSettings.hxx>
|
||||
|
||||
@ -46,7 +47,6 @@
|
||||
#include <V3d_ListOfLight.hxx>
|
||||
#include <V3d_ListOfView.hxx>
|
||||
#include <V3d_TypeOfOrientation.hxx>
|
||||
#include <V3d_TypeOfShadingModel.hxx>
|
||||
#include <V3d_TypeOfView.hxx>
|
||||
#include <V3d_TypeOfVisualization.hxx>
|
||||
|
||||
@ -167,10 +167,10 @@ public:
|
||||
void SetDefaultVisualization (const V3d_TypeOfVisualization theType) { myVisualization = theType; }
|
||||
|
||||
//! Returns the default type of Shading
|
||||
V3d_TypeOfShadingModel DefaultShadingModel() const { return myShadingModel; }
|
||||
Graphic3d_TypeOfShadingModel DefaultShadingModel() const { return myShadingModel; }
|
||||
|
||||
//! Gives the default type of SHADING.
|
||||
void SetDefaultShadingModel (const V3d_TypeOfShadingModel theType) { myShadingModel = theType; }
|
||||
void SetDefaultShadingModel (const Graphic3d_TypeOfShadingModel theType) { myShadingModel = theType; }
|
||||
|
||||
void SetDefaultTypeOfView (const V3d_TypeOfView theType) { myDefaultTypeOfView = theType; }
|
||||
|
||||
@ -417,7 +417,7 @@ public: //! @name deprecated methods
|
||||
const V3d_TypeOfOrientation theViewProj = V3d_XposYnegZpos,
|
||||
const Quantity_Color& theViewBackground = Quantity_NOC_GRAY30,
|
||||
const V3d_TypeOfVisualization theVisualization = V3d_ZBUFFER,
|
||||
const V3d_TypeOfShadingModel theShadingModel = V3d_GOURAUD,
|
||||
const Graphic3d_TypeOfShadingModel theShadingModel = Graphic3d_TOSM_VERTEX,
|
||||
const Standard_Boolean theComputedMode = Standard_True,
|
||||
const Standard_Boolean theDefaultComputedMode = Standard_True);
|
||||
|
||||
@ -474,7 +474,7 @@ private:
|
||||
Standard_Real myViewSize;
|
||||
V3d_TypeOfOrientation myViewProj;
|
||||
V3d_TypeOfVisualization myVisualization;
|
||||
V3d_TypeOfShadingModel myShadingModel;
|
||||
Graphic3d_TypeOfShadingModel myShadingModel;
|
||||
V3d_TypeOfView myDefaultTypeOfView;
|
||||
Graphic3d_RenderingParams myDefaultRenderingParams;
|
||||
|
||||
|
@ -330,6 +330,60 @@ Standard_Boolean ViewerTest::ParseMarkerType (Standard_CString theArg,
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ParseShadingModel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean ViewerTest::ParseShadingModel (Standard_CString theArg,
|
||||
Graphic3d_TypeOfShadingModel& theModel)
|
||||
{
|
||||
TCollection_AsciiString aTypeStr (theArg);
|
||||
aTypeStr.LowerCase();
|
||||
if (aTypeStr == "unlit"
|
||||
|| aTypeStr == "color"
|
||||
|| aTypeStr == "none")
|
||||
{
|
||||
theModel = Graphic3d_TOSM_UNLIT;
|
||||
}
|
||||
else if (aTypeStr == "flat"
|
||||
|| aTypeStr == "facet")
|
||||
{
|
||||
theModel = Graphic3d_TOSM_FACET;
|
||||
}
|
||||
else if (aTypeStr == "gouraud"
|
||||
|| aTypeStr == "vertex"
|
||||
|| aTypeStr == "vert")
|
||||
{
|
||||
theModel = Graphic3d_TOSM_VERTEX;
|
||||
}
|
||||
else if (aTypeStr == "phong"
|
||||
|| aTypeStr == "fragment"
|
||||
|| aTypeStr == "frag"
|
||||
|| aTypeStr == "pixel")
|
||||
{
|
||||
theModel = Graphic3d_TOSM_FRAGMENT;
|
||||
}
|
||||
else if (aTypeStr == "default"
|
||||
|| aTypeStr == "def")
|
||||
{
|
||||
theModel = Graphic3d_TOSM_DEFAULT;
|
||||
}
|
||||
else if (aTypeStr.IsIntegerValue())
|
||||
{
|
||||
const int aTypeInt = aTypeStr.IntegerValue();
|
||||
if (aTypeInt <= Graphic3d_TOSM_DEFAULT || aTypeInt >= Graphic3d_TypeOfShadingModel_NB)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
theModel = (Graphic3d_TypeOfShadingModel)aTypeInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetTypeNames
|
||||
//purpose :
|
||||
@ -1618,52 +1672,56 @@ static int VSetInteriorStyle (Draw_Interpretor& theDI,
|
||||
//! Auxiliary structure for VAspects
|
||||
struct ViewerTest_AspectsChangeSet
|
||||
{
|
||||
Standard_Integer ToSetVisibility;
|
||||
Standard_Integer Visibility;
|
||||
Standard_Integer ToSetVisibility;
|
||||
Standard_Integer Visibility;
|
||||
|
||||
Standard_Integer ToSetColor;
|
||||
Quantity_Color Color;
|
||||
Standard_Integer ToSetColor;
|
||||
Quantity_Color Color;
|
||||
|
||||
Standard_Integer ToSetLineWidth;
|
||||
Standard_Real LineWidth;
|
||||
Standard_Integer ToSetLineWidth;
|
||||
Standard_Real LineWidth;
|
||||
|
||||
Standard_Integer ToSetTypeOfLine;
|
||||
Aspect_TypeOfLine TypeOfLine;
|
||||
Standard_Integer ToSetTypeOfLine;
|
||||
Aspect_TypeOfLine TypeOfLine;
|
||||
|
||||
Standard_Integer ToSetTypeOfMarker;
|
||||
Aspect_TypeOfMarker TypeOfMarker;
|
||||
Handle(Image_PixMap) MarkerImage;
|
||||
Standard_Integer ToSetTypeOfMarker;
|
||||
Aspect_TypeOfMarker TypeOfMarker;
|
||||
Handle(Image_PixMap) MarkerImage;
|
||||
|
||||
Standard_Integer ToSetMarkerSize;
|
||||
Standard_Real MarkerSize;
|
||||
Standard_Integer ToSetMarkerSize;
|
||||
Standard_Real MarkerSize;
|
||||
|
||||
Standard_Integer ToSetTransparency;
|
||||
Standard_Real Transparency;
|
||||
Standard_Integer ToSetTransparency;
|
||||
Standard_Real Transparency;
|
||||
|
||||
Standard_Integer ToSetMaterial;
|
||||
Graphic3d_NameOfMaterial Material;
|
||||
TCollection_AsciiString MatName;
|
||||
Standard_Integer ToSetMaterial;
|
||||
Graphic3d_NameOfMaterial Material;
|
||||
TCollection_AsciiString MatName;
|
||||
|
||||
NCollection_Sequence<TopoDS_Shape> SubShapes;
|
||||
|
||||
Standard_Integer ToSetShowFreeBoundary;
|
||||
Standard_Integer ToSetFreeBoundaryWidth;
|
||||
Standard_Real FreeBoundaryWidth;
|
||||
Standard_Integer ToSetFreeBoundaryColor;
|
||||
Quantity_Color FreeBoundaryColor;
|
||||
Standard_Integer ToSetShowFreeBoundary;
|
||||
Standard_Integer ToSetFreeBoundaryWidth;
|
||||
Standard_Real FreeBoundaryWidth;
|
||||
Standard_Integer ToSetFreeBoundaryColor;
|
||||
Quantity_Color FreeBoundaryColor;
|
||||
|
||||
Standard_Integer ToEnableIsoOnTriangulation;
|
||||
Standard_Integer ToEnableIsoOnTriangulation;
|
||||
|
||||
Standard_Integer ToSetMaxParamValue;
|
||||
Standard_Real MaxParamValue;
|
||||
Standard_Integer ToSetMaxParamValue;
|
||||
Standard_Real MaxParamValue;
|
||||
|
||||
Standard_Integer ToSetSensitivity;
|
||||
Standard_Integer SelectionMode;
|
||||
Standard_Integer Sensitivity;
|
||||
Standard_Integer ToSetSensitivity;
|
||||
Standard_Integer SelectionMode;
|
||||
Standard_Integer Sensitivity;
|
||||
|
||||
Standard_Integer ToSetHatch;
|
||||
Standard_Integer StdHatchStyle;
|
||||
TCollection_AsciiString PathToHatchPattern;
|
||||
Standard_Integer ToSetHatch;
|
||||
Standard_Integer StdHatchStyle;
|
||||
TCollection_AsciiString PathToHatchPattern;
|
||||
|
||||
Standard_Integer ToSetShadingModel;
|
||||
Graphic3d_TypeOfShadingModel ShadingModel;
|
||||
TCollection_AsciiString ShadingModelName;
|
||||
|
||||
//! Empty constructor
|
||||
ViewerTest_AspectsChangeSet()
|
||||
@ -1689,13 +1747,15 @@ struct ViewerTest_AspectsChangeSet
|
||||
ToSetFreeBoundaryColor (0),
|
||||
FreeBoundaryColor (DEFAULT_FREEBOUNDARY_COLOR),
|
||||
ToEnableIsoOnTriangulation (-1),
|
||||
ToSetMaxParamValue (0),
|
||||
MaxParamValue (500000),
|
||||
ToSetSensitivity (0),
|
||||
SelectionMode (-1),
|
||||
Sensitivity (-1),
|
||||
ToSetHatch (0),
|
||||
StdHatchStyle (-1)
|
||||
ToSetMaxParamValue (0),
|
||||
MaxParamValue (500000),
|
||||
ToSetSensitivity (0),
|
||||
SelectionMode (-1),
|
||||
Sensitivity (-1),
|
||||
ToSetHatch (0),
|
||||
StdHatchStyle (-1),
|
||||
ToSetShadingModel (0),
|
||||
ShadingModel (Graphic3d_TOSM_DEFAULT)
|
||||
{}
|
||||
|
||||
//! @return true if no changes have been requested
|
||||
@ -1711,7 +1771,8 @@ struct ViewerTest_AspectsChangeSet
|
||||
&& ToSetFreeBoundaryWidth == 0
|
||||
&& ToSetMaxParamValue == 0
|
||||
&& ToSetSensitivity == 0
|
||||
&& ToSetHatch == 0;
|
||||
&& ToSetHatch == 0
|
||||
&& ToSetShadingModel == 0;
|
||||
}
|
||||
|
||||
//! @return true if properties are valid
|
||||
@ -1768,6 +1829,12 @@ struct ViewerTest_AspectsChangeSet
|
||||
std::cout << "Error: hatch style must be specified\n";
|
||||
isOk = Standard_False;
|
||||
}
|
||||
if (ToSetShadingModel == 1
|
||||
&& (ShadingModel < Graphic3d_TOSM_DEFAULT || ShadingModel > Graphic3d_TOSM_FRAGMENT))
|
||||
{
|
||||
std::cout << "Error: unknown shading model " << ShadingModelName << ".\n";
|
||||
isOk = Standard_False;
|
||||
}
|
||||
return isOk;
|
||||
}
|
||||
|
||||
@ -2321,6 +2388,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
aChangeSet->ToSetHatch = -1;
|
||||
aChangeSet->StdHatchStyle = -1;
|
||||
aChangeSet->PathToHatchPattern.Clear();
|
||||
aChangeSet->ToSetShadingModel = -1;
|
||||
aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
|
||||
}
|
||||
else if (anArg == "-isoontriangulation"
|
||||
|| anArg == "-isoontriang")
|
||||
@ -2413,6 +2482,26 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
aChangeSet->PathToHatchPattern = anArgHatch;
|
||||
}
|
||||
}
|
||||
else if (anArg == "-setshadingmodel")
|
||||
{
|
||||
if (++anArgIter >= theArgNb)
|
||||
{
|
||||
std::cout << "Error: wrong syntax at " << anArg << "\n";
|
||||
return 1;
|
||||
}
|
||||
aChangeSet->ToSetShadingModel = 1;
|
||||
aChangeSet->ShadingModelName = theArgVec[anArgIter];
|
||||
if (!ViewerTest::ParseShadingModel (theArgVec[anArgIter], aChangeSet->ShadingModel))
|
||||
{
|
||||
std::cout << "Error: wrong syntax at " << anArg << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (anArg == "-unsetshadingmodel")
|
||||
{
|
||||
aChangeSet->ToSetShadingModel = -1;
|
||||
aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: wrong syntax at " << anArg << "\n";
|
||||
@ -2504,6 +2593,10 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
{
|
||||
aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
|
||||
}
|
||||
if (aChangeSet->ToSetShadingModel == 1)
|
||||
{
|
||||
aDrawer->ShadingAspect()->Aspect()->SetShadingModel (aChangeSet->ShadingModel);
|
||||
}
|
||||
|
||||
// redisplay all objects in context
|
||||
for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
|
||||
@ -2699,6 +2792,11 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
}
|
||||
toRedisplay = Standard_True;
|
||||
}
|
||||
if (aChangeSet->ToSetShadingModel != 0)
|
||||
{
|
||||
aDrawer->SetShadingModel ((aChangeSet->ToSetShadingModel == -1) ? Graphic3d_TOSM_DEFAULT : aChangeSet->ShadingModel, aChangeSet->ToSetShadingModel != -1);
|
||||
toRedisplay = Standard_True;
|
||||
}
|
||||
}
|
||||
|
||||
for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
|
||||
@ -2735,6 +2833,11 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
|
||||
{
|
||||
aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity);
|
||||
}
|
||||
if (aChangeSet->ToSetShadingModel != 0)
|
||||
{
|
||||
Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
|
||||
aCurColDrawer->SetShadingModel ((aChangeSet->ToSetShadingModel == -1) ? Graphic3d_TOSM_DEFAULT : aChangeSet->ShadingModel, aChangeSet->ToSetShadingModel != -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (toDisplay)
|
||||
@ -6235,6 +6338,8 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
|
||||
"\n\t\t: [-setMaxParamValue {value}]"
|
||||
"\n\t\t: [-setSensitivity {selection_mode} {value}]"
|
||||
"\n\t\t: [-setHatch HatchStyle]"
|
||||
"\n\t\t: [-setShadingModel {color|flat|gouraud|phong}]"
|
||||
"\n\t\t: [-unsetShadingModel]"
|
||||
"\n\t\t: Manage presentation properties of all, selected or named objects."
|
||||
"\n\t\t: When -subshapes is specified than following properties will be"
|
||||
"\n\t\t: assigned to specified sub-shapes."
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <Aspect_TypeOfLine.hxx>
|
||||
#include <Aspect_TypeOfMarker.hxx>
|
||||
#include <Draw_Interpretor.hxx>
|
||||
#include <Graphic3d_TypeOfShadingModel.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_CString.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
@ -200,6 +201,11 @@ public:
|
||||
Aspect_TypeOfMarker& theType,
|
||||
Handle(Image_PixMap)& theImage);
|
||||
|
||||
//! Parses shading model argument.
|
||||
//! Handles either enumeration (integer) value or string constant.
|
||||
Standard_EXPORT static Standard_Boolean ParseShadingModel (Standard_CString theArg,
|
||||
Graphic3d_TypeOfShadingModel& theModel);
|
||||
|
||||
private:
|
||||
|
||||
//! Returns a window class that implements standard behavior of
|
||||
|
@ -164,7 +164,7 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
|
||||
aTA->Aspect()->Font();
|
||||
OpenGl_Vec4 aColor = theWorkspace->LineColor();
|
||||
|
||||
aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), false, false, false, Handle(OpenGl_ShaderProgram)());
|
||||
aCtx->ShaderManager()->BindLineProgram (Handle(OpenGl_TextureSet)(), Aspect_TOL_SOLID, Graphic3d_TOSM_UNLIT, false, Handle(OpenGl_ShaderProgram)());
|
||||
aCtx->SetColor4fv (aColor);
|
||||
|
||||
const OpenGl_Vec3 aVertArray[4] =
|
||||
|
@ -10020,10 +10020,11 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
|
||||
theDI << "shadingModel: ";
|
||||
switch (aView->ShadingModel())
|
||||
{
|
||||
case V3d_COLOR: theDI << "color"; break;
|
||||
case V3d_FLAT: theDI << "flat"; break;
|
||||
case V3d_GOURAUD: theDI << "gouraud"; break;
|
||||
case V3d_PHONG: theDI << "phong"; break;
|
||||
case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
|
||||
case Graphic3d_TOSM_UNLIT: theDI << "unlit"; break;
|
||||
case Graphic3d_TOSM_FACET: theDI << "flat"; break;
|
||||
case Graphic3d_TOSM_VERTEX: theDI << "gouraud"; break;
|
||||
case Graphic3d_TOSM_FRAGMENT: theDI << "phong"; break;
|
||||
}
|
||||
{
|
||||
theDI << "perfCounters:";
|
||||
@ -10496,10 +10497,11 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
|
||||
{
|
||||
switch (aView->ShadingModel())
|
||||
{
|
||||
case V3d_COLOR: theDI << "color "; break;
|
||||
case V3d_FLAT: theDI << "flat "; break;
|
||||
case V3d_GOURAUD: theDI << "gouraud "; break;
|
||||
case V3d_PHONG: theDI << "phong "; break;
|
||||
case Graphic3d_TOSM_DEFAULT: theDI << "default"; break;
|
||||
case Graphic3d_TOSM_UNLIT: theDI << "unlit "; break;
|
||||
case Graphic3d_TOSM_FACET: theDI << "flat "; break;
|
||||
case Graphic3d_TOSM_VERTEX: theDI << "gouraud "; break;
|
||||
case Graphic3d_TOSM_FRAGMENT: theDI << "phong "; break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -10509,34 +10511,15 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
|
||||
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
|
||||
}
|
||||
|
||||
TCollection_AsciiString aMode (theArgVec[anArgIter]);
|
||||
aMode.LowerCase();
|
||||
if (aMode == "color"
|
||||
|| aMode == "none")
|
||||
Graphic3d_TypeOfShadingModel aModel = Graphic3d_TOSM_DEFAULT;
|
||||
if (ViewerTest::ParseShadingModel (theArgVec[anArgIter], aModel)
|
||||
&& aModel != Graphic3d_TOSM_DEFAULT)
|
||||
{
|
||||
aView->SetShadingModel (V3d_COLOR);
|
||||
}
|
||||
else if (aMode == "flat"
|
||||
|| aMode == "facet")
|
||||
{
|
||||
aView->SetShadingModel (V3d_FLAT);
|
||||
}
|
||||
else if (aMode == "gouraud"
|
||||
|| aMode == "vertex"
|
||||
|| aMode == "vert")
|
||||
{
|
||||
aView->SetShadingModel (V3d_GOURAUD);
|
||||
}
|
||||
else if (aMode == "phong"
|
||||
|| aMode == "fragment"
|
||||
|| aMode == "frag"
|
||||
|| aMode == "pixel")
|
||||
{
|
||||
aView->SetShadingModel (V3d_PHONG);
|
||||
aView->SetShadingModel (aModel);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Error: unknown shading model '" << aMode << "'\n";
|
||||
std::cout << "Error: unknown shading model '" << theArgVec[anArgIter] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
45
tests/v3d/glsl/shading_models
Normal file
45
tests/v3d/glsl/shading_models
Normal file
@ -0,0 +1,45 @@
|
||||
puts "========"
|
||||
puts "Test various Shading Models assigned per-object"
|
||||
puts "========"
|
||||
|
||||
# setup viewer
|
||||
vclear
|
||||
vclose ALL
|
||||
vinit View1 -width 912 -height 912
|
||||
|
||||
# define spheres with a rough triangulation to easily distinguish Shading Models
|
||||
psphere p1 10
|
||||
copytranslate p2 p1 40 0 0
|
||||
copytranslate p3 p1 20 20 0
|
||||
copytranslate p4 p1 0 40 0
|
||||
copytranslate p5 p1 40 40 0
|
||||
compound p1 p2 p3 p4 p5 ss
|
||||
incmesh ss 1
|
||||
vdefaults -autoTriang 0
|
||||
|
||||
# display objects
|
||||
vdisplay -dispMode 1 p1 p2 p3 p4 p5
|
||||
vdrawparray p6 triangles v 0 55 0 v 0 75 0 v 20 55 0 v 0 55 0 v 0 75 0 v 0 55 20 v 0 55 0 v 0 55 20 v 20 55 0 v 0 75 0 v 0 55 20 v 20 55 0
|
||||
vdrawparray p7 triangles v 40 55 0 v 40 75 0 v 60 55 0 v 40 55 0 v 40 75 0 v 40 55 20 v 40 55 0 v 40 55 20 v 60 55 0 v 40 75 0 v 40 55 20 v 60 55 0
|
||||
vtop
|
||||
vrotate -0.9 0.1 0
|
||||
vfit
|
||||
vdump $::imagedir/${::casename}_defaults.png
|
||||
|
||||
# customize shading models
|
||||
vaspects p1 -setShadingModel VERTEX
|
||||
vdrawtext t1 Graphic3d_TOSM_VERTEX -pos 10 5 10 -color RED -aspect BOLD
|
||||
vaspects p2 -setShadingModel FRAGMENT
|
||||
vdrawtext t2 Graphic3d_TOSM_FRAGMENT -pos 50 5 10 -color RED -aspect BOLD
|
||||
vaspects p3 -setShadingModel DEFAULT
|
||||
vdrawtext t3 Graphic3d_TOSM_DEFAULT -pos 30 25 10 -color RED -aspect BOLD
|
||||
vaspects p4 -setShadingModel UNLIT
|
||||
vdrawtext t4 Graphic3d_TOSM_UNLIT -pos 10 45 10 -color RED -aspect BOLD
|
||||
vaspects p5 -setShadingModel FACET
|
||||
vdrawtext t5 Graphic3d_TOSM_FACET -pos 50 45 10 -color RED -aspect BOLD
|
||||
vaspects p6 -setShadingModel DEFAULT
|
||||
vdrawtext t6 Graphic3d_TOSM_DEFAULT -pos 10 65 10 -color RED -aspect BOLD
|
||||
vaspects p7 -setShadingModel FACET
|
||||
vdrawtext t7 Graphic3d_TOSM_FACET -pos 50 65 10 -color RED -aspect BOLD
|
||||
vdisplay -topmost t1 t2 t3 t4 t5 t6 t7
|
||||
vdump $::imagedir/${::casename}.png
|
Loading…
x
Reference in New Issue
Block a user