1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-04 18:06:22 +03:00
occt/samples/tcl/materials.tcl
dbp 44c7c33eb0 0024855: Revision of parameters of standard materials
Improve consistency and visual appearance of predefined OCCT materials in various rendering modes, including ray-tracing:
- Increase the specular exponents (shininesses) for metallic surfaces: Brass, Bronze, Copper, Gold, Pewter, Silver, Steel, Chrome, Aluminum.
- Revise specular colors for metals: Copper, Gold, Aluminum, Silver (according to "Real-Time Rendering, 3rd Edition", AK Peters 2008).
- Increase diffuse reflection of metals: Silver, Aluminum, Chrome (to make them brighter in OpenGL mode).
- Extend Material definition by Refraction Index.
  Advanced rendering methods based on shaders or ray-tracing can utilize it to produce refraction effects.

In addition:
- Introduce three translucent materials: Water, Glass, and Diamond.
- Add Charcoal for modeling dark diffuse surfaces.

Add new TCL-based sample (materials.tcl) and test case (tests/v3d/materials/bug24855).
2014-05-15 19:59:28 +04:00

88 lines
2.0 KiB
Tcl

# Script displays properties of different materials available in OCCT
set THE_MATERIALS {brass bronze copper gold jade neon_phc pewter obsidian plaster plastic satin silver steel stone chrome aluminium water glass diamond charcoal}
set THE_COLORS {default red green blue1}
set THE_ROW_DIST 35
proc drawLabels {} {
set x 20
set y 15
set r 25
set g 25
set b 25
foreach aMatIter $::THE_MATERIALS {
vdrawtext "$aMatIter" $x $y 0 $r $g $b 2 1 000 0 14 1 Arial
incr y 10
}
set x 40
set y 5
foreach aColIter $::THE_COLORS {
if { $aColIter == "red" } {
set r 255
set g 0
set b 0
} elseif { $aColIter == "green" } {
set r 0
set g 255
set b 0
} elseif { $aColIter == "blue1" } {
set r 0
set g 0
set b 255
}
vdrawtext "$aColIter" $x $y 0 $r $g $b 1 1 000 0 14 1 Arial
incr x $::THE_ROW_DIST
}
}
proc drawObjects {theRow theColor} {
set aSize 4
set aCtr -2
set aCounter 0
set x [expr 30 + $theRow * $::THE_ROW_DIST]
set y 15
foreach aMatIter $::THE_MATERIALS {
set aSph s${theRow}_${aCounter}
set aBox b${theRow}_${aCounter}
uplevel #0 psphere $aSph $aSize
uplevel #0 box $aBox $aCtr $aCtr $aCtr $aSize $aSize $aSize
uplevel #0 ttranslate $aSph $x $y 0
uplevel #0 ttranslate $aBox [expr $x + 10] $y 0
uplevel #0 vdisplay -noredraw $aSph $aBox
uplevel #0 vsetmaterial -noredraw $aSph $aBox $aMatIter
if {$theColor != ""} {
uplevel #0 vsetcolor -noredraw $aSph $aBox $theColor
}
incr aCounter
incr y 10
}
}
# setup 3D viewer content
pload MODELING VISUALIZATION
catch { vclose View1 }
vinit View1 w=768 h=768
vclear
vtop
vglinfo
vsetgradientbg 180 200 255 180 180 180 2
vlight change 0 pos -1 1 1
vsetdispmode 1
# adjust scene bounding box
box bnd 0 0 0 180 210 1
vdisplay -noredraw bnd
vsetdispmode bnd 0
vfit
vremove -noredraw bnd
# draw spheres and boxes with different materials
drawLabels
drawObjects 0 ""
drawObjects 1 red
drawObjects 2 green
drawObjects 3 blue1
#vfit
vzfit