Skip to content

Commit

Permalink
More fixes and updates in rendering code
Browse files Browse the repository at this point in the history
  • Loading branch information
RodZill4 committed Nov 12, 2023
1 parent 886eab6 commit b894082
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions addons/material_maker/engine/dependencies.gd
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ func buffer_create_compute_material(buffer_name : String, material : MMShaderBas
for p in material.get_parameters().keys():
var value = buffer_add_dependency(buffer_name, p)
if value != null:
await material.set_parameter(p, value)
material.set_parameter(p, value)
buffers[buffer_name].shader_generations += 1

func buffer_create_shader_material(buffer_name : String, material : MMShaderBase, shader : String):
material.set_shader(shader)
await buffer_create_compute_material(buffer_name, material)
buffer_create_compute_material(buffer_name, material)

func print_stats(object = null):
var statuses : Dictionary = {}
Expand Down
5 changes: 1 addition & 4 deletions addons/material_maker/engine/nodes/gen_buffer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ func do_update_shader() -> void:
var context : MMGenContext = MMGenContext.new()
var source : ShaderCode
var source_output : OutputPort = get_source(0)
print(source_output)
if source_output != null:
source = source_output.generator.get_shader_code("uv", source_output.output_index, context)
else:
Expand Down Expand Up @@ -126,10 +125,8 @@ func on_dep_update_buffer(buffer_name : String) -> bool:
if status:
rendering_time = shader_compute.get_render_time()
self.rendering_time_updated.emit(rendering_time)
mm_deps.dependency_update(buffer_name, texture, true)
return true
mm_deps.dependency_update(buffer_name, texture, true)
return false
return status

func _get_shader_code(uv : String, output_index : int, context : MMGenContext) -> ShaderCode:
var genname = "o"+str(get_instance_id())
Expand Down
21 changes: 11 additions & 10 deletions addons/material_maker/engine/nodes/gen_iterate_buffer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var iteration_param_name : String
var used_named_parameters : Array = []


func _init():
func _ready():
#texture.flags = Texture2D.FLAG_REPEAT
shader_computes.append(MMShaderCompute.new())
shader_computes.append(MMShaderCompute.new())
Expand Down Expand Up @@ -77,11 +77,10 @@ func get_output_defs(_show_hidden : bool = false) -> Array:
return [ { type="rgba" }, { type="rgba" } ]

func source_changed(input_port_index : int) -> void:
update_shader(input_port_index)
update_shaders()

func all_sources_changed() -> void:
update_shader(0)
update_shader(1)
update_shaders()

func follow_input(input_index : int) -> Array:
if input_index == 1:
Expand All @@ -91,9 +90,9 @@ func follow_input(input_index : int) -> Array:

var require_shaders_update : bool = false

func update_shader(input_port_index : int) -> void:
if !require_shaders_update:
call_deferred("do_update_shaders")
func update_shaders() -> void:
if ! require_shaders_update:
do_update_shaders.call_deferred()
require_shaders_update = true

func do_update_shaders() -> void:
Expand All @@ -120,6 +119,7 @@ func do_update_shaders() -> void:
else:
await shader_compute.set_shader_from_shadercode(sources[i], f32)
mm_deps.buffer_create_compute_material(buffer_name, shader_compute)
mm_deps.update()
if new_is_greyscale != is_greyscale:
is_greyscale = new_is_greyscale
notify_output_change(0)
Expand Down Expand Up @@ -149,7 +149,7 @@ func on_dep_update_buffer(buffer_name : String) -> bool:
return false
if buffer_name == buffer_names[3]:
return false
if is_rendering:
if false and is_rendering:
return false

is_rendering = true
Expand Down Expand Up @@ -179,7 +179,7 @@ func on_dep_update_buffer(buffer_name : String) -> bool:
if size < 4:
size = 4

await shader_compute.render(texture, size)
var status : bool = await shader_compute.render(texture, size)

is_rendering = false

Expand All @@ -199,7 +199,8 @@ func on_dep_update_buffer(buffer_name : String) -> bool:
else:
mm_deps.dependency_update("o%d_tex" % get_instance_id(), texture, true)
mm_deps.dependency_update(buffer_name, texture, true)
return true

return status

func set_current_iteration(i : int) -> void:
if i == current_iteration:
Expand Down

0 comments on commit b894082

Please sign in to comment.