diff --git a/scenes/bip/bip.gd b/scenes/bip/bip.gd index a7138eb7..9ff16ce5 100644 --- a/scenes/bip/bip.gd +++ b/scenes/bip/bip.gd @@ -13,6 +13,10 @@ func set_ecm_visible(value: bool): $ecm_done.visible = value func update(): $bip.material.set('shader_parameter/tick_update', float(Time.get_ticks_msec()/1000)) +## Задаёт цвет +func set_color(color: Color): $bip.material.set('shader_parameter/color', Vector3(color.r, color.g, color.b)) + + ## Функция присваивает заданое значение видимости селектору. func set_sel_visible(value: bool): selected = value diff --git a/scenes/bip/bip.tscn b/scenes/bip/bip.tscn index c296aff8..861cc7f8 100644 --- a/scenes/bip/bip.tscn +++ b/scenes/bip/bip.tscn @@ -7,6 +7,7 @@ [sub_resource type="ShaderMaterial" id="ShaderMaterial_2dulj"] shader = ExtResource("2_rt0la") shader_parameter/tick_update = 0.0 +shader_parameter/color = Color(0.972549, 0.12549, 0.411765, 1) [sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_w5pye"] @@ -233,6 +234,7 @@ layout_mode = 0 offset_right = 1.0 offset_bottom = 1.0 scale = Vector2(20, 20) +action_mode = 0 button_mask = 3 texture_normal = SubResource("PlaceholderTexture2D_w5pye") stretch_mode = 3 diff --git a/shaders/bip.gdshader b/shaders/bip.gdshader index 17eb2315..b617d0fc 100644 --- a/shaders/bip.gdshader +++ b/shaders/bip.gdshader @@ -4,9 +4,7 @@ shader_type canvas_item; /* Закрашенная окружность */ uniform float tick_update = 0.0; /* Время последнего обновления, мс */ -const float red_channel = 0.972549; -const float green_channel = 0.12549; -const float blue_channel = 0.411765; +uniform vec3 color : source_color = vec3(0.972549, 0.12549, 0.411765); const float time_delta = 0.5; /* Время вспышки при обновлении, c */ const float ds = 0.01; /* Относительное расстояние на котором выполняется сглаживание краёв */ const vec2 center = vec2(0.125, 0.125); /* Центр должен быть в (0.5, 0.5), но это не так */ @@ -16,12 +14,10 @@ const float alpha_main = 1.0; void fragment() { - float time_now = TIME; float alpha = 0.0; - if ((time_now - tick_update) < time_delta) + if ((TIME - tick_update) < time_delta) { - alpha = time_delta - (time_now - tick_update) * alpha_offset; + alpha = time_delta - (TIME - tick_update) * alpha_offset; } - vec4 color = vec4(red_channel, green_channel, blue_channel, alpha_main - alpha); - COLOR = color * smooth_px(length(UV - center), radius, ds); + COLOR = vec4(color, alpha_main - alpha) * smooth_px(length(UV - center), radius, ds); }