1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

0028762: Visualization, Ray tracing - Implement depth-of-field effect

Graphic3d_RenderingParams - introduced new parameters CameraFocalPlaneDist and CameraApertureRadius managing DOF effect.
TKOpenGl - added new ray generation logic to RaytraceBase.fs.
vrenderparams command - added -focal and -aperture parameters.
OpenGl_View.hxx - function for ray generating was split into two functions (ray tracing and path tracing).
OpenGl_View_Raytrace.cxx - fixed interaction between adaptive sampling and stereo camera
This commit is contained in:
duv
2017-06-27 11:22:31 +03:00
committed by bugmaster
parent 475c2302d4
commit b27ab03d09
9 changed files with 588 additions and 45 deletions

View File

@@ -645,8 +645,10 @@ protected: //! @name data types related to ray-tracing
{
OpenGl_RT_OutputImageLft = 0,
OpenGl_RT_OutputImageRgh = 1,
OpenGl_RT_VisualErrorImage = 2,
OpenGl_RT_TileOffsetsImage = 3
OpenGl_RT_VisualErrorImageLft = 2,
OpenGl_RT_VisualErrorImageRgh = 3,
OpenGl_RT_TileOffsetsImageLft = 4,
OpenGl_RT_TileOffsetsImageRgh = 5
};
//! Tool class for management of shader sources.
@@ -742,6 +744,9 @@ protected: //! @name data types related to ray-tracing
//! Number of tiles in Y dimension (in adaptive sampling mode).
Standard_Integer NbTilesY;
//! Enables/disables depth-of-field effect (path tracing, perspective camera).
Standard_Boolean DepthOfField;
//! Tone mapping method for path tracing.
Graphic3d_ToneMappingMethod ToneMappingMethod;
@@ -758,6 +763,7 @@ protected: //! @name data types related to ray-tracing
RadianceClampingValue (30.0),
NbTilesX (16),
NbTilesY (16),
DepthOfField (Standard_False),
ToneMappingMethod (Graphic3d_ToneMappingMethod_Disabled) { }
};
@@ -900,6 +906,7 @@ protected: //! @name methods related to ray-tracing
const Handle(OpenGl_Context)& theGlContext);
//! Generates viewing rays for corners of screen quad.
//! (ray tracing; path tracing for orthographic camera)
void updateCamera (const OpenGl_Mat4& theOrientation,
const OpenGl_Mat4& theViewMapping,
OpenGl_Vec3* theOrigins,
@@ -907,6 +914,15 @@ protected: //! @name methods related to ray-tracing
OpenGl_Mat4& theView,
OpenGl_Mat4& theUnView);
//! Generate viewing rays (path tracing, perspective camera).
void updatePerspCameraPT(const OpenGl_Mat4& theOrientation,
const OpenGl_Mat4& theViewMapping,
Graphic3d_Camera::Projection theProjection,
OpenGl_Mat4& theViewPr,
OpenGl_Mat4& theUnview,
const int theWinSizeX,
const int theWinSizeY);
//! Binds ray-trace textures to corresponding texture units.
void bindRaytraceTextures (const Handle(OpenGl_Context)& theGlContext);
@@ -917,6 +933,7 @@ protected: //! @name methods related to ray-tracing
Standard_Boolean setUniformState (const Standard_Integer theProgramId,
const Standard_Integer theSizeX,
const Standard_Integer theSizeY,
Graphic3d_Camera::Projection theProjection,
const Handle(OpenGl_Context)& theGlContext);
//! Runs ray-tracing shader programs.
@@ -1027,12 +1044,12 @@ protected: //! @name fields related to ray-tracing
//! Used if adaptive screen sampling is activated.
Handle(OpenGl_Texture) myRaytraceOutputTexture[2];
//! Texture containing per-tile visual error estimation.
//! Texture containing per-tile visual error estimation (2 textures are used in stereo mode).
//! Used if adaptive screen sampling is activated.
Handle(OpenGl_Texture) myRaytraceVisualErrorTexture;
//! Texture containing offsets of sampled screen tiles.
Handle(OpenGl_Texture) myRaytraceVisualErrorTexture[2];
//! Texture containing offsets of sampled screen tiles (2 textures are used in stereo mode).
//! Used if adaptive screen sampling is activated.
Handle(OpenGl_Texture) myRaytraceTileOffsetsTexture;
Handle(OpenGl_Texture) myRaytraceTileOffsetsTexture[2];
//! Vertex buffer (VBO) for drawing dummy quad.
OpenGl_VertexBuffer myRaytraceScreenQuad;
@@ -1070,6 +1087,27 @@ protected: //! @name fields related to ray-tracing
//! Tool object for sampling screen tiles in PT mode.
OpenGl_TileSampler myTileSampler;
//! Camera position used for projective mode
OpenGl_Vec3 myEyeOrig;
//! Camera view direction used for projective mode
OpenGl_Vec3 myEyeView;
//! Camera's screen vertical direction used for projective mode
OpenGl_Vec3 myEyeVert;
//! Camera's screen horizontal direction used for projective mode
OpenGl_Vec3 myEyeSide;
//! Camera's screen size used for projective mode
OpenGl_Vec2 myEyeSize;
//! Aperture radius of camera on previous frame used for depth-of-field (path tracing)
float myPrevCameraApertureRadius;
//! Focal distance of camera on previous frame used for depth-of-field (path tracing)
float myPrevCameraFocalPlaneDist;
public:
DEFINE_STANDARD_ALLOC