forked from unfa/liblast
Implemented camera zooming (Z key). Added vignette but it crashes GPU.
parent
6316952ca5
commit
860478b09c
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="1920"
|
||||
height="1080"
|
||||
viewBox="0 0 507.99999 285.75001"
|
||||
version="1.1"
|
||||
id="svg856"
|
||||
inkscape:version="1.0.2 (e86c870879, 2021-01-15, custom)"
|
||||
sodipodi:docname="Vignette.svg"
|
||||
inkscape:export-filename="/data/Projects/Games/Liblast/Game/Assets/HUD/Vignette.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96">
|
||||
<defs
|
||||
id="defs850">
|
||||
<filter
|
||||
inkscape:collect="always"
|
||||
style="color-interpolation-filters:sRGB"
|
||||
id="filter1703"
|
||||
x="-0.26476598"
|
||||
width="1.529532"
|
||||
y="-0.26476598"
|
||||
height="1.529532">
|
||||
<feGaussianBlur
|
||||
inkscape:collect="always"
|
||||
stdDeviation="87.590765"
|
||||
id="feGaussianBlur1705" />
|
||||
</filter>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.35"
|
||||
inkscape:cx="1042.4763"
|
||||
inkscape:cy="593.68372"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:snap-page="true"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1051"
|
||||
inkscape:window-x="1920"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata853">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<rect
|
||||
style="opacity:1;fill:#000000;stroke-linecap:round;stroke-miterlimit:16;paint-order:markers stroke fill"
|
||||
id="rect1419"
|
||||
width="1920"
|
||||
height="1080"
|
||||
x="0"
|
||||
y="0"
|
||||
transform="scale(0.26458333)" />
|
||||
<circle
|
||||
style="opacity:1;fill:#ffffff;stroke-linecap:round;stroke-miterlimit:16;paint-order:markers stroke fill;filter:url(#filter1703)"
|
||||
id="path1421"
|
||||
cx="904.63379"
|
||||
cy="547.9386"
|
||||
r="396.98801"
|
||||
transform="matrix(0.65488695,0,0,0.65488695,-338.43286,-215.96284)" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 2.6 KiB |
|
@ -4,8 +4,22 @@ extends KinematicBody3D
|
|||
#var speed := 15
|
||||
|
||||
@onready var head = $Head
|
||||
@onready var camera = $Head/Camera
|
||||
@onready var tween = $Head/Camera/Tween
|
||||
@onready var ground_check = $GroundCheck
|
||||
|
||||
@onready var hud = get_tree().root.find_node("HUD", true, false)
|
||||
@onready var crosshair = hud.get_node("Crosshair")
|
||||
@onready var vignette = hud.get_node("Vignette")
|
||||
|
||||
var base_fov = 90
|
||||
var view_zoom := 1.0 :
|
||||
set(zoom):
|
||||
view_zoom = zoom
|
||||
camera.fov = base_fov / (zoom * 4)
|
||||
crosshair.modulate.a = 1 - (zoom - 1) * 2
|
||||
vignette.material["shader_param/Factor"] = zoom
|
||||
|
||||
var direction := Vector3.ZERO
|
||||
var accel := 0
|
||||
var speed := 0
|
||||
|
@ -31,15 +45,16 @@ var snap := Vector3.ZERO
|
|||
|
||||
func _ready() -> void:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
view_zoom = .0
|
||||
|
||||
func aim(event) -> void:
|
||||
var mouse_motion = event as InputEventMouseMotion
|
||||
|
||||
if mouse_motion:
|
||||
rotation_degrees.y -= mouse_motion.relative.x * mouse_sensitivity
|
||||
rotation_degrees.y -= mouse_motion.relative.x * mouse_sensitivity / view_zoom
|
||||
|
||||
var current_tilt: float = head.rotation_degrees.x
|
||||
current_tilt -= mouse_motion.relative.y * mouse_sensitivity
|
||||
current_tilt -= mouse_motion.relative.y * mouse_sensitivity / view_zoom
|
||||
head.rotation_degrees.x = clamp(current_tilt, -90, 90)
|
||||
|
||||
func _input(event) -> void:
|
||||
|
@ -50,17 +65,31 @@ func _input(event) -> void:
|
|||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
if Input.is_action_just_pressed("view_zoom"):
|
||||
#tween.stop_all()
|
||||
tween.interpolate_property(self, "view_zoom", view_zoom, 1.0, 0.5, Tween.TRANS_SINE, Tween.EASE_IN_OUT)
|
||||
tween.start()
|
||||
crosshair.hide()
|
||||
|
||||
if Input.is_action_just_released("view_zoom"):
|
||||
#tween.stop_all()
|
||||
tween.interpolate_property(self, "view_zoom", view_zoom, 0.0, 0.25, Tween.TRANS_SINE, Tween.EASE_IN_OUT)
|
||||
tween.start()
|
||||
crosshair.show()
|
||||
|
||||
aim(event)
|
||||
|
||||
func _physics_process(delta):
|
||||
direction = Vector3.ZERO
|
||||
|
||||
snap = Vector3.ZERO
|
||||
|
||||
if is_on_floor() and ground_check.is_colliding():
|
||||
snap = -get_floor_normal()
|
||||
#snap = -get_floor_normal()
|
||||
medium = "ground"
|
||||
gravity_vec = Vector3.ZERO
|
||||
else:
|
||||
snap = Vector3.DOWN
|
||||
#snap = Vector3.DOWN
|
||||
medium = "air"
|
||||
gravity_vec += Vector3.DOWN * gravity * delta
|
||||
|
||||
|
@ -89,7 +118,7 @@ func _physics_process(delta):
|
|||
|
||||
slide = move_and_slide_with_snap(movement, snap, Vector3.UP)
|
||||
|
||||
if not is_on_floor(): # while in mid-air collisions affect momentum
|
||||
if not is_on_floor() and not ground_check.is_colliding(): # while in mid-air collisions affect momentum
|
||||
velocity.x = slide.x
|
||||
velocity.z = slide.z
|
||||
gravity_vec.y = slide.y
|
||||
|
|
|
@ -33,6 +33,9 @@ current = true
|
|||
fov = 90.0
|
||||
script = null
|
||||
|
||||
[node name="Tween" type="Tween" parent="Head/Camera"]
|
||||
script = null
|
||||
|
||||
[node name="Hand" type="Node3D" parent="Head/Camera"]
|
||||
script = null
|
||||
|
||||
|
|
|
@ -9,3 +9,11 @@ func hit():
|
|||
func kill():
|
||||
aplayer.stop()
|
||||
aplayer.play("Kill")
|
||||
|
||||
#func hide():
|
||||
# aplayer.stop()
|
||||
# aplayer.play("Hide")
|
||||
##
|
||||
#func show():
|
||||
# aplayer.stop()
|
||||
# aplayer.play("Show")
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 74 KiB |
|
@ -0,0 +1,34 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/Vignette.png-91c9a8d7fb2c16e38f32b60a556ba3a5.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://Assets/HUD/Vignette.png"
|
||||
dest_files=[ "res://.godot/imported/Vignette.png-91c9a8d7fb2c16e38f32b60a556ba3a5.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
compress/streamed=false
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/invert_color=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
131
Game/Main.tscn
131
Game/Main.tscn
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=15 format=2]
|
||||
[gd_scene load_steps=24 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Characters/Player.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Assets/HUD/Crosshair.png" type="Texture2D" id=2]
|
||||
|
@ -6,6 +6,8 @@
|
|||
[ext_resource path="res://Assets/HUD/Crosshair.gd" type="Script" id=4]
|
||||
[ext_resource path="res://Assets/SFX/UI_Confirm_Hit.wav" type="AudioStream" id=5]
|
||||
[ext_resource path="res://Assets/SFX/UI_Confirm_Kill.wav" type="AudioStream" id=6]
|
||||
[ext_resource path="res://Assets/Props/BeerCan.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://Assets/HUD/Vignette.png" type="Texture2D" id=8]
|
||||
|
||||
[sub_resource type="PhysicalSkyMaterial" id=1]
|
||||
|
||||
|
@ -59,7 +61,23 @@ tracks/0/keys = {
|
|||
}
|
||||
|
||||
[sub_resource type="Animation" id=7]
|
||||
resource_name = "Hit"
|
||||
resource_name = "Hide"
|
||||
length = 0.2
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Crosshair:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array( 0, 0.2 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 1 ), Color( 1, 1, 1, 0 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
length = 0.2
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
|
@ -89,8 +107,7 @@ tracks/1/keys = {
|
|||
"times": PackedFloat32Array( 0 )
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=8]
|
||||
resource_name = "Kill"
|
||||
[sub_resource type="Animation" id=9]
|
||||
length = 0.5
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
|
@ -120,6 +137,90 @@ tracks/1/keys = {
|
|||
"times": PackedFloat32Array( 0 )
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=10]
|
||||
resource_name = "Show"
|
||||
length = 0.2
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Crosshair:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array( 0, 0.2 ),
|
||||
"transitions": PackedFloat32Array( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="VisualShaderNodeFloatUniform" id=11]
|
||||
default_input_values = [ ]
|
||||
uniform_name = "Factor"
|
||||
hint = 1
|
||||
default_value_enabled = true
|
||||
|
||||
[sub_resource type="VisualShaderNodeInput" id=12]
|
||||
output_port_for_preview = 0
|
||||
default_input_values = [ ]
|
||||
input_name = "color"
|
||||
|
||||
[sub_resource type="VisualShaderNodeMix" id=13]
|
||||
default_input_values = [ 0, Vector3( 1, 1, 1 ), 1, Vector3( 1, 1, 1 ), 2, 0.5 ]
|
||||
op_type = 2
|
||||
|
||||
[sub_resource type="VisualShader" id=14]
|
||||
code = "shader_type canvas_item;
|
||||
render_mode blend_mul;
|
||||
|
||||
uniform float Factor : hint_range(0, 1) = 0;
|
||||
|
||||
|
||||
|
||||
void vertex() {
|
||||
// Output:0
|
||||
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
// Input:3
|
||||
vec3 n_out3p0 = COLOR.rgb;
|
||||
|
||||
// FloatUniform:2
|
||||
float n_out2p0 = Factor;
|
||||
|
||||
// Mix:4
|
||||
vec3 n_in4p0 = vec3(1.00000, 1.00000, 1.00000);
|
||||
vec3 n_out4p0 = mix(n_in4p0, n_out3p0, n_out2p0);
|
||||
|
||||
// Output:0
|
||||
COLOR.rgb = n_out4p0;
|
||||
|
||||
}
|
||||
|
||||
void light() {
|
||||
// Output:0
|
||||
|
||||
}
|
||||
"
|
||||
graph_offset = Vector2( -113, 35 )
|
||||
version = "4.0"
|
||||
mode = 1
|
||||
modes/blend = 3
|
||||
flags/light_only = false
|
||||
nodes/fragment/0/position = Vector2( 400, 180 )
|
||||
nodes/fragment/2/node = SubResource( 11 )
|
||||
nodes/fragment/2/position = Vector2( -440, 300 )
|
||||
nodes/fragment/3/node = SubResource( 12 )
|
||||
nodes/fragment/3/position = Vector2( -400, 120 )
|
||||
nodes/fragment/4/node = SubResource( 13 )
|
||||
nodes/fragment/4/position = Vector2( 60, 180 )
|
||||
nodes/fragment/connections = PackedInt32Array( 4, 0, 0, 0, 2, 0, 4, 2, 3, 0, 4, 1 )
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=15]
|
||||
shader = SubResource( 14 )
|
||||
shader_param/Factor = 0.0
|
||||
|
||||
[node name="Game" type="Node3D"]
|
||||
script = null
|
||||
|
||||
|
@ -170,7 +271,6 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="Crosshair" type="TextureRect" parent="HUD/Crosshair"]
|
||||
modulate = Color( 1, 0.716667, 0, 1 )
|
||||
texture_filter = 2
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
|
@ -191,8 +291,10 @@ __meta__ = {
|
|||
[node name="AnimationPlayer" type="AnimationPlayer" parent="HUD/Crosshair"]
|
||||
autoplay = "Default"
|
||||
anims/Default = SubResource( 6 )
|
||||
anims/Hit = SubResource( 7 )
|
||||
anims/Kill = SubResource( 8 )
|
||||
anims/Hide = SubResource( 7 )
|
||||
anims/Hit = SubResource( 8 )
|
||||
anims/Kill = SubResource( 9 )
|
||||
anims/Show = SubResource( 10 )
|
||||
blend_times = [ ]
|
||||
script = null
|
||||
|
||||
|
@ -200,6 +302,18 @@ script = null
|
|||
stream = ExtResource( 6 )
|
||||
script = null
|
||||
|
||||
[node name="Vignette" type="TextureRect" parent="HUD"]
|
||||
material = SubResource( 15 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
texture = ExtResource( 8 )
|
||||
expand = true
|
||||
stretch_mode = 7
|
||||
script = null
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource( 1 )]
|
||||
|
||||
[node name="ReflectionProbe" type="ReflectionProbe" parent="."]
|
||||
|
@ -209,4 +323,7 @@ box_projection = true
|
|||
enable_shadows = true
|
||||
script = null
|
||||
|
||||
[node name="BeerCan" parent="." instance=ExtResource( 7 )]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 22, 11, -3 )
|
||||
|
||||
[editable path="DM1"]
|
||||
|
|
Loading…
Reference in New Issue