mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-24 13:50:49 +03:00
0027974: Visualization, ray tracing - Improve ray tracing engine
* Multiple importance sampling for path tracing * Improved light sources sampling (better handling several light sources) * Fixed issues in light source intersection (light distance is taken into account) * Add new TCL sample - OCCT Ball model for demonstrating physically-based materials * Fix potential issue on NVIDIA GPUs ("Error: Failed to upload light source buffer") * Path tracing materials reviewed; directional light source was smoother by default
This commit is contained in:
78
samples/tcl/pathtrace_ball.tcl
Normal file
78
samples/tcl/pathtrace_ball.tcl
Normal file
@@ -0,0 +1,78 @@
|
||||
# Script demonstrating Global illumination materials
|
||||
# using path tracing rendering engine in 3D view
|
||||
|
||||
#Category: Visualization
|
||||
#Title: Path tracing - Ball
|
||||
|
||||
set aBallPath [locate_data_file occ/Ball.brep]
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
|
||||
# Setup 3D viewer
|
||||
vclear
|
||||
vinit name=View1 w=512 h=512
|
||||
vglinfo
|
||||
vvbo 0
|
||||
vsetdispmode 1
|
||||
|
||||
# Setup view parameters
|
||||
vcamera -persp
|
||||
vviewparams -scale 18 -eye 44.49 -0.15 33.93 -at -14.20 -0.15 1.87 -up -0.48 0.00 0.88
|
||||
|
||||
# Load the model from disk
|
||||
puts "Importing shape..."
|
||||
restore $aBallPath ball
|
||||
|
||||
# Tessellate the model
|
||||
incmesh ball 0.01
|
||||
|
||||
# Display the model and assign material
|
||||
vdisplay -noupdate ball
|
||||
vsetmaterial -noupdate ball glass
|
||||
|
||||
# Create a sphere inside the model
|
||||
psphere s 8
|
||||
incmesh s 0.01
|
||||
vdisplay -noupdate s
|
||||
vsetlocation -noupdate s 0 0 13
|
||||
vsetmaterial -noupdate s plaster
|
||||
|
||||
# Create chessboard-style floor
|
||||
box tile 10 10 0.1
|
||||
eval compound [lrepeat 144 tile] tiles
|
||||
explode tiles
|
||||
for {set i 0} {$i < 12} {incr i} {
|
||||
for {set j 1} {$j <= 12} {incr j} {
|
||||
ttranslate tiles_[expr 12 * $i + $j] [expr $i * 10 - 90] [expr $j * 10 - 70] -0.15
|
||||
vdisplay -noupdate tiles_[expr 12 * $i + $j]
|
||||
|
||||
vsetmaterial -noupdate tiles_[expr 12 * $i + $j] plaster
|
||||
|
||||
if {($i + $j) % 2 == 0} {
|
||||
vbsdf tiles_[expr 12 * $i + $j] -kd 0.85
|
||||
} else {
|
||||
vbsdf tiles_[expr 12 * $i + $j] -kd 0.45
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Configure light sources
|
||||
vlight del 1
|
||||
vlight change 0 head 0
|
||||
vlight change 0 direction -0.25 -1 -1
|
||||
vlight change 0 sm 0.3
|
||||
vlight change 0 int 10
|
||||
|
||||
# Load environment map
|
||||
vtextureenv on 1
|
||||
|
||||
puts "Trying path tracing mode..."
|
||||
vrenderparams -ray -gi -rayDepth 10
|
||||
|
||||
# Start progressive refinement mode
|
||||
#vprogressive
|
||||
|
||||
puts "Make several path tracing iterations to refine the picture, please wait..."
|
||||
vfps 100
|
||||
puts "Done. To improve the image further, or after view manipulations, give command:"
|
||||
puts "vfps \[nb_iteratons\]"
|
@@ -2,11 +2,12 @@
|
||||
# path tracing rendering engine in 3d view
|
||||
|
||||
#Category: Visualization
|
||||
#Title: Path tracing
|
||||
#Title: Path tracing - Cube
|
||||
|
||||
pload MODELING VISUALIZATION
|
||||
|
||||
# setup 3D viewer content
|
||||
vclear
|
||||
vinit name=View1 w=512 h=512
|
||||
vglinfo
|
||||
|
||||
@@ -24,18 +25,18 @@ vcamera -persp
|
||||
# setup outer box
|
||||
box b 1 1 1
|
||||
explode b FACE
|
||||
vdisplay b_1 b_2 b_3 b_5 b_6
|
||||
vsetlocation b_1 1 0 0
|
||||
vsetlocation b_2 -1 0 0
|
||||
vsetlocation b_3 0 1 0
|
||||
vsetlocation b_5 0 0 1
|
||||
vsetlocation b_6 0 0 -1
|
||||
vdisplay -noupdate b_1 b_2 b_3 b_5 b_6
|
||||
vlocation -noupdate b_1 -setLocation 1 0 0
|
||||
vlocation -noupdate b_2 -setLocation -1 0 0
|
||||
vlocation -noupdate b_3 -setLocation 0 1 0
|
||||
vlocation -noupdate b_5 -setLocation 0 0 1
|
||||
vlocation -noupdate b_6 -setLocation 0 0 -1
|
||||
|
||||
vsetmaterial b_1 plastic
|
||||
vsetmaterial b_2 plastic
|
||||
vsetmaterial b_3 plastic
|
||||
vsetmaterial b_5 plastic
|
||||
vsetmaterial b_6 plastic
|
||||
vsetmaterial -noupdate b_1 plastic
|
||||
vsetmaterial -noupdate b_2 plastic
|
||||
vsetmaterial -noupdate b_3 plastic
|
||||
vsetmaterial -noupdate b_5 plastic
|
||||
vsetmaterial -noupdate b_6 plastic
|
||||
vbsdf b_1 -kd 1 0.3 0.3 -ks 0
|
||||
vbsdf b_2 -kd 0.3 0.5 1 -ks 0
|
||||
vbsdf b_3 -kd 1 -ks 0
|
||||
@@ -47,36 +48,36 @@ vfit
|
||||
|
||||
# setup first inner sphere
|
||||
psphere s 0.2
|
||||
vdisplay s
|
||||
vsetlocation s 0.21 0.3 0.2
|
||||
vsetmaterial s glass
|
||||
vdisplay -noupdate s
|
||||
vlocation -noupdate s -setLocation 0.21 0.3 0.2
|
||||
vsetmaterial -noupdate s glass
|
||||
vbsdf s -absorpcolor 0.8 0.8 1.0
|
||||
vbsdf s -absorpcoeff 6
|
||||
|
||||
# setup first inner box
|
||||
box c 0.3 0.3 0.2
|
||||
vdisplay c
|
||||
vsetlocation c 0.55 0.3 0.0
|
||||
vlocrotate c 0 0 0 0 0 1 -30
|
||||
vsetmaterial c plastic
|
||||
vdisplay -noupdate c
|
||||
vlocation -noupdate c -setLocation 0.55 0.3 0.0
|
||||
vlocation -noupdate c -rotate 0 0 0 0 0 1 -30
|
||||
vsetmaterial -noupdate c plastic
|
||||
vbsdf c -kd 1.0 0.8 0.2 -ks 0.3 -n
|
||||
|
||||
# setup second inner box
|
||||
box g 0.15 0.15 0.3
|
||||
vdisplay g
|
||||
vsetlocation g 0.7 0.25 0.2
|
||||
vlocrotate g 0 0 0 0 0 1 10
|
||||
vsetmaterial g glass
|
||||
vdisplay -noupdate g
|
||||
vlocation -noupdate g -setLocation 0.7 0.25 0.2
|
||||
vlocation -noupdate g -rotate 0 0 0 0 0 1 10
|
||||
vsetmaterial -noupdate g glass
|
||||
vbsdf g -absorpcolor 0.8 1.0 0.8
|
||||
vbsdf g -absorpcoeff 6
|
||||
|
||||
# setup second inner sphere
|
||||
psphere r 0.1
|
||||
vdisplay r
|
||||
vsetmaterial r plastic
|
||||
vdisplay -noupdate r
|
||||
vsetmaterial -noupdate r plastic
|
||||
vbsdf r -kd 0.5 0.9 0.3 -ks 0.0 -kr 0.3 -n
|
||||
vbsdf r -fresnel Constant 1.0
|
||||
vsetlocation r 0.5 0.65 0.1
|
||||
vlocation r -setLocation 0.5 0.65 0.1
|
||||
|
||||
puts "Trying path tracing mode..."
|
||||
vrenderparams -ray -gi -rayDepth 8
|
Reference in New Issue
Block a user