diffusion #12
|
@ -4,6 +4,6 @@
|
|||
|
||||
[resource]
|
||||
shader = ExtResource( 1 )
|
||||
shader_param/baseColor = Color( 0.992157, 1, 0, 1 )
|
||||
shader_param/highlightColor = Color( 1, 0, 0.984314, 1 )
|
||||
shader_param/isHighlighted = 0
|
||||
shader_param/lowColor = Color( 1, 0.960784, 0, 1 )
|
||||
shader_param/highColor = Color( 0.921569, 0, 1, 1 )
|
||||
shader_param/t = null
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
[resource]
|
||||
resource_local_to_scene = true
|
||||
shader = ExtResource( 1 )
|
||||
shader_param/baseColor = Color( 0.0823529, 0, 1, 1 )
|
||||
shader_param/highlightColor = Color( 1, 0, 0, 1 )
|
||||
shader_param/isHighlighted = null
|
||||
shader_param/lowColor = Color( 0.0313726, 0, 1, 1 )
|
||||
shader_param/highColor = Color( 1, 0, 0, 1 )
|
||||
shader_param/t = null
|
||||
|
|
|
@ -8,7 +8,7 @@ public class GridCursor : Sprite
|
|||
private WorldGrid _grid;
|
||||
private ShaderMaterial _material;
|
||||
|
||||
private const string IS_HIGHLIGHTED = "isHighlighted";
|
||||
private const string T = "t";
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
@ -38,11 +38,11 @@ public class GridCursor : Sprite
|
|||
var pos = mouseButtonEvent.Position;
|
||||
_grid.GetGridPos(pos, out var x, out var y);
|
||||
_grid.ToggleTileHighlight(x, y);
|
||||
_material.SetShaderParam(IS_HIGHLIGHTED, 1);
|
||||
_material.SetShaderParam(T, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
_material.SetShaderParam(IS_HIGHLIGHTED, 0);
|
||||
_material.SetShaderParam(T, 0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class WorldGrid : Node2D
|
|||
{
|
||||
var tile = _tiles[x, y];
|
||||
var material = tile.material;
|
||||
material.SetShaderParam("isHighlighted", tile.isHighlighted ? 1 : 0);
|
||||
material.SetShaderParam("t", tile.isHighlighted ? 1f : 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform vec4 baseColor : hint_color;
|
||||
uniform vec4 highlightColor : hint_color;
|
||||
uniform int isHighlighted;
|
||||
uniform vec4 lowColor : hint_color;
|
||||
uniform vec4 highColor : hint_color;
|
||||
uniform float t;
|
||||
|
||||
void fragment() {
|
||||
COLOR = mix(baseColor, highlightColor, float(isHighlighted));
|
||||
COLOR = mix(lowColor, highColor, t);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue