material-maker/addons/material_maker/engine/gen_texture.gd

23 lines
674 B
GDScript3
Raw Normal View History

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-10 21:01:08 +02:00
var rv = { defs="", code="" }
var texture_name = name+"_tex"
var variant_index = context.get_variant(self, uv)
if variant_index == -1:
variant_index = context.get_variant(self, uv)
2019-09-10 21:01:08 +02:00
rv.code = "vec4 %s_%d = texture(%s, %s);\n" % [ name, variant_index, texture_name, uv ]
rv.rgba = "%s_%d" % [ name, variant_index ]
rv.textures = { texture_name:texture }
return rv