mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
23 lines
664 B
GDScript
23 lines
664 B
GDScript
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):
|
|
var rv = { defs="" }
|
|
var variant_index = context.get_variant(self, uv)
|
|
if variant_index == -1:
|
|
variant_index = context.get_variant(self, uv)
|
|
var texture_name = name+"_tex"
|
|
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 |