mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-15 02:01:09 +01:00
Runes node.
This commit is contained in:
parent
2b2c485992
commit
a186c71f9a
@ -585,13 +585,13 @@ static func scratchesc(uv : Vector2, layers : int, size : Vector2, waviness : fl
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func runesc(uv : Vector2, col_row : Vector2) -> Color:
|
||||
var f : float = rune(col_row * uv);
|
||||
static func runesc(uv : Vector2, col_row : Vector2, pseed : float) -> Color:
|
||||
var f : float = rune(col_row * uv, pseed);
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func runesf(uv : Vector2, col_row : Vector2) -> float:
|
||||
return rune(col_row * uv);
|
||||
static func runesf(uv : Vector2, col_row : Vector2, pseed : float) -> float:
|
||||
return rune(col_row * uv, pseed);
|
||||
|
||||
#sdline.mmg
|
||||
#vec2 sdLine(vec2 p, vec2 a, vec2 b) {
|
||||
@ -643,17 +643,17 @@ static func runesf(uv : Vector2, col_row : Vector2) -> float:
|
||||
|
||||
# makes a rune in the 0..1 uv space. Seed is which rune to draw.
|
||||
# passes back gray in x and derivates for lighting in yz
|
||||
static func rune(uv : Vector2) -> float:
|
||||
static func rune(uv : Vector2, pseed : float) -> float:
|
||||
var finalLine : float = 0.0;
|
||||
var pseed : Vector2 = Commons.floorv2(uv) - Vector2(0.41, 0.41);
|
||||
var sseed : Vector2 = Commons.floorv2(uv) - Vector2(pseed, pseed);
|
||||
|
||||
uv = Commons.fractv2(uv);
|
||||
|
||||
for i in range(4):# (int i = 0; i < 4; i++): # // number of strokes
|
||||
var posA : Vector2 = Commons.rand2(Commons.floorv2(pseed + Vector2(0.5, 0.5)));
|
||||
var posB : Vector2 = Commons.rand2(Commons.floorv2(pseed + Vector2(1.5, 1.5)));
|
||||
pseed.x += 2.0;
|
||||
pseed.y += 2.0;
|
||||
var posA : Vector2 = Commons.rand2(Commons.floorv2(sseed + Vector2(0.5, 0.5)));
|
||||
var posB : Vector2 = Commons.rand2(Commons.floorv2(sseed + Vector2(1.5, 1.5)));
|
||||
sseed.x += 2.0;
|
||||
sseed.y += 2.0;
|
||||
|
||||
# expand the range and mod it to get a nicely distributed random number - hopefully. :)
|
||||
|
||||
|
@ -1,65 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
var image : Image
|
||||
var tex : ImageTexture
|
||||
|
||||
export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1)
|
||||
export(Vector2) var bmax : Vector2 = Vector2(1, 1)
|
||||
|
||||
export(bool) var refresh setget reff,reffg
|
||||
|
||||
func _ready():
|
||||
if !Engine.editor_hint:
|
||||
gen()
|
||||
|
||||
|
||||
func gen() -> void:
|
||||
if !image:
|
||||
image = Image.new()
|
||||
image.create(300, 300, false, Image.FORMAT_RGBA8)
|
||||
|
||||
if !tex:
|
||||
tex = ImageTexture.new()
|
||||
|
||||
# var bmin : Vector2 = Vector2(0.1, 0.1)
|
||||
# var bmax : Vector2 = Vector2(1, 1)
|
||||
|
||||
image.lock()
|
||||
|
||||
var w : float = image.get_width()
|
||||
var h : float = image.get_width()
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE)
|
||||
|
||||
var col : Color = runecol(v)
|
||||
|
||||
image.set_pixel(x, y, col)
|
||||
|
||||
|
||||
image.unlock()
|
||||
|
||||
tex.create_from_image(image)
|
||||
# texture = tex
|
||||
|
||||
var p_o49619_columns = 4.000000000;
|
||||
var p_o49619_rows = 4.000000000;
|
||||
|
||||
func runecol(uv : Vector2) -> Color:
|
||||
return Patterns.runesc(uv, Vector2(p_o49619_columns, p_o49619_rows))
|
||||
|
||||
func reffg():
|
||||
return false
|
||||
|
||||
func reff(bb):
|
||||
if bb:
|
||||
gen()
|
||||
|
40
game/addons/mat_maker_gd/nodes/pattern/runes.gd
Normal file
40
game/addons/mat_maker_gd/nodes/pattern/runes.gd
Normal file
@ -0,0 +1,40 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Vector2) var size : Vector2 = Vector2(4, 4)
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 1)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#Rune(vec2($columns, $rows)*$uv, float($seed))
|
||||
return Patterns.runesc(uv, size, ps)
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
Loading…
Reference in New Issue
Block a user