2019-08-25 23:27:07 +02:00
|
|
|
tool
|
|
|
|
extends MMGenBase
|
|
|
|
class_name MMGenTexture
|
|
|
|
|
|
|
|
"""
|
|
|
|
Base class for texture generators that provide a texture as output
|
|
|
|
"""
|
|
|
|
|
|
|
|
var texture : ImageTexture = ImageTexture.new()
|
|
|
|
|
|
|
|
func get_output_defs():
|
|
|
|
return [ { rgba="" } ]
|
|
|
|
|
|
|
|
func _get_shader_code(uv : String, output_index : int, context : MMGenContext):
|
2019-09-16 20:45:47 +02:00
|
|
|
var genname = "o"+str(get_instance_id())
|
2019-09-29 10:07:32 +02:00
|
|
|
var rv = { globals=[], defs="", code="" }
|
2019-09-16 20:45:47 +02:00
|
|
|
var texture_name = genname+"_tex"
|
2019-08-25 23:27:07 +02:00
|
|
|
var variant_index = context.get_variant(self, uv)
|
|
|
|
if variant_index == -1:
|
|
|
|
variant_index = context.get_variant(self, uv)
|
2019-09-16 20:45:47 +02:00
|
|
|
rv.code = "vec4 %s_%d = texture(%s, %s);\n" % [ genname, variant_index, texture_name, uv ]
|
|
|
|
rv.rgba = "%s_%d" % [ genname, variant_index ]
|
2019-08-25 23:27:07 +02:00
|
|
|
rv.textures = { texture_name:texture }
|
2019-10-18 08:35:54 +02:00
|
|
|
return rv
|