Skip to content

Commit

Permalink
feat:add light for star wrath
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Aug 25, 2024
1 parent b7ae713 commit 8db77f0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ locale/translations_pot_files=PackedStringArray("res://scenes/multi_game.tscn")
[rendering]

textures/canvas_textures/default_texture_filter=0
viewport/hdr_2d=true
13 changes: 12 additions & 1 deletion scenes/fight.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=27 format=3 uid="uid://cibwxaqnuodid"]
[gd_scene load_steps=29 format=3 uid="uid://cibwxaqnuodid"]

[ext_resource type="Script" path="res://scenes/fight.gd" id="1_dqpk1"]
[ext_resource type="Texture2D" uid="uid://byln211i8r3lq" path="res://scenes/Zenith.png" id="1_jsdtx"]
Expand All @@ -20,6 +20,13 @@
[ext_resource type="Texture2D" uid="uid://drljhif31i83o" path="res://scenes/ui/category_panel.png" id="14_miw1s"]
[ext_resource type="Texture2D" uid="uid://bjxheh0afj37f" path="res://scenes/ui/shield_of_cthulhu.png" id="18_12j3n"]

[sub_resource type="Environment" id="Environment_oaeg7"]
background_mode = 3
glow_enabled = true
glow_blend_mode = 1

[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_64jai"]

[sub_resource type="Gradient" id="Gradient_w6p7b"]
offsets = PackedFloat32Array(0.386487, 0.391892, 0.397297, 0.683784, 1)
colors = PackedColorArray(0, 0, 0, 1, 0, 0, 0, 1, 0.327103, 0.327103, 0.327103, 1, 0.584112, 0.584112, 0.584112, 1, 1, 1, 1, 1)
Expand Down Expand Up @@ -56,6 +63,10 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_dqpk1")

[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_oaeg7")
camera_attributes = SubResource("CameraAttributesPractical_64jai")

[node name="BgColor" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
Expand Down
8 changes: 5 additions & 3 deletions scenes/weapons/star_wrath/star_wrath.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

[sub_resource type="ShaderMaterial" id="ShaderMaterial_t64wj"]
shader = ExtResource("2_xksic")
shader_parameter/color_end = Vector4(0.5, 0, 0.5, 0.1)
shader_parameter/color_start = Vector4(0.5, 0, 0.5, 0.5)
shader_parameter/alpha_bias = 0.0
shader_parameter/color = Vector4(0.5, 0, 0.5, 0)
shader_parameter/alpha_end = 0.0
shader_parameter/alpha_start = 0.5
shader_parameter/end_y_position = 0.6

[sub_resource type="RectangleShape2D" id="RectangleShape2D_qm46a"]
size = Vector2(28.6936, 31.8029)
Expand Down Expand Up @@ -131,6 +132,7 @@ script = ExtResource("3_u5scp")
star_wrath_origin = ExtResource("4_eglqk")

[node name="StarWrath" type="Sprite2D" parent="StarWrath"]
self_modulate = Color(1.6, 1.5, 1.5, 1)
position = Vector2(-100, -60)
scale = Vector2(2.97559, 2.97559)
texture = ExtResource("4_ohxcu")
Expand Down
21 changes: 12 additions & 9 deletions shaders/virtual.gdshader
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
shader_type canvas_item;

uniform vec4 color_end;
uniform vec4 color_start;
uniform float alpha_bias = 0;
uniform vec4 color;
uniform float alpha_end;
uniform float alpha_start;
uniform float end_y_position;

void vertex() {
// Called for every vertex the material is visible on.
Expand All @@ -11,12 +12,14 @@ void vertex() {
void fragment() {
// Called for every pixel the material is visible on.
vec2 screen_coords = SCREEN_UV;
// 垂直翻转Y坐标
screen_coords.y = (1.0 - screen_coords.y);
vec4 gradient_color = color_start + (color_end - color_start) * screen_coords.y * 3.6;
// 设置最终颜色
COLOR = gradient_color;
COLOR.a -= alpha_bias;
if(screen_coords.y < end_y_position) {
COLOR = vec4(0,0,0,0);
} else {
// 垂直翻转Y坐标
screen_coords.y = (1.0 - screen_coords.y);
COLOR = color;
COLOR.a = alpha_start + (alpha_end - alpha_start) * screen_coords.y / (end_y_position / 1.5);
}
}

//void light() {
Expand Down

0 comments on commit 8db77f0

Please sign in to comment.