Пример #1
0
def addImagePlane(token, storage, houdini, skipdefault=True, mainimage=True):
    if mainimage:
        _Settings.MPlane.append(
            SohoParm(houdini, storage, None, skipdefault, token))
    iplane = houdini + '_plane%d'
    _Settings.IPlane.append(SohoParm(iplane, storage, None, skipdefault,
                                     token))
Пример #2
0
def illum_shader(obj, now, value):
    if obj.evalShader('vm_illumshader', now, value):
        if value[0]:
            return True

    if isgilight(obj, now):
        shader = 'diffuselighting glossytodiffuse 0'
    else:
        defmis = -1  # object-centric sampling
        if isportallight(obj, now) or (eval_envmap(obj, now, value)
                                       and value[0] != ''):
            defmis = 0

        illumParms = {
            'vm_misbias': SohoParm('vm_misbias', 'real', [defmis], False),
            'env_filteramount': SohoParm('env_filteramount', 'real', [0],
                                         False),
        }

        plist = obj.evaluate(illumParms, now)
        misbias = plist['vm_misbias'].Value[0]
        filteramount = plist['env_filteramount'].Value[0]
        shader = 'mislighting misbias %f filteramount %f' % \
                (misbias, filteramount)

    value[:] = [shader]
    return True
Пример #3
0
def attenString(obj, now, ltype):
    plist = obj.evaluate(attenParms, now)

    atten_start = plist['atten_start'].Value[0]
    atten_type = plist['atten_type'].Value[0]
    atten_dist = plist['atten_dist'].Value[0]
    attenrampenable = plist['attenrampenable'].Value[0]
    rampstart = plist['atten_rampstart'].Value[0]
    rampend = plist['atten_rampend'].Value[0]

    atten = ' attenstart %g' % atten_start

    if atten_type == 'none':
        atten += ' doatten 0'
    elif atten_type == 'half':
        atten += ' doatten 1 atten %g' % atten_dist
    elif atten_type == 'physical':
        atten += ' doatten 2'

    if attenrampenable:
        parmlist = [SohoParm('object:instancename', 'string', [''])]
        obj.evaluate(parmlist, 0)
        hlight = hou.node(parmlist[0].Value[0])
        if hlight:
            attenramp = hlight.parmTuple('attenramp')
            if attenramp:
                rampParms = shopclerks.ifdclerk.IfdParmEval(
                    None, soho.Precision,
                    None).getRampParms(attenramp, hou.timeToFrame(now))
                atten += ' doattenramp 1'
                atten += ' rampstart %g rampend %g' % (rampstart, rampend)
                for rp in rampParms:
                    atten += ' ' + rp[0]
                    atten += ' ' + rp[1]
    return atten
Пример #4
0
def ouputMotionBlurInfo(obj, now, required=False):
    motionInfo = {
        'xform':
        SohoParm('xform_motionsamples', 'int', [2], not required, key='xform'),
        'geo':
        SohoParm('geo_motionsamples', 'int', [1], not required, key='geo')
    }

    # Write out the number of transform and geometry motion samples
    # if motion blur is enabled.
    if CameraBlur:
        plist = obj.evaluate(motionInfo, now)
        xform = plist.get('xform', None)
        geo = plist.get('geo', None)
        nseg = xform.Value[0] if xform else 1
        if nseg > 1:
            cmd_property('object', 'xformsamples', [nseg])
        nseg = geo.Value[0] if geo else 1
        if nseg > 1:
            cmd_property('object', 'geosamples', [nseg])
Пример #5
0
def export():
    """Main export function."""

    is_last = False

    try:
        T = timer('FrameExport')

        ps = soho.evaluate({
            'now':
            SohoParm('state:time', 'real', [0], False, key='now'),
            'fps':
            SohoParm('state:fps', 'real', [24], False, key='fps'),
            'hver':
            SohoParm('state:houdiniversion', 'string', [''], False,
                     key='hver'),
            'objpath':
            SohoParm('objpath', 'string', [''], False),
            'abcoutput':
            SohoParm('abcoutput', 'string', [''], False),
            'camera':
            SohoParm('camera', 'string', [None], False),
            'trange':
            SohoParm('trange', 'int', [0], False),
            'f':
            SohoParm('f', 'int', None, False)
        })

        now = ps['now'].Value[0]
        fps = ps['fps'].Value[0]
        hver = ps['hver'].Value[0]
        camera = ps['camera'].Value[0]

        dbg("now=%.3f fps=%.3f" % (now, fps))

        if not soho.initialize(now, camera):
            soho.error("couldn't initialize soho (make sure camera is set)")
            abc_cleanup()
            return

        # NOTE: this is prone to float inaccuracies
        frame = now * fps + 1.0

        objpath = ps['objpath'].Value[0]
        abc_file = ps['abcoutput'].Value[0]
        trange = ps['trange'].Value[0]
        f = ps['f'].Value

        is_first = frame < f[0] + 0.5  # working around float funniness
        is_last = frame > f[1] - 0.5

        if trange == 0:
            is_first = is_last = True

        dbg("is_first=%d is_last=%d" % (is_first, is_last))
        dbg("now=%.3f fps=%.3f -> %f" % (now, fps, frame))

        dbg("objpath=%s camera=%s abcoutput=%s trange=%d f=%s" % \
         (objpath, camera, abc_file, trange, str(f)))

        T.lap('init')

        # collect hierarchy to be exported
        # (read from scene directly, ie. not containing instances, etc.)
        # results in array [ (parentname, objname) [, ...]  ] -- (full pathnames)
        #
        #dbg("COLLECTING ARCHY:")
        archy = collect_archy(objpath)
        archy_objs = [n[1] for n in archy]
        #dbg("DONE.")

        # collect geometry to be exported and their render SOPS
        # (including point- and other instances, etc)
        # (NOTE: the entire scene is to be searched, unfortunately)
        #
        soho.addObjects(now, '*', '*', '', do_culling=False)
        soho.lockObjects(now)

        soho_objs = {}  # {objname: soho_obj}
        soho_only = {
        }  # soho-only objects (can't be accessed directly with hdk)

        obj_list = []
        sop_dict = {}  # {objname: sopname}
        objs = soho.objectList('objlist:instance')

        #dbg("COLLECT soho instance/sop pairs ------------------")
        for obj in objs:
            n = obj.getName()  # full pathname
            obj_list.append(n)
            soho_objs[n] = obj
            path = obj.getDefaultedString('object:soppath', now, [None])[0]
            #dbg(" -- %s (sop:%s)" % (n, str(path)) )
            if path and path != "":
                sop_dict[n] = path

        T.lap('collect-objs')

        if False:
            dbg('-' * 40)
            dbg("sop_dict: %s" % str(sop_dict))

        # extend hierarchy with per-point instances
        #
        p1 = re.compile(":[^:]+:")
        for obj in obj_list:
            if re.search(p1, obj):
                m = obj.split(":")
                p = m[-2]  # parent: 2nd from right
                if p in archy_objs:
                    archy.append((p, obj, "%s__%s" % (m[-2], m[-1])))
                    soho_only[obj] = p
                    #dbg(" -+- %s %s" % (p, obj))

        # fill rest of the archy array
        # elem: (parentpath, objpath, exportname, soppath)
        #
        archy2 = []
        for a in archy:
            N = list(a)
            if len(N) < 3: N.append(N[1])  # N = [ N[0], N[1], N[1] ]
            if N[1] in sop_dict:
                N = [N[0], N[1], N[2], sop_dict[N[1]]]
            else:
                # empty xform (no sop)
                N = [N[0], N[1], N[1], None]

            N[2] = re.search("[^/]+$", N[2]).group(0)
            archy2.append(N)
        archy = archy2

        if False:
            dbg('-' * 40)
            dbg("COLLECTED ARCHY:")
            for a in archy:
                dbg("- %s: " % (a[1], ))

        dbg("COLLECTED ARCHY: %d elems" % len(archy))

        T.lap('got-archy')

        # we now have a list of all objects to be exported
        # (parentname, objname, exportname, soppath)
        #
        archy_objs = [n[1] for n in archy]
        skip_frame = False

        now_out = now + (1.0 / fps)

        # check for user abort
        #
        if False:  # TODO: check for user abort!
            skip_frame = True
            is_last = True
            warn("user abort")

        # first frame: init all internal stuff
        #
        if is_first:
            dbg("\n\n\n")
            dbg("IS_FIRST--INIT")
            G.archy = archy[:]
            G.archy_objs = archy_objs[:]

            s = abc_init(abc_file, tstep=1.0 / fps, tstart=now_out)
            if s:
                # build objects for oarchive
                #
                for E in archy:
                    objname = E[1]
                    parent = E[0]
                    outname = E[2]
                    soppath = E[3]
                    if parent is None: parent = "-"
                    if soppath is None: soppath = "-"

                    # TODO: if instance, objname should be the base obj name
                    obj_src = objname
                    if objname in soho_only:
                        obj_src = soho_only[objname]

                    #dbg("-- new xform\n\toutname= %s\n\tobj    = %s\n\tparent = %s\n\tsop    = %s" % (outname, objname, parent, soppath))

                    hou.hscript('%s newobject "%s" "%s" "%s" "%s" "%s"' % \
                     (CCMD, objname, obj_src, parent, outname, soppath))

                    # set object flags (static, etc.)
                    #
                    if objname in soho_objs:
                        ps = soho_objs[objname].evaluate(
                            {
                                'abc_staticgeo':
                                SohoParm('abc_staticgeo', 'int', [0], False)
                            }, now)

                        if ps['abc_staticgeo'].Value[0] != 0:
                            hou.hscript('%s objset "%s" static' %
                                        (CCMD, objname))

            else:
                warn("couldn't output to file %s--aborting" % abc_file)
                skip_frame = True
                is_last = True

        T.lap('frame-first')

        # frame export: collect xforms, geoms, and export them
        #
        if archy_objs == G.archy_objs and not skip_frame:

            dbg("\n")
            dbg(" -- EXPORTING frame %.1f" % frame)

            for E in archy:
                #dbg("\n-")
                #dbg("- OBJ: %s" % str(E))
                objname = E[1]
                soppath = E[3]
                #dbg("- OBJ: %s" % E[1])

                # get xform matrix (TODO: get pretransform too!)
                #
                xform = ''

                # TODO: use this only for instances!
                #if objname in soho_objs:
                if objname in soho_only:
                    # get matrix from soho
                    #dbg(" --- (mtx from soho)")
                    xform = []
                    soho_objs[objname].evalFloat('space:local', now, xform)
                    xform = hou.Matrix4(xform)
                    xform = ' '.join([str(n) for n in xform.asTuple()])

                # perform sample write
                # (c++ code decides if geom is to be written)
                #
                if True:
                    hou.hscript('%s writesample %f "%s" %s' % \
                     (CCMD, now_out, objname, xform))

        else:
            #soho.error("couldn't export frame %.1f--no. of objects changed" % frame)
            warn("couldn't export frame %.1f--no. of objects changed" % frame)

        T.lap('frame-export')

    except:
        dbg("INTERRUPTED BY EXCEPTION")
        is_last = True

    # last frame: cleanup all internal stuff,
    # finish export
    #
    if is_last:
        dbg("\n\n\n")
        dbg("IS_LAST--FINISHING...")
        abc_cleanup()

    T.lap('frame-last')

    T.stats()
Пример #6
0
def soho_render():
    control_parms = {
        # The time at which the scene is being rendered
        "now": SohoParm("state:time", "real", [0], False, key="now")
    }

    parms = soho.evaluate(control_parms)

    now = parms["now"].Value[0]
    camera = None

    options = {}
    if not soho.initialize(now, camera, options):
        soho.error("Unable to initialize rendering module with given camera")

    object_selection = {
        # Candidate object selection
        "vobject": SohoParm("vobject", "string", ["*"], False),
        "forceobject": SohoParm("forceobject", "string", [""], False),
        "excludeobject": SohoParm("excludeobject", "string", [""], False),
    }

    objparms = soho.evaluate(object_selection, now)

    stdobject = objparms["vobject"].Value[0]
    forceobject = objparms["forceobject"].Value[0]
    excludeobject = objparms["excludeobject"].Value[0]

    # First, we add objects based on their display flags or dimmer values
    soho.addObjects(now,
                    stdobject,
                    "",
                    "",
                    True,
                    geo_parm="vobject",
                    light_parm="",
                    fog_parm="")
    soho.addObjects(
        now,
        forceobject,
        "",
        "",
        False,
        geo_parm="forceobject",
        light_parm="",
        fog_parm="",
    )
    soho.removeObjects(now,
                       excludeobject,
                       "",
                       "",
                       geo_parm="excludeobject",
                       light_parm="",
                       fog_parm="")

    # Lock off the objects we've selected
    soho.lockObjects(now)

    with hou.undos.disabler(), scene_state:
        if "SOHO_PBRT_DEV" in os.environ:  # pragma: no coverage
            import cProfile

            pr = cProfile.Profile()
            pr.enable()
            try:
                PBRTscene.archive(now)
            finally:
                pr.disable()
                pr.dump_stats("hou-prbtarchive.stats")
        else:
            PBRTscene.archive(now)
    return
Пример #7
0
        self.UVHiddenObjects = {}
        self.ParsedStyleSheets = {}

        self.Features = {}


_Settings = Settings()
SettingDefs = []

# Order versions in descending order
theVersion = 'lava%d.%d' % (hou.applicationVersion()[0],
                            hou.applicationVersion()[1])

_UserAttributes = {
    'lv_username':
    SohoParm('lv_username%d', 'string', [''], False, key='lv_username'),
    'lv_usertype':
    SohoParm('lv_usertype%d', 'string', [''], False, key='lv_usertype'),
    'lv_userint':
    SohoParm('lv_userint%d', 'real', [0], False, key='lv_userint'),
    'lv_userscalar':
    SohoParm('lv_userscalar%d', 'real', [0], False, key='lv_userscalar'),
    'lv_user3tuple':
    SohoParm('lv_user3tuple%d', 'real', [0, 0, 0], False, key='lv_user3tuple'),
    'lv_user4tuple':
    SohoParm('lv_user4tuple%d',
             'real', [0, 0, 0, 0],
             False,
             key='lv_user4tuple'),
    'lv_user9tuple':
    SohoParm('lv_user9tuple%d',
Пример #8
0
    def getViewParams(camera, sohoCam, t):
        camParms = {
            'space:world': SohoParm('space:world', 'real', [], False),
            'focal': SohoParm('focal', 'real', [0.050], False),
            'aperture': SohoParm('aperture', 'real', [0.0414214], False),
            'orthowidth': SohoParm('orthowidth', 'real', [2], False),
            'near': SohoParm('near', 'real', [0.001], False),
            'far': SohoParm('far', 'real', [1000], False),
            'res': SohoParm('res', 'int', [640, 480], False),
            'projection': SohoParm('projection', 'string', ["perspective"],
                                   False),
            'cropl': SohoParm('cropl', 'real', [-1], False),
            'cropr': SohoParm('cropr', 'real', [-1], False),
            'cropb': SohoParm('cropb', 'real', [-1], False),
            'cropt': SohoParm('cropt', 'real', [-1], False),
            'camera': SohoParm('camera', 'string', ['/obj/cam1'], False)
        }

        camParmsEval = sohoCam.evaluate(camParms, t)
        if not camParmsEval:
            return {}

        viewParams = {}
        for key in camParmsEval:
            viewParams[key] = camParmsEval[key].Value[0]

        viewParams['transform'] = camParmsEval['space:world'].Value
        viewParams['ortho'] = 1 if camParmsEval['projection'].Value[0] in {
            'ortho'
        } else 0
        viewParams['res'] = camParmsEval['res'].Value

        cropX = viewParams['res'][0] * viewParams['cropl']
        cropY = viewParams['res'][1] * (1.0 - viewParams['cropt'])
        cropW = viewParams['res'][0] * (viewParams['cropr'] -
                                        viewParams['cropl'])
        cropH = viewParams['res'][1] * (viewParams['cropt'] -
                                        viewParams['cropb'])

        printDebug("  Res: %s" % viewParams['res'])
        printDebug("  Crop: %i-%i %i x %i " % (cropX, cropY, cropW, cropH))

        return viewParams
Пример #9
0
'''
    IFDuserhooks.py
    A simple example to illustrate the IFDhooks features
'''
import traceback
from IFDapi import *
import math
import os
import re
import hou
import soho
from soho import SohoParm

ifdcodeParms = {
    'vm_ifdcode': SohoParm('vm_ifdcode', 'string', [''], False),
}


def processInclude(filename):

    if filename:
        if filename.find(' ') >= 0:
            ray_comment('Inline include (value has spaces)')
            #soho.indent()
            print filename
            ray_comment('End of Inline include')
        else:
            try:
                fp = open(filename, 'r')
                ray_comment('Include file: %s' % filename)
                for line in fp.readlines():
Пример #10
0
import sys

import hou

import soho
import sohoglue
import SOHOcommon

import _vfh_ipr

from soho import SohoParm

RENDER_RT_MODE_SOHO = 1

camParms = {
    'space:world': SohoParm('space:world', 'real', [], False),
    'focal': SohoParm('focal', 'real', [0.050], False),
    'aperture': SohoParm('aperture', 'real', [0.0414214], False),
    'orthowidth': SohoParm('orthowidth', 'real', [2], False),
    'near': SohoParm('near', 'real', [0.001], False),
    'far': SohoParm('far', 'real', [1000], False),
    'res': SohoParm('res', 'int', [640, 480], False),
    'projection': SohoParm('projection', 'string', ["perspective"], False),
    'cropLeft': SohoParm('cropl', 'real', [-1], False),
    'cropRight': SohoParm('cropr', 'real', [-1], False),
    'cropBottom': SohoParm('cropb', 'real', [-1], False),
    'cropTop': SohoParm('cropt', 'real', [-1], False),
}


def printDebug(fmt, *args):
Пример #11
0
def addFog(token, storage, houdini, skipdefault=True):
    _Settings.Fog.append(SohoParm(houdini, storage, None, skipdefault, token))
Пример #12
0
def addGlobal(style, token, storage, houdini, skipdefault=True):
    parm = SohoParm(houdini, storage, None, skipdefault, key=token)
    parm.Style = style
    _Settings.Global.append(parm)
Пример #13
0
def addImageOption(token, storage, houdini, skipdefault=True):
    _Settings.IOption.append(
        SohoParm(houdini, storage, None, skipdefault, token))
Пример #14
0
def addBokeh(driver, token, storage, houdini, skipdefault=True):
    if not _Settings.Bokeh.has_key(driver):
        _Settings.Bokeh[driver] = []
    _Settings.Bokeh[driver].append(
        SohoParm(houdini, storage, None, skipdefault, token))
Пример #15
0
def addDeepResolver(driver, token, storage, houdini, default=None):
    if not _Settings.DeepResolver.has_key(driver):
        _Settings.DeepResolver[driver] = []
    _Settings.DeepResolver[driver].append(
        SohoParm(houdini, storage, default, default == None, token))
Пример #16
0
def addGeometry(token, storage, houdini, skipdefault=True):
    _Settings.Geometry.append(
        SohoParm(houdini, storage, None, skipdefault, token))
Пример #17
0
        if value[0]:
            value[0] = 0
            return True
    return False


def envintensity(obj, now, value):
    plist = obj.evaluate(lshaderParms, now)
    value[:] = get_color(plist)
    return True


# Properties in the HoudiniLight object which get mapped to the
# surface shader.
lshaderParms = {
    'env_mode': SohoParm('env_mode', 'string', ['direct'], False),
    'env_doadaptive': SohoParm('env_doadaptive', 'int', [0], False),
    'env_domaxdist': SohoParm('env_domaxdist', 'int', [0], False),
    'env_maxdist': SohoParm('env_maxdist', 'real', [10], False),
    'env_angle': SohoParm('env_angle', 'real', [90], False),
    'light_color': SohoParm('light_color', 'real', [1, 1, 1], False),
    'light_intensity': SohoParm('light_intensity', 'real', [1], False),
    'light_exposure': SohoParm('light_exposure', 'real', [0], False),
    'env_null': SohoParm('env_null', 'string', [''], False),
    'env_clipy': SohoParm('env_clipy', 'int', [0], False),
    'shadowmask': SohoParm('shadowmask', 'string', ['*'], False),
    'shadow_intensity': SohoParm('shadow_intensity', 'real', [1], False),
    'shadow_transparent': SohoParm('shadow_transparent', 'int', [1], False),
}

Пример #18
0
def soho_render():
    control_parms = {
        # The time at which the scene is being rendered
        "now": SohoParm("state:time", "real", [0], False, key="now"),
        "camera": SohoParm("camera", "string", ["/obj/cam1"], False),
    }

    parms = soho.evaluate(control_parms)

    now = parms["now"].Value[0]
    camera = parms["camera"].Value[0]

    options = {}
    if not soho.initialize(now, camera, options):
        soho.error("Unable to initialize rendering module with given camera")

    object_selection = {
        # Candidate object selection
        "vobject": SohoParm("vobject", "string", ["*"], False),
        "alights": SohoParm("alights", "string", ["*"], False),
        "forceobject": SohoParm("forceobject", "string", [""], False),
        "forcelights": SohoParm("forcelights", "string", [""], False),
        "excludeobject": SohoParm("excludeobject", "string", [""], False),
        "excludelights": SohoParm("excludelights", "string", [""], False),
        "sololight": SohoParm("sololight", "string", [""], False),
    }

    for cam in soho.objectList("objlist:camera"):
        break
    else:
        soho.error("Unable to find viewing camera for render")

    objparms = cam.evaluate(object_selection, now)

    stdobject = objparms["vobject"].Value[0]
    stdlights = objparms["alights"].Value[0]
    forceobject = objparms["forceobject"].Value[0]
    forcelights = objparms["forcelights"].Value[0]
    excludeobject = objparms["excludeobject"].Value[0]
    excludelights = objparms["excludelights"].Value[0]
    sololight = objparms["sololight"].Value[0]
    forcelightsparm = "forcelights"

    if sololight:
        stdlights = excludelights = ""
        forcelights = sololight
        forcelightsparm = "sololight"

    # First, we add objects based on their display flags or dimmer values
    soho.addObjects(
        now,
        stdobject,
        stdlights,
        "",
        True,
        geo_parm="vobject",
        light_parm="alights",
        fog_parm="",
    )
    soho.addObjects(
        now,
        forceobject,
        forcelights,
        "",
        False,
        geo_parm="forceobject",
        light_parm=forcelightsparm,
        fog_parm="",
    )
    soho.removeObjects(
        now,
        excludeobject,
        excludelights,
        "",
        geo_parm="excludeobject",
        light_parm="excludelights",
        fog_parm="",
    )

    # Lock off the objects we've selected
    soho.lockObjects(now)

    with hou.undos.disabler(), scene_state:
        if "SOHO_PBRT_DEV" in os.environ:  # pragma: no coverage
            import cProfile

            pr = cProfile.Profile()
            pr.enable()
            try:
                PBRTscene.render(cam, now)
            finally:
                pr.disable()
                pr.dump_stats("hou-prbt.stats")
        else:
            PBRTscene.render(cam, now)
    return
Пример #19
0
import soho
import hou
import IFDapi
import IFDmisc
import IFDframe
import IFDgeo
import IFDsettings
import IFDhooks
from soho import SohoParm
from IFDapi import *

clockstart = time.clock()

controlParameters = {
    # The time at which the scene is being rendered
    'now'     : SohoParm('state:time', 'real',  [0], False,  key='now'),

    'main'    : SohoParm('render_viewcamera','int', [1], False, key='main'),
    'decl'    : SohoParm('declare_all_shops', 'int', [0], False, key='decl'),
    'engine'  : SohoParm('vm_renderengine',  'string', ['micropoly'],
                                            False, key='engine'),
    'vm_inheritproperties' : SohoParm('vm_inheritproperties', 'int', [0], False),
    'vm_embedvex' :SohoParm('vm_embedvex',  'int', [0], False, key='embedvex'),
}

parmlist = soho.evaluate(controlParameters)

now     = parmlist['now'].Value[0]
IFDapi.ForceEmbedVex = parmlist['embedvex'].Value[0]
decl_shops = parmlist['decl'].Value[0]
Пример #20
0
def addLight(token, storage, houdini, skipdefault=True):
    _Settings.Light.append(SohoParm(houdini, storage, None, skipdefault,
                                    token))
Пример #21
0
Файл: APS.py Проект: symek/haps
import sys, os

import time
import soho
import sohog
import hou
from soho import SohoParm
from datetime import datetime

# IFDhooks.call("pre_ifdGen")
clockstart = time.time()

controlParameters = {
    # The time at which the scene is being rendered
    'now':
    SohoParm('state:time', 'real', [0], False, key='now'),

    # The mode (default, rerender generate, rerender update)
    'mode':
    SohoParm('state:previewmode', 'string', ['default'], False, key='mode'),

    # A string with names of style sheets changed since the last IPR update.
    'dirtystylesheets':
    SohoParm('state:dirtystylesheets',
             'string', [''],
             False,
             key='dirtystylesheets'),

    # A string with names of bundles changed since the last IPR update.
    'dirtybundles':
    SohoParm('state:dirtybundles', 'string', [''], False, key='dirtybundles'),
Пример #22
0
# Now Houdini stuff:

clockstart = time.clock()

# If you look at the parameters below, you'll see 'state:time'.  There
# are a set of special tokens which SOHO recognizes.  To get a list of
# these tokens, you can enable the following code.
#tokens = []
#soho.evalString('state:alltokens', tokens)
#print 'SOHO Tokens:', tokens
#soho.evalString('state:allgeotokens', tokens)
#print 'Geometry Tokens:', tokens

controlParameters = {
    # The time at which the scene is being rendered
    'now'     : SohoParm('state:time',  'real', [0], False,  key='now'),
    'fps'     : SohoParm('state:fps',   'real', [24], False, key='fps'),
    'camera'  : SohoParm('camera', 'string', ['/obj/cam1'], False),
    'picture' : SohoParm('vm_picture', 'string', ['ip'], False),
    'samples' : SohoParm('vm_samples', 'real', [2], False),
    'sampler' : SohoParm('vm_sampler', 'string', ['ldsampler'], False),
    'reflectlimit' : SohoParm('vm_reflectlimit', 'int', [1], False),
    'integrator' : SohoParm('vm_integrator', 'string', ['path'], False),
     'camera' : SohoParm('camera', 'string', ['/obj/cam1'], False),
     'skip_geo_export' : SohoParm('skip_geo_export', 'int', [0], False)}



# Evaluate the control parameters to determine settings for the render
parmlist = soho.evaluate(controlParameters)
Пример #23
0
def soho_render():
    control_parms = {
        # The time at which the scene is being rendered
        'now': SohoParm('state:time', 'real', [0], False, key='now'),
        'fps': SohoParm('state:fps', 'real', [24], False, key='fps'),
        'camera': SohoParm('camera', 'string', ['/obj/cam1'], False),
    }

    parms = soho.evaluate(control_parms)

    now = parms['now'].Value[0]
    camera = parms['camera'].Value[0]
    fps = parms['fps'].Value[0]

    options = {'state:precision': 6}
    if not soho.initialize(now, camera, options):
        soho.error("Unable to initialize rendering module with given camera")

    object_selection = {
        # Candidate object selection
        'vobject': SohoParm('vobject', 'string', ['*'], False),
        'alights': SohoParm('alights', 'string', ['*'], False),
        'forceobject': SohoParm('forceobject', 'string', [''], False),
        'forcelights': SohoParm('forcelights', 'string', [''], False),
        'excludeobject': SohoParm('excludeobject', 'string', [''], False),
        'excludelights': SohoParm('excludelights', 'string', [''], False),
        'sololight': SohoParm('sololight', 'string', [''], False),
    }

    for cam in soho.objectList('objlist:camera'):
        break
    else:
        soho.error('Unable to find viewing camera for render')

    objparms = cam.evaluate(object_selection, now)

    stdobject = objparms['vobject'].Value[0]
    stdlights = objparms['alights'].Value[0]
    forceobject = objparms['forceobject'].Value[0]
    forcelights = objparms['forcelights'].Value[0]
    excludeobject = objparms['excludeobject'].Value[0]
    excludelights = objparms['excludelights'].Value[0]
    sololight = objparms['sololight'].Value[0]
    forcelightsparm = 'forcelights'

    if sololight:
        stdlights = excludelights = None
        forcelights = sololight
        forcelightsparm = 'sololight'

    # First, we add objects based on their display flags or dimmer values
    soho.addObjects(now, stdobject, stdlights, '', True)
    soho.addObjects(now, forceobject, forcelights, '', False)
    soho.removeObjects(now, excludeobject, excludelights, '')

    # Lock off the objects we've selected
    soho.lockObjects(now)

    with hou.undos.disabler(), scene_state:
        PBRTscene.render(cam, now)
    return
Пример #24
0

def aperture(obj, now, value):
    if isdistantlight(obj, now):
        return False
    return obj.evalFloat('aperture', now, value)


def orthowidth(obj, now, value):
    if not isdistantlight(obj, now):
        return False
    return obj.evalFloat('orthowidth', now, value)


attenParms = {
    'atten_start': SohoParm('atten_start', 'real', [1], False),
    'atten_type': SohoParm('atten_type', 'string', ['half'], False),
    'atten_dist': SohoParm('atten_dist', 'real', [1e6], False),
    'attenrampenable': SohoParm('attenrampenable', 'int', [0], False),
    'atten_rampstart': SohoParm('atten_rampstart', 'real', [0], False),
    'atten_rampend': SohoParm('atten_rampend', 'real', [100], False),
}


def attenString(obj, now, ltype):
    plist = obj.evaluate(attenParms, now)

    atten_start = plist['atten_start'].Value[0]
    atten_type = plist['atten_type'].Value[0]
    atten_dist = plist['atten_dist'].Value[0]
    attenrampenable = plist['attenrampenable'].Value[0]
Пример #25
0
CameraShutter = 0
CameraShutterF = 0  # Frame based shutter
CameraDelta = 0
CameraStyle = 'trailing'
InlineGeoDefault = [0]  # By default, outline geometry

# State information for saving external resources
PipeStream = True  # Whether SOHO is writing to a pipe
ExternalSessionId = ''  # A string based on the frame number/hip file
ExternalSharedSessionId = ''  # A string based on the hip file alone
TmpSharedStorage = ''  # Directory used to store side-car files
TmpLocalStorage = ''  # Directory used to store piped temporary files

headerParms = {
    "ropname":
    SohoParm("object:name", "string", key="ropname"),
    "hip":
    SohoParm("$HIP", "string", key="hip"),
    "hipname":
    SohoParm("$HIPNAME", "string", key="hipname"),
    "seqnumber":
    SohoParm("state:sequencenumber", "int", key="seqnumber"),
    "seqlength":
    SohoParm("state:sequencelength", "int", key="seqlength"),
    "soho_program":
    SohoParm("soho_program", "string"),
    "hver":
    SohoParm("state:houdiniversion", "string", ["9.0"], False, key="hver"),
    "lv_hippath":
    SohoParm("lv_hippath", "string", key="lv_hippath"),
    "lv_verbose":
Пример #26
0
# Mostly copied from IFDmisc
import soho
import hou
from soho import SohoParm
from sohog import SohoGeometry
import posixpath

import os

objXformMotion = [
    SohoParm('xform_motionsamples', 'int', [2], False),
]

HOUDINI_TEMP_DIR = '$HOUDINI_TEMP_DIR/ifds/storage'
HOUDINI_SHARED_DIR = '$HIP/ifds/storage'
EXTENSION = '.binarymesh'  # .obj
# GEOMETRY_PATH      =  getLocalStoragePath()
DEFAULT_MATERIAL_NAME = 'default'


def get_obj_filename(obj, group='', ext=EXTENSION):
    objectname = obj.getName().replace("/", "_")[1:] + group + ext
    geometrypath = getLocalStoragePath()
    return os.path.join(geometrypath, objectname)


def ouputMotionBlurInfo(obj, now, CameraBlur, required=False):
    motionInfo = {
        'xform':
        SohoParm('xform_motionsamples', 'int', [2], not required, key='xform'),
        'geo':
# NAME: HoudiniIndirectLightRIB.py ( Python )
#
# COMMENTS:     Wrangler for the HoudiniIndirectLight object.

import os
import soho
import hou
from soho import SohoParm

# Properties in the HoudiniIndirectLight object which get mapped to the
# light shader.
lshaderParms = {
    'r'               : SohoParm('r', 'real', [0,0,0], False),
    
    'light_type'            : SohoParm('light_type',        'string', ['point'], False),
    'light_color'           : SohoParm('light_color',      'real', [.5,.5,.5], False),
    'light_intensity'       : SohoParm('light_intensity',     'real', [1], False),
    
    'light_contribdiff'     : SohoParm('light_contribdiff', 'int', [1], False),
    'light_contribspec'     : SohoParm('light_contribspec', 'int', [1], False),

    'vm_samplingquality'    : SohoParm('vm_samplingquality', 'real', [1], False),
    'render_domaxdist'         : SohoParm('render_domaxdist', 'int', [0], False),
    'render_maxdist'           : SohoParm('render_maxdist', 'real', [10], False),
    'render_angle'             : SohoParm('render_angle', 'real', [90], False),
    'render_doadaptive'        : SohoParm('render_doadaptive', 'int', [0], False),
}

def _fixpath(path):
    if path.startswith('temp:'):
        # Strip off the leading 'temp:'
Пример #28
0
def isObjectFastPointInstancer(obj, now):
    if not obj:
        return False
    plist = obj.evaluate([SohoParm('ptinstance', 'int', [0], False)], now)
    return plist[0].Value[0] == 2
Пример #29
0
#TODO: move it to version.py
__version__            = '0.1-alpha'
__appleseed_version__  = "2.0-beta"


PREAMBULE="""<?xml version="1.0" encoding="UTF-8"?>
<!-- File created by Houdini: {houdini_version}
             Generation Time: {date}
               Render Target: {renderer_version} 
            APS soho version: {aps_version}
               Output driver: {driver}
                    HIP File: {hipfile}, $T={TIME}, $FPS={FPS}
-->"""

oshaderSkipParms = {
    'shop_surfacepath' : SohoParm('shop_disable_surface_shader',  
                                   'bool', [False], False, key='surface'),
    'shop_displacepath' : SohoParm('shop_disable_displace_shader', 
                                   'bool', [False], False, key='displace'),
    'vm_matteshader' : SohoParm('shop_disable_surface_shader',  
                                   'bool', [False], False, key='matteshader'),
}

oshaderMap = {       
    'shop_materialpath' : 'surface',
    'shop_surfacepath'  : 'surface',
    'shop_photonpath'   : 'surface',
    'vm_matteshader'    : 'matteshader',
    'shop_displacepath' : 'displace',
    'shop_cvexpath'     : 'cvex',
}
# NAME: HoudiniEnvLightRIB.py ( Python )
#
# COMMENTS:     Wrangler for the HoudiniEnvLight object.

import os
import soho
import hou, shopclerks
from soho import SohoParm

# Properties in the HoudiniEnvLight object which get mapped to the
# light shader.
lshaderParms = {
    'r': SohoParm('r', 'real', [0, 0, 0], False),
    'light_type': SohoParm('light_type', 'string', ['point'], False),
    'light_color': SohoParm('light_color', 'real', [.5, .5, .5], False),
    'light_intensity': SohoParm('light_intensity', 'real', [1], False),
    'shadow_type': SohoParm('shadow_type', 'string', ['raytrace'], False),
    'light_contribdiff': SohoParm('light_contribdiff', 'int', [1], False),
    'light_contribspec': SohoParm('light_contribspec', 'int', [1], False),
    'env_mode': SohoParm('env_mode', 'string', ['direct'], False),
    'env_map': SohoParm('env_map', 'string', [''], False),
    'env_clipy': SohoParm('env_clipy', 'int', [0], False),
    'vm_samplingquality': SohoParm('vm_samplingquality', 'real', [1], False),
    'env_domaxdist': SohoParm('env_domaxdist', 'int', [0], False),
    'env_maxdist': SohoParm('env_maxdist', 'real', [10], False),
    'env_angle': SohoParm('env_angle', 'real', [90], False),
    'env_doadaptive': SohoParm('env_doadaptive', 'int', [0], False),
    'shadow_intensity': SohoParm('shadow_intensity', 'real', [1], False),
    'shadow_transparent': SohoParm('shadow_transparent', 'int', [1], False),
}