def parse_tex_noise(node: bpy.types.ShaderNodeTexNoise, out_socket: bpy.types.NodeSocket, state: ParserState) -> Union[floatstr, vec3str]: c.write_procedurals() state.curshader.add_function(c_functions.str_tex_noise) c.assets_add(os.path.join(arm.utils.get_sdk_path(), 'armory', 'Assets', 'noise256.png')) c.assets_add_embedded_data('noise256.png') state.curshader.add_uniform('sampler2D snoise256', link='$noise256.png') if node.inputs[0].is_linked: co = c.parse_vector_input(node.inputs[0]) else: co = 'bposition' scale = c.parse_value_input(node.inputs[2]) detail = c.parse_value_input(node.inputs[3]) roughness = c.parse_value_input(node.inputs[4]) distortion = c.parse_value_input(node.inputs[5]) # Color if out_socket == node.outputs[1]: res = 'vec3(tex_noise({0} * {1},{2},{3}), tex_noise({0} * {1} + 120.0,{2},{3}), tex_noise({0} * {1} + 168.0,{2},{3}))'.format(co, scale, detail, distortion) # Fac else: res = 'tex_noise({0} * {1},{2},{3})'.format(co, scale, detail, distortion) if state.sample_bump: c.write_bump(node, out_socket, res, 0.1) return res
def parse_tex_wave(node: bpy.types.ShaderNodeTexWave, out_socket: bpy.types.NodeSocket, state: ParserState) -> Union[floatstr, vec3str]: c.write_procedurals() state.curshader.add_function(c_functions.str_tex_wave) if node.inputs[0].is_linked: co = c.parse_vector_input(node.inputs[0]) else: co = 'bposition' scale = c.parse_value_input(node.inputs[1]) distortion = c.parse_value_input(node.inputs[2]) detail = c.parse_value_input(node.inputs[3]) detail_scale = c.parse_value_input(node.inputs[4]) if node.wave_profile == 'SIN': wave_profile = 0 else: wave_profile = 1 if node.wave_type == 'BANDS': wave_type = 0 else: wave_type = 1 # Color if out_socket == node.outputs[0]: res = 'vec3(tex_wave_f({0} * {1},{2},{3},{4},{5},{6}))'.format(co, scale, wave_type, wave_profile, distortion, detail, detail_scale) # Fac else: res = 'tex_wave_f({0} * {1},{2},{3},{4},{5},{6})'.format(co, scale, wave_type, wave_profile, distortion, detail, detail_scale) if state.sample_bump: c.write_bump(node, out_socket, res) return res
def parse_tex_voronoi(node: bpy.types.ShaderNodeTexVoronoi, out_socket: bpy.types.NodeSocket, state: ParserState) -> Union[floatstr, vec3str]: outp = 0 if out_socket.type == 'RGBA': outp = 1 elif out_socket.type == 'VECTOR': outp = 2 m = 0 if node.distance == 'MANHATTAN': m = 1 elif node.distance == 'CHEBYCHEV': m = 2 elif node.distance == 'MINKOWSKI': m = 3 c.write_procedurals() state.curshader.add_function(c_functions.str_tex_voronoi) if node.inputs[0].is_linked: co = c.parse_vector_input(node.inputs[0]) else: co = 'bposition' scale = c.parse_value_input(node.inputs[2]) exp = c.parse_value_input(node.inputs[4]) randomness = c.parse_value_input(node.inputs[5]) # Color or Position if out_socket == node.outputs[1] or out_socket == node.outputs[2]: res = 'tex_voronoi({0}, {1}, {2}, {3}, {4}, {5})'.format( co, randomness, m, outp, scale, exp) # Distance else: res = 'tex_voronoi({0}, {1}, {2}, {3}, {4}, {5}).x'.format( co, randomness, m, outp, scale, exp) if state.sample_bump: c.write_bump(node, out_socket, res) return res