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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...