Hscript used to generate a reflection pass.
Reflection pass script.
Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Wednesday July 30th, 2008 09:07 PM
NOTES FOR SETTING UP A REFLECTION PASS Use a VEX Layered Surface Diffuse to 0,0,0 Relfection to 1,1,1 Lighting Model to Blinn Any objects in reflection need to have Phantom turned on and to a value of 1 Also take off any shadow shaders from any lights In Compositing: turn down the foreground weight when using a composite COP in compositing Remember to composite shadows over reflections.
set SOP = `oppwf()`
set reflect = `chs("$SOP/reflectionpass")`
set phantom = `chs("$SOP/displayedreflphtm")
set reflnum = `argc($reflect)`
set phtmnum = `argc($phantom)`
set passname = `chs("$SOP/passname")`
set passarg = `argc($passname)`
if ($passarg==0) #pass check
message You must enter a name for this pass!
else #pass check
# phantom
# step one...any objects in reflection need to be phantom.
set phtm = tphantom 1 phantom 1
set dhtm = phantom 0 tphantom 0
if ($phtmnum>1)
for i =0 to `evals($phtmnum-1)`
set ptobjd = `arg($phantom, $i)`
set phtman = opparm $OBJECTCONTAINER${ptobjd} $phtm\;
set thtman = $thtman $phtman
end
else
set ptobjd = $phantom
set thtman = opparm $OBJECTCONTAINER${ptobjd} $phtm\;
endif
if ($phtmnum>1)
for i =0 to `evals($phtmnum-1)`
set nptobjd = `arg($phantom, $i)`
set nphtman = opparm $OBJECTCONTAINER${nptobjd} $dhtm\;
set nthtman = $nthtman $nphtman
end
else
set nptobjd = $phantom
set nthtman = opparm $OBJECTCONTAINER${nptobjd} $dhtm\;
endif
# end phantom
# reflect
# step two....create VEX layered Surface and put in on relection objects
set vexshade = vexreflectsurf
cd /shop
opadd v_layered $vexshade
opparm $vexshade Cd (0 0 0) Cr (1 1 1) lmodel blinn
##
# ensures searching for shops only in reflected objects
for h = 0 to `(evals(argc($reflect)-1)`
set repath = ${OBJECTCONTAINER}`arg($reflect,$h)`
foreach z (`run("opfind -p $repath -t shop")`)
# for surfpath
set numsurfpath = `chs("$z/numsurfpath")`
if "numsurfpath" > "0" then
for d = 1 to $numsurfpath
if `chs("$z/surfpath$d")` == "" then
continue
endif
set surf = `chs("$z/surfpath$d")`
set nurf = $z/surfpath$d
set endsurf = ${endsurf} opparm $nurf $surf\;
set begsurf = ${begsurf} opparm $nurf /shop/$vexshade\;
end
endif
# for quicksurface
if `chs("$z/quicksurface")` != "" then
set quicksurf = `chs("$z/quicksurface")`
set nqsurf = $z/quicksurface
set endquicksurf = opparm $nqsurf $quicksurf\;
set begquicksurf = opparm $nqsurf /shop/$vexshade\;
endif
# test for geo
set geocheck = 0
while ($geocheck==0)
set zed = `strreplace($z,"/"," ")`
set lst = `evals(argc(${zed})-1)`
set ltt = `arg(${zed},${lst})`
set nzz = `strreplace($z,"/${ltt}","")`
set z = $nzz
if `optype($z)` == "geo" then
set geocheck = 1
endif
end
# for shop_surfacepath
if `chs("$z/shop_surfacepath")` != "" then
set shsurfacepath = `chs("$z/shop_surfacepath")`
set nsurfacepath = $z/shop_surfacepath
set geosurf = opparm $nsurfacepath $shsurfacepath\;
set beggeoo = opparm $nsurfacepath /shop/$vexshade\;
endif
end
# if there is no shader to take note of, then apply shader to the object
if "$z" = "" then
set shsurfacepath = `chs("$repath/shop_surfacepath")`
set nsurfacepath = $repath/shop_surfacepath
set geosurf = opparm $nsurfacepath (\"\")\;
set beggeoo = opparm $nsurfacepath /shop/$vexshade\;
endif
end
# step three....take shadows off of any lights
foreach lz (`run("opfind -p $OBJECTCONTAINER -t light")`)
if `chs("$lz/shadowmask")` != "" then
set shadowmask = shadowmask `chs("$lz/shadowmask")`
endif
set autogenshadow = autogen `ch("$lz/autogen")`
if `chs("$lz/shop_shadowpath")` != "" then
set shopshadow = shop_shadowpath `chs("$lz/shop_shadowpath")`
endif
if `chs("$lz/depthmap")` != "" then
set shopdepthmap = depthmap `chs("$lz/depthmap")`
endif
set lightshdow = $lightshdow opparm $lz shop_shadowpath (\"\") shadowmask * depthmap (\"\") autogen 0\;
set pightshdow = $pightshdow opparm $lz $shopshadow $shadowmask $shopdepthmap $autogenshadow\;
end
set delvexshade = oprm /shop/$vexshade\;
set preerl = $beggeoo $begquicksurf $begsurf $lightshdow
set poster = $geosurf $endquicksurf $endsurf $pightshdow $delvexshade
# end reflect
cd $SOP/codegen
set passname = `strreplace($passname, " ","_")`
set qikck = `opexist($passname)`
if ($qikck==1)
message This Pass exists. Change name to continue.
else
# add operator, unsync it, change parameters
opadd houdini_code $passname
otunsync $passname
# add parameters
opparm $SOP/codegen/$passname pre_er ("$preerl")
opparm $SOP/codegen/$passname post_er ("$poster")
opparm $SOP/codegen/$passname pre_ep ("$thtman")
opparm $SOP/codegen/$passname post_ep ("$nthtman")
oppane -t parmeditor $SOP/codegen/$passname
endif
endif #pass check
Downloads:
Download: reflection.sh 5 KB
Please login or Click Here to register for downloads
Reflection Pass by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com
