Skip to content

Commit

Permalink
Fixed Iterate Buffer's .iteration attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
RodZill4 committed Jan 22, 2025
1 parent 59a9c16 commit 50774e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions addons/material_maker/engine/nodes/gen_iterate_buffer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ func _get_shader_code(uv : String, output_index : int, context : MMGenContext) -
var genname = "o"+str(get_instance_id())
var shader_code = _get_shader_code_lod(uv, output_index, context, is_greyscale, -1.0, "_it_tex" if output_index == 0 else "_loop_tex")
shader_code.add_uniform("%s_it_tex_size" % genname, "float", pow(2, get_parameter("size")))
shader_code.add_uniform(iteration_param_name, "int", current_iteration)
return shader_code

func get_output_attributes(output_index : int) -> Dictionary:
Expand Down
5 changes: 3 additions & 2 deletions addons/material_maker/engine/nodes/gen_shader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -597,15 +597,16 @@ func replace_input(input_name : String, suffix : String, parameters : String, va
var replaced : String = replace_variables(input_def.default, variables, rv, context)
variables.uv = old_uv
return replaced
if suffix == "texture" or suffix == "size":
if suffix != null:
if source.generator.has_method("get_output_attributes"):
var attributes = source.generator.get_output_attributes(source.output_index)
var attribute_name : String = suffix
if attribute_name == "size":
attribute_name = "texture_size"
if attributes != null and attributes is Dictionary and attributes.has(attribute_name):
return attributes[attribute_name]
return "(error: Cannot find texture for input %s)" % input_name
if suffix == "texture" or suffix == "size":
return "(error: Cannot find attribute %s for input %s)" % [ suffix, input_name ]
if input_def.has("function") and input_def.function:
var function_name : String = "o%s_input_%s" % [ str(get_instance_id()), input_def.name ]
if suffix == "variation":
Expand Down

0 comments on commit 50774e4

Please sign in to comment.