Tex-Gen HDA

Tex-Gen demo

import hou

# Set visuzlizer and color1 attribute from attribute paint

def visualize_map():

# Fetch attribute name from attribute paint

tex_gen_path = hou.pwd().path()

paint_attrib = hou.parm('{0}/paint_map/attribute'.format(tex_gen_path))

# attrib_num need to plus 1

attrib_num = paint_attrib.eval()+1

attrib = ('{0}/paint_map/attribname{1}'.format(tex_gen_path, attrib_num))

attrib_name = hou.parm(attrib).eval()

# Check if override exist

override = hou.parm('{0}/bake_map_override'.format(tex_gen_path)).eval()

if override=='':

# Set attribute to visualizer

category = hou.viewportVisualizerCategory.Node

vis_node = hou.node('{0}/visualize_map'.format(tex_gen_path))

hou.viewportVisualizers.visualizers(category,vis_node)[0].setParm('attrib', attrib_name)

# Set attribute to baking

hou.parm('{0}/baking_map'.format(tex_gen_path)).set(attrib_name)

hou.parm('{0}/tex_name'.format(tex_gen_path)).set(attrib_name)

else :

return

# Set override attribute to visualizer and color1 from parameter

def override_baking():

# Get override

tex_gen_path = hou.pwd().path()

override = hou.parm('{0}/bake_map_override'.format(tex_gen_path)).eval()

# Check override

if override=='':

paint_attrib = hou.parm('{0}/attribute'.format(tex_gen_path))

# attrib_num need to plus 1

attrib_num = paint_attrib.eval()+1

attrib = ('{0}/paint_map/attribname{1}'.format(tex_gen_path,attrib_num))

attrib_name = hou.parm(attrib).eval()

# Set Visualizer

category = hou.viewportVisualizerCategory.Node

vis_node = hou.node('{0}/visualize_map'.format(tex_gen_path))

hou.viewportVisualizers.visualizers(category,vis_node)[0].setParm('attrib', attrib_name)

# Set Baking Map

hou.parm('{0}/baking_map'.format(tex_gen_path)).set(attrib_name)

else:

# Set Override

# Set Visualizer

category = hou.viewportVisualizerCategory.Node

vis_node = hou.node('{0}/visualize_map'.format(tex_gen_path))

hou.viewportVisualizers.visualizers(category,vis_node)[0].setParm('attrib', override)

# Set Baking Map

hou.parm('{0}/baking_map'.format(tex_gen_path)).set(override)

hou.parm('{0}/tex_name'.format(tex_gen_path)).set(override)

# Use UDIM

def set_UDIM():

tex_gen_path = hou.pwd().path()

# Check if use UDIM

udim = hou.parm('{0}/use_UDIM'.format(tex_gen_path)).eval()

# Set

if udim == 1:

hou.parm('{0}/udim_extension'.format(tex_gen_path)).set('.%(UDIM)d')

else:

hou.parm('{0}/udim_extension'.format(tex_gen_path)).set('')

# Press bake texture ROP render button

def bake_map():

tex_gen_path = hou.pwd().path()

hou.parm('{0}/objnet1/ropnet1/baketexture1/execute'.format(tex_gen_path)).pressButton()

# Force re-cook all hair sop

def forceRecook():

all_type = ['hairgen', 'hairgen::2.0', 'groomblend', 'guideadvect',

'guideprocess', 'guidemask','hairclump', 'hairclump::2.0',

'guidecollidevdb']

obj = hou.node('/obj')

all_geo = obj.children()

# Checking obj level

for n in all_geo:

if n.type().name()=='geo':

all_geoChild = n.allSubChildren()

for c in all_geoChild:

if c.type().name() in all_type:

c.setGenericFlag(hou.nodeFlag.Lock,1)

c.setGenericFlag(hou.nodeFlag.Lock,0)

elif n.type().name()=='guidegroom':

guide_children = n.children()

for a in guide_children:

if a.name() =="groom":

all_guideChild = a.children()

for g in all_guideChild:

if g.type().name() in all_type:

g.setGenericFlag(hou.nodeFlag.Lock,1)

g.setGenericFlag(hou.nodeFlag.Lock,0)

elif n.type().name()=='hairgen::2.0':

guide_children = n.children()

for b in guide_children:

if b.name() =="modify":

all_guideChild = b.children()

for h in all_guideChild:

if h.type().name() in all_type:

h.setGenericFlag(hou.nodeFlag.Lock,1)

h.setGenericFlag(hou.nodeFlag.Lock,0)

# Generate Output Nulls

def makeOutput():

tex_gen = hou.pwd()

tex_gen_path = hou.pwd().parent()

out = tex_gen.outputs()

if len(out) > 1 :

hou.ui.displayMessage('Outputs are connected')

elif len(out) == 1:

hou.ui.displayMessage('Output is connected')

else:

# Painted

paint_skin = tex_gen_path.createNode('null','OUT_Painted_SKIN')

paint_skin.setPosition(tex_gen.position())

paint_skin.move((-3,-1))

paint_skin.setColor(hou.Color((0.475,0.812,0.204)))

paint_skin.setInput(0,tex_gen,0)

# Orininal

origin_skin = tex_gen_path.createNode('null','OUT_Original_SKIN')

origin_skin.setPosition(tex_gen.position())

origin_skin.move((0,-1))

origin_skin.setColor(hou.Color((1,0.529,0.624)))

origin_skin.setInput(0,tex_gen,1)

# VDB

skin_vdb = tex_gen_path.createNode('null','OUT_SKIN_VDB')

skin_vdb.setPosition(tex_gen.position())

skin_vdb.move((3,-1))

skin_vdb.setColor(hou.Color((0.518,0.561,0.741)))

skin_vdb.setInput(0,tex_gen,2)

# Force re-cook all hair sop

def force_recook():

hou.hscript(('texcache -c'))

all_type = ['hairgen', 'hairgen::2.0', 'groomblend', 'guideadvect',

'guideprocess', 'guidemask','hairclump', 'hairclump::2.0',

'guidecollidevdb']

obj = hou.node('/obj')

all_geo = obj.children()

# Checking obj level

for n in all_geo:

if n.type().name()=='geo':

all_geoChild = n.allSubChildren()

for c in all_geoChild:

if c.type().name() in all_type:

c.setGenericFlag(hou.nodeFlag.Lock,1)

c.setGenericFlag(hou.nodeFlag.Lock,0)

elif n.type().name()=='guidegroom':

guide_children = n.children()

for a in guide_children:

if a.name() =="groom":

all_guideChild = a.children()

for g in all_guideChild:

if g.type().name() in all_type:

g.setGenericFlag(hou.nodeFlag.Lock,1)

g.setGenericFlag(hou.nodeFlag.Lock,0)

elif n.type().name()=='hairgen::2.0':

guide_children = n.children()

for b in guide_children:

if b.name() =="modify":

all_guideChild = b.children()

for h in all_guideChild:

if h.type().name() in all_type:

h.setGenericFlag(hou.nodeFlag.Lock,1)

h.setGenericFlag(hou.nodeFlag.Lock,0)

Previous
Previous

Clump Viewer HDA

Next
Next

How to Create Curveu Attribute