Fix OOB mousing, small shader tweak
This commit is contained in:
parent
292a4943a0
commit
cc1fec841b
28
Main.tscn
28
Main.tscn
|
@ -11,22 +11,27 @@ uniform float cols = 63.0; // ^
|
||||||
void fragment(){
|
void fragment(){
|
||||||
vec2 frag_pos = UV * vec2(cols, rows);
|
vec2 frag_pos = UV * vec2(cols, rows);
|
||||||
vec2 frag_marginal = fract(frag_pos+0.05);
|
vec2 frag_marginal = fract(frag_pos+0.05);
|
||||||
|
vec2 frag_marginal_2 = fract(frag_pos-0.4);
|
||||||
vec2 grid_data = texture(TEXTURE, (frag_pos+0.05)/vec2(cols+1.0, rows+1.0)).rg;
|
vec2 grid_data = texture(TEXTURE, (frag_pos+0.05)/vec2(cols+1.0, rows+1.0)).rg;
|
||||||
COLOR = vec4(0.0);
|
COLOR = vec4(0.0);
|
||||||
if (frag_marginal.x < 0.1)
|
if (frag_marginal.x < 0.1){
|
||||||
if (grid_data.g >= 0.99)
|
if (grid_data.g >= 0.99){
|
||||||
COLOR = vec4(1.0, 0.0, 0.0, 1.0);
|
if (frag_marginal_2.y <= 0.2)
|
||||||
else if (grid_data.g >= 0.49)
|
COLOR = vec4(1.0, 0.0, 0.0, 1.0);
|
||||||
|
}else if (grid_data.g >= 0.49){
|
||||||
COLOR = vec4(0.0, 0.0, 1.0, 1.0);
|
COLOR = vec4(0.0, 0.0, 1.0, 1.0);
|
||||||
else
|
}else
|
||||||
COLOR = vec4(0.5, 0.5, 0.5, 1.0);
|
COLOR = vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
if (frag_marginal.y < 0.1)
|
}
|
||||||
if (grid_data.r >= 0.99)
|
if (frag_marginal.y < 0.1){
|
||||||
COLOR = vec4(1.0, 0.0, 0.0, 1.0);
|
if (grid_data.r >= 0.99){
|
||||||
else if (grid_data.r >= 0.49)
|
if (frag_marginal_2.x <= 0.2)
|
||||||
|
COLOR = vec4(1.0, 0.0, 0.0, 1.0);
|
||||||
|
}else if (grid_data.r >= 0.49){
|
||||||
COLOR = vec4(0.0, 0.0, 1.0, 1.0);
|
COLOR = vec4(0.0, 0.0, 1.0, 1.0);
|
||||||
else
|
}else
|
||||||
COLOR = vec4(0.5, 0.5, 0.5, 1.0);
|
COLOR = vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
|
}
|
||||||
}"
|
}"
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id=2]
|
[sub_resource type="ShaderMaterial" id=2]
|
||||||
|
@ -63,3 +68,6 @@ margin_right = 40.0
|
||||||
margin_bottom = 38.0
|
margin_bottom = 38.0
|
||||||
expand = true
|
expand = true
|
||||||
stretch_mode = 1
|
stretch_mode = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ const N_COLORS = 5
|
||||||
|
|
||||||
var grid_0 := Vector2(0.0, 0.0)
|
var grid_0 := Vector2(0.0, 0.0)
|
||||||
var grid_space := Vector2(1.0, 1.0)
|
var grid_space := Vector2(1.0, 1.0)
|
||||||
|
var grid_rect := Rect2(0.0, 0.0, 1.0, 1.0)
|
||||||
var h0 := 0.0
|
var h0 := 0.0
|
||||||
var v0 := 0.0
|
var v0 := 0.0
|
||||||
var h_space := 1.0
|
var h_space := 1.0
|
||||||
|
@ -59,6 +60,7 @@ func update_grid_spacing() -> void:
|
||||||
v0 = v_space * v_margin
|
v0 = v_space * v_margin
|
||||||
grid_0 = Vector2(h0, v0)
|
grid_0 = Vector2(h0, v0)
|
||||||
grid_space = Vector2(h_space, v_space)
|
grid_space = Vector2(h_space, v_space)
|
||||||
|
grid_rect = Rect2(h0, v0, h_space*cols, v_space*rows)
|
||||||
|
|
||||||
func grid_corner(row, col) -> Vector2:
|
func grid_corner(row, col) -> Vector2:
|
||||||
return (Vector2(col, row) * grid_space) + grid_0
|
return (Vector2(col, row) * grid_space) + grid_0
|
||||||
|
@ -235,6 +237,8 @@ var drag_action = 0
|
||||||
var drag_color := 0
|
var drag_color := 0
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event is InputEventMouse:
|
if event is InputEventMouse:
|
||||||
|
if !grid_rect.has_point(event.position):
|
||||||
|
return
|
||||||
var gridpos = to_grid_space(event.position)
|
var gridpos = to_grid_space(event.position)
|
||||||
var dx = fmod(gridpos.x, 1.0)
|
var dx = fmod(gridpos.x, 1.0)
|
||||||
var dy = fmod(gridpos.y, 1.0)
|
var dy = fmod(gridpos.y, 1.0)
|
||||||
|
|
Loading…
Reference in New Issue