Simple light object instancing

   6153   5   0
User Avatar
Member
196 posts
Joined: Aug. 2011
Offline
Hi,

I did a bit of research, but I can't figure this out..

I have a workflow with the ‘instance’ SOP, with feeding the ‘instancePath’ attribute, per point. I'd like to continue using that route, like for standard geometries.

Now I have tried with multiple methods, but I can't instance lights that same way (see screenshot). The only thing I got instanced was a geometric representation of the light's gizmo.

Is there a way to get this working in Houdini 15.5?
If not, what other efficient instancing way would be recommended? (if possible withouth the ‘copy’ SOP!).


Any input welcome!

Thanks,
matt

Attachments:
lightInst.jpg (69.6 KB)

User Avatar
Member
2537 posts
Joined: June 2008
Offline
I don't think you can instance lights in Houdini. You can use a Copy sop to create a geometry that you then turn into a single geometry light. You could also write a Python script to manage light deployment in a scene, but it would need to actually create a physical light at every point.
Edited by Enivob - Nov. 7, 2016 08:49:54

Attachments:
Untitled-1.jpg (134.1 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
196 posts
Joined: Aug. 2011
Offline
hey!

thanks for the help!


in your example: how do you ‘convert’ the sphere geo into a specific light, e.g. spot?
User Avatar
Member
2537 posts
Joined: June 2008
Offline
You can convert any geometry object into a Geometry Light by clicking the Geometry Light button on the Lights And Cameras Shelf Tool Bar. Select the geometry then click the button. This process takes care of removing the original geometry from the scene as well, so it does not block itself from illumination.

This does not make it a spotlight, it acts more like a point light.

You can create lights with a script like this.
node = hou.pwd()
geo = node.geometry()
def fetchIfObject (passedName):
    # Return a named item if it exists.
    try:
        result = hou.node(passedName)
        if result == 0:
            result = None
    except:
        result = None
    return result
    
parent_name = "light_container"   # Name of master object that will hold all the generated lights.
subnet_name = "/obj/%s" % parent_name
        
parent = fetchIfObject(subnet_name)
if parent == None:
    # Create a SubNet for all lights to reside under.
    parent = hou.node('/obj').createNode('subnet', parent_name)
    
for (i,point) in enumerate(geo.points()):
    light_name = "ilight_%s" % i
    ob = fetchIfObject('/obj/%s/%s' % (parent_name, light_name))
    if ob == None:
        # Light does not exist, time to create it.
        ob = parent.createNode('hlight', light_name, run_init_scripts=False)
        ob.parm("light_type").set(0)        # Set the type of light.
        ob.parm("coneenable").set(1)        # Turn on the spotlight cone to convert this point light to a spotlight.
        ob.parm("light_colorr").set(1)      # Set light color.
        ob.parm("light_colorg").set(0.75)
        ob.parm("light_colorb").set(0.8)
        ob.parm("light_intensity").set(1.0) # Set light intensity.
        
    # Set the position for this light.
    p = point.position()
    ob.parm('tx').set(p[0])         # Position the item.
    ob.parm('ty').set(p[1])         # Position the item.
    ob.parm('tz').set(p[2])         # Position the item.
    
    # Rotate the spotlight so it is facing down.
    ob.parm("rx").set(-90)
Edited by Enivob - Nov. 7, 2016 21:48:29

Attachments:
Untitled-1.jpg (25.1 KB)
ap_scatter_lights.hipnc (172.4 KB)
Untitled-1.jpg (163.5 KB)

Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
196 posts
Joined: Aug. 2011
Offline
wow, awesome stuff!

I'm definitely not a shelf button person, so I'll go with the Python option, because then I can also set multiple colors and stuff at the same time.

sweeeet!

HUGE thanks!
matt
User Avatar
Member
137 posts
Joined:
Offline
Enivob
I don't think you can instance lights in Houdini.

For the record, you can instance light in Houdini. Here is an example file and things to keep in mind.

-You need Full Point Instancing. Fast Point Instancing won't work.
-Even thought the Instance Object parameter is called “instancepath” the attribute you have to create per point is “instance”.
-You need to make sure your object containing all the instances is visible to Mantra as an object but you don't need to put it in the candidate lights. For example my workflow involves to not use Candidate Objects, I use Force Objects instead. For this reason I have to write my instance node there.
-You generally want to exclude the single light be instance from the center of the world by writing its name in “Exclude Lights”.

Attachments:
light_instancing.hip (251.6 KB)

  • Quick Links