mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Initial shapes node implementation / cleanup. It still needs universal inputs.
This commit is contained in:
parent
0923f1095b
commit
ebb8098ba2
@ -1,8 +1,9 @@
|
||||
[gd_resource type="Resource" load_steps=6 format=2]
|
||||
[gd_resource type="Resource" load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/mm_material.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/perlin.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/noise.gd" type="Script" id=3]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/simple/shape.gd" type="Script" id=4]
|
||||
|
||||
[sub_resource type="Resource" id=1]
|
||||
script = ExtResource( 2 )
|
||||
@ -18,7 +19,15 @@ bmin = Vector2( 0.1, 0.1 )
|
||||
bmax = Vector2( 1, 1 )
|
||||
refresh = false
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
script = ExtResource( 4 )
|
||||
graph_position = Vector2( -280, -220 )
|
||||
shape_type = 0
|
||||
sides = 6
|
||||
radius = 0.845361
|
||||
edge = 0.051546
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
image_size = Vector2( 128, 128 )
|
||||
nodes = [ SubResource( 1 ), SubResource( 2 ) ]
|
||||
nodes = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ) ]
|
||||
|
@ -1,73 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Shapes = preload("res://addons/mat_maker_gd/nodes/common/shapes.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
|
||||
|
||||
|
||||
var p_o3704_albedo_color_r : float = 1.000000000;
|
||||
var p_o3704_albedo_color_g : float = 1.000000000;
|
||||
var p_o3704_albedo_color_b : float = 1.000000000;
|
||||
var p_o3704_albedo_color_a : float = 1.000000000;
|
||||
var p_o3704_metallic : float = 1.000000000;
|
||||
var p_o3704_roughness : float = 1.000000000;
|
||||
var p_o3704_emission_energy : float = 1.000000000;
|
||||
var p_o3704_normal : float = 1.000000000;
|
||||
var p_o3704_ao : float = 1.000000000;
|
||||
var p_o3704_depth_scale : float = 0.500000000;
|
||||
var p_o3704_sss : float = 0.000000000;
|
||||
|
||||
var p_o69054_sides : float = 6.000000000;
|
||||
var p_o69054_radius : float = 0.845361000;
|
||||
var p_o69054_edge : float = 0.051546000;
|
||||
|
||||
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 c : float = Commons.shape_circle(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0)
|
||||
# var c : float = Commons.shape_polygon(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0)
|
||||
# var c : float = Commons.shape_star(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0)
|
||||
# var c : float = Commons.shape_curved_star(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0)
|
||||
var c : float = Shapes.shape_rays(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0)
|
||||
|
||||
image.set_pixel(x, y, Color(c, c, c, 1))
|
||||
|
||||
image.unlock()
|
||||
|
||||
tex.create_from_image(image)
|
||||
# texture = tex
|
||||
|
||||
func reffg():
|
||||
return false
|
||||
|
||||
func reff(bb):
|
||||
if bb:
|
||||
gen()
|
||||
|
56
game/addons/mat_maker_gd/nodes/simple/shape.gd
Normal file
56
game/addons/mat_maker_gd/nodes/simple/shape.gd
Normal file
@ -0,0 +1,56 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Shapes = preload("res://addons/mat_maker_gd/nodes/common/shapes.gd")
|
||||
|
||||
enum ShapeType {
|
||||
SHAPE_TYPE_CIRCLE = 0,
|
||||
SHAPE_TYPE_POLYGON = 1,
|
||||
SHAPE_TYPE_STAR = 2,
|
||||
SHAPE_TYPE_CURVED_STAR = 3,
|
||||
SHAPE_TYPE_RAYS = 4,
|
||||
}
|
||||
|
||||
export(int, "Circle,Polygon,Star,Curved Star,Rays") var shape_type : int = 0
|
||||
export(int) var sides : int = 6
|
||||
export(float) var radius : float = 0.845361000; #univ input todo
|
||||
export(float) var edge : float = 0.051546000; #univ input todo
|
||||
|
||||
func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color:
|
||||
var c : float = 0
|
||||
|
||||
if shape_type == ShapeType.SHAPE_TYPE_CIRCLE:
|
||||
c = Shapes.shape_circle(uv, sides, radius * 1.0, edge * 1.0)
|
||||
elif shape_type == ShapeType.SHAPE_TYPE_POLYGON:
|
||||
c = Shapes.shape_polygon(uv, sides, radius * 1.0, edge * 1.0)
|
||||
elif shape_type == ShapeType.SHAPE_TYPE_STAR:
|
||||
c = Shapes.shape_star(uv, sides, radius * 1.0, edge * 1.0)
|
||||
elif shape_type == ShapeType.SHAPE_TYPE_CURVED_STAR:
|
||||
c = Shapes.shape_curved_star(uv, sides, radius * 1.0, edge * 1.0)
|
||||
elif shape_type == ShapeType.SHAPE_TYPE_RAYS:
|
||||
c = Shapes.shape_rays(uv, sides, radius * 1.0, edge * 1.0)
|
||||
|
||||
return Color(c, c, c, 1)
|
||||
|
||||
func register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_IMAGE, "recalculate_image", "")
|
||||
mm_graph_node.add_slot_enum(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_shape_typoe", "set_shape_typoe", "shape_type", [ "Circle", "Polygon", "Star", "Curved Star", "Rays" ])
|
||||
mm_graph_node.add_slot_int(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_sides", "set_sides", "sides")#, Vector2(1, 10))
|
||||
#mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_persistence", "set_persistence", "persistence", 0.05)#, Vector2(0, 1))
|
||||
#mm_graph_node.add_slot_vector2(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_scale", "set_scale", "scale", 1)#, Vector2(1, 32))
|
||||
|
||||
func get_shape_typoe() -> int:
|
||||
return shape_type
|
||||
|
||||
func set_shape_typoe(val : int) -> void:
|
||||
shape_type = val
|
||||
|
||||
emit_changed()
|
||||
|
||||
func get_sides() -> int:
|
||||
return sides
|
||||
|
||||
func set_sides(val : int) -> void:
|
||||
sides = val
|
||||
|
||||
emit_changed()
|
Loading…
Reference in New Issue
Block a user