def parse_mixshader(node: bpy.types.ShaderNodeMixShader, out_socket: NodeSocket, state: ParserState) -> None: prefix = '' if node.inputs[0].is_linked else 'const ' fac = c.parse_value_input(node.inputs[0]) fac_var = c.node_name(node.name) + '_fac' fac_inv_var = c.node_name(node.name) + '_fac_inv' state.curshader.write('{0}float {1} = {2};'.format(prefix, fac_var, fac)) state.curshader.write('{0}float {1} = 1.0 - {2};'.format( prefix, fac_inv_var, fac_var)) bc1, rough1, met1, occ1, spec1, opac1, emi1 = c.parse_shader_input( node.inputs[1]) bc2, rough2, met2, occ2, spec2, opac2, emi2 = c.parse_shader_input( node.inputs[2]) if state.parse_surface: state.out_basecol = '({0} * {3} + {1} * {2})'.format( bc1, bc2, fac_var, fac_inv_var) state.out_roughness = '({0} * {3} + {1} * {2})'.format( rough1, rough2, fac_var, fac_inv_var) state.out_metallic = '({0} * {3} + {1} * {2})'.format( met1, met2, fac_var, fac_inv_var) state.out_occlusion = '({0} * {3} + {1} * {2})'.format( occ1, occ2, fac_var, fac_inv_var) state.out_specular = '({0} * {3} + {1} * {2})'.format( spec1, spec2, fac_var, fac_inv_var) state.out_emission = '({0} * {3} + {1} * {2})'.format( emi1, emi2, fac_var, fac_inv_var) if state.parse_opacity: state.out_opacity = '({0} * {3} + {1} * {2})'.format( opac1, opac2, fac_var, fac_inv_var)
def parse_addshader(node: bpy.types.ShaderNodeAddShader, out_socket: NodeSocket, state: ParserState) -> None: bc1, rough1, met1, occ1, spec1, opac1, emi1 = c.parse_shader_input(node.inputs[0]) bc2, rough2, met2, occ2, spec2, opac2, emi2 = c.parse_shader_input(node.inputs[1]) if state.parse_surface: state.out_basecol = '({0} + {1})'.format(bc1, bc2) state.out_roughness = '({0} * 0.5 + {1} * 0.5)'.format(rough1, rough2) state.out_metallic = '({0} * 0.5 + {1} * 0.5)'.format(met1, met2) state.out_occlusion = '({0} * 0.5 + {1} * 0.5)'.format(occ1, occ2) state.out_specular = '({0} * 0.5 + {1} * 0.5)'.format(spec1, spec2) state.out_emission = '({0} * 0.5 + {1} * 0.5)'.format(emi1, emi2) if state.parse_opacity: state.out_opacity = '({0} * 0.5 + {1} * 0.5)'.format(opac1, opac2)
def parse_ambientocclusion(node: bpy.types.ShaderNodeAmbientOcclusion, out_socket: NodeSocket, state: ParserState) -> None: if state.parse_surface: # Single channel state.out_occlusion = c.parse_vector_input(node.inputs[0]) + '.r'
def parse_holdout(node: bpy.types.ShaderNodeHoldout, out_socket: NodeSocket, state: ParserState) -> None: if state.parse_surface: # Occlude state.out_occlusion = '0.0'