Announcement

Collapse
No announcement yet.

V-Ray Sky as the environment by default | Python

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • V-Ray Sky as the environment by default | Python

    Hi all,
    Coming from 3ds Max I'm used to setting up V-Ray Sun and Sky together by default, especially at the early stage of working with the scene.
    Since that's not the case in Houdini, I wrote a tiny Python script to do that. Thought some people here may find it useful :

    Code:
    #CHECK FOR V-RAY SUN
    chldrn = hou.node('/obj').children()
    vr_sun = None
    
    for i in chldrn:[INDENT]if i.type().name() == 'VRayNodeSunLight':[/INDENT][INDENT=2]vr_sun = i
    break[/INDENT]
     
    if vr_sun == None:[INDENT]from vfh import vfh_tools; vfh_tools.newLight(kwargs, 'VRayNodeSunLight', "vrayLightSun")[/INDENT]
     
    
    
    #CREATE VRAY ENVIRONMENT AND LINK IT TO V-RAY SKY TEXTURE
    if hou.node('/out/env_sky') == None:[INDENT]hou.node('/out').createNode('vray_environment', 'env_sky')[/INDENT]
     
    env = hou.node('/out/env_sky')
    
    if hou.node('/out/env_sky/sky_tex') == None:[INDENT]hou.node('/out/env_sky').createNode('VRayNodeTexSky', 'sky_tex')[/INDENT]
     
    sky = hou.node('/out/env_sky/sky_tex')
    
    env_set = hou.node('/out/env_sky/environmentSettings')
    
    env_set.setInput(0, sky, 0)
    env_set.setInput(1, sky, 0)
    env_set.setInput(2, sky, 0)
    env_set.setInput(3, sky, 0)
    
    env_set.parm('use_bg').set(1)
    env_set.parm('use_gi').set(1)
    env_set.parm('use_reflect').set(1)
    env_set.parm('use_refract').set(1)
    
    
    
    #CHECK FOR V-RAY ROP
    if hou.node('/out/vray') == None:[INDENT]from vfh import vfh_toolbar; vfh_toolbar.vray_render_settings()[/INDENT]
     
    vr_rop = hou.node('/out/vray')
    vr_rop.parm('render_network_environment').set('../env_sky')
    
    
    
    #ARRANGE NODES
    env.moveToGoodPosition()
    env_set.moveToGoodPosition()
    sky.moveToGoodPosition()
    Feel free to point out better way of doing that.
    For anyone not sure how to use it - make a custom tool on a shelf and paste it in in the 'Script' tab.
    Last edited by mateusz_sum; 02-02-2022, 04:14 PM.
Working...
X