mirror of
https://github.com/Relintai/material-maker.git
synced 2025-01-09 05:39:38 +01:00
Bug fixes
* In Material node, ORM was not rendered when a channel depended on a texture * Missing HSlider in generic node broke the Switch
This commit is contained in:
parent
fd2064181e
commit
4d90c20493
@ -92,28 +92,20 @@ func source_changed(input_index : int) -> void:
|
|||||||
func render_textures() -> void:
|
func render_textures() -> void:
|
||||||
for t in TEXTURE_LIST:
|
for t in TEXTURE_LIST:
|
||||||
var texture = null
|
var texture = null
|
||||||
|
var result
|
||||||
if t.has("port"):
|
if t.has("port"):
|
||||||
if generated_textures[t.texture] != null:
|
if generated_textures[t.texture] != null:
|
||||||
continue
|
continue
|
||||||
var source = get_source(t.port)
|
var source = get_source(t.port)
|
||||||
if source != null:
|
if source == null:
|
||||||
var result = source.generator.render(source.output_index, get_image_size())
|
generated_textures[t.texture] = null
|
||||||
while result is GDScriptFunctionState:
|
continue
|
||||||
result = yield(result, "completed")
|
result = source.generator.render(source.output_index, get_image_size())
|
||||||
texture = ImageTexture.new()
|
|
||||||
result.copy_to_texture(texture)
|
|
||||||
result.release()
|
|
||||||
# To work, this must be set after calling `copy_to_texture()`
|
|
||||||
texture.flags |= ImageTexture.FLAG_ANISOTROPIC_FILTER
|
|
||||||
|
|
||||||
# Disable filtering for small textures, as they're considered to be used
|
|
||||||
# for a pixel art style
|
|
||||||
if texture.get_size().x <= 128:
|
|
||||||
texture.flags ^= ImageTexture.FLAG_FILTER
|
|
||||||
elif t.has("ports"):
|
elif t.has("ports"):
|
||||||
var context : MMGenContext = MMGenContext.new()
|
var context : MMGenContext = MMGenContext.new()
|
||||||
var code = []
|
var code = []
|
||||||
var shader_textures = {}
|
var shader_textures = {}
|
||||||
|
var sources = 0
|
||||||
for i in range(t.ports.size()):
|
for i in range(t.ports.size()):
|
||||||
var source = get_source(t.ports[i])
|
var source = get_source(t.ports[i])
|
||||||
if source != null:
|
if source != null:
|
||||||
@ -123,22 +115,30 @@ func render_textures() -> void:
|
|||||||
code.push_back(status)
|
code.push_back(status)
|
||||||
for t in status.textures.keys():
|
for t in status.textures.keys():
|
||||||
shader_textures[t] = status.textures[t]
|
shader_textures[t] = status.textures[t]
|
||||||
|
sources += 1
|
||||||
else:
|
else:
|
||||||
code.push_back({ defs="", code="", f=t.default_values[i] })
|
code.push_back({ defs="", code="", f=t.default_values[i] })
|
||||||
|
if sources == 0:
|
||||||
|
generated_textures[t.texture] = null
|
||||||
|
continue
|
||||||
var shader : String = mm_renderer.generate_combined_shader(code[0], code[1], code[2])
|
var shader : String = mm_renderer.generate_combined_shader(code[0], code[1], code[2])
|
||||||
var result = mm_renderer.render_shader(shader, shader_textures, get_image_size())
|
result = mm_renderer.render_shader(shader, shader_textures, get_image_size())
|
||||||
while result is GDScriptFunctionState:
|
else:
|
||||||
result = yield(result, "completed")
|
generated_textures[t.texture] = null
|
||||||
texture = ImageTexture.new()
|
continue
|
||||||
result.copy_to_texture(texture)
|
|
||||||
result.release()
|
|
||||||
# To work, this must be set after calling `copy_to_texture()`
|
|
||||||
texture.flags |= ImageTexture.FLAG_ANISOTROPIC_FILTER
|
|
||||||
|
|
||||||
# Disable filtering for small textures, as they're considered to be used
|
while result is GDScriptFunctionState:
|
||||||
# for a pixel art style
|
result = yield(result, "completed")
|
||||||
if texture.get_size().x <= 128:
|
texture = ImageTexture.new()
|
||||||
texture.flags ^= ImageTexture.FLAG_FILTER
|
result.copy_to_texture(texture)
|
||||||
|
result.release()
|
||||||
|
# To work, this must be set after calling `copy_to_texture()`
|
||||||
|
texture.flags |= ImageTexture.FLAG_ANISOTROPIC_FILTER
|
||||||
|
|
||||||
|
# Disable filtering for small textures, as they're considered to be used
|
||||||
|
# for a pixel art style
|
||||||
|
if texture.get_size().x <= 128:
|
||||||
|
texture.flags ^= ImageTexture.FLAG_FILTER
|
||||||
|
|
||||||
generated_textures[t.texture] = texture
|
generated_textures[t.texture] = texture
|
||||||
|
|
||||||
|
@ -43,11 +43,17 @@ static func generate_combined_shader(red_code, green_code, blue_code) -> String:
|
|||||||
code += file.get_as_text()
|
code += file.get_as_text()
|
||||||
code += "\n"
|
code += "\n"
|
||||||
var globals = []
|
var globals = []
|
||||||
|
var textures = {}
|
||||||
for c in [ red_code, green_code, blue_code ]:
|
for c in [ red_code, green_code, blue_code ]:
|
||||||
|
if c.has("textures"):
|
||||||
|
for t in c.textures.keys():
|
||||||
|
textures[t] = c.textures[t]
|
||||||
if c.has("globals"):
|
if c.has("globals"):
|
||||||
for g in c.globals:
|
for g in c.globals:
|
||||||
if globals.find(g) == -1:
|
if globals.find(g) == -1:
|
||||||
globals.push_back(g)
|
globals.push_back(g)
|
||||||
|
for t in textures.keys():
|
||||||
|
code += "uniform sampler2D "+t+";\n"
|
||||||
for g in globals:
|
for g in globals:
|
||||||
code += g
|
code += g
|
||||||
var shader_code = ""
|
var shader_code = ""
|
||||||
|
@ -26,6 +26,8 @@ func on_parameter_changed(p, v) -> void:
|
|||||||
var o = controls[p]
|
var o = controls[p]
|
||||||
if o is MMFloatEdit:
|
if o is MMFloatEdit:
|
||||||
o.value = v
|
o.value = v
|
||||||
|
elif o is HSlider:
|
||||||
|
o.value = v
|
||||||
elif o is LineEdit:
|
elif o is LineEdit:
|
||||||
o.text = v
|
o.text = v
|
||||||
elif o is SizeOptionButton:
|
elif o is SizeOptionButton:
|
||||||
|
Loading…
Reference in New Issue
Block a user