mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
893e5446f8
- The maximum allowed size is now 4096x4096 for all textures. - The material texture size can now be set as low as 16x16. - The default material texture size is now 1024x1024, which matches modern expectations better. Note that this will change the output size of existing material files. This can be solved by changing the output size and saving the material again.
53 lines
1.3 KiB
GDScript
53 lines
1.3 KiB
GDScript
tool
|
|
extends MMGenTexture
|
|
class_name MMGenBuffer
|
|
|
|
"""
|
|
Texture generator buffers, that render their input in a specific resolution and provide the result as output.
|
|
This is useful when using generators that sample their inputs several times (such as convolutions)
|
|
"""
|
|
|
|
var updated : bool = false
|
|
|
|
func _ready():
|
|
if !parameters.has("size"):
|
|
parameters.size = 4
|
|
|
|
func get_type():
|
|
return "buffer"
|
|
|
|
func get_type_name():
|
|
return "Buffer"
|
|
|
|
func get_parameter_defs():
|
|
return [ { name="size", type="size", first=4, last=12, default=4 } ]
|
|
|
|
func get_input_defs():
|
|
return [ { name="in", type="rgba" } ]
|
|
|
|
func get_output_defs():
|
|
return [ { type="rgba" } ]
|
|
|
|
func source_changed(input_port_index : int):
|
|
updated = false
|
|
.source_changed(input_port_index)
|
|
|
|
func _get_shader_code(uv : String, output_index : int, context : MMGenContext):
|
|
var source = get_source(0)
|
|
if source != null and !updated:
|
|
var result = source.generator.render(source.output_index, context.renderer, pow(2, 4+parameters.size))
|
|
while result is GDScriptFunctionState:
|
|
result = yield(result, "completed")
|
|
result.copy_to_texture(texture)
|
|
result.release()
|
|
texture.flags = 0
|
|
updated = true
|
|
var rv = ._get_shader_code(uv, output_index, context)
|
|
while rv is GDScriptFunctionState:
|
|
rv = yield(rv, "completed")
|
|
return rv
|
|
|
|
func _serialize(data):
|
|
data.type = "buffer"
|
|
return data
|