1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00
occt/tests/v3d/glsl/shading_models
anv dc89236fee 0029097: Visualization - allow picking Graphic3d_TypeOfShadingModel per-object
Graphic3d_AspectFillArea3d has been extended by new property ::ShadingModel(),
which is set to Graphic3d_TOSM_DEFAULT by default.
The new API allows assigning Shading Model to specific Primitive Array groups
instead of entire Viewer, which was the only possibility before.

Graphic3d_TypeOfShadingModel has been extended with Graphic3d_TOSM_DEFAULT value
meaining that Shading Model defined as default for the Viewer should be used.
Graphic3d_TOSM_NONE has been renamed to Graphic3d_TOSM_UNLIT.
Documentation of Shading Models has been improved by more details.

V3d_TypeOfShadingModel enumeration has been merged into Graphic3d_TypeOfShadingModel
avoiding duplicated definitions and confusion.
Old values has been left for compatibility with old code and can be marked deprecated in future.

Draw Harness command vaspects has been extended by new argument -setShadingModel
for testing Shading Models assigned to entire objects.

OpenGl_SetOfShaderPrograms now holds an array of Shading Models.
OpenGl_ShaderManager interface has been modified and now requires enumeration as input
in several places where Boolean flags have been used previously
(methods ::BindFaceProgram(), ::BindLineProgram(), ::BindMarkerProgram()).

OpenGl_Workspace now defines default (undefined) OpenGl_AspectFace as Graphic3d_TOSM_UNLIT
to simplify indication of primitive groups with undefined Fill Area aspects,
and so that Graphic3d_TOSM_UNLIT set as default Shading Model will not make artifacts on Lines and Markers.

AIS_Manipulator::Axis::Compute() - added missing initialization of Fill Area aspects (leading to undefined behavior).
2018-02-22 11:32:55 +03:00

46 lines
1.7 KiB
Plaintext

puts "========"
puts "Test various Shading Models assigned per-object"
puts "========"
# setup viewer
vclear
vclose ALL
vinit View1 -width 912 -height 912
# define spheres with a rough triangulation to easily distinguish Shading Models
psphere p1 10
copytranslate p2 p1 40 0 0
copytranslate p3 p1 20 20 0
copytranslate p4 p1 0 40 0
copytranslate p5 p1 40 40 0
compound p1 p2 p3 p4 p5 ss
incmesh ss 1
vdefaults -autoTriang 0
# display objects
vdisplay -dispMode 1 p1 p2 p3 p4 p5
vdrawparray p6 triangles v 0 55 0 v 0 75 0 v 20 55 0 v 0 55 0 v 0 75 0 v 0 55 20 v 0 55 0 v 0 55 20 v 20 55 0 v 0 75 0 v 0 55 20 v 20 55 0
vdrawparray p7 triangles v 40 55 0 v 40 75 0 v 60 55 0 v 40 55 0 v 40 75 0 v 40 55 20 v 40 55 0 v 40 55 20 v 60 55 0 v 40 75 0 v 40 55 20 v 60 55 0
vtop
vrotate -0.9 0.1 0
vfit
vdump $::imagedir/${::casename}_defaults.png
# customize shading models
vaspects p1 -setShadingModel VERTEX
vdrawtext t1 Graphic3d_TOSM_VERTEX -pos 10 5 10 -color RED -aspect BOLD
vaspects p2 -setShadingModel FRAGMENT
vdrawtext t2 Graphic3d_TOSM_FRAGMENT -pos 50 5 10 -color RED -aspect BOLD
vaspects p3 -setShadingModel DEFAULT
vdrawtext t3 Graphic3d_TOSM_DEFAULT -pos 30 25 10 -color RED -aspect BOLD
vaspects p4 -setShadingModel UNLIT
vdrawtext t4 Graphic3d_TOSM_UNLIT -pos 10 45 10 -color RED -aspect BOLD
vaspects p5 -setShadingModel FACET
vdrawtext t5 Graphic3d_TOSM_FACET -pos 50 45 10 -color RED -aspect BOLD
vaspects p6 -setShadingModel DEFAULT
vdrawtext t6 Graphic3d_TOSM_DEFAULT -pos 10 65 10 -color RED -aspect BOLD
vaspects p7 -setShadingModel FACET
vdrawtext t7 Graphic3d_TOSM_FACET -pos 50 65 10 -color RED -aspect BOLD
vdisplay -topmost t1 t2 t3 t4 t5 t6 t7
vdump $::imagedir/${::casename}.png