1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-18 14:27:39 +03:00

Compare commits

...

21 Commits

Author SHA1 Message Date
vpa
9925e4cd12 0027612: Visualization, AIS_InteractiveContext - handle SelectMgr_EntityOwner::IsForcedHilight() flag in neutral point
- the check for IsForcedHilight was added to interactive context
2016-10-18 15:03:42 +03:00
vpa
a8d343c379 Provide an interface to retrieve selecting volume's planes from SelectBasics_SelectingVolumeManager 2016-10-17 18:22:44 +03:00
vpa
4e79be7a53 0027969: Visualization - add interfaces to access selecting volumes from SelectMgr_SelectingVolumeManager
- getter for selection frustum computed during last run of selection mechanism was added to SelectMgr_SelectingVolumeManager
2016-10-14 20:20:05 +03:00
isk
e5593d7d75 public fields of OpenGl_TextureBufferArb. 2016-08-31 12:20:36 +03:00
isk
ef92081286 Add a new OpenGl_BindlessTextureWrapper class. 2016-08-29 13:35:33 +03:00
isk
b7624e93b5 0025464: Visualization - provide package for Volume Rendering.
Add type definitions for BVH_Box.
Add a new method NCollection_Vec3::Convert.
Add define occTexture1D/3D in Declarations.glsl.
2016-08-29 13:35:04 +03:00
dbp
e367fede31 Update BVH to support extended metadata. 2016-04-22 14:26:21 +03:00
isk
9d43c8ef61 Release FBO resources in OpenGl_GrabDepthElement::Release(). 2016-03-25 12:44:57 +03:00
isk
4746883373 Fix MeshVS_TextPrsBuilder 2016-03-25 12:44:57 +03:00
isk
2b12eb862a Fix Path Tracing trouble. 2016-03-25 12:44:57 +03:00
isk
a33b35dd1f fix CR0002618: use Camera() instead of myCamera 2016-03-25 12:44:57 +03:00
isk
a7dabcc955 Fix errors. 2016-03-25 12:44:57 +03:00
omy
ef51767a6c Added getters for Graphic3d_Fresnel's data
(cherry picked from commit cccf89f361)
2016-03-25 12:44:57 +03:00
duv
dff5c981af filtering fix
(cherry picked from commit 45dd1259a3)
2016-03-25 12:44:57 +03:00
isk
a38e6170cc 0026434: Visualization - Textured objects should have priority over the environment mapping.
Add handle on environment texture in OpenGl_Workspace.
Add a new parameter UseEnvironmentTexture to the Graphic3d_ZLayerSettings.
OSD layers don't use environment texture by default.
zbuffertrihedron doesn't use environment texture.
vzlayer can enable/disable environment texture mappping.

Delete unnecessary files Graphic3d_TypeOfSurfaceDetail.hxx and V3d_TypeOfSurface.hxx.
Delete functions SurfaceDetailType and SetSurfaceDetailType functions from Graphic3d_CView.
Delete functions SurfaceDetailState and UpdateSurfaceDetailStateTo from OpenGl_ShaderManager.
Delete class OpenGl_SurfaceDetailState.
Delete functions SurfaceDetailType and SetSurfaceDetailType from OpenGl_View.
Delete functions SetSurfaceDetail and SurfaceDetail() from V3d_View.
Delete functions SetDefaultSurfaceDetail and DefaultSurfaceDetail from V3d_Viewer.
Delete draw command VSetTextureMode.
2016-03-25 12:44:57 +03:00
isk
33238608fb 0026432: Improving Path Tracing functionality
Samples per pixel parameter added. Simple filtering added. Lights fixed. Max radiance parameter.
2016-03-25 12:44:57 +03:00
dbp
6bb12a9bfa TKMeshVS fixes for AVD
(cherry picked from commit 80f5efa1d0)
2016-03-25 12:44:57 +03:00
duv
461fb9c4be 0002618: Visualization - choose better center of gravity for camera rotation operations
Gravity point set to camera center.
2016-03-25 12:44:57 +03:00
dbp
3323aa8e5c Add missing file. 2016-03-25 12:44:57 +03:00
isk
dc834db34c 0025464: Visualization - provide package for Volume Rendering.
Add two functions OSD_OpenStream for std::ifstream.
Add four functions SetUnfirom in the OpenGl_ShaderProgram for 64-bit unsigned integer variables.
Add OpenGl_Texture::Init3D.
Update Declarations.glsl.
2016-03-25 12:44:57 +03:00
duv
a4c29e8425 OpenGl_Texture API extended. 2016-03-25 12:41:49 +03:00
63 changed files with 1129 additions and 474 deletions

View File

@@ -971,3 +971,11 @@ Zoom persistent selection introduces a new structure *Graphic3d_TransformPers* f
* Transformation matrix utilities from *OpenGl_Utils* namespace have been moved to *Graphic3d_TransformUtils* and *Graphic3d_TransformUtils.hxx* header respectively.
* Matrix stack utilities from *OpenGl_Utils* namespace have been moved to *OpenGl_MatrixStack* class and *OpenGl_MatrixStack.hxx* header respectively.
* *OpenGl_View* methods *Begin/EndTransformPersistence* have been removed. Please, use *Graphic3d_TransformPers::Apply()* instead to apply persistence to perspective and world-view projection matrices.
Applications that use gp_Quaternion to convert Yaw-Pitch-Roll angles (or other intrinsic Tait-Bryan sequences) may need to be updated to take this change into account.
@subsection Correction of texture mapping of objects
Interaction of texture and environment texture is fixed. Textured objects have priority over the environment mapping.
Redundant enumerations V3d_TypeOfSurface and Graphic3d_TypeOfSurface, class OpenGl_SurfaceDetailState, corresponding methods from Graphic3d_CView, OpenGl_ShaderManager, OpenGl_View, V3d_View, V3d_Viewer are deleted.
Draw command VSetTextureMode is deleted.

View File

@@ -216,9 +216,14 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th
if (aNewDetected >= 1)
{
// does nothing if previously detected object is equal to the current one
// Does nothing if previously detected object is equal to the current one.
// However in advanced selection modes the owners comparison
// is not effective because in that case only one owner manage the
// selection in current selection mode. It is necessary to check the current detected
// entity and hilight it only if the detected entity is not the same as
// previous detected (IsForcedHilight call)
Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
if (aNewPickedOwner == myLastPicked)
if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
{
return myLastPicked->IsSelected()
? AIS_SOD_Selected

View File

@@ -281,4 +281,18 @@ namespace BVH
#include <BVH_Box.lxx>
//! 2D box of double precision reals.
typedef BVH_Box<Standard_Real, 2> BVH_Box2d;
//! 3D box of double precision reals.
typedef BVH_Box<Standard_Real, 3> BVH_Box3d;
//! 4D box of double precision reals.
typedef BVH_Box<Standard_Real, 4> BVH_Box4d;
//! 2D box of single precision reals.
typedef BVH_Box<Standard_ShortReal, 2> BVH_Box2f;
//! 3D box of single precision reals.
typedef BVH_Box<Standard_ShortReal, 3> BVH_Box3f;
//! 4D box of single precision reals.
typedef BVH_Box<Standard_ShortReal, 4> BVH_Box4f;
#endif // _BVH_Box_Header

View File

@@ -25,6 +25,14 @@ namespace BVH
const Standard_Real THE_NODE_MIN_SIZE = 1e-5;
}
//! Type of metadata written in W component of
//! BVH data vector corresponding to the node.
enum BVH_NodeMetadata
{
BVH_NODE_LEVEL = 0, //!< level (depth) of the node
BVH_NODE_PRIMS = 1 //!< number of node primitives
};
//! Performs construction of BVH tree using bounding
//! boxes (AABBs) of abstract objects.
//! \tparam T Numeric data type
@@ -46,6 +54,18 @@ public:
BVH_Tree<T, N>* theBVH,
const BVH_Box<T, N>& theBox) = 0;
//! Returns type of metadata written in BVH node.
BVH_NodeMetadata MetadataType() const
{
return myMetadataType;
}
//! Sets type of metadata written in BVH node.
void SetMetadataType (const BVH_NodeMetadata theMetadata)
{
myMetadataType = theMetadata;
}
protected:
//! Updates depth of constructed BVH tree.
@@ -62,6 +82,7 @@ protected:
Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
Standard_Integer myLeafNodeSize; //!< Maximum number of objects per leaf
BVH_NodeMetadata myMetadataType; //!< Type of metadata written in BVH node
};

View File

@@ -21,7 +21,8 @@ template<class T, int N>
BVH_Builder<T, N>::BVH_Builder (const Standard_Integer theLeafNodeSize,
const Standard_Integer theMaxTreeDepth)
: myMaxTreeDepth (theMaxTreeDepth),
myLeafNodeSize (theLeafNodeSize)
myLeafNodeSize (theLeafNodeSize),
myMetadataType (BVH_NODE_LEVEL)
{
//
}

View File

@@ -88,6 +88,13 @@ void BVH_QueueBuilder<T, N>::AddChildren (BVH_Tree<T, N>*
myBuildQueue.Enqueue (aChildIndex);
}
}
// Correct node's metadata if necessary
if (myMetadataType != BVH_NODE_LEVEL)
{
theBVH->NodeInfoBuffer()[theNode].w() =
theSubNodes.Ranges[1].Final - theSubNodes.Ranges[0].Start + 1;
}
}
// =======================================================================

View File

@@ -160,7 +160,6 @@ Graphic3d_TypeOfReflection.hxx
Graphic3d_TypeOfShaderObject.hxx
Graphic3d_TypeOfShadingModel.hxx
Graphic3d_TypeOfStructure.hxx
Graphic3d_TypeOfSurfaceDetail.hxx
Graphic3d_TypeOfTexture.hxx
Graphic3d_TypeOfTextureFilter.hxx
Graphic3d_TypeOfTextureMode.hxx

View File

@@ -82,6 +82,10 @@ public:
&& myFresnelData == theOther.myFresnelData;
}
Graphic3d_FresnelModel GetFresnelModel() const { return myFresnelType; }
Graphic3d_Vec3 GetFresnelData() const { return myFresnelData; }
protected:
//! Creates new Fresnel reflectance factor.

View File

@@ -1068,7 +1068,6 @@ void Graphic3d_CView::CopySettings (const Handle(Graphic3d_CView)& theOther)
SetTextureEnv (theOther->TextureEnv());
SetCullingEnabled (theOther->IsCullingEnabled());
SetShadingModel (theOther->ShadingModel());
SetSurfaceDetailType (theOther->SurfaceDetailType());
SetBackfacingModel (theOther->BackfacingModel());
SetCamera (new Graphic3d_Camera (theOther->Camera()));
SetBackZClippingOn (theOther->BackZClippingIsOn());

View File

@@ -40,7 +40,6 @@
#include <Graphic3d_TypeOfAnswer.hxx>
#include <Graphic3d_TypeOfBackfacingModel.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
#include <Graphic3d_TypeOfSurfaceDetail.hxx>
#include <Graphic3d_TypeOfVisualization.hxx>
#include <Graphic3d_Vec3.hxx>
#include <Graphic3d_ZLayerId.hxx>
@@ -434,12 +433,6 @@ public:
//! Sets shading model of the view.
virtual void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel) = 0;
//! Returns surface detail type of the view.
virtual Graphic3d_TypeOfSurfaceDetail SurfaceDetailType() const = 0;
//! Sets surface detail type of the view.
virtual void SetSurfaceDetailType (const Graphic3d_TypeOfSurfaceDetail theType) = 0;
//! Return backfacing model used for the view.
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const = 0;

View File

@@ -61,6 +61,9 @@ public:
IsTransparentShadowEnabled (Standard_False),
UseEnvironmentMapBackground (Standard_False),
CoherentPathTracingMode (Standard_False),
IsGIFilteringEnabled (Standard_False),
RadianceClampValue (10.0),
// stereoscopic parameters
StereoMode (Graphic3d_StereoMode_QuadBuffer),
AnaglyphFilter (Anaglyph_RedCyan_Optimized),
@@ -99,6 +102,8 @@ public:
Standard_Boolean IsTransparentShadowEnabled; //!< enables/disables light propagation through transparent media, False by default
Standard_Boolean UseEnvironmentMapBackground; //!< enables/disables environment map background
Standard_Boolean CoherentPathTracingMode; //!< enables/disables 'coherent' tracing mode (single RNG seed within 16x16 image blocks)
Standard_Boolean IsGIFilteringEnabled; //!< enables/disables post-processing of GI rendering results
Standard_Real RadianceClampValue; //!< maximum radiance value which will not be clamped.
Graphic3d_StereoMode StereoMode; //!< stereoscopic output mode, Graphic3d_StereoMode_QuadBuffer by default
Anaglyph AnaglyphFilter; //!< filter for anaglyph output, Anaglyph_RedCyan_Optimized by default

View File

@@ -1,32 +0,0 @@
// Created on: 1991-10-07
// Created by: NW,JPB,CAL
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Graphic3d_TypeOfSurfaceDetail_HeaderFile
#define _Graphic3d_TypeOfSurfaceDetail_HeaderFile
//! Modes of visualisation of objects in a view
//!
//! TOD_NONE no texture mapping
//! TOD_ENVIRONMENT only environnement mapping
//! TOD_ALL environnement + texture mapping
enum Graphic3d_TypeOfSurfaceDetail
{
Graphic3d_TOD_NONE,
Graphic3d_TOD_ENVIRONMENT,
Graphic3d_TOD_ALL
};
#endif // _Graphic3d_TypeOfSurfaceDetail_HeaderFile

View File

@@ -35,7 +35,8 @@ struct Graphic3d_ZLayerSettings
Flags (Graphic3d_ZLayerDepthTest
| Graphic3d_ZLayerDepthWrite
| Graphic3d_ZLayerDepthClear),
IsImmediate (false)
IsImmediate (false),
UseEnvironmentTexture (true)
{}
//! Returns true if theSetting is enabled.
@@ -76,10 +77,11 @@ struct Graphic3d_ZLayerSettings
public:
Standard_ShortReal DepthOffsetFactor; //!< factor argument value for OpenGl glPolygonOffset function
Standard_ShortReal DepthOffsetUnits; //!< units argument value for OpenGl glPolygonOffset function
Standard_Integer Flags; //!< storage field for settings
bool IsImmediate; //!< immediate layer will be drawn after all normal layers
Standard_ShortReal DepthOffsetFactor; //!< factor argument value for OpenGl glPolygonOffset function
Standard_ShortReal DepthOffsetUnits; //!< units argument value for OpenGl glPolygonOffset function
Standard_Integer Flags; //!< storage field for settings
bool IsImmediate; //!< immediate layer will be drawn after all normal layers
bool UseEnvironmentTexture; //!< flag to allow/prevent environment texture mapping usage for specific layer
};

View File

@@ -38,6 +38,9 @@
#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_Workspace.hxx>
IMPLEMENT_STANDARD_RTTIEXT(MeshVS_TextPrsBuilder,MeshVS_PrsBuilder)
//================================================================
@@ -136,6 +139,89 @@ void MeshVS_TextPrsBuilder::SetText ( const Standard_Boolean IsElement,
aMap->Bind ( ID, Text );
}
#include <OpenGl_Group.hxx>
#include <OpenGl_Element.hxx>
#include <OpenGl_Texture.hxx>
#include <OpenGl_ArbFBO.hxx>
namespace
{
//! Custom OpenGL element for fetching current depth buffer.
class OpenGl_GrabDepthElement : public OpenGl_Element
{
public:
Standard_EXPORT OpenGl_GrabDepthElement() : OpenGl_Element()
{
myFBO = new OpenGl_FrameBuffer;
}
Standard_EXPORT virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
glFinish(); // wait for rendering mesh
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
if (myFBO->GetVPSizeX() != theWorkspace->Width() || myFBO->GetVPSizeY() != theWorkspace->Height())
{
myFBO->Init (aContext, theWorkspace->Width(), theWorkspace->Height(), GL_RGBA8, GL_DEPTH24_STENCIL8);
}
GLint aDrawFboId = 0;
glGetIntegerv (GL_DRAW_FRAMEBUFFER_BINDING, &aDrawFboId);
if (aContext->arbFBOBlit != NULL)
{
aContext->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, 0);
aContext->arbFBO->glBindFramebuffer (GL_READ_FRAMEBUFFER, aDrawFboId);
myFBO->BindDrawBuffer (aContext);
aContext->arbFBOBlit->glBlitFramebuffer (0,
0,
myFBO->GetVPSizeX(),
myFBO->GetVPSizeY(),
0,
0,
myFBO->GetVPSizeX(),
myFBO->GetVPSizeY(),
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
GL_NEAREST);
if (glGetError() != GL_NO_ERROR)
return;
aContext->arbFBO->glBindFramebuffer (GL_FRAMEBUFFER, aDrawFboId);
}
myFBO->DepthStencilTexture()->Bind (aContext, GL_TEXTURE5);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
Standard_EXPORT virtual void Release (OpenGl_Context* theContext)
{
myFBO->Release (theContext);
}
protected:
Standard_EXPORT virtual ~OpenGl_GrabDepthElement()
{
Release (NULL);
}
protected:
mutable Handle(OpenGl_FrameBuffer) myFBO;
public:
DEFINE_STANDARD_ALLOC
};
}
//================================================================
// Function : Build
// Purpose :
@@ -159,6 +245,16 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
!aDrawer->GetDouble ( MeshVS_DA_TextHeight, aHeight ) )
return;
Prs3d_Root::NewGroup ( Prs );
Handle (Graphic3d_Group) aCustomGroup = Prs3d_Root::CurrentGroup ( Prs );
OpenGl_Group* aGroupGL = dynamic_cast<OpenGl_Group*> (aCustomGroup.operator->());
if (aGroupGL != NULL)
{
aGroupGL->AddElement (new OpenGl_GrabDepthElement);
}
///////////////////////////////////////////////////////////////////////
Prs3d_Root::NewGroup ( Prs );
Handle (Graphic3d_Group) aTextGroup = Prs3d_Root::CurrentGroup ( Prs );
@@ -198,6 +294,30 @@ void MeshVS_TextPrsBuilder::Build ( const Handle(Prs3d_Presentation)& Prs,
aTextAspect->SetTextFontAspect( AFontAspectType );
Handle (Graphic3d_AspectMarker3d) anAspectMarker3d =
new Graphic3d_AspectMarker3d( Aspect_TOM_POINT, Quantity_NOC_GRAY, 1. );
// Set custom shader program
{
Handle(Graphic3d_ShaderProgram) aShaderProgram = new Graphic3d_ShaderProgram();
const TCollection_AsciiString& aShaderFolder = Graphic3d_ShaderProgram::ShadersFolder();
if (!aShaderProgram->AttachShader (Graphic3d_ShaderObject::
CreateFromFile (Graphic3d_TOS_VERTEX, aShaderFolder + "/TextRender.vs")))
{
return;
}
if (!aShaderProgram->AttachShader (Graphic3d_ShaderObject::
CreateFromFile (Graphic3d_TOS_FRAGMENT, aShaderFolder + "/TextRender.fs")))
{
return;
}
aShaderProgram->PushVariable ("DepthTexture", 5);
aTextAspect->SetShaderProgram (aShaderProgram);
}
aTextGroup->SetPrimitivesAspect( aTextAspect );
aTextGroup->SetPrimitivesAspect( anAspectMarker3d );

View File

@@ -351,6 +351,15 @@ public:
return NCollection_Vec3 (Element_t(0), Element_t(0), Element_t(1));
}
//! Convert the vector.
template<class T>
NCollection_Vec3<T> Convert() const
{
return NCollection_Vec3<T> (static_cast<T> (v[0]),
static_cast<T> (v[1]),
static_cast<T> (v[2]));
}
private:
Element_t v[3]; //!< define the vector as array to avoid structure alignment issues

View File

@@ -65,6 +65,8 @@ OpenGl_Font.cxx
OpenGl_tgl_funcs.hxx
OpenGl_BackgroundArray.cxx
OpenGl_BackgroundArray.hxx
OpenGl_BindlessTextureWrapper.cxx
OpenGl_BindlessTextureWrapper.hxx
OpenGl_BVHClipPrimitiveSet.cxx
OpenGl_BVHClipPrimitiveSet.hxx
OpenGl_BVHClipPrimitiveTrsfPersSet.cxx

View File

@@ -0,0 +1,84 @@
// Created on: 2016-08-05
// Created by: Ilya SEVRIKOV
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_ArbTexBindless.hxx>
#include <OpenGl_BindlessTextureWrapper.hxx>
IMPLEMENT_STANDARD_RTTIEXT (OpenGl_BindlessTextureWrapper, Standard_Transient)
// =======================================================================
// function : GetTextureSamplerHandle
// purpose :
// =======================================================================
GLuint64 OpenGl_BindlessTextureWrapper::GetTextureSamplerHandle (const GLuint theTextureId, const GLuint theSamplerId)
{
GLuint64 aHandle = myContext->arbTexBindless->glGetTextureSamplerHandleARB (theTextureId, theSamplerId);
#ifdef OCCT_DEBUG
GLenum anError = glGetError();
if (anError != GL_NO_ERROR)
{
Message::DefaultMessenger()->Send ("Error: Can not get texture sampler handle.", Message_Fail);
}
#endif
return aHandle;
}
// =======================================================================
// function : MakeTextureHandleResident
// purpose :
// =======================================================================
GLvoid OpenGl_BindlessTextureWrapper::MakeTextureHandleResident (const GLuint64 theHandle)
{
myContext->arbTexBindless->glMakeTextureHandleResidentARB (theHandle);
#ifdef OCCT_DEBUG
GLenum anError = glGetError();
if (anError != GL_NO_ERROR)
{
Message::DefaultMessenger()->Send ("Error: Can not make texture handle as resident.", Message_Fail);
}
#endif
}
// =======================================================================
// function : MakeTextureHandleNonResident
// purpose :
// =======================================================================
GLvoid OpenGl_BindlessTextureWrapper::MakeTextureHandleNonResident (const GLuint64 theHandle)
{
myContext->arbTexBindless->glMakeTextureHandleNonResidentARB (theHandle);
#ifdef OCCT_DEBUG
GLenum anError = glGetError();
if (anError != GL_NO_ERROR)
{
Message::DefaultMessenger()->Send("Error: Can not make texture handle as non-resident.", Message_Fail);
}
#endif
}
// =======================================================================
// function : IsTextureHandleResident
// purpose :
// =======================================================================
GLboolean OpenGl_BindlessTextureWrapper::IsTextureHandleResident (const GLuint64 theHandle)
{
return myContext->arbTexBindless->glIsTextureHandleResidentARB (theHandle);
}

View File

@@ -0,0 +1,81 @@
// Created on: 2016-08-05
// Created by: Ilya SEVRIKOV
// Copyright (c) 2016 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _OpenGl_BindlessTextureWrapper_HeaderFile
#define _OpenGl_BindlessTextureWrapper_HeaderFile
#include <OpenGl_Context.hxx>
//! ARB texture bindless wrapper.
//!
//! To access texture or image resources using handles, the handles must first be made resident.
//! Accessing a texture or image by handle without first making it resident can result in undefined results,
//! including program termination.
class OpenGl_BindlessTextureWrapper : public Standard_Transient
{
public:
OpenGl_BindlessTextureWrapper (const Handle(OpenGl_Context)& theContext)
: myContext (theContext)
{
//
}
//! Create a texture handle using the current non-sampler state from the texture named <texture>
//! and the sampler state from the sampler object <sampler>.
//! Returns a 64-bit unsigned integer handle.
//! The error INVALID_VALUE is generated if <texture> is zero or is not the name of an existing texture object
//! or if <sampler> is zero or is not the name of an existing sampler object.
//! The error INVALID_OPERATION is generated if the texture object <texture> is not complete (section 3.9.14).
//! If an error occurs, a handle of zero is returned.
//!
//! The error INVALID_OPERATION is generated if the border color (taken from the <sampler>)
//! is not one of the following allowed values. If the texture's base internal format is signed
//! or unsigned integer, allowed values are (0,0,0,0), (0,0,0,1), (1,1,1,0), and (1,1,1,1).
//! If the base internal format is not integer, allowed values are (0.0, 0.0, 0.0, 0.0),
//! (0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 0.0), and (1.0, 1.0, 1.0, 1.0).
//!
//! The handle for each texture or texture/sampler pair is unique;
//! the same handle will if GetTextureSamplerHandleARB is called multiple times for the same texture/sampler pair.
Standard_EXPORT GLuint64 GetTextureSamplerHandle (const GLuint theTextureId, const GLuint theSamplerId);
//! Makes a texture handle accessible to shaders for texture mapping operations.
//!
//! While the texture handle is resident, it may be used in texture mapping operations.
//! If a shader attempts to perform a texture mapping operation using a handle that is not resident,
//! the results of that operation are undefined and may lead to application termination.
//! When a texture handle is resident, the texture it references is also considered resident for the
//! purposes of the AreTexturesResident command. The error INVALID_OPERATION is generated
//! if <handle> is not a valid texture handle, or if <handle> is already resident in the current GL context.
Standard_EXPORT GLvoid MakeTextureHandleResident (const GLuint64 theHandle);
//! Makes a texture handle inaccessible to shaders for texture mapping operations.
//!
//! The error INVALID_OPERATION is generated if <handle> is not a valid
//! texture handle, or if <handle> is not resident in the current GL context.
Standard_EXPORT GLvoid MakeTextureHandleNonResident (const GLuint64 theHandle);
//!
Standard_EXPORT GLboolean IsTextureHandleResident (const GLuint64 theHandle);
protected:
Handle(OpenGl_Context) myContext;
public:
DEFINE_STANDARD_RTTIEXT (OpenGl_BindlessTextureWrapper, Standard_Transient)
};
DEFINE_STANDARD_HANDLE (OpenGl_BindlessTextureWrapper, Standard_Transient)
#endif //_OpenGl_BindlessTextureWrapper_HeaderFile

View File

@@ -284,6 +284,12 @@ public:
Standard_EXPORT static Standard_Boolean CheckExtension (const char* theExtString,
const char* theExtName);
//! Returns true if hardware supports floating-point texture.
bool HasFloatingPointTexture()
{
return (IsGlGreaterEqual (3, 0) || CheckExtension ("GL_ARB_texture_float"));
}
//! Auxiliary template to retrieve GL function pointer.
//! Pointer to function retrieved from library is statically casted
//! to requested type - there no way to check real signature of exported function.

View File

@@ -101,6 +101,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio
Graphic3d_ZLayerSettings anUnderlaySettings;
anUnderlaySettings.Flags = 0;
anUnderlaySettings.IsImmediate = false;
anUnderlaySettings.UseEnvironmentTexture = false;
myLayerIds.Add (Graphic3d_ZLayerId_BotOSD);
myLayerSeq.Append (Graphic3d_ZLayerId_BotOSD);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_BotOSD, anUnderlaySettings);
@@ -133,6 +134,7 @@ OpenGl_GraphicDriver::OpenGl_GraphicDriver (const Handle(Aspect_DisplayConnectio
Graphic3d_ZLayerSettings anOsdSettings;
anOsdSettings.Flags = 0;
anOsdSettings.IsImmediate = true;
anOsdSettings.UseEnvironmentTexture = false;
myLayerIds.Add (Graphic3d_ZLayerId_TopOSD);
myLayerSeq.Append (Graphic3d_ZLayerId_TopOSD);
myMapOfZLayerSettings.Bind (Graphic3d_ZLayerId_TopOSD, anOsdSettings);

View File

@@ -365,6 +365,14 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace,
glDepthFunc (GL_ALWAYS);
}
// save environment texture
Handle(OpenGl_Texture) anEnvironmentTexture = theWorkspace->EnvironmentTexture();
if (!myLayerSettings.UseEnvironmentTexture)
{
Handle(OpenGl_Texture) anEmptyTexture;
theWorkspace->SetEnvironmentTexture (anEmptyTexture);
}
// handle depth offset
if (IsSettingEnabled (Graphic3d_ZLayerDepthOffset))
{
@@ -390,4 +398,10 @@ void OpenGl_Layer::Render (const Handle(OpenGl_Workspace)& theWorkspace,
theWorkspace->SetPolygonOffset (anAppliedOffsetParams.mode,
anAppliedOffsetParams.factor,
anAppliedOffsetParams.units);
// restore environment texture
if (!myLayerSettings.UseEnvironmentTexture)
{
theWorkspace->SetEnvironmentTexture (anEnvironmentTexture);
}
}

View File

@@ -23,7 +23,6 @@
#define OPENGL_NS_ANTIALIASING (1<<5)
#define OPENGL_NS_2NDPASSNEED (1<<6)
#define OPENGL_NS_2NDPASSDO (1<<7)
#define OPENGL_NS_FORBIDSETTEX (1<<8)
#define OPENGL_NS_WHITEBACK (1<<9)
#define OPENGL_NS_WHITEBACK (1<<8)
#endif //_OpenGl_NamedStatus_Header

View File

@@ -824,25 +824,6 @@ const OpenGl_MaterialState* OpenGl_ShaderManager::MaterialState (const Handle(Op
return &myMaterialStates.Find (theProgram);
}
// =======================================================================
// function : SurfaceDetailState
// purpose : Returns current state of OCCT surface detail
// =======================================================================
const OpenGl_SurfaceDetailState& OpenGl_ShaderManager::SurfaceDetailState() const
{
return mySurfaceDetailState;
}
// =======================================================================
// function : UpdateSurfaceDetailStateTo
// purpose : Updates state of OCCT surface detail
// =======================================================================
void OpenGl_ShaderManager::UpdateSurfaceDetailStateTo (const Graphic3d_TypeOfSurfaceDetail theDetail)
{
mySurfaceDetailState.Set (theDetail);
mySurfaceDetailState.Update();
}
namespace
{

View File

@@ -19,7 +19,6 @@
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_StereoMode.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
#include <Graphic3d_TypeOfSurfaceDetail.hxx>
#include <NCollection_DataMap.hxx>
#include <NCollection_Sequence.hxx>
@@ -253,14 +252,6 @@ public:
//! Returns current state of OCCT material for specified program.
Standard_EXPORT const OpenGl_MaterialState* MaterialState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
public:
//! Returns current state of OCCT surface detail.
Standard_EXPORT const OpenGl_SurfaceDetailState& SurfaceDetailState() const;
//! Updates state of OCCT surface detail.
Standard_EXPORT void UpdateSurfaceDetailStateTo (const Graphic3d_TypeOfSurfaceDetail theDetail);
public:
//! Pushes current state of OCCT graphics parameters to specified program.
@@ -309,7 +300,7 @@ protected:
{
aBits |= OpenGl_PO_ClipPlanes;
}
if (theEnableEnvMap && mySurfaceDetailState.Detail() == Graphic3d_TOD_ENVIRONMENT)
if (theEnableEnvMap)
{
// Environment map overwrites material texture
aBits |= OpenGl_PO_TextureEnv;
@@ -413,7 +404,6 @@ protected:
OpenGl_WorldViewState myWorldViewState; //!< State of OCCT world-view transformation
OpenGl_ClippingState myClippingState; //!< State of OCCT clipping planes
OpenGl_LightSourceState myLightSourceState; //!< State of OCCT light sources
OpenGl_SurfaceDetailState mySurfaceDetailState; //!< State of OCCT surface detail
private:

View File

@@ -16,7 +16,6 @@
#ifndef _OpenGl_State_HeaderFile
#define _OpenGl_State_HeaderFile
#include <Graphic3d_TypeOfSurfaceDetail.hxx>
#include <InterfaceGraphic_tgl_all.hxx>
#include <NCollection_List.hxx>
#include <OpenGl_Element.hxx>
@@ -183,28 +182,4 @@ protected:
};
//! Defines generic state of OCCT surface detail.
class OpenGl_SurfaceDetailState : public OpenGl_StateInterface
{
public:
//! Creates new surface detail state.
OpenGl_SurfaceDetailState (const Graphic3d_TypeOfSurfaceDetail theDetail = Graphic3d_TOD_NONE)
: myDetail (theDetail)
{
//
}
//! Sets new surface detail.
void Set (const Graphic3d_TypeOfSurfaceDetail theDetail) { myDetail = theDetail; }
//! Returns surface detail.
Graphic3d_TypeOfSurfaceDetail Detail() const { return myDetail; }
private:
Graphic3d_TypeOfSurfaceDetail myDetail; //!< OCCT surface detail
};
#endif // _OpenGl_State_HeaderFile

View File

@@ -808,6 +808,15 @@ void OpenGl_Text::render (const Handle(OpenGl_PrinterContext)& thePrintCtx,
}
myExportHeight = (float )myFont->FTFont()->PointSize() / myExportHeight;
{
const Handle(OpenGl_ShaderProgram)& aProgram = theTextAspect.ShaderProgramRes (theCtx);
if (!aProgram.IsNull())
{
aProgram->SetUniform (theCtx, "Pixel", OpenGl_Vec3 (myWinX, myWinY, myWinZ));
}
}
#if !defined(GL_ES_VERSION_2_0)
if (theCtx->core11 != NULL)
{

View File

@@ -186,7 +186,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
{
if (theCtx->core11 == NULL)
{
theTextFormat = GL_R8; // GL_R32F
theTextFormat = GL_R32F;
thePixelFormat = GL_RED;
}
else
@@ -201,7 +201,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
{
if (theCtx->core11 == NULL)
{
theTextFormat = GL_R8; // GL_R32F
theTextFormat = GL_R32F;
thePixelFormat = GL_RED;
}
else
@@ -214,7 +214,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
}
case Image_PixMap::ImgRGBAF:
{
theTextFormat = GL_RGBA8; // GL_RGBA32F
theTextFormat = GL_RGBA32F;
thePixelFormat = GL_RGBA;
theDataType = GL_FLOAT;
return true;
@@ -225,14 +225,14 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
{
return false;
}
theTextFormat = GL_RGBA8; // GL_RGBA32F
theTextFormat = GL_RGBA32F;
thePixelFormat = GL_BGRA_EXT; // equals to GL_BGRA
theDataType = GL_FLOAT;
return true;
}
case Image_PixMap::ImgRGBF:
{
theTextFormat = GL_RGB8; // GL_RGB32F
theTextFormat = GL_RGB32F;
thePixelFormat = GL_RGB;
theDataType = GL_FLOAT;
return true;
@@ -240,7 +240,7 @@ bool OpenGl_Texture::GetDataFormat (const Handle(OpenGl_Context)& theCtx,
case Image_PixMap::ImgBGRF:
{
#if !defined(GL_ES_VERSION_2_0)
theTextFormat = GL_RGB8; // GL_RGB32F
theTextFormat = GL_RGB32F;
thePixelFormat = GL_BGR; // equals to GL_BGR_EXT
theDataType = GL_FLOAT;
return true;
@@ -376,6 +376,18 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
myHasMipmaps = Standard_False;
myTextFormat = thePixelFormat;
#if !defined(GL_ES_VERSION_2_0)
if (theTextFormat >= Image_PixMap::ImgGrayF && !theCtx->arbTexFloat)
{
TCollection_ExtendedString aMsg ("Error: floating-point textures are not supported by hardware.");
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_ERROR,
0,
GL_DEBUG_SEVERITY_HIGH,
aMsg);
Release (theCtx.operator->());
return false;
}
const GLint anIntFormat = theTextFormat;
#else
// ES does not support sized formats and format conversions - them detected from data type
@@ -477,7 +489,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
glTexImage1D (GL_PROXY_TEXTURE_1D, 0, anIntFormat,
aWidth, 0,
thePixelFormat, theDataType, NULL);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_1D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
if (aTestWidth == 0)
{
// no memory or broken input parameters
@@ -747,6 +759,22 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
const GLint anIntFormat = theFormat.Internal();
myTextFormat = theFormat.Format();
if (anIntFormat == GL_FLOAT
|| !theCtx->HasFloatingPointTexture())
{
TCollection_ExtendedString aMsg ("Error: floating-point textures are not supproted by hardware.");
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB,
GL_DEBUG_TYPE_ERROR_ARB,
0,
GL_DEBUG_SEVERITY_HIGH_ARB,
aMsg);
Release (theCtx.operator->());
Unbind (theCtx);
return false;
}
glTexImage2D (GL_PROXY_TEXTURE_RECTANGLE,
0,
anIntFormat,
@@ -919,3 +947,102 @@ bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
Unbind (theCtx);
return true;
}
// =======================================================================
// function : Init2D
// purpose :
// =======================================================================
bool OpenGl_Texture::Init2D (const Handle(OpenGl_Context)& theCtx,
const GLint theTextFormat,
const GLenum thePixelFormat,
const GLenum theDataType,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
const void* thePixels)
{
if (!Create(theCtx))
{
return false;
}
myTarget = GL_TEXTURE_2D;
const GLsizei aSizeX = Min (theCtx->MaxTextureSize(), theSizeX);
const GLsizei aSizeY = Min (theCtx->MaxTextureSize(), theSizeY);
Bind (theCtx);
if (theDataType == GL_FLOAT && !theCtx->arbTexFloat)
{
TCollection_ExtendedString aMsg ("Error: floating-point textures are not supported by hardware.");
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_ERROR,
0,
GL_DEBUG_SEVERITY_HIGH,
aMsg);
Release (theCtx.operator->());
Unbind (theCtx);
return false;
}
const GLint anIntFormat = theTextFormat;
#if !defined (GL_ES_VERSION_2_0)
theCtx->core15fwd->glTexImage2D (GL_PROXY_TEXTURE_2D,
0,
anIntFormat,
aSizeX,
aSizeY,
0,
thePixelFormat,
theDataType,
NULL);
GLint aTestSizeX = 0;
GLint aTestSizeY = 0;
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestSizeX);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestSizeY);
if (aTestSizeX == 0 || aTestSizeY == 0)
{
Unbind (theCtx);
Release (theCtx.operator->());
return false;
}
#endif
const GLenum aWrapMode = myParams->IsRepeat() ? GL_REPEAT : theCtx->TextureWrapClamp();
const GLenum aFilter = (myParams->Filter() == Graphic3d_TOTF_NEAREST) ? GL_NEAREST : GL_LINEAR;
glTexParameteri (myTarget, GL_TEXTURE_WRAP_S, aWrapMode);
glTexParameteri (myTarget, GL_TEXTURE_WRAP_T, aWrapMode);
glTexParameteri (myTarget, GL_TEXTURE_MIN_FILTER, aFilter);
glTexParameteri (myTarget, GL_TEXTURE_MAG_FILTER, aFilter);
theCtx->core15fwd->glTexImage2D (myTarget,
0,
anIntFormat,
aSizeX,
aSizeY,
0,
thePixelFormat,
theDataType,
thePixels);
if (glGetError() != GL_NO_ERROR)
{
Unbind (theCtx);
Release (theCtx.operator->());
return false;
}
mySizeX = aSizeX;
mySizeY = aSizeY;
Unbind (theCtx);
return true;
}

View File

@@ -404,6 +404,15 @@ public:
const Standard_Integer theSizeZ,
const void* thePixels);
//! Initializes 2D texture with specified format and size.
Standard_EXPORT bool Init2D (const Handle(OpenGl_Context)& theCtx,
const GLint theTextFormat,
const GLenum thePixelFormat,
const GLenum theDataType,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
const void* thePixels);
//! @return true if texture was generated within mipmaps
Standard_EXPORT Standard_Boolean HasMipmaps() const;

View File

@@ -181,6 +181,98 @@ bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
return true;
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theComponentsNb,
const GLsizei theElemsNb,
const GLushort* theData)
{
if (theGlCtx->arbTBO == NULL)
{
return false;
}
else if (theComponentsNb < 1
|| theComponentsNb > 4)
{
// unsupported format
return false;
}
else if (theComponentsNb == 3
&& !theGlCtx->arbTboRGB32)
{
return false;
}
else if (!Create (theGlCtx)
|| !OpenGl_VertexBuffer::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
{
return false;
}
switch (theComponentsNb)
{
case 1: myTexFormat = GL_R16I; break;
case 2: myTexFormat = GL_RG16I; break;
case 3: myTexFormat = GL_RGB16I; break;
case 4: myTexFormat = GL_RGBA16I; break;
}
Bind (theGlCtx);
BindTexture (theGlCtx);
theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
UnbindTexture (theGlCtx);
Unbind (theGlCtx);
return true;
}
// =======================================================================
// function : Init
// purpose :
// =======================================================================
bool OpenGl_TextureBufferArb::Init (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theComponentsNb,
const GLsizei theElemsNb,
const GLubyte* theData)
{
if (theGlCtx->arbTBO == NULL)
{
return false;
}
else if (theComponentsNb < 1
|| theComponentsNb > 4)
{
// unsupported format
return false;
}
else if (theComponentsNb == 3
&& !theGlCtx->arbTboRGB32)
{
return false;
}
else if (!Create (theGlCtx)
|| !OpenGl_VertexBuffer::Init (theGlCtx, theComponentsNb, theElemsNb, theData))
{
return false;
}
switch (theComponentsNb)
{
case 1: myTexFormat = GL_R8; break;
case 2: myTexFormat = GL_RG8; break;
case 3: myTexFormat = GL_RGB8; break;
case 4: myTexFormat = GL_RGBA8; break;
}
Bind (theGlCtx);
BindTexture (theGlCtx);
theGlCtx->arbTBO->glTexBuffer (GetTarget(), myTexFormat, myBufferId);
UnbindTexture (theGlCtx);
Unbind (theGlCtx);
return true;
}
// =======================================================================
// function : BindTexture
// purpose :

View File

@@ -76,6 +76,20 @@ public:
const GLsizei theElemsNb,
const GLuint* theData);
//! Perform TBO initialization with specified data.
//! Existing data will be deleted.
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theComponentsNb,
const GLsizei theElemsNb,
const GLushort* theData);
//! Perform TBO initialization with specified data.
//! Existing data will be deleted.
Standard_EXPORT bool Init (const Handle(OpenGl_Context)& theGlCtx,
const GLuint theComponentsNb,
const GLsizei theElemsNb,
const GLubyte* theData);
//! Bind TBO to specified Texture Unit.
Standard_EXPORT void BindTexture (const Handle(OpenGl_Context)& theGlCtx,
const GLenum theTextureUnit = GL_TEXTURE0) const;
@@ -84,7 +98,7 @@ public:
Standard_EXPORT void UnbindTexture (const Handle(OpenGl_Context)& theGlCtx,
const GLenum theTextureUnit = GL_TEXTURE0) const;
protected:
public:
GLuint myTextureId; //!< texture id
GLenum myTexFormat; //!< internal texture format

View File

@@ -66,7 +66,6 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
myAntiAliasing (Standard_False),
myCulling (Standard_True),
myShadingModel (Graphic3d_TOSM_FACET),
mySurfaceDetail (Graphic3d_TOD_ALL),
myBackfacing (Graphic3d_TOBM_AUTOMATIC),
myBgColor (myDefaultBg),
myFog (myDefaultFog),

View File

@@ -34,7 +34,6 @@
#include <Graphic3d_GraduatedTrihedron.hxx>
#include <Graphic3d_SequenceOfHClipPlane.hxx>
#include <Graphic3d_TypeOfShadingModel.hxx>
#include <Graphic3d_TypeOfSurfaceDetail.hxx>
#include <Graphic3d_WorldViewProjState.hxx>
#include <Graphic3d_ZLayerSettings.hxx>
@@ -308,16 +307,6 @@ public:
//! Sets shading model of the view.
virtual void SetShadingModel (const Graphic3d_TypeOfShadingModel theModel) Standard_OVERRIDE { myShadingModel = theModel; }
//! Returns surface detail type of the view.
virtual Graphic3d_TypeOfSurfaceDetail SurfaceDetailType() const Standard_OVERRIDE { return mySurfaceDetail; }
//! Sets surface detail type of the view.
virtual void SetSurfaceDetailType (const Graphic3d_TypeOfSurfaceDetail theType) Standard_OVERRIDE
{
mySurfaceDetail = theType;
myToUpdateEnvironmentMap = Standard_True;
}
//! Return backfacing model used for the view.
virtual Graphic3d_TypeOfBackfacingModel BackfacingModel() const Standard_OVERRIDE { return myBackfacing; }
@@ -562,7 +551,6 @@ protected:
Standard_Boolean myAntiAliasing;
Standard_Boolean myCulling;
Graphic3d_TypeOfShadingModel myShadingModel;
Graphic3d_TypeOfSurfaceDetail mySurfaceDetail;
Graphic3d_TypeOfBackfacingModel myBackfacing;
TEL_COLOUR myBgColor;
OPENGL_FOG myFog;
@@ -673,10 +661,12 @@ protected: //! @name data types related to ray-tracing
OpenGl_RT_uSphereMapForBack,
OpenGl_RT_uTexSamplersArray,
OpenGl_RT_uBlockedRngEnabled,
OpenGl_RT_uMaxRadiance,
// sampled frame params
OpenGl_RT_uSampleWeight,
OpenGl_RT_uFrameRndSeed,
OpenGl_RT_uBilateralEnabled,
// adaptive FSAA params
OpenGl_RT_uOffsetX,
@@ -789,7 +779,7 @@ protected: //! @name data types related to ray-tracing
: StackSize (THE_DEFAULT_STACK_SIZE),
NbBounces (THE_DEFAULT_NB_BOUNCES),
TransparentShadows (Standard_False),
GlobalIllumination (Standard_False),
GlobalIllumination (Standard_True),
UseBindlessTextures (Standard_False)
{
//

View File

@@ -1553,6 +1553,8 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
aShaderProgram->GetUniformLocation (theGlContext, "uSampleWeight");
myUniformLocations[anIndex][OpenGl_RT_uFrameRndSeed] =
aShaderProgram->GetUniformLocation (theGlContext, "uFrameRndSeed");
myUniformLocations[anIndex][OpenGl_RT_uMaxRadiance] =
aShaderProgram->GetUniformLocation (theGlContext, "uMaxRadiance");
myUniformLocations[anIndex][OpenGl_RT_uBackColorTop] =
aShaderProgram->GetUniformLocation (theGlContext, "uBackColorTop");
@@ -1562,6 +1564,9 @@ Standard_Boolean OpenGl_View::initRaytraceResources (const Handle(OpenGl_Context
theGlContext->BindProgram (myOutImageProgram);
myUniformLocations[0][OpenGl_RT_uBilateralEnabled] =
myOutImageProgram->GetUniformLocation (theGlContext, "uBilateralEnabled");
myOutImageProgram->SetSampler (theGlContext,
"uInputTexture", OpenGl_RT_PrevAccumTexture);
@@ -2166,7 +2171,7 @@ Standard_Boolean OpenGl_View::updateRaytraceEnvironmentMap (const Handle(OpenGl_
{
aResult &= theGlContext->BindProgram (aProgram);
if (!myTextureEnv.IsNull() && mySurfaceDetail != Graphic3d_TOD_NONE)
if (!myTextureEnv.IsNull())
{
myTextureEnv->Bind (theGlContext,
GL_TEXTURE0 + OpenGl_RT_EnvironmentMapTexture);
@@ -2398,14 +2403,49 @@ Standard_Boolean OpenGl_View::runRaytraceShaders (const Standard_Integer
// Set frame accumulation weight
myRaytraceProgram->SetUniform (theGlContext,
myUniformLocations[0][OpenGl_RT_uSampleWeight], 1.f / (myAccumFrames + 1));
myUniformLocations[0][OpenGl_RT_uMaxRadiance], static_cast<Standard_ShortReal> (myRenderParams.RadianceClampValue));
// Set random number generator seed
myRaytraceProgram->SetUniform (theGlContext,
myUniformLocations[0][OpenGl_RT_uFrameRndSeed], static_cast<Standard_Integer> (myRNG.NextInt() >> 2));
Standard_Integer aSamplesPerPixel =myRenderParams.SamplesPerPixel;
if (aSamplesPerPixel == 0)
{
// Set frame accumulation weight
myRaytraceProgram->SetUniform (theGlContext,
myUniformLocations[0][OpenGl_RT_uSampleWeight], 1.f / (myAccumFrames + 1));
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
}
else
{
for (int aPassIndex = 0; aPassIndex < aSamplesPerPixel; ++aPassIndex)
{
aRenderFramebuffer = (myAccumFrames + aPassIndex) % 2 ? myRaytraceFBO1[aFBOIdx] : myRaytraceFBO2[aFBOIdx];
anAccumFramebuffer = (myAccumFrames + aPassIndex) % 2 ? myRaytraceFBO2[aFBOIdx] : myRaytraceFBO1[aFBOIdx];
aRenderFramebuffer->BindBuffer (theGlContext);
anAccumFramebuffer->ColorTexture()->Bind (
theGlContext, GL_TEXTURE0 + OpenGl_RT_PrevAccumTexture);
// Set frame accumulation weight
myRaytraceProgram->SetUniform (theGlContext,
myUniformLocations[0][OpenGl_RT_uSampleWeight], 1.f / (myAccumFrames + aPassIndex + 1));
// Set random number generator seed
myRaytraceProgram->SetUniform (theGlContext,
myUniformLocations[0][OpenGl_RT_uFrameRndSeed], static_cast<Standard_Integer> (myRNG.NextInt() >> 2));
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
//++myAccumFrames;
glFinish();
}
}
}
else
{
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
++myAccumFrames;
}
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
if (myRaytraceParameters.GlobalIllumination)
{
@@ -2427,6 +2467,9 @@ Standard_Boolean OpenGl_View::runRaytraceShaders (const Standard_Integer
aRenderFramebuffer->DepthStencilTexture()->Bind (
theGlContext, GL_TEXTURE0 + OpenGl_RT_DepthTexture);
myOutImageProgram->SetUniform (theGlContext,
myUniformLocations[0][OpenGl_RT_uBilateralEnabled], myRenderParams.IsGIFilteringEnabled ? 1 : 0);
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
aRenderFramebuffer->DepthStencilTexture()->Unbind (

View File

@@ -475,7 +475,8 @@ void OpenGl_View::Redraw()
if (myRenderParams.Method == Graphic3d_RM_RAYTRACING
&& myRenderParams.IsGlobalIlluminationEnabled)
{
myAccumFrames++;
//myAccumFrames++;
myAccumFrames += myRenderParams.SamplesPerPixel ? myRenderParams.SamplesPerPixel : 1;
}
// bind default FBO
@@ -1137,7 +1138,15 @@ void OpenGl_View::renderTrihedron (const Handle(OpenGl_Workspace) &theWorkspace)
// display global trihedron
if (myToShowTrihedron)
{
// disable environment texture
Handle(OpenGl_Texture) anEnvironmentTexture = theWorkspace->EnvironmentTexture();
Handle(OpenGl_Texture) anEmptyTexture;
theWorkspace->SetEnvironmentTexture (anEmptyTexture);
myTrihedron.Render (theWorkspace);
// restore environment texture
theWorkspace->SetEnvironmentTexture (anEnvironmentTexture);
}
if (myToShowGradTrihedron)
{
@@ -1284,84 +1293,50 @@ void OpenGl_View::renderScene (Graphic3d_Camera::Projection theProjection,
// Clear status bitfields
myWorkspace->NamedStatus &= ~(OPENGL_NS_2NDPASSNEED | OPENGL_NS_2NDPASSDO);
// Update state of surface detail level
myWorkspace->GetGlContext()->ShaderManager()->UpdateSurfaceDetailStateTo (mySurfaceDetail);
// First pass
myWorkspace->SetEnvironmentTexture (myTextureEnv);
renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate);
myWorkspace->DisableTexture();
// Added PCT for handling of textures
switch (mySurfaceDetail)
// Second pass
if (myWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED)
{
case Graphic3d_TOD_NONE:
myWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
myWorkspace->DisableTexture();
// Render the view
renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate);
break;
myWorkspace->NamedStatus |= OPENGL_NS_2NDPASSDO;
case Graphic3d_TOD_ENVIRONMENT:
myWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
if (myRenderParams.Method != Graphic3d_RM_RAYTRACING)
{
myWorkspace->EnableTexture (myTextureEnv);
}
// Render the view
renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate);
myWorkspace->DisableTexture();
break;
// Remember OpenGl properties
GLint aSaveBlendDst = GL_ONE_MINUS_SRC_ALPHA, aSaveBlendSrc = GL_SRC_ALPHA;
GLint aSaveZbuffFunc;
GLboolean aSaveZbuffWrite;
glGetBooleanv (GL_DEPTH_WRITEMASK, &aSaveZbuffWrite);
glGetIntegerv (GL_DEPTH_FUNC, &aSaveZbuffFunc);
#if !defined(GL_ES_VERSION_2_0)
glGetIntegerv (GL_BLEND_DST, &aSaveBlendDst);
glGetIntegerv (GL_BLEND_SRC, &aSaveBlendSrc);
#endif
GLboolean wasZbuffEnabled = glIsEnabled (GL_DEPTH_TEST);
GLboolean wasBlendEnabled = glIsEnabled (GL_BLEND);
case Graphic3d_TOD_ALL:
// First pass
myWorkspace->NamedStatus &= ~OPENGL_NS_FORBIDSETTEX;
// Render the view
renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate);
myWorkspace->DisableTexture();
// Change the properties for second rendering pass
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable (GL_BLEND);
// Second pass
if (myWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED)
{
myWorkspace->NamedStatus |= OPENGL_NS_2NDPASSDO;
if (myRenderParams.Method != Graphic3d_RM_RAYTRACING)
{
myWorkspace->EnableTexture (myTextureEnv);
}
glDepthFunc (GL_EQUAL);
glDepthMask (GL_FALSE);
glEnable (GL_DEPTH_TEST);
// Remember OpenGl properties
GLint aSaveBlendDst = GL_ONE_MINUS_SRC_ALPHA, aSaveBlendSrc = GL_SRC_ALPHA;
GLint aSaveZbuffFunc;
GLboolean aSaveZbuffWrite;
glGetBooleanv (GL_DEPTH_WRITEMASK, &aSaveZbuffWrite);
glGetIntegerv (GL_DEPTH_FUNC, &aSaveZbuffFunc);
#if !defined(GL_ES_VERSION_2_0)
glGetIntegerv (GL_BLEND_DST, &aSaveBlendDst);
glGetIntegerv (GL_BLEND_SRC, &aSaveBlendSrc);
#endif
GLboolean wasZbuffEnabled = glIsEnabled (GL_DEPTH_TEST);
GLboolean wasBlendEnabled = glIsEnabled (GL_BLEND);
// Render the view
renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate);
myWorkspace->DisableTexture();
// Change the properties for second rendering pass
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable (GL_BLEND);
// Restore properties back
glBlendFunc (aSaveBlendSrc, aSaveBlendDst);
if (!wasBlendEnabled)
glDisable (GL_BLEND);
glDepthFunc (GL_EQUAL);
glDepthMask (GL_FALSE);
glEnable (GL_DEPTH_TEST);
myWorkspace->NamedStatus |= OPENGL_NS_FORBIDSETTEX;
// Render the view
renderStructs (theProjection, theReadDrawFbo, theToDrawImmediate);
myWorkspace->DisableTexture();
// Restore properties back
glBlendFunc (aSaveBlendSrc, aSaveBlendDst);
if (!wasBlendEnabled)
glDisable (GL_BLEND);
glDepthFunc (aSaveZbuffFunc);
glDepthMask (aSaveZbuffWrite);
if (!wasZbuffEnabled)
glDisable (GL_DEPTH_FUNC);
}
break;
glDepthFunc (aSaveZbuffFunc);
glDepthMask (aSaveZbuffWrite);
if (!wasZbuffEnabled)
glDisable (GL_DEPTH_FUNC);
}
// Apply restored view matrix.

View File

@@ -970,12 +970,17 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th
updateMaterial (TEL_BACK_MATERIAL);
}
if ((NamedStatus & OPENGL_NS_FORBIDSETTEX) == 0)
if (AspectFace_set->DoTextureMap())
{
if (AspectFace_set->DoTextureMap())
EnableTexture (AspectFace_set->TextureRes (myGlContext),
AspectFace_set->TextureParams());
}
else
{
if (!myEnvironmentTexture.IsNull())
{
EnableTexture (AspectFace_set->TextureRes (myGlContext),
AspectFace_set->TextureParams());
EnableTexture (myEnvironmentTexture,
myEnvironmentTexture->GetParams());
}
else
{

View File

@@ -236,6 +236,18 @@ public:
return myFrontCulling;
}
//! Sets a new environment texture.
void SetEnvironmentTexture (const Handle(OpenGl_Texture)& theTexture)
{
myEnvironmentTexture = theTexture;
}
//! Returns environment texture.
const Handle(OpenGl_Texture)& EnvironmentTexture() const
{
return myEnvironmentTexture;
}
protected:
void updateMaterial (const int theFlag);
@@ -281,6 +293,8 @@ protected: //! @name fields related to status
OpenGl_AspectFace myAspectFaceHl; //!< Hiddenline aspect
Handle(OpenGl_Texture) myEnvironmentTexture;
public: //! @name type definition
DEFINE_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)

View File

@@ -546,10 +546,6 @@ static Standard_Integer OCC280 (Draw_Interpretor& di, Standard_Integer argc, con
TCollection_AsciiString anOldName = ViewerTest::GetCurrentViewName();
Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
if (Draw::Atoi (argv[2]))
{
aViewer->SetDefaultSurfaceDetail (V3d_TEX_ALL);
}
aViewer->SetDefaultTypeOfView (V3d_PERSPECTIVE);
Handle(Aspect_Window) asp = ViewerTest::CurrentView()->Window();
Handle(V3d_View) aNewView = aViewer->CreateView();

View File

@@ -96,6 +96,9 @@ public:
virtual Standard_Boolean IsOverlapAllowed() const = 0;
//! Stores plane equations to the given vector
virtual void GetPlanes (NCollection_Vector<NCollection_Vec4<Standard_Real> >& thePlaneEquations) const = 0;
protected:
SelectionType myActiveSelectionType; //!< Active selection type: point, box or polyline
};

View File

@@ -162,6 +162,9 @@ public:
//! Computes depth range for global (defined for the whole view) clipping planes.
Standard_EXPORT virtual void SetViewClipping (const Graphic3d_SequenceOfHClipPlane& /*thePlanes*/) {};
//! Stores plane equations to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const = 0;
DEFINE_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
protected:

View File

@@ -741,3 +741,24 @@ Standard_Boolean SelectMgr_RectangularFrustum::isViewClippingOk (const Standard_
return myViewClipRange.MaxDepth() > theDepth
&& myViewClipRange.MinDepth() < theDepth;
}
// =======================================================================
// function : GetPlanes
// purpose :
// =======================================================================
void SelectMgr_RectangularFrustum::GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
{
thePlaneEquations.Clear();
SelectMgr_Vec4 anEquation;
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < 6; ++aPlaneIdx)
{
const gp_Vec& aPlaneNorm = myIsOrthographic && aPlaneIdx % 2 == 1 ?
myPlanes[aPlaneIdx - 1].Reversed() : myPlanes[aPlaneIdx];
anEquation.x() = aPlaneNorm.X();
anEquation.y() = aPlaneNorm.Y();
anEquation.z() = aPlaneNorm.Z();
anEquation.w() = - (aPlaneNorm.XYZ().Dot (myVertices[aPlaneIdx % 2 == 0 ? aPlaneIdx : aPlaneIdx + 2].XYZ()));
thePlaneEquations.Append (anEquation);
}
}

View File

@@ -117,6 +117,10 @@ public:
inline gp_Pnt GetNearPnt() const { return myNearPickedPnt; }
inline gp_Pnt GetFarPnt() const { return myFarPickedPnt; }
//! Stores plane equations to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
protected:
Standard_EXPORT void segmentSegmentDistance (const gp_Pnt& theSegPnt1,

View File

@@ -173,6 +173,28 @@ public:
Standard_EXPORT gp_Pnt GetFarPnt() const;
//! Returns active selecting volume that was built during last
//! run of OCCT selection mechanism
NCollection_Handle<SelectMgr_BaseFrustum> ActiveVolume() const
{
if (myActiveSelectionType == Unknown)
return NCollection_Handle<SelectMgr_BaseFrustum>();
return mySelectingVolumes[myActiveSelectionType];
}
//! Stores plane equations to the given vector
virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE
{
if (myActiveSelectionType == Unknown)
{
thePlaneEquations.Clear();
return;
}
return mySelectingVolumes[myActiveSelectionType]->GetPlanes (thePlaneEquations);
}
private:
enum { Frustum, FrustumSet, VolumeTypesNb }; //!< Defines the amount of available selecting volumes

View File

@@ -285,3 +285,21 @@ void SelectMgr_TriangularFrustum::Clear()
{
myBuilder.Nullify();
}
// =======================================================================
// function : GetPlanes
// purpose :
// =======================================================================
void SelectMgr_TriangularFrustum::GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
{
SelectMgr_Vec4 aPlaneEquation;
for (Standard_Integer aPlaneIdx = 0; aPlaneIdx < 5; ++aPlaneIdx)
{
const gp_Vec& aNorm = myPlanes[aPlaneIdx];
aPlaneEquation.x() = aNorm.X();
aPlaneEquation.y() = aNorm.Y();
aPlaneEquation.z() = aNorm.Z();
aPlaneEquation.w() = - (aNorm.XYZ().Dot (myVertices[aPlaneIdx % 2 == 0 ? aPlaneIdx : 1].XYZ()));
thePlaneEquations.Append (aPlaneEquation);
}
}

View File

@@ -84,6 +84,9 @@ public:
//! Nullifies the handle to corresponding builder instance to prevent memory leaks
Standard_EXPORT void Clear();
//! Stores plane equations to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
private:
void cacheVertexProjections (SelectMgr_TriangularFrustum* theFrustum);

View File

@@ -224,4 +224,18 @@ Standard_Boolean SelectMgr_TriangularFrustumSet::Overlaps (const gp_Pnt& thePnt1
return Standard_False;
}
// =======================================================================
// function : GetPlanes
// purpose :
// =======================================================================
void SelectMgr_TriangularFrustumSet::GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const
{
thePlaneEquations.Clear();
for (SelectMgr_TriangFrustumsIter anIter (myFrustums); anIter.More(); anIter.Next())
{
anIter.Value()->GetPlanes (thePlaneEquations);
}
}
#undef MEMORY_BLOCK_SIZE

View File

@@ -75,6 +75,9 @@ public:
Select3D_TypeOfSensitivity theSensType,
Standard_Real& theDepth) Standard_OVERRIDE;
//! Stores plane equations to the given vector
Standard_EXPORT virtual void GetPlanes (NCollection_Vector<SelectMgr_Vec4>& thePlaneEquations) const Standard_OVERRIDE;
private:
SelectMgr_TriangFrustums myFrustums;

View File

@@ -24,13 +24,17 @@
#define THE_SHADER_IN in
#define THE_SHADER_OUT out
#define THE_OUT out
#define occTexture1D texture
#define occTexture2D texture
#define occTexture3D texture
#else
#define THE_ATTRIBUTE attribute
#define THE_SHADER_IN varying
#define THE_SHADER_OUT varying
#define THE_OUT
#define occTexture1D texture1D
#define occTexture2D texture2D
#define occTexture3D texture3D
#endif
#ifdef GL_ES
@@ -46,9 +50,11 @@
THE_ATTRIBUTE vec4 occTexCoord;
THE_ATTRIBUTE vec4 occVertColor;
#elif (__VERSION__ >= 130)
out vec4 occFragColor;
out vec4 occFragColor;
out float occFragDepth;
#else
#define occFragColor gl_FragColor
#define occFragDepth gl_FragDepth
#endif
// Matrix state

View File

@@ -4,16 +4,65 @@ uniform sampler2D uInputTexture;
//! Ray tracing depth image.
uniform sampler2D uDepthTexture;
uniform int uBilateralEnabled;
//! Output pixel color.
out vec4 OutColor;
const float rI = 0.270 * 1.0f; // The intensity radius (in pixels).
const float rL = 1.71 * 0.5f; // The geometric radius (in pixels).
const int WindowSize = 6; // The window size (in pixels).
float gaussian (float theL, float theR)
{
return exp (-theL * theL / (2.0f * theR * theR));
}
vec4 posprocess (vec4 theColor)
{
return clamp (theColor, 0.f, 1.f);
}
vec4 bilateral()
{
// Get the sizes
int aWindow = WindowSize / 2;
vec4 anOutCol = vec4 (0.f, 0.f, 0.f, 0.f);
vec4 aRefCol = posprocess (texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy), 0));
float aNorm = 0.f;
// Compute the kernel
for (int i = -aWindow; i <= aWindow; i++)
{
for (int j = -aWindow; j <= aWindow; j++)
{
vec4 aCol = posprocess (
texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy) + ivec2 (j, i), 0));
float A = gaussian (distance (aCol, aRefCol), rI);
float B = gaussian (length (vec2(j, i)), rL);
anOutCol += aCol * A * B;
aNorm += A * B;
}
}
return anOutCol * (1.f / aNorm);
}
void main (void)
{
vec4 aColor = texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy), 0);
vec4 aColor;
if (bool (uBilateralEnabled))
{
aColor = bilateral();
}
else
{
aColor = texelFetch (uInputTexture, ivec2 (gl_FragCoord.xy), 0);
}
float aDepth = texelFetch (uDepthTexture, ivec2 (gl_FragCoord.xy), 0).r;
gl_FragDepth = aDepth;
// apply gamma correction (we use gamma = 2)
OutColor = vec4 (sqrt (aColor.rgb), aColor.a);
}
}

View File

@@ -473,7 +473,7 @@ void sampleMaterial (in SMaterial theMaterial,
theBounce = SPEC_REFLECT_BOUNCE; // specular bounce
}
else // specular transmission
else if (aKsi < aReflection) // specular transmission
{
theWeight *= theMaterial.Kt.rgb * (aReflection / aPt) *
sampleSpecularTransmission (theOutput, theInput, theBounce, theWeight, theMaterial.Fresnel);
@@ -493,12 +493,12 @@ void sampleMaterial (in SMaterial theMaterial,
//=======================================================================
float handlePointLight (in vec3 theInput, in vec3 theToLight, in float theRadius, in float theDistance)
{
float aDistance = dot (theToLight, theToLight);
float aSquareLightDist = dot (theToLight, theToLight);
float aCosMax = inversesqrt (1.f + theRadius * theRadius / aDistance);
float aCosMax = inversesqrt (1.f + theRadius * theRadius / aSquareLightDist);
return float (aDistance < theDistance * theDistance) *
step (aCosMax, dot (theToLight, theInput) * inversesqrt (aDistance));
return float (aSquareLightDist < theDistance * theDistance) *
step (aCosMax, dot (theToLight, theInput) * inversesqrt (aSquareLightDist));
}
//=======================================================================
@@ -514,13 +514,12 @@ float handleDirectLight (in vec3 theInput, in vec3 theToLight, in float theCosMa
// function : sampleLight
// purpose : general sampling function for directional and point lights
//=======================================================================
vec3 sampleLight (in vec3 theToLight, in bool isDirectional, in float theSmoothness, inout float thePDF)
vec3 sampleLight (in vec3 theToLight, in float theDistance, in bool isDirectional, in float theSmoothness, inout float thePDF)
{
SLocalSpace aSpace = LocalSpace (theToLight);
// for point lights smoothness defines radius
float aCosMax = isDirectional ? theSmoothness :
inversesqrt (1.f + theSmoothness * theSmoothness / dot (theToLight, theToLight));
float aCosMax = inversesqrt (1.f + theSmoothness * theSmoothness / (theDistance * theDistance));
float aKsi1 = RandFloat();
float aKsi2 = RandFloat();
@@ -593,8 +592,8 @@ vec3 intersectLight (in SRay theRay, in bool isViewRay, in int theBounce, in flo
return aRadiance;
}
#define MIN_THROUGHPUT vec3 (0.02f)
#define MIN_CONTRIBUTION vec3 (0.01f)
#define MIN_THROUGHPUT vec3 (2.0e-2f)
#define MIN_CONTRIBUTION vec3 (0.5e-2f)
#define MATERIAL_KD(index) (18 * index + 11)
#define MATERIAL_KR(index) (18 * index + 12)
@@ -732,7 +731,7 @@ vec4 PathTrace (in SRay theRay, in vec3 theInverse)
float aPDF = 1.f / uLightCount, aDistance = length (aLight.xyz);
aLight.xyz = sampleLight (aLight.xyz * (1.f / aDistance),
aLight.xyz = sampleLight (aLight.xyz * (1.f / aDistance), aDistance,
aLight.w == 0.f /* is infinite */, aParam.w /* angle cosine */, aPDF);
vec3 aContrib = (1.f / aPDF) * aParam.rgb /* Le */ * handleMaterial (

View File

@@ -13,7 +13,8 @@ uniform sampler2D uAccumTexture;
//! Increases performance up to 4 times, but noise becomes structured.
uniform int uBlockedRngEnabled;
#define MAX_RADIANCE vec3 (10.f)
//! Maximum value for radiance clamping.
uniform float uMaxRadiance;
// =======================================================================
// function : main
@@ -46,7 +47,7 @@ void main (void)
aColor.rgb = ZERO;
}
aColor.rgb = min (aColor.rgb, MAX_RADIANCE);
aColor.rgb = min (aColor.rgb, vec3 (uMaxRadiance));
OutColor = mix (texture2D (uAccumTexture, vPixel), aColor, uSampleWeight);
#else

View File

@@ -4,3 +4,5 @@ TKService
TKernel
TKG3d
TKG2d
TKOpenGl
CSF_OpenGlLibs

View File

@@ -31,7 +31,6 @@ V3d_TypeOfPickCamera.hxx
V3d_TypeOfPickLight.hxx
V3d_TypeOfRepresentation.hxx
V3d_TypeOfShadingModel.hxx
V3d_TypeOfSurfaceDetail.hxx
V3d_TypeOfUpdate.hxx
V3d_TypeOfView.hxx
V3d_TypeOfVisualization.hxx

View File

@@ -1,31 +0,0 @@
// Created on: 1992-11-13
// Created by: GG
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _V3d_TypeOfSurfaceDetail_HeaderFile
#define _V3d_TypeOfSurfaceDetail_HeaderFile
//! Modes of visualization for objects in a view
//! - V3d_TEX_NONE: no texture mapping,
//! - V3d_TEX_ENVIRONMENT: environment mapping only,
//! - V3d_TEX_ALL: environment and texture mapping.
enum V3d_TypeOfSurfaceDetail
{
V3d_TEX_NONE,
V3d_TEX_ENVIRONMENT,
V3d_TEX_ALL
};
#endif // _V3d_TypeOfSurfaceDetail_HeaderFile

View File

@@ -159,7 +159,6 @@ V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView th
SetAxis (0.,0.,0.,1.,1.,1.);
SetVisualization (theViewer->DefaultVisualization());
SetShadingModel (theViewer->DefaultShadingModel());
SetSurfaceDetail (theViewer->DefaultSurfaceDetail());
SetTwist (0.);
SetAt (0.,0.,0.);
SetProj (theViewer->DefaultViewProj());
@@ -625,15 +624,6 @@ void V3d_View::SetShadingModel (const V3d_TypeOfShadingModel theShadingModel)
myView->SetShadingModel (static_cast<Graphic3d_TypeOfShadingModel> (theShadingModel));
}
//=============================================================================
//function : SetSurfaceDetail
//purpose :
//=============================================================================
void V3d_View::SetSurfaceDetail (const V3d_TypeOfSurfaceDetail theSurfaceDetail)
{
myView->SetSurfaceDetailType (static_cast<Graphic3d_TypeOfSurfaceDetail> (theSurfaceDetail));
}
//=============================================================================
//function : SetTextureEnv
//purpose :
@@ -2167,107 +2157,9 @@ void V3d_View::Gravity (Standard_Real& theX,
Standard_Real& theY,
Standard_Real& theZ) const
{
Graphic3d_MapOfStructure aSetOfStructures;
myView->DisplayedStructures (aSetOfStructures);
Standard_Boolean hasSelection = Standard_False;
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
aStructIter.More(); aStructIter.Next())
{
if (aStructIter.Key()->IsHighlighted()
&& aStructIter.Key()->IsVisible())
{
hasSelection = Standard_True;
break;
}
}
Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
Standard_Integer aNbPoints = 0;
gp_XYZ aResult (0.0, 0.0, 0.0);
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
aStructIter.More(); aStructIter.Next())
{
const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
if (!aStruct->IsVisible()
|| aStruct->IsInfinite()
|| (hasSelection && !aStruct->IsHighlighted()))
{
continue;
}
const Graphic3d_BndBox4f& aBox = aStruct->CStructure()->BoundingBox();
if (!aBox.IsValid())
{
continue;
}
// skip transformation-persistent objects
if (aStruct->TransformPersistence().Flags != Graphic3d_TMF_None)
{
continue;
}
// use camera projection to find gravity point
Xmin = (Standard_Real )aBox.CornerMin().x();
Ymin = (Standard_Real )aBox.CornerMin().y();
Zmin = (Standard_Real )aBox.CornerMin().z();
Xmax = (Standard_Real )aBox.CornerMax().x();
Ymax = (Standard_Real )aBox.CornerMax().y();
Zmax = (Standard_Real )aBox.CornerMax().z();
gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
{
gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax),
gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax)
};
for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt)
{
const gp_Pnt& aBndPnt = aPnts[aPntIt];
const gp_Pnt aProjected = Camera()->Project (aBndPnt);
if (Abs (aProjected.X()) <= 1.0
&& Abs (aProjected.Y()) <= 1.0)
{
aResult += aBndPnt.XYZ();
++aNbPoints;
}
}
}
if (aNbPoints == 0)
{
// fallback - just use bounding box of entire scene
Bnd_Box aBox = myView->MinMaxValues (Standard_True);
if (!aBox.IsVoid())
{
aBox.Get (Xmin, Ymin, Zmin,
Xmax, Ymax, Zmax);
gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
{
gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax),
gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax)
};
for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt)
{
const gp_Pnt& aBndPnt = aPnts[aPntIt];
aResult += aBndPnt.XYZ();
++aNbPoints;
}
}
}
if (aNbPoints > 0)
{
aResult /= aNbPoints;
}
theX = aResult.X();
theY = aResult.Y();
theZ = aResult.Z();
theX = Camera()->Center().X();
theY = Camera()->Center().Y();
theZ = Camera()->Center().Z();
}
//=======================================================================
@@ -2421,15 +2313,6 @@ V3d_TypeOfShadingModel V3d_View::ShadingModel() const
return static_cast<V3d_TypeOfShadingModel> (myView->ShadingModel());
}
//=============================================================================
//function : SurfaceDetail
//purpose :
//=============================================================================
V3d_TypeOfSurfaceDetail V3d_View::SurfaceDetail() const
{
return static_cast<V3d_TypeOfSurfaceDetail> (myView->SurfaceDetailType());
}
//=============================================================================
//function : TextureEnv
//purpose :

View File

@@ -75,7 +75,6 @@
#include <V3d_TypeOfBackfacingModel.hxx>
#include <V3d_TypeOfOrientation.hxx>
#include <V3d_TypeOfShadingModel.hxx>
#include <V3d_TypeOfSurfaceDetail.hxx>
#include <V3d_TypeOfView.hxx>
#include <V3d_TypeOfVisualization.hxx>
#include <V3d_TypeOfZclipping.hxx>
@@ -260,9 +259,6 @@ public:
//! Defines the shading model for the visualization. Various models are available.
Standard_EXPORT void SetShadingModel (const V3d_TypeOfShadingModel theShadingModel);
//! Selects the kind of rendering for texture mapping. No texture mapping by default.
Standard_EXPORT void SetSurfaceDetail (const V3d_TypeOfSurfaceDetail theSurfaceDetail);
//! Sets the environment texture to use. No environment texture by default.
Standard_EXPORT void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTexture);
@@ -721,8 +717,6 @@ public:
//! Returns the current shading model.
Standard_EXPORT V3d_TypeOfShadingModel ShadingModel() const;
Standard_EXPORT V3d_TypeOfSurfaceDetail SurfaceDetail() const;
Standard_EXPORT Handle(Graphic3d_TextureEnv) TextureEnv() const;
//! Returns the current visualisation mode.

View File

@@ -48,8 +48,7 @@ V3d_Viewer::V3d_Viewer (const Handle(Graphic3d_GraphicDriver)& theDriver,
const V3d_TypeOfShadingModel theShadingModel,
const V3d_TypeOfUpdate theUpdateMode,
const Standard_Boolean theComputedMode,
const Standard_Boolean theDefaultComputedMode,
const V3d_TypeOfSurfaceDetail theSurfaceDetail)
const Standard_Boolean theDefaultComputedMode)
:myNextCount (-1),
myDriver (theDriver),
myName (TCollection_ExtendedString (theName)),
@@ -78,7 +77,6 @@ myZLayerGenId (1, IntegerLast())
SetDefaultBackgroundColor (theViewBackground);
SetDefaultVisualization (theVisualization);
SetDefaultShadingModel (theShadingModel);
SetDefaultSurfaceDetail (theSurfaceDetail);
SetDefaultAngle (M_PI / 2.);
SetDefaultTypeOfView (V3d_ORTHOGRAPHIC);
@@ -319,11 +317,6 @@ void V3d_Viewer::SetDefaultShadingModel(const V3d_TypeOfShadingModel Type) {
MyShadingModel = Type ;
}
void V3d_Viewer::SetDefaultSurfaceDetail(const V3d_TypeOfSurfaceDetail Type) {
MySurfaceDetail = Type ;
}
void V3d_Viewer::SetDefaultAngle(const Quantity_PlaneAngle Angle) {
MyDefaultAngle = Angle;
}
@@ -372,10 +365,6 @@ V3d_TypeOfShadingModel V3d_Viewer::DefaultShadingModel() const {
return MyShadingModel ;
}
V3d_TypeOfSurfaceDetail V3d_Viewer::DefaultSurfaceDetail() const {
return MySurfaceDetail ;
}
Quantity_PlaneAngle V3d_Viewer::DefaultAngle() const {
return MyDefaultAngle;
}

View File

@@ -48,7 +48,6 @@
#include <V3d_ListOfTransient.hxx>
#include <V3d_TypeOfOrientation.hxx>
#include <V3d_TypeOfShadingModel.hxx>
#include <V3d_TypeOfSurfaceDetail.hxx>
#include <V3d_TypeOfUpdate.hxx>
#include <V3d_TypeOfView.hxx>
#include <V3d_TypeOfVisualization.hxx>
@@ -91,7 +90,7 @@ public:
//! This limitation might be addressed in some future OCCT releases.
//! If the size of the view is <= 0
//! Warning: Client must creates a graphic driver
Standard_EXPORT V3d_Viewer(const Handle(Graphic3d_GraphicDriver)& theDriver, const Standard_ExtString theName, const Standard_CString theDomain = "", const Quantity_Length theViewSize = 1000.0, const V3d_TypeOfOrientation theViewProj = V3d_XposYnegZpos, const Quantity_NameOfColor theViewBackground = Quantity_NOC_GRAY30, const V3d_TypeOfVisualization theVisualization = V3d_ZBUFFER, const V3d_TypeOfShadingModel theShadingModel = V3d_GOURAUD, const V3d_TypeOfUpdate theUpdateMode = V3d_WAIT, const Standard_Boolean theComputedMode = Standard_True, const Standard_Boolean theDefaultComputedMode = Standard_True, const V3d_TypeOfSurfaceDetail theSurfaceDetail = V3d_TEX_NONE);
Standard_EXPORT V3d_Viewer(const Handle(Graphic3d_GraphicDriver)& theDriver, const Standard_ExtString theName, const Standard_CString theDomain = "", const Quantity_Length theViewSize = 1000.0, const V3d_TypeOfOrientation theViewProj = V3d_XposYnegZpos, const Quantity_NameOfColor theViewBackground = Quantity_NOC_GRAY30, const V3d_TypeOfVisualization theVisualization = V3d_ZBUFFER, const V3d_TypeOfShadingModel theShadingModel = V3d_GOURAUD, const V3d_TypeOfUpdate theUpdateMode = V3d_WAIT, const Standard_Boolean theComputedMode = Standard_True, const Standard_Boolean theDefaultComputedMode = Standard_True);
//! creates a view in the viewer according to its
//! default parameters.
@@ -179,9 +178,6 @@ public:
//! Gives the default type of SHADING.
Standard_EXPORT void SetDefaultShadingModel (const V3d_TypeOfShadingModel Type);
//! Gives the default type of texture mapping.
Standard_EXPORT void SetDefaultSurfaceDetail (const V3d_TypeOfSurfaceDetail Type);
Standard_EXPORT void SetDefaultAngle (const Quantity_PlaneAngle Angle);
//! Defines the mode of regenerating the views making
@@ -240,9 +236,6 @@ public:
//! Returns the default type of Shading
Standard_EXPORT V3d_TypeOfShadingModel DefaultShadingModel() const;
//! Returns the default type of texture mapping
Standard_EXPORT V3d_TypeOfSurfaceDetail DefaultSurfaceDetail() const;
Standard_EXPORT Quantity_PlaneAngle DefaultAngle() const;
//! Returns the regeneration mode of views in the viewer.
@@ -489,7 +482,6 @@ private:
V3d_TypeOfOrientation MyViewProj;
V3d_TypeOfVisualization MyVisualization;
V3d_TypeOfShadingModel MyShadingModel;
V3d_TypeOfSurfaceDetail MySurfaceDetail;
Quantity_PlaneAngle MyDefaultAngle;
V3d_TypeOfView MyDefaultTypeOfView;
Graphic3d_RenderingParams myDefaultRenderingParams;

View File

@@ -3201,8 +3201,6 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
Standard_Integer aPreviousMode = 0;
ViewerTest::CurrentView()->SetSurfaceDetail (V3d_TEX_ALL);
TCollection_AsciiString aShapeName (theArgv[1]);
Handle(AIS_InteractiveObject) anIO;

View File

@@ -4473,21 +4473,7 @@ static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** ar
}
else if (argc < 2)
{
di << "Use: vzlayer ";
di << " add/del/get/settings/enable/disable [id]\n";
di << " add - add new z layer to viewer and print its id\n";
di << " del - del z layer by its id\n";
di << " get - print sequence of z layers in increasing order of their overlay level\n";
di << " settings - print status of z layer settings\n";
di << " enable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n enables given setting for the z layer\n";
di << " enable (p[ositive]offset/n[egative]offset) \n enables given setting for the z layer\n";
di << " disable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n disables given setting for the z layer\n";
di << "\nWhere id is the layer identificator\n";
di << "\nExamples:\n";
di << " vzlayer add\n";
di << " vzlayer enable poffset 1\n";
di << " vzlayer disable depthtest 1\n";
di << " vzlayer del 1\n";
di << di.PrintHelp (argv[0]);
return 1;
}
@@ -4625,6 +4611,10 @@ static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** ar
{
aSettings.SetDepthOffsetNegative();
}
else if (aSubOp == "textureenv")
{
aSettings.UseEnvironmentTexture = true;
}
aViewer->SetZLayerSettings (anId, aSettings);
}
@@ -4662,6 +4652,10 @@ static int VZLayer (Draw_Interpretor& di, Standard_Integer argc, const char** ar
{
aSettings.DisableSetting (Graphic3d_ZLayerDepthOffset);
}
else if (aSubOp == "textureenv")
{
aSettings.UseEnvironmentTexture = false;
}
aViewer->SetZLayerSettings (anId, aSettings);
}
@@ -6572,11 +6566,9 @@ static int VTextureEnv (Draw_Interpretor& /*theDI*/, Standard_Integer theArgNb,
);
}
aView->SetTextureEnv(aTexEnv);
aView->SetSurfaceDetail(V3d_TEX_ENVIRONMENT);
}
else // Disabling environment mapping
{
aView->SetSurfaceDetail(V3d_TEX_NONE);
Handle(Graphic3d_TextureEnv) aTexture;
aView->SetTextureEnv(aTexture); // Passing null handle to clear the texture data
}
@@ -6980,40 +6972,6 @@ static int VClipPlane (Draw_Interpretor& theDi, Standard_Integer theArgsNb, cons
return 1;
}
//===============================================================================================
//function : VSetTextureMode
//purpose :
//===============================================================================================
static int VSetTextureMode (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const char** theArgVec)
{
if (theArgsNb < 3)
{
theDi << theArgVec[0] << ": insufficient command arguments. Type help for more information.\n";
return 1;
}
TCollection_AsciiString aViewName (theArgVec[1]);
if (!ViewerTest_myViews.IsBound1 (aViewName))
{
theDi << theArgVec[0] << ": view is not found.\n";
return 1;
}
const Handle(V3d_View)& aView = ViewerTest_myViews.Find1 (aViewName);
switch (atoi (theArgVec[2]))
{
case 0: aView->SetSurfaceDetail (V3d_TEX_NONE); break;
case 1: aView->SetSurfaceDetail (V3d_TEX_ENVIRONMENT); break;
case 2: aView->SetSurfaceDetail (V3d_TEX_ALL); break;
default:
theDi << theArgVec[0] << ": invalid mode.\n";
return 1;
}
aView->Redraw();
return 0;
}
//===============================================================================================
//function : VZRange
//purpose :
@@ -8301,6 +8259,8 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
theDI << "reflections: " << (aParams.IsReflectionEnabled ? "on" : "off") << "\n";
theDI << "gleam: " << (aParams.IsTransparentShadowEnabled ? "on" : "off") << "\n";
theDI << "GI: " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n";
theDI << "samples: " << aParams.SamplesPerPixel << "\n";
theDI << "filtering: " << (aParams.IsGIFilteringEnabled ? "on" : "off") << "\n";
theDI << "blocked RNG: " << (aParams.CoherentPathTracingMode ? "on" : "off") << "\n";
theDI << "shadingModel: ";
switch (aView->ShadingModel())
@@ -8424,6 +8384,48 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
aParams.RaytracingDepth = aDepth;
}
}
else if (aFlag == "-maxrad"
|| aFlag == "-rclamp")
{
if (toPrint)
{
theDI << aParams.RadianceClampValue << " ";
continue;
}
else if (++anArgIter >= theArgNb)
{
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
return 1;
}
aParams.RadianceClampValue = Draw::Atoi (theArgVec[anArgIter]);
}
else if (aFlag == "-samples"
|| aFlag == "-spp")
{
if (toPrint)
{
theDI << aParams.SamplesPerPixel << " ";
continue;
}
else if (++anArgIter >= theArgNb)
{
std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
return 1;
}
const Standard_Integer aSamples = Draw::Atoi (theArgVec[anArgIter]);
if (aSamples < 0)
{
std::cerr << "Error: invalid ray-tracing samples per pixel " << aSamples << ". SPP should be a positive number.\n";
return 1;
}
else
{
aParams.SamplesPerPixel = aSamples;
}
}
else if (aFlag == "-shad"
|| aFlag == "-shadows")
{
@@ -8510,6 +8512,22 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
aParams.RaytracingDepth = Min (aParams.RaytracingDepth, 10);
}
}
else if (aFlag == "-filter" || aFlag == "-pp" )
{
if (toPrint)
{
theDI << (aParams.IsGIFilteringEnabled ? "on" : "off") << " ";
continue;
}
Standard_Boolean toEnable = Standard_True;
if (++anArgIter < theArgNb
&& !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
{
--anArgIter;
}
aParams.IsGIFilteringEnabled = toEnable;
}
else if (aFlag == "-blockedrng"
|| aFlag == "-brng")
{
@@ -9023,7 +9041,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
" settings - print status of z layer settings\n"
" enable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n enables given setting for the z layer\n"
" enable (p[ositive]offset/n[egative]offset) \n enables given setting for the z layer\n"
" enable textureenv \n enables environment texture mapping\n"
" disable ([depth]test/[depth]write/[depth]clear/[depth]offset) \n disables given setting for the z layer\n"
" disable textureenv \n disables environment texture mapping\n"
"\nWhere id is the layer identificator\n"
"\nExamples:\n"
" vzlayer add\n"
@@ -9278,13 +9298,6 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
" change <plane_name> capping hatch on/off/<id> - set hatching mask.\n"
" please use VSetTextureMode command to enable texture rendering in view.\n"
, __FILE__, VClipPlane, group);
theCommands.Add("vsettexturemode", "vsettexturemode view_name mode \n"
" mode can be:\n"
" 0 - no textures enabled in view.\n"
" 1 - only environment textures enabled.\n"
" 2 - all textures enabled.\n"
" this command sets texture details mode for the specified view.\n"
, __FILE__, VSetTextureMode, group);
theCommands.Add("vdefaults",
"vdefaults [-absDefl value]"
"\n\t\t: [-devCoeff value]"

View File

@@ -839,11 +839,6 @@ static Standard_Integer meshcolors( Draw_Interpretor& di,
aBuilder->SetInvalidColor(Quantity_NOC_BLACK);
aBuilder->SetTextureCoords(aScaleMap);
aMesh->AddBuilder(aBuilder, Standard_True);
//set viewer to display texures
const Handle(V3d_Viewer)& aViewer = anIC->CurrentViewer();
for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
aViewer->ActiveView()->SetSurfaceDetail(V3d_TEX_ALL);
}
aMesh->GetDrawer()->SetBoolean ( MeshVS_DA_ColorReflection, Standard_Boolean(aReflection) );

36
tests/bugs/vis/bug26434 Normal file
View File

@@ -0,0 +1,36 @@
puts "============"
puts "CR26434"
puts "============"
puts ""
##########################################################################################
puts "Visualization - Textured objects should have priority over the environment mapping"
##########################################################################################
pload MODELING VISUALIZATION
vclear
vclose all
vinit View1
vsetdispmode 1
box b0 -1 -1 -1 1 2 3
box b1 1 1 1 1 2 3
vdisplay b0 b1
vzbufftrihedron
vfit
vdump $imagedir/${casename}_0.png
vtexture b1 0
vdump $imagedir/${casename}_1.png
puts "Checking that texture have priority over the environment mapping"
vtextureenv on 0
vdump $imagedir/${casename}_2.png

View File

@@ -0,0 +1,40 @@
puts "========"
puts "Ray Tracing - check PT lights correctness"
puts "========"
pload ALL
vinit
vsetdispmode 1
vvbo 0
box b 500 500 1
box b1 2 50 20
vdisplay b
vdisplay b1
vsetlocation b -250 -250 0
vsetlocation b1 -1 -25 0
vlight del 0
vlight del 0
vlight add positional head 0 pos -10 0 20
vlight change 0 sm 5.0
vrenderparams -ray -gi
vsetmaterial b plaster
vsetmaterial b1 plaster
vviewparams -scale 23.40302443511418 -proj 3.1690307533723025e-006 -0.053740375441171516 0.99855494192227556 -up 0.00011815109169240122 0.99855493498157033 0.05374037461975216 -at -0.039728087058276865 17.658749465576971 0.40052090530867673 -eye -0.038141096586915293 -9.2534108729671232 500.45788900604856
vlight change 0 int 20
psphere s 5.0
vdisplay s
vsetlocation s 10 0 20
vbsdf s -Kd 0.0 -Ks 0.0 -Kr 0.0 -Kt 0.0
vbsdf s -Le 20.0
vfps 500

View File

@@ -0,0 +1,37 @@
puts "========"
puts "Ray Tracing - check PT lights correctness"
puts "========"
pload ALL
vinit
vsetdispmode 1
vvbo 0
box b 500 500 1
psphere s 6.0
vdisplay b
vdisplay s
vsetlocation b -250 -250 0
vsetlocation s 0.0 0.0 7.0
vlight del 0
vlight del 0
vlight add positional head 0 pos -15 0 20 sm 4.0 int 20
vrenderparams -ray -gi -rayDepth 12
vsetmaterial b plaster
vsetmaterial s glass
psphere ls 4.0
vdisplay ls
vsetlocation ls 15 0 20
vbsdf ls -Kd 0.0 -Ks 0.0 -Kr 0.0 -Kt 0.0
vbsdf ls -Le 20.0
vviewparams -scale 23.40302443511418 -proj 3.1690307533720754e-006 -0.053740375441171412 0.99855494192227556 -up 0.00011815108764545944 0.99855493500381731 0.053740374206389462 -at 0.062905867278332972 2.1147318213590474 -0.43602962811169049 -eye 0.064492857749694432 -24.79742851718504 499.62133847262908
vfps 400