add piece thickness
This commit is contained in:
parent
375851ca00
commit
ae89c2b46a
|
@ -34,6 +34,6 @@ Color palette: https://lospec.com/palette-list/slso8
|
||||||
|
|
||||||
Inspiration
|
Inspiration
|
||||||
-----------
|
-----------
|
||||||
- [ZHED](playzhed.com)
|
- https://playzhed.com
|
||||||
- [adrena...line](managore.itch.io/adrena-line)
|
- https://managore.itch.io/adrena-line
|
||||||
- [pet putt](http://petputt.com/)
|
- https://petputt.com/
|
||||||
|
|
|
@ -39,9 +39,6 @@ margin_right = 540.0
|
||||||
margin_bottom = 560.0
|
margin_bottom = 560.0
|
||||||
rows = 4
|
rows = 4
|
||||||
columns = 4
|
columns = 4
|
||||||
width = 512
|
|
||||||
height = 512
|
|
||||||
current_state = 0
|
|
||||||
|
|
||||||
[node name="VSplitContainer" type="VBoxContainer" parent="HSplitContainer"]
|
[node name="VSplitContainer" type="VBoxContainer" parent="HSplitContainer"]
|
||||||
margin_left = 548.0
|
margin_left = 548.0
|
||||||
|
|
114
src/Piece.tscn
114
src/Piece.tscn
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=14 format=2]
|
[gd_scene load_steps=16 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/Piece.gd" type="Script" id=1]
|
[ext_resource path="res://src/Piece.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://assets/escher_lizards.jpg" type="Texture" id=2]
|
[ext_resource path="res://assets/escher_lizards.jpg" type="Texture" id=2]
|
||||||
|
@ -8,13 +8,26 @@ constant = Vector3( 0.3, 0.3, 0 )
|
||||||
|
|
||||||
[sub_resource type="VisualShaderNodeExpression" id=12]
|
[sub_resource type="VisualShaderNodeExpression" id=12]
|
||||||
output_port_for_preview = 0
|
output_port_for_preview = 0
|
||||||
size = Vector2( 620, 395 )
|
size = Vector2( 657, 584 )
|
||||||
expression = "// https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
|
expression = "// https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
|
||||||
vec2 rel_p = input.xy - vec2(0.5, 0.5);
|
vec2 rel_p = input.xy - vec2(0.5, 0.5);
|
||||||
float box = 0.4;
|
float box_size = 0.4;
|
||||||
vec2 d = abs(rel_p) - vec2(box, box); // mirroring
|
vec2 box = vec2(box_size, box_size);
|
||||||
float dist = length(max(d, 0.0)) + min(max(d.x,d.y), 0.0);
|
vec2 d = abs(rel_p) - box; // mirroring
|
||||||
alpha_mask = dist < (0.5 - box);"
|
float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
||||||
|
alpha_mask = dist < (0.5 - box_size);
|
||||||
|
|
||||||
|
float thickness = 0.05;
|
||||||
|
vec2 box_thick = vec2(box_size, box_size - thickness);
|
||||||
|
vec2 d_thick = abs(rel_p) - box_thick;
|
||||||
|
float dist_thick = length(max(d_thick, 0.0)) + min(max(d_thick.x, d_thick.y), 0.0);
|
||||||
|
is_thickness = rel_p.y > 0.0 && dist_thick > (0.5 - box_size);"
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeColorConstant" id=13]
|
||||||
|
constant = Color( 0.734375, 0.347832, 0.0657608, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="VisualShaderNodeSwitch" id=14]
|
||||||
|
output_port_for_preview = 0
|
||||||
|
|
||||||
[sub_resource type="VisualShaderNodeTexture" id=2]
|
[sub_resource type="VisualShaderNodeTexture" id=2]
|
||||||
output_port_for_preview = 0
|
output_port_for_preview = 0
|
||||||
|
@ -58,6 +71,31 @@ void fragment() {
|
||||||
// Input:4
|
// Input:4
|
||||||
vec3 n_out4p0 = vec3(UV, 0.0);
|
vec3 n_out4p0 = vec3(UV, 0.0);
|
||||||
|
|
||||||
|
// Expression:13
|
||||||
|
bool n_out13p0;
|
||||||
|
bool n_out13p1;
|
||||||
|
n_out13p0 = false;
|
||||||
|
n_out13p1 = false;
|
||||||
|
{
|
||||||
|
// https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
|
||||||
|
vec2 rel_p = n_out4p0.xy - vec2(0.5, 0.5);
|
||||||
|
float box_size = 0.4;
|
||||||
|
vec2 box = vec2(box_size, box_size);
|
||||||
|
vec2 d = abs(rel_p) - box; // mirroring
|
||||||
|
float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
||||||
|
n_out13p0 = dist < (0.5 - box_size);
|
||||||
|
|
||||||
|
float thickness = 0.05;
|
||||||
|
vec2 box_thick = vec2(box_size, box_size - thickness);
|
||||||
|
vec2 d_thick = abs(rel_p) - box_thick;
|
||||||
|
float dist_thick = length(max(d_thick, 0.0)) + min(max(d_thick.x, d_thick.y), 0.0);
|
||||||
|
n_out13p1 = rel_p.y > 0.0 && dist_thick > (0.5 - box_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Color:15
|
||||||
|
vec3 n_out15p0 = vec3(0.734375, 0.347832, 0.065761);
|
||||||
|
float n_out15p1 = 1.000000;
|
||||||
|
|
||||||
// VectorUniform:7
|
// VectorUniform:7
|
||||||
vec3 n_out7p0 = scale;
|
vec3 n_out7p0 = scale;
|
||||||
|
|
||||||
|
@ -75,20 +113,19 @@ void fragment() {
|
||||||
vec3 n_out3p0 = tex_frg_3_read.rgb;
|
vec3 n_out3p0 = tex_frg_3_read.rgb;
|
||||||
float n_out3p1 = tex_frg_3_read.a;
|
float n_out3p1 = tex_frg_3_read.a;
|
||||||
|
|
||||||
// Expression:13
|
// VectorSwitch:17
|
||||||
bool n_out13p0;
|
vec3 n_out17p0;
|
||||||
n_out13p0 = false;
|
if(n_out13p1)
|
||||||
{
|
{
|
||||||
// https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
|
n_out17p0 = n_out15p0;
|
||||||
vec2 rel_p = n_out4p0.xy - vec2(0.5, 0.5);
|
}
|
||||||
float box = 0.4;
|
else
|
||||||
vec2 d = abs(rel_p) - vec2(box, box); // mirroring
|
{
|
||||||
float dist = length(max(d, 0.0)) + min(max(d.x,d.y), 0.0);
|
n_out17p0 = n_out3p0;
|
||||||
n_out13p0 = dist < (0.5 - box);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output:0
|
// Output:0
|
||||||
COLOR.rgb = n_out3p0;
|
COLOR.rgb = n_out17p0;
|
||||||
COLOR.a = n_out13p0 ? 1.0 : 0.0;
|
COLOR.a = n_out13p0 ? 1.0 : 0.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,38 +135,49 @@ void light() {
|
||||||
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
graph_offset = Vector2( -213.196, 77.3248 )
|
graph_offset = Vector2( -380.872, -106.674 )
|
||||||
mode = 1
|
mode = 1
|
||||||
flags/light_only = false
|
flags/light_only = false
|
||||||
nodes/fragment/0/position = Vector2( 1120, 360 )
|
nodes/fragment/0/position = Vector2( 1540, 360 )
|
||||||
nodes/fragment/3/node = SubResource( 2 )
|
nodes/fragment/3/node = SubResource( 2 )
|
||||||
nodes/fragment/3/position = Vector2( 820, 120 )
|
nodes/fragment/3/position = Vector2( 740, 20 )
|
||||||
nodes/fragment/4/node = SubResource( 3 )
|
nodes/fragment/4/node = SubResource( 3 )
|
||||||
nodes/fragment/4/position = Vector2( -120, 360 )
|
nodes/fragment/4/position = Vector2( -120, 360 )
|
||||||
nodes/fragment/5/node = SubResource( 4 )
|
nodes/fragment/5/node = SubResource( 4 )
|
||||||
nodes/fragment/5/position = Vector2( 360, 80 )
|
nodes/fragment/5/position = Vector2( 280, -20 )
|
||||||
nodes/fragment/6/node = SubResource( 5 )
|
nodes/fragment/6/node = SubResource( 5 )
|
||||||
nodes/fragment/6/position = Vector2( 620, 240 )
|
nodes/fragment/6/position = Vector2( 540, 140 )
|
||||||
nodes/fragment/7/node = SubResource( 6 )
|
nodes/fragment/7/node = SubResource( 6 )
|
||||||
nodes/fragment/7/position = Vector2( 80, 60 )
|
nodes/fragment/7/position = Vector2( 0, -40 )
|
||||||
nodes/fragment/8/node = SubResource( 7 )
|
nodes/fragment/8/node = SubResource( 7 )
|
||||||
nodes/fragment/8/position = Vector2( 380, 340 )
|
nodes/fragment/8/position = Vector2( 300, 240 )
|
||||||
nodes/fragment/9/node = SubResource( 8 )
|
nodes/fragment/9/node = SubResource( 8 )
|
||||||
nodes/fragment/9/position = Vector2( -80, 120 )
|
nodes/fragment/9/position = Vector2( -160, 20 )
|
||||||
nodes/fragment/11/node = SubResource( 1 )
|
nodes/fragment/11/node = SubResource( 1 )
|
||||||
nodes/fragment/11/position = Vector2( 220, 400 )
|
nodes/fragment/11/position = Vector2( 140, 300 )
|
||||||
nodes/fragment/13/node = SubResource( 12 )
|
nodes/fragment/13/node = SubResource( 12 )
|
||||||
nodes/fragment/13/position = Vector2( 260, 540 )
|
nodes/fragment/13/position = Vector2( 440, 440 )
|
||||||
nodes/fragment/13/size = Vector2( 620, 395 )
|
nodes/fragment/13/size = Vector2( 657, 584 )
|
||||||
nodes/fragment/13/input_ports = "0,1,input;"
|
nodes/fragment/13/input_ports = "0,1,input;"
|
||||||
nodes/fragment/13/output_ports = "0,2,alpha_mask;"
|
nodes/fragment/13/output_ports = "0,2,alpha_mask;1,2,is_thickness;"
|
||||||
nodes/fragment/13/expression = "// https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
|
nodes/fragment/13/expression = "// https://iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm
|
||||||
vec2 rel_p = input.xy - vec2(0.5, 0.5);
|
vec2 rel_p = input.xy - vec2(0.5, 0.5);
|
||||||
float box = 0.4;
|
float box_size = 0.4;
|
||||||
vec2 d = abs(rel_p) - vec2(box, box); // mirroring
|
vec2 box = vec2(box_size, box_size);
|
||||||
float dist = length(max(d, 0.0)) + min(max(d.x,d.y), 0.0);
|
vec2 d = abs(rel_p) - box; // mirroring
|
||||||
alpha_mask = dist < (0.5 - box);"
|
float dist = length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
||||||
nodes/fragment/connections = PoolIntArray( 3, 0, 0, 0, 5, 0, 6, 0, 6, 0, 3, 0, 13, 0, 0, 1, 4, 0, 5, 0, 4, 0, 13, 0, 8, 0, 6, 1, 7, 0, 5, 1 )
|
alpha_mask = dist < (0.5 - box_size);
|
||||||
|
|
||||||
|
float thickness = 0.05;
|
||||||
|
vec2 box_thick = vec2(box_size, box_size - thickness);
|
||||||
|
vec2 d_thick = abs(rel_p) - box_thick;
|
||||||
|
float dist_thick = length(max(d_thick, 0.0)) + min(max(d_thick.x, d_thick.y), 0.0);
|
||||||
|
is_thickness = rel_p.y > 0.0 && dist_thick > (0.5 - box_size);"
|
||||||
|
nodes/fragment/15/node = SubResource( 13 )
|
||||||
|
nodes/fragment/15/position = Vector2( 780, -100 )
|
||||||
|
nodes/fragment/17/node = SubResource( 14 )
|
||||||
|
nodes/fragment/17/position = Vector2( 1080, 80 )
|
||||||
|
nodes/fragment/connections = PoolIntArray( 5, 0, 6, 0, 6, 0, 3, 0, 13, 0, 0, 1, 4, 0, 5, 0, 4, 0, 13, 0, 13, 1, 17, 0, 15, 0, 17, 1, 3, 0, 17, 2, 17, 0, 0, 0, 7, 0, 5, 1, 8, 0, 6, 1 )
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id=10]
|
[sub_resource type="ShaderMaterial" id=10]
|
||||||
shader = SubResource( 9 )
|
shader = SubResource( 9 )
|
||||||
|
|
Loading…
Reference in a new issue