1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

Compare commits

...

14 Commits

Author SHA1 Message Date
isk
5e36e3b711 Fix Path Tracing trouble. 2015-11-03 17:08:08 +03:00
isk
33941bc3d5 Add missing whitespace. 2015-11-03 07:45:31 +03:00
isk
a30aa7b60f Fix V3d_View::Gravity(). 2015-11-03 07:45:08 +03:00
isk
f3268bac61 Fix errors. 2015-10-29 16:53:38 +03:00
omy
685e2f65ec Added getters for Graphic3d_Fresnel's data 2015-10-29 16:43:38 +03:00
duv
a3a87fb157 filtering fix 2015-10-29 16:42:36 +03:00
isk
4b9006befa Add changes from CR26433. 2015-10-29 14:51:14 +03:00
isk
934a41bc88 Add changes from CR26434. 2015-10-29 14:47:46 +03:00
duv
e3abe871e2 0026432: Improving Path Tracing functionality
Samples per pixel parameter added. Simple filtering added. Lights fixed. Max radiance parameter.

Conflicts:
	src/OpenGl/OpenGl_View_Raytrace.cxx
	src/Shaders/PathtraceBase.fs
2015-10-29 14:44:11 +03:00
dbp
4eaeaf9aa2 TKMeshVS fixes for AVD
(cherry picked from commit 80f5efa1d0)
2015-10-29 14:32:51 +03:00
isk
c0ecf6bbf2 Changes from CR2618_1. 2015-10-29 14:30:46 +03:00
isk
4b8d662287 Changes from CR0-AVD-NEW-1, commit SHA1: 113d8db4f3 2015-10-29 14:26:58 +03:00
abv
e947084861 0026561: Porting CSharp wrapper to OCCT 7.0.0
Added missing Standard_EXPORT for public methods; declaration of unimplemented method removed.

Restoring some changes made for #26788 but omitted in its commit.

OpenGl_View::ReadDepths() - drop obsolete and broken method; V3d_View::ToPixMap() should be used instead
2015-10-29 14:16:49 +03:00
isk
8fd1409744 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.
2015-10-29 11:39:18 +03:00
34 changed files with 811 additions and 234 deletions

View File

@@ -502,6 +502,11 @@ void AIS_Dimension::DrawText (const Handle(Prs3d_Presentation)& thePresentation,
// draw text
if (myDrawer->DimensionAspect()->IsTextShaded())
{
if (!myDrawer->HasOwnShadingAspect())
{
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
}
// Setting text shading and color parameters
Graphic3d_MaterialAspect aShadeMat (Graphic3d_NOM_DEFAULT);
aShadeMat.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);

View File

@@ -95,10 +95,6 @@ public:
Standard_EXPORT void Terminate (const Standard_Boolean updateviewer = Standard_True);
//! to be called when a upper local context was closed...
//! useful to put pack the right projector...
Standard_EXPORT void Reactivate();
//! returns true if done...
Standard_EXPORT Standard_Boolean Display (const Handle(AIS_InteractiveObject)& anInteractive, const Standard_Integer DisplayMode = 0, const Standard_Boolean AllowShapeDecomposition = Standard_True, const Standard_Integer ActivationMode = 0);

View File

@@ -2095,8 +2095,8 @@ void BRepFill_Evolved::AddTopAndBottom(BRepTools_Quilt& Glue)
gp_Pnt PC;
gp_Vec VC;
C.D1(u,PC,VC);
gp_Vec PPC(P,PC);
gp_Vec Prod = PPC.Crossed(VC);
gp_Vec aPPC(P,PC);
gp_Vec Prod = aPPC.Crossed(VC);
if (IsOut) {
ToReverse = Prod.Z() < 0.;
}

View File

@@ -203,7 +203,7 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
TopoDS_Edge E = TopoDS::Edge(ex.Current());
Standard_Real f,l,ff,ll;
Handle(Geom2d_Curve) PC,PPC;
Handle(Geom2d_Curve) PC,aPPC;
Handle(Geom_Surface) SS;
TopLoc_Location L;
Standard_Integer i = 0,j;
@@ -221,8 +221,7 @@ void BRepLib_FindSurface::Init(const TopoDS_Shape& S,
j = 0;
for(;;) {
j++;
BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()),
PPC,SS,L,ff,ll,j);
BRep_Tool::CurveOnSurface(TopoDS::Edge(ex.Current()),aPPC,SS,L,ff,ll,j);
if (SS.IsNull()) {
break;
}

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

@@ -386,11 +386,11 @@ void Bisector_BisecPC::Values(const Standard_Real U,
case 2 : {curve->D3(UOnCurve,PC,Tu,Tuu,T3u);break;}
}
gp_Vec2d PPC(PC.X() - point.X(), PC.Y() - point.Y());
gp_Vec2d aPPC(PC.X() - point.X(), PC.Y() - point.Y());
gp_Vec2d Nor( - Tu.Y(), Tu.X());
Standard_Real SquarePPC = PPC.SquareMagnitude();
Standard_Real NorPPC = Nor.Dot(PPC);
Standard_Real SquarePPC = aPPC.SquareMagnitude();
Standard_Real NorPPC = Nor.Dot(aPPC);
Standard_Real A1;
if (Abs(NorPPC) > gp::Resolution() && (NorPPC*sign) < 0.) {
@@ -402,8 +402,8 @@ void Bisector_BisecPC::Values(const Standard_Real U,
if (N == 0) return; // End Calculation Point;
gp_Vec2d Nu ( - Tuu.Y() , Tuu.X()); // derivative of the normal by U.
Standard_Real NuPPC = Nu .Dot(PPC);
Standard_Real TuPPC = Tu .Dot(PPC);
Standard_Real NuPPC = Nu .Dot(aPPC);
Standard_Real TuPPC = Tu .Dot(aPPC);
Standard_Real NorPPCE2 = NorPPC*NorPPC;
Standard_Real A2 = TuPPC/NorPPC - 0.5*NuPPC*SquarePPC/NorPPCE2;
@@ -415,8 +415,8 @@ void Bisector_BisecPC::Values(const Standard_Real U,
gp_Vec2d Nuu ( - T3u.Y() , T3u.X());
Standard_Real NorPPCE4 = NorPPCE2*NorPPCE2;
Standard_Real NuuPPC = Nuu.Dot(PPC);
Standard_Real TuuPPC = Tuu.Dot(PPC);
Standard_Real NuuPPC = Nuu.Dot(aPPC);
Standard_Real TuuPPC = Tuu.Dot(aPPC);
Standard_Real A21 = TuuPPC/NorPPC - TuPPC*NuPPC/NorPPCE2;
Standard_Real A22 = (0.5*NuuPPC*SquarePPC + NuPPC*TuPPC)/NorPPCE2 -
@@ -470,12 +470,12 @@ Standard_Real Bisector_BisecPC::Distance (const Standard_Real U) const
Standard_Real UOnCurve = LinkBisCurve(U);
curve->D1(UOnCurve,PC,Tan);
gp_Vec2d PPC(PC.X() - point.X(), PC.Y() - point.Y());
gp_Vec2d aPPC(PC.X() - point.X(), PC.Y() - point.Y());
gp_Vec2d Nor( - Tan.Y(), Tan.X());
Standard_Real NorNor = Nor.SquareMagnitude();
Standard_Real SquareMagPPC = PPC.SquareMagnitude();
Standard_Real Prosca = Nor.Dot(PPC);
Standard_Real SquareMagPPC = aPPC.SquareMagnitude();
Standard_Real Prosca = Nor.Dot(aPPC);
if (point.IsEqual(PC,Precision::Confusion())) {
if (isConvex) { return 0.;}

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

@@ -296,13 +296,6 @@ public:
//! @param theMax [in] the maximum point of scene.
virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax) = 0;
//! Reads depths of shown pixels of the given rectangle.
virtual void ReadDepths (const Standard_Integer theX,
const Standard_Integer theY,
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Standard_Address theBuffer) const = 0;
//! Dump active rendering buffer into specified memory buffer.
virtual Standard_Boolean BufferDump (Image_PixMap& theImage, const Graphic3d_BufferType& theBufferType) = 0;

View File

@@ -59,6 +59,8 @@ public:
IsTransparentShadowEnabled (Standard_False),
UseEnvironmentMapBackground (Standard_False),
CoherentPathTracingMode (Standard_False),
IsGIFilteringEnabled (Standard_False),
RadianceClampValue (10.0),
StereoMode (Graphic3d_StereoMode_QuadBuffer),
AnaglyphFilter (Anaglyph_RedCyan_Optimized),
@@ -90,6 +92,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

@@ -38,6 +38,9 @@
#include <TColStd_ListIteratorOfListOfReal.hxx>
#include <TColStd_MapIteratorOfPackedMapOfInteger.hxx>
#include <OpenGl_FrameBuffer.hxx>
#include <OpenGl_Workspace.hxx>
//================================================================
// Function : Constructor MeshVS_TextPrsBuilder
// Purpose :
@@ -134,6 +137,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());
}
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)
{
//
}
protected:
Standard_EXPORT virtual ~OpenGl_GrabDepthElement()
{
//
}
protected:
mutable Handle(OpenGl_FrameBuffer) myFBO;
public:
DEFINE_STANDARD_ALLOC
};
}
//================================================================
// Function : Build
// Purpose :
@@ -157,6 +243,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 );
@@ -196,6 +292,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

@@ -123,3 +123,37 @@ void OSD_OpenStream(std::ofstream& theStream,
#endif
}
// ==============================================
// function : OSD_OpenStream
// purpose : Opens file stream
// ==============================================
void OSD_OpenStream (std::ifstream& theStream,
const char* theName,
const std::ios_base::openmode theMode)
{
#ifdef _WIN32
// file name is treated as UTF-8 string and converted to UTF-16 one
const TCollection_ExtendedString aFileNameW (theName, Standard_True);
theStream.open ((const wchar_t* )aFileNameW.ToExtString(), theMode);
#else
theStream.open (theName, theMode);
#endif
}
// ==============================================
// function : OSD_OpenStream
// purpose : Opens file stream
// ==============================================
void OSD_OpenStream (std::ifstream& theStream,
const TCollection_ExtendedString& theName,
const std::ios_base::openmode theMode)
{
#ifdef _WIN32
theStream.open ((const wchar_t* )theName.ToExtString(), theMode);
#else
// conversion in UTF-8 for linux
NCollection_Utf8String aString ((const Standard_Utf16Char*)theName.ToExtString());
theStream.open (aString.ToCString(),theMode);
#endif
}

View File

@@ -40,6 +40,22 @@ __Standard_API void OSD_OpenStream (std::ofstream& theStream,
const TCollection_ExtendedString& theName,
const std::ios_base::openmode theMode);
//! Function opens the file stream.
//! @param theStream stream to open
//! @param theName name of file encoded in UTF-8
//! @param theMode opening mode
__Standard_API void OSD_OpenStream (std::ifstream& theStream,
const char* theName,
const std::ios_base::openmode theMode);
//! Function opens the file stream.
//! @param theStream stream to open
//! @param theName name of file encoded in UTF-16
//! @param theMode opening mode
__Standard_API void OSD_OpenStream (std::ifstream& theStream,
const TCollection_ExtendedString& theName,
const std::ios_base::openmode theMode);
//! Function opens the file buffer.
//! @param theBuff file buffer to open
//! @param theName name of file encoded in UTF-8

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

@@ -805,6 +805,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

@@ -183,7 +183,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
@@ -198,7 +198,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
@@ -211,7 +211,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;
@@ -222,14 +222,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;
@@ -237,7 +237,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;
@@ -373,6 +373,19 @@ 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->HasFloatingPointTexture())
{
TCollection_ExtendedString aMsg ("Error: floating-point textures are not supproted 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
@@ -473,7 +486,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
@@ -612,7 +625,7 @@ bool OpenGl_Texture::Init (const Handle(OpenGl_Context)& theCtx,
{
const TCollection_ExtendedString aWarnMessage ("Warning: generating mipmaps requires GL_ARB_framebuffer_object extension which is missing.");
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_PORTABILITY_ARB, 0, GL_DEBUG_SEVERITY_HIGH_ARB, aWarnMessage);
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_PORTABILITY, 0, GL_DEBUG_SEVERITY_HIGH, aWarnMessage);
Unbind (theCtx);
Release (theCtx.operator->());
@@ -691,6 +704,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,
@@ -740,3 +769,123 @@ bool OpenGl_Texture::InitRectangle (const Handle(OpenGl_Context)& theCtx,
return false;
#endif
}
// =======================================================================
// function : Init3D
// purpose :
// =======================================================================
bool OpenGl_Texture::Init3D (const Handle(OpenGl_Context)& theCtx,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
const Standard_Integer theSizeZ,
const OpenGl_TextureFormat& theFormat,
const void* thePixels)
{
if (!Create (theCtx) || !theCtx->IsGlGreaterEqual (1, 2))
{
return false;
}
myTarget = GL_TEXTURE_3D;
const GLsizei aSizeX = Min (theCtx->MaxTextureSize(), theSizeX);
const GLsizei aSizeY = Min (theCtx->MaxTextureSize(), theSizeY);
const GLsizei aSizeZ = Min (theCtx->MaxTextureSize(), theSizeZ);
Bind (theCtx);
if (myParams->Filter() == Graphic3d_TOTF_NEAREST)
{
glTexParameteri (myTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri (myTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
else
{
glTexParameteri (myTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (myTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
if (theFormat.Internal() == GL_FLOAT
&& !theCtx->HasFloatingPointTexture())
{
TCollection_ExtendedString aMsg ("Error: floating-point textures are not supproted 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;
}
#if !defined(OPENGL_ES_2_0)
theCtx->core15fwd->glTexImage3D (GL_PROXY_TEXTURE_3D,
0,
theFormat.Internal(),
aSizeX,
aSizeY,
aSizeZ,
0,
theFormat.Format(),
theFormat.DataType(),
NULL);
GLint aTestSizeX = 0;
GLint aTestSizeY = 0;
GLint aTestSizeZ = 0;
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_WIDTH, &aTestSizeX);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_HEIGHT, &aTestSizeY);
glGetTexLevelParameteriv (GL_PROXY_TEXTURE_3D, 0, GL_TEXTURE_DEPTH, &aTestSizeZ);
if (aTestSizeX == 0 || aTestSizeY == 0 || aTestSizeZ == 0)
{
Unbind (theCtx);
return false;
}
#endif
GLint anInternal = theFormat.Internal();
if (anInternal == GL_R8_SNORM
|| anInternal == GL_R16_SNORM
|| anInternal == GL_RED_SNORM)
{
glPixelTransferf (GL_RED_SCALE, 0.5f);
glPixelTransferf (GL_RED_BIAS, 0.5f);
}
glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri (GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);
theCtx->core15fwd->glTexImage3D (GL_TEXTURE_3D,
0,
anInternal,
aSizeX,
aSizeY,
aSizeZ,
0,
theFormat.Format(),
theFormat.DataType(),
thePixels);
glPixelTransferf (GL_RED_SCALE, 1.0f);
glPixelTransferf (GL_RED_BIAS, 0.0f);
if (glGetError() != GL_NO_ERROR)
{
Unbind (theCtx);
return false;
}
mySizeX = aSizeX;
mySizeY = aSizeY;
mySizeZ = aSizeZ;
Unbind (theCtx);
return true;
}

View File

@@ -49,6 +49,37 @@ struct OpenGl_TextureFormatSelector<GLubyte>
return GL_NONE;
}
}
static GLint DataType()
{
return GL_UNSIGNED_BYTE;
}
};
template<>
struct OpenGl_TextureFormatSelector<GLbyte>
{
static GLint Internal (GLuint theChannels)
{
switch (theChannels)
{
case 1:
return GL_R8_SNORM;
case 2:
return GL_RG8_SNORM;
case 3:
return GL_RGB8_SNORM;
case 4:
return GL_RGBA8_SNORM;
default:
return GL_NONE;
}
}
static GLint DataType()
{
return GL_BYTE;
}
};
template<>
@@ -70,6 +101,37 @@ struct OpenGl_TextureFormatSelector<GLushort>
return GL_NONE;
}
}
static GLint DataType()
{
return GL_UNSIGNED_SHORT;
}
};
template<>
struct OpenGl_TextureFormatSelector<GLshort>
{
static GLint Internal (GLuint theChannels)
{
switch (theChannels)
{
case 1:
return GL_R16_SNORM;
case 2:
return GL_RG16_SNORM;
case 3:
return GL_RGB16_SNORM;
case 4:
return GL_RGBA16_SNORM;
default:
return GL_NONE;
}
}
static GLint DataType()
{
return GL_SHORT;
}
};
template<>
@@ -91,6 +153,63 @@ struct OpenGl_TextureFormatSelector<GLfloat>
return GL_NONE;
}
}
static GLint DataType()
{
return GL_FLOAT;
}
};
template<>
struct OpenGl_TextureFormatSelector<GLuint>
{
static GLint Internal (GLuint theChannels)
{
switch (theChannels)
{
case 1:
return GL_RED;
case 2:
return GL_RG;
case 3:
return GL_RGB;
case 4:
return GL_RGBA;
default:
return GL_NONE;
}
}
static GLint DataType()
{
return GL_UNSIGNED_INT;
}
};
template<>
struct OpenGl_TextureFormatSelector<GLint>
{
static GLint Internal (GLuint theChannels)
{
switch (theChannels)
{
case 1:
return GL_RED_SNORM;
case 2:
return GL_RG_SNORM;
case 3:
return GL_RGB_SNORM;
case 4:
return GL_RGBA_SNORM;
default:
return GL_NONE;
}
}
static GLint DataType()
{
return GL_INT;
}
};
//! Stores parameters of OpenGL texture format.
@@ -124,25 +243,36 @@ public:
return myInternal;
}
//! Returns OpenGL data type of the pixel data.
inline GLint DataType() const
{
return myDataType;
}
//! Returns texture format for specified type and number of channels.
template<class T, int N>
static OpenGl_TextureFormat Create()
{
return OpenGl_TextureFormat (N, OpenGl_TextureFormatSelector<T>::Internal (N));
return OpenGl_TextureFormat (N,
OpenGl_TextureFormatSelector<T>::Internal (N),
OpenGl_TextureFormatSelector<T>::DataType ());
}
private:
//! Creates new texture format.
OpenGl_TextureFormat (const GLint theChannels,
const GLint theInternal)
const GLint theInternal,
const GLint theDataType)
: myInternal (theInternal),
myChannels (theChannels) {}
myChannels (theChannels),
myDataType (theDataType) {}
private:
GLint myInternal; //!< OpenGL internal format of the pixel data
GLint myChannels; //!< Number of channels for each pixel (from 1 to 4)
GLint myDataType; //!< OpenGL data type of input pixel data
};
@@ -254,6 +384,14 @@ public:
const Standard_Integer theSizeY,
const OpenGl_TextureFormat& theFormat);
//! Initializes 3D texture rectangle with specified format and size.
Standard_EXPORT bool Init3D (const Handle(OpenGl_Context)& theCtx,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
const Standard_Integer theSizeZ,
const OpenGl_TextureFormat& theFormat,
const void* thePixels);
//! @return true if texture was generated within mipmaps
Standard_EXPORT const Standard_Boolean HasMipmaps() const;
@@ -273,9 +411,10 @@ public:
protected:
GLuint myTextureId; //!< GL resource ID
GLenum myTarget; //!< GL_TEXTURE_1D/GL_TEXTURE_2D
GLenum myTarget; //!< GL_TEXTURE_1D/GL_TEXTURE_2D/GL_TEXTURE_3D
GLsizei mySizeX; //!< texture width
GLsizei mySizeY; //!< texture height
GLsizei mySizeZ; //!< texture depth
GLenum myTextFormat; //!< texture format - GL_RGB, GL_RGBA,...
Standard_Boolean myHasMipmaps; //!< flag indicates that texture was uploaded with mipmaps
bool myIsAlpha; //!< indicates alpha format

View File

@@ -366,22 +366,6 @@ void OpenGl_View::GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, c
myGraduatedTrihedron.SetMinMax (theMin, theMax);
}
// =======================================================================
// function : ReadDepths
// purpose :
// =======================================================================
void OpenGl_View::ReadDepths (const Standard_Integer theX,
const Standard_Integer theY,
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Standard_Address theBuffer) const
{
if (myWindow.IsNull())
return;
myWindow->ReadDepths (theX, theY, theWidth, theHeight, (float*)theBuffer);
}
// =======================================================================
// function : BufferDump
// purpose :

View File

@@ -183,13 +183,6 @@ public:
//! @param theMax [in] the maximum point of scene.
Standard_EXPORT virtual void GraduatedTrihedronMinMaxValues (const Graphic3d_Vec3 theMin, const Graphic3d_Vec3 theMax) Standard_OVERRIDE;
//! Reads depths of shown pixels of the given rectangle.
Standard_EXPORT virtual void ReadDepths (const Standard_Integer theX,
const Standard_Integer theY,
const Standard_Integer theWidth,
const Standard_Integer theHeight,
const Standard_Address theBuffer) const Standard_OVERRIDE;
//! Dump active rendering buffer into specified memory buffer.
Standard_EXPORT virtual Standard_Boolean BufferDump (Image_PixMap& theImage,
const Graphic3d_BufferType& theBufferType) Standard_OVERRIDE;
@@ -674,10 +667,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 +784,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

@@ -1566,6 +1566,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");
@@ -1575,6 +1577,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);
@@ -2421,14 +2426,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)
{
@@ -2449,6 +2489,9 @@ Standard_Boolean OpenGl_View::runRaytraceShaders (const Standard_Integer
aRenderFramebuffer->ColorTexture()->Bind (
theGlContext, GL_TEXTURE0 + OpenGl_RT_PrevAccumTexture);
myOutImageProgram->SetUniform (theGlContext,
myUniformLocations[0][OpenGl_RT_uBilateralEnabled], myRenderParams.IsGIFilteringEnabled ? 1 : 0);
theGlContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
}
else if (myRenderParams.IsAntialiasingEnabled)

View File

@@ -463,7 +463,8 @@ void OpenGl_View::Redraw()
if (myRenderParams.Method == Graphic3d_RM_RAYTRACING
&& myRenderParams.IsGlobalIlluminationEnabled)
{
myAccumFrames++;
//myAccumFrames++;
myAccumFrames += myRenderParams.SamplesPerPixel ? myRenderParams.SamplesPerPixel : 1;
}
// bind default FBO

View File

@@ -702,47 +702,6 @@ void OpenGl_Window::Resize()
Init();
}
#endif // !__APPLE__
// =======================================================================
// function : ReadDepths
// purpose : TelReadDepths
// =======================================================================
void OpenGl_Window::ReadDepths (const Standard_Integer theX, const Standard_Integer theY,
const Standard_Integer theWidth, const Standard_Integer theHeight,
float* theDepths)
{
if (theDepths == NULL || !Activate())
return;
OpenGl_Mat4 aProjectMat;
Graphic3d_TransformUtils::Ortho2D (aProjectMat,
0.f, static_cast<GLfloat> (myWidth), 0.f, static_cast<GLfloat> (myHeight));
myGlContext->WorldViewState.Push();
myGlContext->ProjectionState.Push();
myGlContext->WorldViewState.SetIdentity();
myGlContext->ProjectionState.SetCurrent (aProjectMat);
myGlContext->ApplyProjectionMatrix();
myGlContext->ApplyWorldViewMatrix();
#if !defined(GL_ES_VERSION_2_0)
glRasterPos2i (theX, theY);
myGlContext->DisableFeatures();
glReadPixels (theX, theY, theWidth, theHeight, GL_DEPTH_COMPONENT, GL_FLOAT, theDepths);
myGlContext->EnableFeatures();
#endif
myGlContext->WorldViewState.Pop();
myGlContext->ProjectionState.Pop();
myGlContext->ApplyProjectionMatrix();
}
#if !defined(__APPLE__) || defined(MACOSX_USE_GLX)
// =======================================================================
// function : Init
// purpose :

View File

@@ -59,11 +59,6 @@ public:
//! Resizes the window.
Standard_EXPORT virtual void Resize();
//! Reads depth component for current scene into specified buffer.
void ReadDepths (const Standard_Integer theX, const Standard_Integer theY,
const Standard_Integer theWidth, const Standard_Integer theHeight,
float* theDepths);
Handle(Aspect_Window) PlatformWindow() { return myPlatformWindow; }
Standard_Integer Width() const { return myWidth; }

View File

@@ -984,6 +984,14 @@ const OpenGl_AspectFace* OpenGl_Workspace::AspectFace (const Standard_Boolean th
DisableTexture();
}
}
else
{
if (AspectFace_set->DoTextureMap())
{
EnableTexture (AspectFace_set->TextureRes (myGlContext),
AspectFace_set->TextureParams());
}
}
AspectFace_applied = AspectFace_set;
return AspectFace_set;

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

@@ -1,13 +1,62 @@
//! Input image.
uniform sampler2D uInputTexture;
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);
}
// 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)
@@ -720,7 +719,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

@@ -218,7 +218,7 @@ public:
Standard_EXPORT void SetContext (const Handle(ShapeBuild_ReShape)& context);
//! Returns context
Handle(ShapeBuild_ReShape) Context() const;
Standard_EXPORT Handle(ShapeBuild_ReShape) Context() const;
DEFINE_STANDARD_RTTI(ShapeFix_Edge,MMgt_TShared)

View File

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

View File

@@ -2163,108 +2163,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()
|| (hasSelection && !aStruct->IsHighlighted())
|| aStruct->IsEmpty())
{
continue;
}
Bnd_Box aBox = aStruct->MinMaxValues();
if (aBox.IsVoid() || aStruct->IsInfinite())
{
continue;
}
// use camera projection to find gravity point
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];
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)
{
for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
aStructIter.More(); aStructIter.Next())
{
const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
if (aStruct->IsEmpty())
{
continue;
}
Bnd_Box aBox = aStruct->MinMaxValues();
if (aBox.IsVoid() || aStruct->IsInfinite())
{
continue;
}
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();
}
//=======================================================================

View File

@@ -8273,6 +8273,8 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
theDI << "rayDepth: " << aParams.RaytracingDepth << "\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())
@@ -8372,6 +8374,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")
{
@@ -8458,6 +8502,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")
{

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