Shadow Pass
eharetea

Shadow pass generated in Hscript.

Hscript shadow pass.

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Wednesday July 30th, 2008 10:19 PM

SETTING UP A SHADOW PASS

open up a parameter spreadsheet

//this will find all nodes with shop in the node name
Op Mask: *shop*

//shows only sops
Op filter: Any SOP

//shows the quicksurface param for all sops
//find out name of params with opscript or holding mouse over name for second
Parm Mask: quicksurface

click on the word quicksurface to select all the parameter fields at once

then set the path to a VEX shadow matte shader

*	you mainly want to use key lights for light masking to bring out the shadows
*	fill lights can dull the image contrast


Compositing:
use composite COP with an over operation for shadow on image.
The forground weight is to dim the shadow, or top image.



set SOP = `oppwf()`

set shdwmat = `chs("$SOP/shadowmattedisplay")`
set phantom = `chs("$SOP/phtmshdwmattedisplay")`
set shdwnum = `argc($shdwmat)`
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 that cast shadows need to be phantom.
set phtm tphantom 1 phantom 1
set dhtm phantom 0 tphantom 0

if ($phtmnum>1)
    for =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 =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

# shadow matte
# step two....create VEX shadow matte and apply
set vexshade vexshadowmatte
 cd /shop
 opadd v_shadowmatte $vexshade


##
# ensures searching for shops only in shadow matte objects
for 0 to `(evals(argc($shdwmat)-1)`
    set repath = ${OBJECTCONTAINER}`arg($shdwmat,$h)`


foreach (`run("opfind -p $repath -t shop")`)


# for surfpath
set numsurfpath = `chs("$z/numsurfpath")`
    if "numsurfpath" "0" then
        for 1 to $numsurfpath
              if `chs("$z/surfpath$d")` == "" then
                continue
              endif
            set surf = `chs("$z/surfpath$d")`
            set nurf $z/surfpath$d
            
            set endsurf = ${endsurfopparm $nurf $surf;
            set begsurf = ${begsurfopparm $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
set delvexshade = oprm /shop/$vexshade\;

set preerl = $beggeoo $begquicksurf $begsurf $lightshdow
set poster = $geosurf $endquicksurf $endsurf $pightshdow $delvexshade

# end shadowmatte

    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_es ("$preerl")
        opparm $SOP/codegen/$passname post_es ("$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: shadow.sh 4 KB

Please login or Click Here to register for downloads
Creative Commons License
Shadow 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