Jump to content

bake and composite textures script

Recommended Posts

Hello there!

I'm trying to bake textures for a directory full of models. I'm rendering some types (occlusion and curvature in this case)

and I also want to composite those 2 into one map while I'm at it.

I got all the parts working in my scene and set values with this script accordingly:


import os
import hou

root = 'E:/Items/'

fbxs = []
for root, dirs, files in os.walk(root):
    for f in files:
        if f.endswith(".fbx"):

importNode = hou.node('/obj/geo1/import');
bakeNode = hou.node('out/baketexture1');

temp_dir = 'E:/temp'

for fbx in fbxs:
    outputFilepath = os.path.join(temp_dir, os.path.split(fbx)[1].replace('.fbx','.png'))
    print('Baking: ' + outputFilepath)
    compnode = hou.node('img/img1/composite_channels')    
    print ('Comping')

My problem is that the comp rop is executing without waiting for the bake to finish.

I tried several things..

Using a post-render script that i would modify to set the outputfilename the comp node should use, something like this:

post_script_t = """
import hou
compnode = hou.node('img/img1/composite_channels')    

but then it seems the script cannot find the comp node (do these render scripts have a different environment?) 

I tried checking for the resulting bakes to continue once the files are there but if I do something like this:

    # wait for the textures
        if os.path.exists(f1) and os.path.exists(f2):

the bake  doesn't even seem to start.

Mmh, my last resort would be to do the whole thing in 2 passes, first baking, then compositing but I was curious what's the best 

solution here :)


Thanks for any enlightenment!


PS: first time python in houdini - it's awesome! 



Edited by sschoellhammer

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now