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:
RodZill4 2019-11-14 08:47:21 +01:00
parent fd2064181e
commit 4d90c20493
3 changed files with 34 additions and 26 deletions

View File

@ -92,28 +92,20 @@ func source_changed(input_index : int) -> void:
func render_textures() -> void:
for t in TEXTURE_LIST:
var texture = null
var result
if t.has("port"):
if generated_textures[t.texture] != null:
continue
var source = get_source(t.port)
if source != null:
var result = source.generator.render(source.output_index, get_image_size())
while result is GDScriptFunctionState:
result = yield(result, "completed")
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
if source == null:
generated_textures[t.texture] = null
continue
result = source.generator.render(source.output_index, get_image_size())
elif t.has("ports"):
var context : MMGenContext = MMGenContext.new()
var code = []
var shader_textures = {}
var sources = 0
for i in range(t.ports.size()):
var source = get_source(t.ports[i])
if source != null:
@ -123,22 +115,30 @@ func render_textures() -> void:
code.push_back(status)
for t in status.textures.keys():
shader_textures[t] = status.textures[t]
sources += 1
else:
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 result = mm_renderer.render_shader(shader, shader_textures, get_image_size())
while result is GDScriptFunctionState:
result = yield(result, "completed")
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
result = mm_renderer.render_shader(shader, shader_textures, get_image_size())
else:
generated_textures[t.texture] = null
continue
# 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
while result is GDScriptFunctionState:
result = yield(result, "completed")
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
generated_textures[t.texture] = texture

View File

@ -43,11 +43,17 @@ static func generate_combined_shader(red_code, green_code, blue_code) -> String:
code += file.get_as_text()
code += "\n"
var globals = []
var textures = {}
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"):
for g in c.globals:
if globals.find(g) == -1:
globals.push_back(g)
for t in textures.keys():
code += "uniform sampler2D "+t+";\n"
for g in globals:
code += g
var shader_code = ""

View File

@ -26,6 +26,8 @@ func on_parameter_changed(p, v) -> void:
var o = controls[p]
if o is MMFloatEdit:
o.value = v
elif o is HSlider:
o.value = v
elif o is LineEdit:
o.text = v
elif o is SizeOptionButton: