first commit
This commit is contained in:
16
scripts/mat.gd
Normal file
16
scripts/mat.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
extends RefCounted
|
||||
## Material-Cache: eine ShaderMaterial pro Farbe, flat shaded.
|
||||
|
||||
const FLAT_SHADER := preload("res://shaders/flat.gdshader")
|
||||
|
||||
static var _cache: Dictionary = {}
|
||||
|
||||
static func flat(color: Color) -> ShaderMaterial:
|
||||
var key := color.to_rgba32()
|
||||
if _cache.has(key):
|
||||
return _cache[key]
|
||||
var m := ShaderMaterial.new()
|
||||
m.shader = FLAT_SHADER
|
||||
m.set_shader_parameter("albedo", color)
|
||||
_cache[key] = m
|
||||
return m
|
||||
Reference in New Issue
Block a user