1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0030575: Tests - v3d/materials unstable image screenshots of alpha-blending on GeForce with MSAA

testdiff now looks for "IMAGE_COLOR_TOLERANCE: Tol" statements in log
to execute diffimage with -toleranceOfColor Tol parameter.

Image difference is first performed with 0 tolerance and then optionally with non-zero tolerance,
so that the log always includes information that some images are different,
but with two different messages:
- "IMAGE differs" for images failed comparison;
- "IMAGE is similar" for images passed comparison only with non-zero tolerance.

v3d/materials - disabled MSAA and removed duplicate.
demo/samples/materials - compare screenshots with 0.8% color tolerance (2/255).
This commit is contained in:
kgv 2019-03-15 00:12:12 +03:00 committed by apn
parent 6072d5975a
commit f2b42160f4
8 changed files with 76 additions and 50 deletions

View File

@ -51,7 +51,7 @@ proc drawObjects {theRow theColor} {
uplevel #0 box $aBox $aCtr $aCtr $aCtr $aSize $aSize $aSize uplevel #0 box $aBox $aCtr $aCtr $aCtr $aSize $aSize $aSize
uplevel #0 ttranslate $aSph $x $y 0 uplevel #0 ttranslate $aSph $x $y 0
uplevel #0 ttranslate $aBox [expr $x + 10] $y 0 uplevel #0 ttranslate $aBox [expr $x + 10] $y 0
uplevel #0 vdisplay -noredraw $aSph $aBox uplevel #0 vdisplay -noredraw -dispMode 1 $aSph $aBox
uplevel #0 vsetmaterial -noredraw $aSph $aBox $aMatIter uplevel #0 vsetmaterial -noredraw $aSph $aBox $aMatIter
if {$theColor != ""} { if {$theColor != ""} {
uplevel #0 vsetcolor -noredraw $aSph $aBox $theColor uplevel #0 vsetcolor -noredraw $aSph $aBox $theColor
@ -64,21 +64,19 @@ proc drawObjects {theRow theColor} {
# setup 3D viewer content # setup 3D viewer content
pload MODELING VISUALIZATION pload MODELING VISUALIZATION
catch { vclose View1 }
vinit View1 w=768 h=768
vclear vclear
vclose ALL
vinit View1 w=768 h=768
vtop vtop
vglinfo vglinfo
vsetgradientbg 180 200 255 180 180 180 2 vsetgradientbg 180 200 255 180 180 180 2
vlight -change 0 -dir 0.577 -0.577 -0.577 vlight -change 0 -dir 0.577 -0.577 -0.577
vsetdispmode 1
vrenderparams -msaa 8 vrenderparams -msaa 8
# adjust scene bounding box # adjust scene bounding box
box bnd 0 0 0 180 210 1 box bnd 0 0 0 180 210 1
vdisplay -noredraw bnd vdisplay -noredraw -dispMode 0 bnd
vsetdispmode bnd 0
vfit vfit
vremove -noredraw bnd vremove -noredraw bnd
@ -88,5 +86,3 @@ drawObjects 0 ""
drawObjects 1 red drawObjects 1 red
drawObjects 2 green drawObjects 2 green
drawObjects 3 blue1 drawObjects 3 blue1
#vfit
vzfit

View File

@ -718,6 +718,7 @@ help testdiff {
Compare results of two executions of tests (CPU times, ...) Compare results of two executions of tests (CPU times, ...)
Use: testdiff dir1 dir2 [groupname [gridname]] [options...] Use: testdiff dir1 dir2 [groupname [gridname]] [options...]
Where dir1 and dir2 are directories containing logs of two test runs. Where dir1 and dir2 are directories containing logs of two test runs.
dir1 (A) should point to NEW tests results to be verified and dir2 (B) to REFERENCE results.
Allowed options are: Allowed options are:
-image [filename]: compare only images and save its in specified file (default -image [filename]: compare only images and save its in specified file (default
name is <dir1>/diffimage-<dir2>.log) name is <dir1>/diffimage-<dir2>.log)
@ -2215,6 +2216,8 @@ proc _test_diff {dir1 dir2 basename image cpu memory status verbose _logvar _log
# check images # check images
if {$image != false || ($image == false && $cpu == false && $memory == false)} { if {$image != false || ($image == false && $cpu == false && $memory == false)} {
set aCaseDiffColorTol 0
if { [regexp {IMAGE_COLOR_TOLERANCE:\s*([\d.]+)} $log1 res1 imgtol1] } { set aCaseDiffColorTol $imgtol1 }
set imglist1 [glob -directory $path1 -types f -tails -nocomplain ${casename}.{png,gif} ${casename}-*.{png,gif} ${casename}_*.{png,gif}] set imglist1 [glob -directory $path1 -types f -tails -nocomplain ${casename}.{png,gif} ${casename}-*.{png,gif} ${casename}_*.{png,gif}]
set imglist2 [glob -directory $path2 -types f -tails -nocomplain ${casename}.{png,gif} ${casename}-*.{png,gif} ${casename}_*.{png,gif}] set imglist2 [glob -directory $path2 -types f -tails -nocomplain ${casename}.{png,gif} ${casename}-*.{png,gif} ${casename}_*.{png,gif}]
_list_diff $imglist1 $imglist2 imgin1 imgin2 imgcommon _list_diff $imglist1 $imglist2 imgin1 imgin2 imgcommon
@ -2239,7 +2242,7 @@ proc _test_diff {dir1 dir2 basename image cpu memory status verbose _logvar _log
set diffile [_diff_img_name $dir1 $dir2 $basename $imgfile] set diffile [_diff_img_name $dir1 $dir2 $basename $imgfile]
if { [catch {diffimage [file join $dir1 $basename $imgfile] \ if { [catch {diffimage [file join $dir1 $basename $imgfile] \
[file join $dir2 $basename $imgfile] \ [file join $dir2 $basename $imgfile] \
0 0 0 $diffile} diff] } { -toleranceOfColor 0.0 -blackWhite off -borderFilter off $diffile} diff] } {
if {$image != false} { if {$image != false} {
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile cannot be compared" _log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile cannot be compared"
} else { } else {
@ -2247,10 +2250,35 @@ proc _test_diff {dir1 dir2 basename image cpu memory status verbose _logvar _log
} }
file delete -force $diffile ;# clean possible previous result of diffimage file delete -force $diffile ;# clean possible previous result of diffimage
} elseif { $diff != 0 } { } elseif { $diff != 0 } {
set diff [string trimright $diff \n]
if {$aCaseDiffColorTol != 0} {
# retry with color tolerance
if { [catch {diffimage [file join $dir1 $basename $imgfile] \
[file join $dir2 $basename $imgfile] \
-toleranceOfColor $aCaseDiffColorTol -blackWhite off -borderFilter off $diffile} diff2] } {
if {$image != false} { if {$image != false} {
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile differs" _log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile cannot be compared"
} else { } else {
_log_and_puts log "IMAGE [split $basename /] $casename: $imgfile differs" _log_and_puts log "IMAGE [split $basename /] $casename: $imgfile cannot be compared"
}
continue
} elseif { $diff2 == 0 } {
# exclude image diff within tolerance but still keep info in the log
set toLogImageCase false
file delete -force $diffile
if {$image != false} {
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile is similar \[$diff different pixels\]"
} else {
_log_and_puts log "IMAGE [split $basename /] $casename: $imgfile is similar \[$diff different pixels\]"
}
continue
}
}
if {$image != false} {
_log_and_puts log_image "IMAGE [split $basename /] $casename: $imgfile differs \[$diff different pixels\]"
} else {
_log_and_puts log "IMAGE [split $basename /] $casename: $imgfile differs \[$diff different pixels\]"
} }
} else { } else {
file delete -force $diffile ;# clean useless artifact of diffimage file delete -force $diffile ;# clean useless artifact of diffimage
@ -2311,8 +2339,8 @@ proc _log_html_diff {file log dir1 dir2 highlight_percent} {
# print header # print header
puts $fd "<html><head><title>Diff $dir1 vs. $dir2</title></head><body>" puts $fd "<html><head><title>Diff $dir1 vs. $dir2</title></head><body>"
puts $fd "<h1>Comparison of test results:</h1>" puts $fd "<h1>Comparison of test results:</h1>"
puts $fd "<h2>Version A - $dir1</h2>" puts $fd "<h2>Version A \[NEW\] - $dir1</h2>"
puts $fd "<h2>Version B - $dir2</h2>" puts $fd "<h2>Version B \[REF\] - $dir2</h2>"
# add script for switching between images on click # add script for switching between images on click
puts $fd "" puts $fd ""
@ -2334,12 +2362,16 @@ proc _log_html_diff {file log dir1 dir2 highlight_percent} {
if { [regexp "\[\\\[](\[0-9.e+-]+)%\[\]]" $line res value] && if { [regexp "\[\\\[](\[0-9.e+-]+)%\[\]]" $line res value] &&
[expr abs($value)] > ${highlight_percent} } { [expr abs($value)] > ${highlight_percent} } {
puts $fd "<table><tr><td bgcolor=\"[expr $value > 0 ? \"ff8080\" : \"lightgreen\"]\">$line</td></tr></table>" puts $fd "<table><tr><td bgcolor=\"[expr $value > 0 ? \"ff8080\" : \"lightgreen\"]\">$line</td></tr></table>"
} else { } elseif { [regexp {IMAGE[ \t]+([^:]+):[ \t]+([A-Za-z0-9_.-]+) is similar} $line res case img] } {
puts $fd $line if { [catch {eval file join "" [lrange $case 0 end-1]} gridpath] } {
# note: special handler for the case if test grid directoried are compared directly
set gridpath ""
} }
set aCaseName [lindex $case end]
puts $fd "<table><tr><td bgcolor=\"orange\"><a href=\"[_make_url $file [file join $dir1 $gridpath $aCaseName.html]]\">$line</a></td></tr></table>"
} elseif { [regexp {IMAGE[ \t]+([^:]+):[ \t]+([A-Za-z0-9_.-]+)} $line res case img] } {
# add images # add images
if { [regexp {IMAGE[ \t]+([^:]+):[ \t]+([A-Za-z0-9_.-]+)} $line res case img] } { puts $fd $line
if { [catch {eval file join "" [lrange $case 0 end-1]} gridpath] } { if { [catch {eval file join "" [lrange $case 0 end-1]} gridpath] } {
# note: special handler for the case if test grid directoried are compared directly # note: special handler for the case if test grid directoried are compared directly
set gridpath "" set gridpath ""
@ -2360,6 +2392,8 @@ proc _log_html_diff {file log dir1 dir2 highlight_percent} {
puts $fd "<table><tr><th><abbr title=\"$dir1\">Version A</abbr></th><th><abbr title=\"$dir2\">Version B</abbr></th><th>Diff (click to toggle)</th></tr>" puts $fd "<table><tr><th><abbr title=\"$dir1\">Version A</abbr></th><th><abbr title=\"$dir2\">Version B</abbr></th><th>Diff (click to toggle)</th></tr>"
puts $fd "<tr><td>$img1</td><td>$img2</td><td>$imgd</td></tr></table>" puts $fd "<tr><td>$img1</td><td>$img2</td><td>$imgd</td></tr></table>"
} else {
puts $fd $line
} }
} }
puts $fd "</pre></body></html>" puts $fd "</pre></body></html>"

View File

@ -1,4 +1,8 @@
# test for visual properties of materials in 3d viewer puts "Test visual properties of materials in 3d viewer"
puts "Workaround instability on GeForce cards with MSAA at semitransparent sphere"
puts "IMAGE_COLOR_TOLERANCE: 0.008"
source $env(CSF_OCCTSamplesPath)/tcl/materials.tcl source $env(CSF_OCCTSamplesPath)/tcl/materials.tcl
# make a snapshot # make a snapshot

View File

@ -1,5 +1,5 @@
puts "========" puts "========"
puts "OCC24855: Revision of parameters of standard materials" puts "0024855: Revision of parameters of standard materials"
puts "========" puts "========"
# custom shapes # custom shapes
@ -14,8 +14,7 @@ vsetgradientbg 180 200 255 180 180 180 2
# display shape # display shape
vlight -change 0 -dir 0.577 -0.577 -0.577 vlight -change 0 -dir 0.577 -0.577 -0.577
restore $aShape s restore $aShape s
vsetdispmode 1 vdisplay -dispMode 1 s
vdisplay s
vfit vfit
proc testmat {dirname filename} { proc testmat {dirname filename} {
@ -25,18 +24,15 @@ proc testmat {dirname filename} {
} }
} }
# make material screenshots # material screenshots, Gouraud shading model (rasterization)
vrenderparams -shadingModel GOURAUD
testmat $imagedir $casename testmat $imagedir $casename
vshaderprog s phong # material screenshots, Phong shading model (rasterization)
vrenderparams -shadingModel PHONG
testmat $imagedir ${casename}_phong testmat $imagedir ${casename}_phong
# material screenshots, Ray-Tracing
vrenderparams -raytrace -reflections -fsaa vrenderparams -raytrace -reflections -fsaa
vtextureenv on 5 vtextureenv on 5
testmat $imagedir ${casename}_rt testmat $imagedir ${casename}_rt
vclear
vrenderparams -rasterization
vtextureenv off
source $env(CSF_OCCTSamplesPath)/tcl/materials.tcl

View File

@ -1,10 +0,0 @@
puts "========="
puts "OCC24872"
puts "========="
puts ""
###########################################################
# Support of emission color in Phong shader and ray-tracing
###########################################################
source $env(CSF_OCCTSamplesPath)/tcl/materials.tcl
vshaderprog phong

View File

@ -1,10 +0,0 @@
puts "========="
puts "OCC24872"
puts "========="
puts ""
###########################################################
# Support of emission color in Phong shader and ray-tracing
###########################################################
source $env(CSF_OCCTSamplesPath)/tcl/materials.tcl
vrenderparams -raytrace

View File

@ -0,0 +1,8 @@
puts "========="
puts "0024872: Support of emission color in Phong shader and ray-tracing"
puts "Test emission material within Phong rasterization model"
puts "========="
puts ""
source $env(CSF_OCCTSamplesPath)/tcl/materials.tcl
vrenderparams -shadingModel PHONG -msaa 0

View File

@ -0,0 +1,8 @@
puts "========="
puts "0024872: Support of emission color in Phong shader and ray-tracing"
puts "Test emission material within Ray-Tracing"
puts "========="
puts ""
source $env(CSF_OCCTSamplesPath)/tcl/materials.tcl
vrenderparams -raytrace -msaa 0