View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0024192 | Open CASCADE | OCCT:Visualization | public | 2013-09-19 11:40 | 2021-04-09 12:10 |
Reporter | Assigned To | ||||
Priority | normal | Severity | feature | ||
Status | closed | Resolution | fixed | ||
Platform | A | OS | L | ||
Target Version | 6.7.0 | Fixed in Version | 6.7.0 | ||
Summary | 0024192: Adding support for shaders to OCCT visualization toolkit | ||||
Description | The purpose of this feature is implementing the following functionality: 1. Support of both modern (3.0 and higher) and old versions of OpenGL and GLSL. Interoperability between 'old' and 'new' shader sources - by implementing custom shader programming interface. 2. Setting individual shader programs for different types of primitives. 3. Possibility of setting shader program 'by default', for presentation and for individual group inside presentation. 4. Possibility of manipulating shaders from application level, including adding and removing shader programs and setting non-standard shader variables. Thus, application developer can implement custom rendering techniques. | ||||
Additional information and documentation updates | The purpose of this feature is adding support of GLSL shaders to OCCT visualization core. Shaders allow to implement different rendering effects on graphics hardware with a high degree of flexibility, such as per-pixel lighting, custom shading models, bump mapping, procedural texturing and others. Currently OCCT supports only vertex and fragment GLSL shader, but this functionality will be extended in future releases. To set custom vertex and fragment GLSL shaders in DRAW the following command is used: vshaderprog <ShapeName> <Path to Vertex Shader> <Path to Fragment Shader> To detach shader program from specific shape, use the following command: vshaderprog <ShapeName> off Note, that to execute shader programs the OpenGL 2.0+ GPU is required. To enable custom shader for specific AISShape in your application, the following API functions are used: // Create shader program Handle(Graphic3d_ShaderProgram) aProgram = new Graphic3d_ShaderProgram(); // Attach vertex shader aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromFile( Graphic3d_TOS_VERTEX, "<Path to VS>")); // Attach fragment shader aProgram->AttachShader (Graphic3d_ShaderObject::CreateFromFile( Graphic3d_TOS_FRAGMENT, "<Path to FS>")); // Set values for custom uniform variables (if they are) aProgram->PushVariable ("MyColor", Graphic3d_Vec3(0.f, 1.f, 0.f)); // Set aspect property for specific AISShape AISShape->Attributes()->ShadingAspect()->Aspect()->SetShaderProgram (aProgram); | ||||
Tags | No tags attached. | ||||
Test case number | Not needed | ||||
parent of | 0024241 | closed | Open CASCADE | Adding shaders directory to OCCT resources | |
parent of | 0030126 | assigned | Open CASCADE | Visualization, Graphic3d_ShaderManager - define standard Lighting & Clipping within custom GLSL programs as template functions | |
parent of | 0031715 | closed | bugmaster | Open CASCADE | Visualization, OpenGl_ShaderProgram - add access to proxy shader program |
parent of | 0032289 | closed | bugmaster | Open CASCADE | Visualization - add NCollection_Mat3 for 3x3 matrix similar to NCollection_Mat4 |
related to | 0024228 | closed | Open CASCADE | TKOpenGL - destroy GL context at view close | |
related to | 0026275 | closed | bugmaster | Open CASCADE | Visualization, TKOpenGl - add public constructor for OpenGl_ShaderProgram |
Not all the children of this issue are yet resolved or closed. |
|
Dear dbp, please post/attach the following info as soon as patch will be available: - Image comparison on several test cases (with/without shaders). - Performance comparison (including CPU times) on several test cases (including big number of simple objects with different presentation mode / interleaved presentation mode). |
|
Dear kgv, Preliminary version of shader fucntionality is ready for review (branch CR24192_2). Could you please have a look at it? |
|
Dear apl, the patch CR24192 is ready for review (branch CR24192). Could you please have a look at it? |
|
Dear Bugmaster, The branch CR24192 is ready for tests. Please test. |
|
Dear BugMaster, Branch CR24192 (and products from GIT master) was compiled on Linux and Windows platforms. There is compilation error on Linux platform: http://jenkins-test-02.nnov.opencascade.com:8080/user/mnt/my-views/view/CR24192/job/mnt-CR24192-master_build_occt_linux/1/parsed_console/? In file included from ../../../../inc/Graphic3d_ShaderVariable.hxx:179, from ../../../../inc/Graphic3d_ShaderProgram.hxx:25, from ../../../../src/Graphic3d/Graphic3d_Group_8.cxx:49: ../../../../inc/Graphic3d_ShaderVariable_Impl.lxx:61: error: cannot declare member function ‘static Graphic3d_ShaderVariable* Graphic3d_ShaderVariable::Create(const TCollection_AsciiString&, const T&)’ to have static linkage make[2]: *** [Graphic3d_Group_8.lo] Error 1 |
|
Patch CR24192 has been updated. |
|
Dear Bugmaster, The compilation error corrected. Please proceed. |
|
According to frame rate comparison, there is no a performance regression when the feature is not used (no shader programs are used). The results shown for 6400 small boxes. Before the patch: ---------------------------------- FPS: 56.800739991127884 CPU: 17.78411399999996 msec After the patch: ---------------------------------- FPS: 58.451109685153412 CPU: 17.31611099999995 msec For performance estimation the following script was used: pload ALL vinit w=1024 h=768 vsetdispmode 1 set N 1 for {set X 1} {$X <= 80} {incr X} { for {set Y 1} {$Y <= 80} {incr Y} { box b${N} [expr $X * 20] [expr $Y * 20] [expr 50 * ( sin($X) + sin($Y) )] 10 10 25; vdisplay b${N}; incr N; } } vfit vfps |
|
Then using individual 'Phong Shading' shader (per-pixel lighting) for each box, the performance regression for previous test is about 50% (6400 boxes): FPS: 28.340777629084517 CPU: 35.256225999999913 msec Then using the same 'Phong Shading' shader program (per-pixel lighting) for all boxes, the performance regression is about 33%: FPS: 37.848268270758574 CPU: 26.208168000000001 msec Then using the same 'Gouraud Shading' shader program (per-vertex lighting like FFP) for all boxes, the performance regression is about 14%: FPS: 48.030730269723115 CPU: 20.904133999999885 msec So, it seems that shader functionality does not increase the CPU load significantly. Simple profiling showed, that performance decrease is largely due to switching graphics pipeline state (calling of glUseProgram). All tests were performed with Windows 7 PC: Core i5 3.1 GHz, AMD Radeon 7870. |
|
Could you please test also on some real-case model, like Vessel_Head? |
|
For real-life shape with fine tesselation (6M triangles) the results are the following. Before the patch ---------------------------------- FPS: 137.43942063408832 CPU: 5.6160359999999798 msec After the patch (NO shaders) ---------------------------------- FPS: 145.7065051774959 CPU: 5.9280379999999866 msec After the patch + 'Gouraud Shading' shader ------------------------------------------- FPS: 143.91671800136763 CPU: 5.6160359999999798 msec After the patch + 'Phong Shading' shader ------------------------------------------- FPS: 143.1793642049785 CPU: 6.2400399999999934 msec So, then using custom shaders for single object (or small number of objects) thre is no performance regression. |
2013-10-10 17:00 developer |
Normal.vs (211 bytes) |
2013-10-10 17:00 developer |
Normal.fs (85 bytes) |
|
For testing shader functionality the simplest 'Normal' shaders can be used (attached to this issue). To set up custom shader program for AIS interactive object, the following DRAW script can be used: pload ALL vinit vsetdispmode 1 restore <PATH TO SHAPE> SHAPE vdisplay SHAPE vshaderprog SHAPE <PATH TO VERTEX SHADER> <PATH TO FRAGMENT SHADER> |
|
Dear BugMaster, Branch CR24192 (and products from GIT master) was compiled on Linux and Windows platforms. There is compilation error on Linux platform: http://jenkins-test-02.nnov.opencascade.com:8080/user/mnt/my-views/view/CR24192/job/mnt-CR24192-master_build_occt_linux/1/parsed_console/? ../../../../src/Graphic3d/Graphic3d_ShaderVariable.cxx:30: error: expected unqualified-id before ‘;’ token ../../../../src/Graphic3d/Graphic3d_ShaderVariable.cxx:31: error: expected unqualified-id before ‘;’ token ../../../../src/Graphic3d/Graphic3d_ShaderVariable.cxx:32: error: expected unqualified-id before ‘;’ token ../../../../src/Graphic3d/Graphic3d_ShaderVariable.cxx:33: error: expected unqualified-id before ‘;’ token ../../../../src/Graphic3d/Graphic3d_ShaderVariable.cxx:34: error: expected unqualified-id before ‘;’ token ../../../../src/Graphic3d/Graphic3d_ShaderVariable.cxx:35: error: expected unqualified-id before ‘;’ token ../../../../src/Graphic3d/Graphic3d_ShaderVariable.cxx:36: error: expected unqualified-id before ‘;’ token ../../../../src/Graphic3d/Graphic3d_ShaderVariable.cxx:37: error: expected unqualified-id before ‘;’ token make[2]: *** [Graphic3d_ShaderVariable.lo] Error 1 |
|
Dear dbp, The solution for proper initialization of resources is implemented in branch CR24192. The branch is based on CR24228 (the original version of the patch for resources). Could you please review it? |
|
Dear Bugmaster, The compilation error was corrected (branch CR24192). Please proceed. |
|
Dear BugMaster, Branch CR24192 (and products from GIT master) was compiled on Linux and Windows platforms and tested. SHA-1: 14a2a50abeb4268a8dfe48b8c663355575ebec90 Number of compiler warnings: occt component : Linux: 365 (368 on master) Windows: 6 (6 on master) products component : Linux: 189 (190 on master) Windows: 287 (287 on master) Regressions/Differences: http://occt-tests/CR24192-master-occt/Windows-32-VC9/bugs/vis/bug23654_MarkersRecompute.html bugs vis(004) bug23654_MarkersRecompute: FAILED (exception) Testing cases: Not needed Testing on Linux: Total MEMORY difference: 355386952 / 353811788 Total CPU difference: 41218.42000000063 / 42952.64000000077 Testing on Windows: Total MEMORY difference: 407624752 / 406995556 Total CPU difference: 25346.65625 / 37404.296875 There are not differences in images found by testdiff. |
|
Dear dbp, The branch CR24192 is rebased for the current state of CR24228. CR24228 improves approach to managing resources and contains changes necessary for CR24192. The reported problem is already fixed in its current state. Please review. |
|
Dear Bugmaster, please re-test (branch CR24192). |
|
Dear mkv, The crash in DrawElements function when using shaders is produced by Mesa's software OpenGL implementation. Patch is ok, and testing my be continued. |
|
Dear BugMaster, Branch CR24192 (and products from GIT master) was compiled on Linux and Windows platforms and tested. SHA-1: 7c67468be1f9f118485f2fd42484b7b4c42c57a2 Number of compiler warnings: occt component : Linux: 362 (368 on master) Windows: 6 (6 on master) products component : Linux: 189 (190 on master) Windows: 287 (287 on master) Regressions/Differences: No regressions/differences Testing cases: Not needed Testing on Linux: Total MEMORY difference: 355499732 / 353799020 Total CPU difference: 43739.12000000061 / 42953.02000000077 Testing on Windows: Total MEMORY difference: 408358948 / 407073520 Total CPU difference: 31213.734375 / 37415.03125 There are not differences in images found by testdiff. |
|
Dear dbp, Please fill in description sections. |
occt: master 30f0ad28 2013-10-21 07:47:10
Committer: abv Details Diff |
0024192: Adding support for shaders to OCCT visualization toolkit |
Affected Issues 0024192 |
|
mod - src/Graphic3d/FILES | Diff File | ||
mod - src/Graphic3d/Graphic3d.cdl | Diff File | ||
mod - src/Graphic3d/Graphic3d_AspectFillArea3d.cdl | Diff File | ||
mod - src/Graphic3d/Graphic3d_AspectFillArea3d.cxx | Diff File | ||
mod - src/Graphic3d/Graphic3d_AspectLine3d.cdl | Diff File | ||
mod - src/Graphic3d/Graphic3d_AspectLine3d.cxx | Diff File | ||
mod - src/Graphic3d/Graphic3d_AspectMarker3d.cdl | Diff File | ||
mod - src/Graphic3d/Graphic3d_AspectMarker3d.cxx | Diff File | ||
mod - src/Graphic3d/Graphic3d_AspectText3d.cdl | Diff File | ||
mod - src/Graphic3d/Graphic3d_AspectText3d.cxx | Diff File | ||
mod - src/Graphic3d/Graphic3d_CGroup.hxx | Diff File | ||
mod - src/Graphic3d/Graphic3d_Group_8.cxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderObject.cxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderObject.hxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderObject_Handle.hxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderProgram.cxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderProgram.hxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderProgram_Handle.hxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderVariable.cxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderVariable.hxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderVariable.lxx | Diff File | ||
add - src/Graphic3d/Graphic3d_ShaderVariable_Handle.hxx | Diff File | ||
add - src/Graphic3d/Graphic3d_TypeOfShaderObject.hxx | Diff File | ||
mod - src/InterfaceGraphic/InterfaceGraphic_Graphic3d.hxx | Diff File | ||
mod - src/NCollection/FILES | Diff File | ||
add - src/NCollection/NCollection_Mat4.hxx | Diff File | ||
mod - src/OpenGl/FILES | Diff File | ||
add - src/OpenGl/Handle_OpenGl_ShaderManager.hxx | Diff File | ||
add - src/OpenGl/Handle_OpenGl_ShaderObject.hxx | Diff File | ||
add - src/OpenGl/Handle_OpenGl_ShaderProgram.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_AspectFace.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_AspectFace.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_AspectLine.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_AspectLine.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_AspectMarker.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_AspectMarker.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_AspectText.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_AspectText.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_Context.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_Context.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_GraphicDriver_Layer.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_Group.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_PrimitiveArray.cxx | Diff File | ||
add - src/OpenGl/OpenGl_ShaderManager.cxx | Diff File | ||
add - src/OpenGl/OpenGl_ShaderManager.hxx | Diff File | ||
add - src/OpenGl/OpenGl_ShaderObject.cxx | Diff File | ||
add - src/OpenGl/OpenGl_ShaderObject.hxx | Diff File | ||
add - src/OpenGl/OpenGl_ShaderProgram.cxx | Diff File | ||
add - src/OpenGl/OpenGl_ShaderProgram.hxx | Diff File | ||
add - src/OpenGl/OpenGl_ShaderStates.cxx | Diff File | ||
add - src/OpenGl/OpenGl_ShaderStates.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_Structure.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_Structure.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_Text.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_TextFormatter.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_Trihedron.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_Vec.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_View.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_View.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_View_2.cxx | Diff File | ||
mod - src/OpenGl/OpenGl_Workspace.hxx | Diff File | ||
mod - src/OpenGl/OpenGl_Workspace_5.cxx | Diff File | ||
add - src/Shaders/Declarations.glsl | Diff File | ||
mod - src/ViewerTest/ViewerTest.cxx | Diff File |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-09-19 11:40 |
|
New Issue | |
2013-09-19 11:40 |
|
Assigned To | => san |
2013-10-04 17:10 |
|
Assigned To | san => dbp |
2013-10-04 17:10 |
|
Status | new => assigned |
2013-10-08 13:03 | kgv | Note Added: 0025955 | |
2013-10-08 15:29 |
|
Relationship added | parent of 0024241 |
2013-10-08 17:12 |
|
Note Added: 0025973 | |
2013-10-08 17:12 |
|
Assigned To | dbp => kgv |
2013-10-08 17:12 |
|
Status | assigned => resolved |
2013-10-09 08:48 | kgv | Assigned To | kgv => dbp |
2013-10-09 08:48 | kgv | Status | resolved => assigned |
2013-10-09 19:10 |
|
Note Added: 0026001 | |
2013-10-09 19:10 |
|
Assigned To | dbp => apl |
2013-10-09 19:10 |
|
Status | assigned => resolved |
2013-10-09 21:43 |
|
Note Added: 0026002 | |
2013-10-09 21:43 |
|
Assigned To | apl => bugmaster |
2013-10-09 21:43 |
|
Status | resolved => reviewed |
2013-10-10 08:34 |
|
Assigned To | bugmaster => mkv |
2013-10-10 08:34 |
|
Note Added: 0026004 | |
2013-10-10 08:35 |
|
Assigned To | mkv => dbp |
2013-10-10 08:35 |
|
Status | reviewed => assigned |
2013-10-10 10:56 | kgv | Note Added: 0026015 | |
2013-10-10 12:49 |
|
Assigned To | dbp => apl |
2013-10-10 12:49 |
|
Status | assigned => resolved |
2013-10-10 12:51 |
|
Note Added: 0026020 | |
2013-10-10 12:51 |
|
Assigned To | apl => bugmaster |
2013-10-10 12:51 |
|
Status | resolved => reviewed |
2013-10-10 13:52 |
|
Assigned To | bugmaster => mkv |
2013-10-10 15:38 |
|
Note Added: 0026025 | |
2013-10-10 16:11 |
|
Note Added: 0026029 | |
2013-10-10 16:25 |
|
Note Added: 0026031 | |
2013-10-10 16:42 |
|
Note Edited: 0026029 | |
2013-10-10 16:47 |
|
Note Edited: 0026029 | |
2013-10-10 16:56 |
|
Note Added: 0026032 | |
2013-10-10 17:00 |
|
File Added: Normal.vs | |
2013-10-10 17:00 |
|
File Added: Normal.fs | |
2013-10-10 17:04 |
|
Note Added: 0026033 | |
2013-10-11 06:58 |
|
Note Added: 0026036 | |
2013-10-11 06:59 |
|
Assigned To | mkv => dbp |
2013-10-11 06:59 |
|
Status | reviewed => assigned |
2013-10-17 15:28 |
|
Relationship added | related to 0024228 |
2013-10-17 19:30 |
|
Note Added: 0026130 | |
2013-10-17 19:30 |
|
Status | assigned => resolved |
2013-10-18 14:06 |
|
Note Added: 0026141 | |
2013-10-18 14:06 |
|
Assigned To | dbp => bugmaster |
2013-10-18 14:06 |
|
Status | resolved => reviewed |
2013-10-18 14:37 |
|
Assigned To | bugmaster => mkv |
2013-10-21 12:18 |
|
Note Added: 0026156 | |
2013-10-21 12:18 |
|
Test case number | => Not needed |
2013-10-21 12:18 |
|
Assigned To | mkv => apl |
2013-10-21 12:18 |
|
Status | reviewed => assigned |
2013-10-21 12:37 |
|
Note Added: 0026157 | |
2013-10-21 12:37 |
|
Assigned To | apl => dbp |
2013-10-21 12:37 |
|
Status | assigned => resolved |
2013-10-21 12:55 |
|
Note Added: 0026158 | |
2013-10-21 12:55 |
|
Assigned To | dbp => bugmaster |
2013-10-21 12:55 |
|
Status | resolved => reviewed |
2013-10-21 13:39 | bugmaster | Assigned To | bugmaster => mkv |
2013-10-21 13:42 |
|
Assigned To | mkv => dbp |
2013-10-21 13:42 |
|
Status | reviewed => feedback |
2013-10-21 14:25 |
|
Note Added: 0026167 | |
2013-10-21 14:25 |
|
Assigned To | dbp => mkv |
2013-10-21 14:25 |
|
Status | feedback => reviewed |
2013-10-22 09:55 |
|
Target Version | => 6.7.0 |
2013-10-23 08:46 |
|
Note Added: 0026224 | |
2013-10-23 08:47 |
|
Assigned To | mkv => bugmaster |
2013-10-23 08:47 |
|
Status | reviewed => tested |
2013-10-23 09:03 |
|
Note Added: 0026231 | |
2013-10-25 14:42 |
|
Changeset attached | => occt master 30f0ad28 |
2013-10-25 14:42 |
|
Assigned To | bugmaster => abv |
2013-10-25 14:42 |
|
Status | tested => verified |
2013-10-25 14:42 |
|
Resolution | open => fixed |
2013-10-28 17:17 |
|
Additional Information Updated | |
2013-12-19 13:51 | bugmaster | Status | verified => closed |
2013-12-19 13:58 | bugmaster | Fixed in Version | => 6.7.0 |
2015-05-29 12:16 | kgv | Relationship added | related to 0026275 |
2018-09-11 14:13 | kgv | Relationship added | parent of 0030126 |
2020-08-18 16:08 | kgv | Relationship added | parent of 0031715 |
2021-04-09 12:10 | kgv | Relationship added | parent of 0032289 |