Skip to content

Commit

Permalink
Merge pull request #3106 from 1k8/main
Browse files Browse the repository at this point in the history
Updated noise to support color socket with fix
  • Loading branch information
luboslenco authored Dec 24, 2024
2 parents e084bef + 4a0f1a4 commit 1c610ed
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions armory/blender/arm/material/cycles_nodes/nodes_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,28 +268,31 @@ def parse_tex_noise(node: bpy.types.ShaderNodeTexNoise, out_socket: bpy.types.No
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 bpy.app.version >= (4, 1, 0):
# Needs a switch for the new set of types for noise where the musgrave was moved
if node.noise_type == "FBM"
state.curshader.add_function(c_functions.str_tex_musgrave)
res = f'tex_musgrave_f({co} * {scale} * 1.0)'
if node.noise_type == "FBM":
if out_socket == node.outputs[1]:
state.curshader.add_function(c_functions.str_tex_musgrave)
res = 'vec3(tex_musgrave_f({0} * {1}), tex_musgrave_f({0} * {1} + 120.0), tex_musgrave_f({0} * {1} + 168.0))'.format(co, scale, detail, distortion)
else:
res = f'tex_musgrave_f({co} * {scale} * 1.0)'
else:
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)
else:
res = 'tex_noise({0} * {1},{2},{3})'.format(co, scale, detail, distortion)
else:
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)
else:
res = 'tex_noise({0} * {1},{2},{3})'.format(co, scale, detail, distortion)
return res


Expand Down

0 comments on commit 1c610ed

Please sign in to comment.