Pipeline: double bake pass
This commit is contained in:
parent
10d5ed451a
commit
d9d07b33b1
1 changed files with 65 additions and 48 deletions
|
@ -1,22 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
'''
|
||||
DESCRIPTION.
|
||||
Basic mesh processing for asset pipeline.
|
||||
'''
|
||||
__version__ = '0.2'
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
# coding: utf-8
|
||||
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
@ -32,7 +14,7 @@ __version__ = '0.2'
|
|||
DESCRIPTION.
|
||||
Preparing and execution methods for the baking process.
|
||||
'''
|
||||
__version__ = '0.1'
|
||||
__version__ = '0.2'
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
@ -66,8 +48,9 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
|
||||
asm_name = os.path.basename(bpy.context.blend_data.filepath).split('.')[0]
|
||||
asm_path = os.path.dirname(bpy.context.blend_data.filepath)
|
||||
textures_path = os.path.join(asm_path,"textures").replace('\\', '/')
|
||||
bake_path = os.path.join(textures_path,"bake")
|
||||
textures_path = os.path.join(asm_path,'textures').replace('\\', '/')
|
||||
bake_path = os.path.join(textures_path,'bake')
|
||||
bake_path_double = os.path.join(textures_path,'bake_double')
|
||||
os.makedirs(bake_path, exist_ok=True)
|
||||
|
||||
# create node tree
|
||||
|
@ -87,7 +70,7 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
area = target_area
|
||||
break
|
||||
else:
|
||||
logger.info('Please, set default Bledner settings or set "area" parameter!')
|
||||
logger.info('Please, set default Bledner settings or set <area> parameter!')
|
||||
area.spaces[0].tree_type = 'BakeWrangler_Tree'
|
||||
area.spaces[0].path.start(tree)
|
||||
|
||||
|
@ -106,7 +89,7 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
|
||||
tree.nodes['Mesh Settings'].pinned = True
|
||||
tree.nodes['Mesh Settings']['margin'] = 8
|
||||
tree.nodes['Mesh Settings']['ray_dist'] = 0.002
|
||||
tree.nodes['Mesh Settings']['ray_dist'] = 0.001
|
||||
tree.nodes['Sample Settings'].pinned = True
|
||||
tree.nodes['Sample Settings']['bake_samples'] = 4
|
||||
tree.nodes['Pass Settings'].pinned = True
|
||||
|
@ -119,14 +102,18 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
tree.nodes['Output Settings']['img_compression'] = 50
|
||||
tree.nodes['Output Settings']['img_color_mode'] = 1 # RGB
|
||||
|
||||
## batch bake node
|
||||
# batch bake node
|
||||
node_batch = tree.nodes.new('BakeWrangler_Output_Batch_Bake')
|
||||
node_batch.location = (1000, -500)
|
||||
|
||||
node_batch_double = tree.nodes.new('BakeWrangler_Output_Batch_Bake')
|
||||
node_batch_double.location = (2000, -1500)
|
||||
|
||||
node_y_pos = 0
|
||||
pass_socket = 0
|
||||
pass_socket_double = 0
|
||||
for lp_name in lowpoly_obj_names:
|
||||
""" run for eatch low poly object """
|
||||
# run for eatch lowpoly object
|
||||
lp = bpy.data.objects[lp_name]
|
||||
mp = bpy.data.objects['_'.join(lp.name.split('_')[:-1] + [midpoly])]
|
||||
img_name = '_'.join(lp.name.split('_')[:-1]) + '_'
|
||||
|
@ -138,7 +125,7 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
node_inputs.inputs['Source'].value = mp
|
||||
|
||||
# bake passes
|
||||
## Diffuse
|
||||
# Diffuse
|
||||
node_d_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_d_pass.location = (-200, node_y_pos - 500)
|
||||
node_d_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
|
@ -166,14 +153,17 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
node_c_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_c_img.inputs['Split Output'].img_name = img_name
|
||||
'''
|
||||
## Normal
|
||||
# Normal
|
||||
node_n_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
#tree.nodes['Bake Pass.001'].name = 'normal_pass'
|
||||
node_n_pass.location = (-200, node_y_pos - 1500)
|
||||
node_n_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_n_img.location = (200, node_y_pos - 1500)
|
||||
|
||||
node_n_img_double = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_n_img_double.location = (200, node_y_pos - 1750)
|
||||
|
||||
tree.links.new(node_n_pass.outputs['Color'], node_n_img.inputs['Color'])
|
||||
tree.links.new(node_n_pass.outputs['Color'], node_n_img_double.inputs['Color'])
|
||||
|
||||
node_n_pass.bake_cat = 'CORE'
|
||||
node_n_pass.bake_core = 'NORMAL'
|
||||
|
@ -181,13 +171,21 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
node_n_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_n_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
## AO
|
||||
node_n_img_double.inputs['Color'].suffix = 'N'
|
||||
node_n_img_double.inputs['Split Output'].disp_path = bake_path_double
|
||||
node_n_img_double.inputs['Split Output'].img_name = img_name
|
||||
|
||||
# AO
|
||||
node_ao_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_ao_pass.location = (-200, node_y_pos - 2000)
|
||||
node_ao_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_ao_img.location = (200, node_y_pos - 2000)
|
||||
|
||||
node_ao_img_double = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
node_ao_img_double.location = (200, node_y_pos - 2250)
|
||||
|
||||
tree.links.new(node_ao_pass.outputs['Color'], node_ao_img.inputs['Color'])
|
||||
tree.links.new(node_ao_pass.outputs['Color'], node_ao_img_double.inputs['Color'])
|
||||
|
||||
node_ao_pass.bake_cat = 'CORE'
|
||||
node_ao_pass.bake_core = 'AO'
|
||||
|
@ -196,7 +194,11 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
node_ao_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_ao_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
## Roughness
|
||||
node_ao_img_double.inputs['Color'].suffix = 'AO'
|
||||
node_ao_img_double.inputs['Split Output'].disp_path = bake_path_double
|
||||
node_ao_img_double.inputs['Split Output'].img_name = img_name
|
||||
|
||||
# Roughness
|
||||
node_r_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_r_pass.location = (-200, node_y_pos - 2500)
|
||||
node_r_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
|
@ -210,7 +212,7 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
node_r_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_r_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
## Metallic
|
||||
# Metallic
|
||||
node_m_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_m_pass.location = (-200, node_y_pos - 3000)
|
||||
node_m_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
|
@ -224,7 +226,7 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
node_m_img.inputs['Split Output'].disp_path = bake_path
|
||||
node_m_img.inputs['Split Output'].img_name = img_name
|
||||
|
||||
## UV
|
||||
# UV
|
||||
node_uv_pass = tree.nodes.new('BakeWrangler_Bake_Pass')
|
||||
node_uv_pass.location = (-200, node_y_pos - 3500)
|
||||
node_uv_img = tree.nodes.new('BakeWrangler_Output_Image_Path')
|
||||
|
@ -249,7 +251,7 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
tree.links.new(node_inputs.outputs['Mesh'], node_m_pass.inputs[1])
|
||||
tree.links.new(node_inputs.outputs['Mesh'], node_uv_pass.inputs[1])
|
||||
|
||||
## batch bake node
|
||||
# batch bake node
|
||||
tree.links.new(node_d_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
'''
|
||||
pass_socket += 1
|
||||
|
@ -267,6 +269,21 @@ def bw_submit(lowpoly_obj_names, resolution=4096, tree_name='robossembler', area
|
|||
tree.links.new(node_uv_img.outputs['Bake'], node_batch.inputs[pass_socket])
|
||||
pass_socket += 1
|
||||
|
||||
# batch bake node double
|
||||
tree.links.new(node_n_img_double.outputs['Bake'],
|
||||
node_batch_double.inputs[pass_socket_double])
|
||||
pass_socket_double += 1
|
||||
tree.links.new(node_ao_img_double.outputs['Bake'],
|
||||
node_batch_double.inputs[pass_socket_double])
|
||||
pass_socket_double += 1
|
||||
|
||||
node_y_pos -= 4000
|
||||
|
||||
return bpy.ops.bake_wrangler.bake_pass(tree=tree_name, node="Batch Bake", sock=-1)
|
||||
bpy.ops.bake_wrangler.bake_pass(tree=tree_name, node=node_batch.name, sock=-1)
|
||||
|
||||
# double pass
|
||||
tree.nodes['Mesh Settings']['ray_dist'] = 0.01
|
||||
|
||||
bpy.ops.bake_wrangler.bake_pass(tree=tree_name, node=node_batch_double.name, sock=-1)
|
||||
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue