mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0027925: Visualization - implement order-independent transparency algorithm within rasterization rendering
Weighted, Blended Order-Independent Transparency algorithm has been added rasterization pipeline. In contrast to classical blending transparency it makes transparent objects look independent from point of view. It also gives better depth occlusion when being used together with a weight factor based on value of a GL depth buffer. The feature supports desktop OpenGL, OpenGL ES 3.0, ANGLE and can be used together with MSAA on desktop GL. To be used it require availability of: 1) Shaders pipeline. 2) Floating point color format for framebuffer (GL_ARB_color_buffer_float). 3) Multiple render targets (GL_ARB_draw_buffers). Patch does not modify API and does not require application porting. It adds new rendering options to Graphic3d_RenderingParams structure: a) Transparency method from enumeration. b) Scalar factor [0-1] controlling influence of a fragment's depth to its visibility. Patch also simplifies processing of transparent objects for standard method: rendering priority of transparent graphical structures is managed automatically, therefore there is no need to care about it at application's side.
This commit is contained in:
@@ -70,9 +70,11 @@ Standard_CString OpenGl_ShaderProgram::PredefinedKeywords[] =
|
||||
"occBackMaterial", // OpenGl_OCCT_BACK_MATERIAL
|
||||
"occColor", // OpenGl_OCCT_COLOR
|
||||
|
||||
"occOitOutput", // OpenGl_OCCT_OIT_OUTPUT
|
||||
"occOitDepthFactor", // OpenGl_OCCT_OIT_DEPTH_FACTOR
|
||||
|
||||
"occTexTrsf2d", // OpenGl_OCCT_TEXTURE_TRSF2D
|
||||
"occPointSize" // OpenGl_OCCT_POINT_SIZE
|
||||
|
||||
};
|
||||
|
||||
// =======================================================================
|
||||
@@ -204,11 +206,43 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
}
|
||||
|
||||
TCollection_AsciiString aSource = aDeclarations + anIter.Value()->Source();
|
||||
TCollection_AsciiString anExtensions = "// This section enables extensions used in OCCT GLSL programs\n";
|
||||
if (theCtx->hasDrawBuffers)
|
||||
{
|
||||
anExtensions += "#define OCC_ENABLE_draw_buffers\n";
|
||||
}
|
||||
if (theCtx->hasDrawBuffers == OpenGl_FeatureInExtensions)
|
||||
{
|
||||
if (theCtx->arbDrawBuffers)
|
||||
{
|
||||
anExtensions += "#extension GL_ARB_draw_buffers : enable\n";
|
||||
}
|
||||
else if (theCtx->extDrawBuffers)
|
||||
{
|
||||
anExtensions += "#extension GL_EXT_draw_buffers : enable\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (theCtx->hasSampleVariables == OpenGl_FeatureInExtensions)
|
||||
{
|
||||
#if defined(GL_ES_VERSION_2_0)
|
||||
if (theCtx->oesSampleVariables)
|
||||
{
|
||||
anExtensions += "#extension GL_OES_sample_variables : enable\n";
|
||||
}
|
||||
#else
|
||||
if (theCtx->arbSampleShading)
|
||||
{
|
||||
anExtensions += "#extension GL_ARB_sample_shading : enable\n";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (anIter.Value()->Type())
|
||||
{
|
||||
case Graphic3d_TOS_VERTEX:
|
||||
{
|
||||
aSource = aHeader + TCollection_AsciiString ("#define VERTEX_SHADER\n") + aSource;
|
||||
aSource = aHeader + TCollection_AsciiString ("#define VERTEX_SHADER\n") + anExtensions + aSource;
|
||||
break;
|
||||
}
|
||||
case Graphic3d_TOS_FRAGMENT:
|
||||
@@ -219,9 +253,9 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
"precision highp int;\n"
|
||||
: "precision mediump float;\n"
|
||||
"precision mediump int;\n");
|
||||
aSource = aHeader + aPrefix + aSource;
|
||||
aSource = aHeader + aPrefix + anExtensions + aSource;
|
||||
#else
|
||||
aSource = aHeader + aSource;
|
||||
aSource = aHeader + anExtensions + aSource;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -229,6 +263,7 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
|
||||
if (!aShader->LoadSource (theCtx, aSource))
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aSource);
|
||||
const TCollection_ExtendedString aMsg = "Error! Failed to set shader source";
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION,
|
||||
GL_DEBUG_TYPE_ERROR,
|
||||
@@ -241,6 +276,7 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
|
||||
|
||||
if (!aShader->Compile (theCtx))
|
||||
{
|
||||
theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH, aSource);
|
||||
TCollection_AsciiString aLog;
|
||||
aShader->FetchInfoLog (theCtx, aLog);
|
||||
if (aLog.IsEmpty())
|
||||
|
Reference in New Issue
Block a user