Merge pull request #692 from aaronfranke/gd4-viewport

Update Viewport demos to Godot 4
This commit is contained in:
Aaron Franke
2022-03-27 18:24:43 -05:00
committed by GitHub
35 changed files with 853 additions and 865 deletions

View File

@@ -3,11 +3,7 @@ extends Node3D
func _ready():
# Clear the viewport.
var viewport = $SubViewport
$SubViewport.set_clear_mode(SubViewport.CLEAR_MODE_ONLY_NEXT_FRAME)
# Let two frames pass to make sure the vieport is captured.
await get_tree().process_frame
await get_tree().process_frame
$SubViewport.set_clear_mode(SubViewport.CLEAR_MODE_ONCE)
# Retrieve the texture and set it to the viewport quad.
$ViewportQuad.material_override.albedo_texture = viewport.get_texture()

View File

@@ -1,102 +1,61 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=16 format=3 uid="uid://c587vtbfwth3k"]
[ext_resource path="res://2D_in_3D.gd" type="Script" id=1]
[ext_resource path="res://pong.gd" type="Script" id=2]
[ext_resource path="res://ball.png" type="Texture2D" id=3]
[ext_resource path="res://left_pallete.png" type="Texture2D" id=4]
[ext_resource path="res://right_pallete.png" type="Texture2D" id=5]
[ext_resource path="res://separator.png" type="Texture2D" id=6]
[ext_resource type="Script" path="res://2D_in_3D.gd" id="1"]
[ext_resource type="Script" path="res://pong.gd" id="2"]
[ext_resource type="Texture2D" uid="uid://dbuw5tlmsx6ss" path="res://ball.png" id="3"]
[ext_resource type="Texture2D" uid="uid://gtbg1ogxcsl7" path="res://left_pallete.png" id="4"]
[ext_resource type="Texture2D" uid="uid://bc2vi0nh1j1hs" path="res://right_pallete.png" id="5"]
[ext_resource type="Texture2D" uid="uid://wiyhsl0rfkrs" path="res://separator.png" id="6"]
[sub_resource type="PlaneMesh" id=1]
[sub_resource type="StandardMaterial3D" id="6"]
[sub_resource type="StandardMaterial3D" id=2]
[sub_resource type="PlaneMesh" id="1"]
[sub_resource type="StandardMaterial3D" id="2"]
roughness = 0.7
[sub_resource type="BoxMesh" id=3]
[sub_resource type="BoxMesh" id="3"]
size = Vector3(2, 2, 2)
[sub_resource type="StandardMaterial3D" id=4]
[sub_resource type="StandardMaterial3D" id="4"]
albedo_color = Color(0.652344, 0.652344, 0.652344, 1)
roughness = 0.0
[sub_resource type="BoxMesh" id=5]
[sub_resource type="BoxMesh" id="5"]
size = Vector3(1.1, 0.8, 0.1)
[sub_resource type="StandardMaterial3D" id=6]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_cvh5i"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_7gemw"]
sky_material = SubResource( "ProceduralSkyMaterial_cvh5i" )
[sub_resource type="Environment" id="Environment_fvsgw"]
background_mode = 2
sky = SubResource( "Sky_7gemw" )
tonemap_mode = 2
glow_enabled = true
[node name="2Din3D" type="Node3D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1, 0)
fov = 74.0
near = 0.1
[node name="Floor" type="MeshInstance3D" parent="."]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, -1, -2)
mesh = SubResource( 1 )
surface_material_override/0 = SubResource( 2 )
[node name="Pillar1" type="Node3D" parent="."]
transform = Transform3D(0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, -3, -0.2, -4)
[node name="PillarBottom" type="MeshInstance3D" parent="Pillar1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource( 3 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarTop" type="MeshInstance3D" parent="Pillar1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0)
mesh = SubResource( 3 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarMiddle" type="MeshInstance3D" parent="Pillar1"]
transform = Transform3D(0.7, 0, 0, 0, 2, 0, 0, 0, 0.7, 0, 2.5, 0)
mesh = SubResource( 3 )
surface_material_override/0 = SubResource( 4 )
[node name="Pillar2" type="Node3D" parent="."]
transform = Transform3D(0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, 3, -0.2, -4)
[node name="PillarBottom" type="MeshInstance3D" parent="Pillar2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource( 3 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarTop" type="MeshInstance3D" parent="Pillar2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0)
mesh = SubResource( 3 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarMiddle" type="MeshInstance3D" parent="Pillar2"]
transform = Transform3D(0.7, 0, 0, 0, 2, 0, 0, 0, 0.7, 0, 2.5, 0)
mesh = SubResource( 3 )
surface_material_override/0 = SubResource( 4 )
[node name="PillarBack" type="MeshInstance3D" parent="."]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 1.2, -4.5)
mesh = SubResource( 5 )
surface_material_override/0 = SubResource( 4 )
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.623013, -0.733525, 0.271654, 0.321394, 0.55667, 0.766044, -0.713134, -0.389948, 0.582563, 0, 10, 0)
shadow_enabled = true
directional_shadow_blend_splits = true
directional_shadow_normal_bias = 0.2
[node name="ViewportQuad" type="MeshInstance3D" parent="."]
transform = Transform3D(2, 0, 0, 0, 0, -1.333, 0, 1, 0, 0, 1.2, -4.25)
material_override = SubResource( 6 )
mesh = SubResource( 1 )
surface_material_override/0 = null
material_override = SubResource( "6" )
mesh = SubResource( "1" )
[node name="SubViewport" type="SubViewport" parent="."]
size = Vector2(600, 400)
hdr = false
usage = 0
render_target_v_flip = true
size = Vector2i(600, 400)
render_target_update_mode = 4
[node name="Pong" type="Node2D" parent="SubViewport"]
script = ExtResource( 2 )
script = ExtResource( "2" )
[node name="Background" type="Panel" parent="SubViewport/Pong"]
offset_right = 600.0
@@ -104,16 +63,74 @@ offset_bottom = 400.0
[node name="Ball" type="Sprite2D" parent="SubViewport/Pong"]
position = Vector2(300, 200)
texture = ExtResource( 3 )
texture = ExtResource( "3" )
[node name="LeftPaddle" type="Sprite2D" parent="SubViewport/Pong"]
position = Vector2(20, 200)
texture = ExtResource( 4 )
texture = ExtResource( "4" )
[node name="RightPaddle" type="Sprite2D" parent="SubViewport/Pong"]
position = Vector2(580, 200)
texture = ExtResource( 5 )
texture = ExtResource( "5" )
[node name="Separator" type="Sprite2D" parent="SubViewport/Pong"]
position = Vector2(298, 200)
texture = ExtResource( 6 )
texture = ExtResource( "6" )
[node name="Environment" type="Node3D" parent="."]
[node name="Floor" type="MeshInstance3D" parent="Environment"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, -1, -2)
mesh = SubResource( "1" )
skeleton = NodePath("../..")
surface_material_override/0 = SubResource( "2" )
[node name="Pillar1" type="Node3D" parent="Environment"]
transform = Transform3D(0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, -3, -0.2, -4)
[node name="PillarBottom" type="MeshInstance3D" parent="Environment/Pillar1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource( "3" )
surface_material_override/0 = SubResource( "4" )
[node name="PillarTop" type="MeshInstance3D" parent="Environment/Pillar1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0)
mesh = SubResource( "3" )
surface_material_override/0 = SubResource( "4" )
[node name="PillarMiddle" type="MeshInstance3D" parent="Environment/Pillar1"]
transform = Transform3D(0.7, 0, 0, 0, 2, 0, 0, 0, 0.7, 0, 2.5, 0)
mesh = SubResource( "3" )
surface_material_override/0 = SubResource( "4" )
[node name="Pillar2" type="Node3D" parent="Environment"]
transform = Transform3D(0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, 3, -0.2, -4)
[node name="PillarBottom" type="MeshInstance3D" parent="Environment/Pillar2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
mesh = SubResource( "3" )
surface_material_override/0 = SubResource( "4" )
[node name="PillarTop" type="MeshInstance3D" parent="Environment/Pillar2"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 5.5, 0)
mesh = SubResource( "3" )
surface_material_override/0 = SubResource( "4" )
[node name="PillarMiddle" type="MeshInstance3D" parent="Environment/Pillar2"]
transform = Transform3D(0.7, 0, 0, 0, 2, 0, 0, 0, 0.7, 0, 2.5, 0)
mesh = SubResource( "3" )
surface_material_override/0 = SubResource( "4" )
[node name="PillarBack" type="MeshInstance3D" parent="Environment"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 1.2, -4.5)
mesh = SubResource( "5" )
skeleton = NodePath("../..")
surface_material_override/0 = SubResource( "4" )
[node name="WorldEnvironment" type="WorldEnvironment" parent="Environment"]
environment = SubResource( "Environment_fvsgw" )
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="Environment"]
transform = Transform3D(0.623013, -0.733525, 0.271653, 0.321394, 0.55667, 0.766045, -0.713134, -0.389948, 0.582563, 0, 10, 0)
shadow_enabled = true
directional_shadow_blend_splits = true

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"
type="CompressedTexture2D"
uid="uid://dbuw5tlmsx6ss"
path="res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://ball.png"
dest_files=["res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.stex"]
dest_files=["res://.godot/imported/ball.png-9a4ca347acb7532f6ae347744a6b04f7.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://dkugtedjas1op"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex"
type="CompressedTexture2D"
uid="uid://gtbg1ogxcsl7"
path="res://.godot/imported/left_pallete.png-bc33611074a0f886142e37c77bd2545a.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://left_pallete.png"
dest_files=["res://.godot/imported/left_pallete.png-bc33611074a0f886142e37c77bd2545a.stex"]
dest_files=["res://.godot/imported/left_pallete.png-bc33611074a0f886142e37c77bd2545a.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -6,7 +6,7 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
[application]
@@ -14,6 +14,7 @@ config/name="2D in 3D"
config/description="A demo showing how a 2D scene can be shown within a 3D one using viewports."
run/main_scene="res://2D_in_3D.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[gdnative]

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex"
type="CompressedTexture2D"
uid="uid://bc2vi0nh1j1hs"
path="res://.godot/imported/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://right_pallete.png"
dest_files=["res://.godot/imported/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.stex"]
dest_files=["res://.godot/imported/right_pallete.png-fc6e4a6a7c8197834656482b94708e47.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.stex"
type="CompressedTexture2D"
uid="uid://wiyhsl0rfkrs"
path="res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://separator.png"
dest_files=["res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.stex"]
dest_files=["res://.godot/imported/separator.png-f981c8489b9148e2e1dc63398273da74.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,62 +1,58 @@
[gd_scene load_steps=11 format=2]
[gd_scene load_steps=11 format=3 uid="uid://xwkspajfdmd7"]
[ext_resource path="res://3d_in_2d.gd" type="Script" id=1]
[ext_resource path="res://robot_demo.png" type="Texture2D" id=2]
[ext_resource path="res://robot_3d.tscn" type="PackedScene" id=3]
[ext_resource type="Script" path="res://3d_in_2d.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://q5bonn8iowbc" path="res://robot_demo.png" id="2"]
[ext_resource type="PackedScene" uid="uid://8nlipuu0ceal" path="res://robot_3d.tscn" id="3"]
[sub_resource type="ViewportTexture" id=1]
[sub_resource type="ViewportTexture" id="ViewportTexture_2squv"]
viewport_path = NodePath("SubViewport")
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 2 )
[sub_resource type="AtlasTexture" id="2"]
atlas = ExtResource( "2" )
region = Rect2(0, 0, 64, 64)
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 2 )
[sub_resource type="AtlasTexture" id="3"]
atlas = ExtResource( "2" )
region = Rect2(64, 0, 64, 64)
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 2 )
[sub_resource type="AtlasTexture" id="4"]
atlas = ExtResource( "2" )
region = Rect2(128, 0, 64, 64)
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 2 )
[sub_resource type="AtlasTexture" id="5"]
atlas = ExtResource( "2" )
region = Rect2(192, 0, 64, 64)
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 2 )
[sub_resource type="AtlasTexture" id="6"]
atlas = ExtResource( "2" )
region = Rect2(256, 0, 64, 64)
[sub_resource type="SpriteFrames" id=7]
[sub_resource type="SpriteFrames" id="7"]
animations = [{
"frames": [SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 )],
"frames": [SubResource( "2" ), SubResource( "3" ), SubResource( "4" ), SubResource( "5" ), SubResource( "6" )],
"loop": true,
"name": "default",
"name": &"default",
"speed": 5.0
}]
[node name="3Din2D" type="Node2D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="SubViewport" type="SubViewport" parent="."]
size = Vector2(300, 300)
own_world = true
transparent_bg = true
msaa = 2
hdr = false
usage = 3
size = Vector2i(300, 300)
render_target_update_mode = 4
[node name="Robot3D" parent="SubViewport" instance=ExtResource( 3 )]
[node name="Robot3D" parent="SubViewport" instance=ExtResource( "3" )]
[node name="ViewportSprite" type="Sprite2D" parent="."]
position = Vector2(650, 300)
scale = Vector2(1, -1)
texture = SubResource( 1 )
texture = SubResource( "ViewportTexture_2squv" )
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
position = Vector2(350, 300)
scale = Vector2(3, 3)
frames = SubResource( 7 )
frames = SubResource( "7" )
[node name="Camera2D" type="Camera2D" parent="."]
offset = Vector2(512, 300)

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://bjah7o5vmbfs1"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -6,7 +6,7 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
[application]
@@ -14,10 +14,10 @@ config/name="3D in 2D"
config/description="A demo showing how a 3D scene can be shown within a 2D one using viewports."
run/main_scene="res://3d_in_2d.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[display]
window/dpi/allow_hidpi=true
window/stretch/mode="2d"
window/stretch/aspect="expand"

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/robot_demo.png-8502817e0037b3f31eaca3dae49dcfc5.stex"
type="CompressedTexture2D"
uid="uid://q5bonn8iowbc"
path="res://.godot/imported/robot_demo.png-8502817e0037b3f31eaca3dae49dcfc5.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://robot_demo.png"
dest_files=["res://.godot/imported/robot_demo.png-8502817e0037b3f31eaca3dae49dcfc5.stex"]
dest_files=["res://.godot/imported/robot_demo.png-8502817e0037b3f31eaca3dae49dcfc5.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,17 +1,15 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://bbnebk7xoaoto"]
[sub_resource type="BoxMesh" id=1]
[sub_resource type="BoxMesh" id="1"]
[node name="Cubes" type="Node3D"]
[node name="MeshInstance1" type="MeshInstance3D" parent="."]
mesh = SubResource( 1 )
surface_material_override/0 = null
mesh = SubResource( "1" )
[node name="MeshInstance2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, -1)
mesh = SubResource( 1 )
surface_material_override/0 = null
mesh = SubResource( "1" )
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(0.877582, 0.229849, -0.420736, 0, 0.877582, 0.479426, 0.479426, -0.420736, 0.770151, -1.68294, 2.25571, 3.0806)

View File

@@ -6,12 +6,13 @@ extends Control
# (SSAA), but filtering must be enabled for supersampling to work.
var scale_factor = 1.0
@onready var viewport_container = $SubViewportContainer
@onready var viewport = $SubViewportContainer/SubViewport
@onready var scale_label = $VBoxContainer/Scale
@onready var filter_label = $VBoxContainer/Filter
func _ready():
viewport.get_texture().flags = Texture2D.FLAG_FILTER
viewport_container.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR
# Required to change the 3D viewport's size when the window is resized.
# warning-ignore:return_value_discarded
@@ -26,10 +27,12 @@ func _unhandled_input(event):
if event.is_action_pressed("toggle_filtering"):
# Toggle the Filter flag on the ViewportTexture.
viewport.get_texture().flags ^= Texture2D.FLAG_FILTER
var filter_enabled = viewport.get_texture().flags & Texture2D.FLAG_FILTER
filter_label.text = "Filter: %s" % ("Enabled" if filter_enabled else "Disabled")
if viewport_container.texture_filter == CanvasItem.TEXTURE_FILTER_LINEAR:
viewport_container.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
filter_label.text = "Filter: Disabled"
else:
viewport_container.texture_filter = CanvasItem.TEXTURE_FILTER_LINEAR
filter_label.text = "Filter: Enabled"
# Called when the root's viewport size changes (i.e. when the window is resized).

View File

@@ -1,41 +1,34 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=6 format=3 uid="uid://c5uc5vwuqvck5"]
[ext_resource path="res://noto_sans_ui_regular.ttf" type="FontData" id=1]
[ext_resource path="res://cubes.tscn" type="PackedScene" id=2]
[ext_resource path="res://hud.gd" type="Script" id=3]
[ext_resource type="FontData" uid="uid://dj5xxi41l3y1r" path="res://noto_sans_ui_regular.ttf" id="1"]
[ext_resource type="PackedScene" uid="uid://bbnebk7xoaoto" path="res://cubes.tscn" id="2"]
[ext_resource type="Script" path="res://hud.gd" id="3"]
[sub_resource type="Font" id=1]
size = 20
font_data = ExtResource( 1 )
[sub_resource type="Font" id="1"]
data/0 = ExtResource( "1" )
[sub_resource type="Theme" id=2]
default_font = SubResource( 1 )
[sub_resource type="Theme" id="2"]
default_font = SubResource( "1" )
[node name="HUD" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
theme = SubResource( 2 )
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
theme = SubResource( "2" )
script = ExtResource( "3" )
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
texture_filter = 1
anchor_right = 1.0
anchor_bottom = 1.0
stretch = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
size = Vector2(1024, 600)
handle_input_locally = false
usage = 3
render_target_update_mode = 3
shadow_atlas_size = 4096
size = Vector2i(1024, 600)
render_target_update_mode = 4
[node name="Cubes" parent="SubViewportContainer/SubViewport" instance=ExtResource( 2 )]
[node name="Cubes" parent="SubViewportContainer/SubViewport" instance=ExtResource( "2" )]
[node name="Help" type="Label" parent="."]
anchor_top = 1.0
@@ -44,11 +37,6 @@ offset_left = 16.0
offset_top = -106.0
offset_right = 554.0
offset_bottom = -16.0
custom_colors/font_color_shadow = Color(0, 0, 0, 0.752941)
custom_constants/shadow_offset_x = 2
custom_constants/shadow_offset_y = 2
custom_constants/shadow_as_outline = 0
custom_fonts/font = SubResource( 1 )
text = "This text will always render at the native resolution.
Press Space to adjust the 3D viewport's resolution scaling.
Press Enter to toggle filtering."
@@ -66,25 +54,17 @@ __meta__ = {
}
[node name="Scale" type="Label" parent="VBoxContainer"]
offset_right = 130.0
offset_bottom = 28.0
custom_colors/font_color_shadow = Color(0, 0, 0, 0.752941)
custom_constants/shadow_offset_x = 2
custom_constants/shadow_offset_y = 2
custom_constants/shadow_as_outline = 0
offset_right = 108.0
offset_bottom = 26.0
text = "Scale: 100%"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Filter" type="Label" parent="VBoxContainer"]
offset_top = 32.0
offset_right = 130.0
offset_bottom = 60.0
custom_colors/font_color_shadow = Color(0, 0, 0, 0.752941)
custom_constants/shadow_offset_x = 2
custom_constants/shadow_offset_y = 2
custom_constants/shadow_as_outline = 0
offset_top = 30.0
offset_right = 108.0
offset_bottom = 56.0
text = "Filter: Enabled"
__meta__ = {
"_edit_use_anchors_": false

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://t7xypb53csjt"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontData"
uid="uid://dj5xxi41l3y1r"
path="res://.godot/imported/noto_sans_ui_regular.ttf-37da988dfa3a55ebf3ea2c9fc7b383a8.fontdata"
[deps]
source_file="res://noto_sans_ui_regular.ttf"
dest_files=["res://.godot/imported/noto_sans_ui_regular.ttf-37da988dfa3a55ebf3ea2c9fc7b383a8.fontdata"]
[params]
antialiased=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
force_autohinter=false
hinting=1
subpixel_positioning=1
embolden=0.0
transform=Transform2D(1, 0, 0, 1, 0, 0)
oversampling=0.0
compress=true
opentype_feature_overrides={}
preload/char_ranges=PackedStringArray()
preload/glyph_ranges=PackedStringArray()
preload/configurations=PackedStringArray()
support_overrides/language_enabled=PackedStringArray()
support_overrides/language_disabled=PackedStringArray()
support_overrides/script_enabled=PackedStringArray()
support_overrides/script_disabled=PackedStringArray()

View File

@@ -6,7 +6,7 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
[application]
@@ -18,10 +18,10 @@ be used to have a \"pixel art\" viewport for the main game area and a
non-pixel-art viewport for HUD elements."
run/main_scene="res://hud.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[display]
window/dpi/allow_hidpi=true
window/stretch/mode="2d"
window/stretch/aspect="expand"

View File

@@ -21,7 +21,7 @@ extends Node3D
@export var max_separation: float = 20.0
@export var split_line_thickness: float = 3.0
@export var split_line_color: Color, RGBA = Color.BLACK
@export var split_line_color: Color = Color.BLACK
@export var adaptive_split_line_thickness: bool = true
@onready var player1 = $"../Player1"

View File

@@ -1,22 +1,14 @@
[gd_resource type="Environment" load_steps=2 format=2]
[gd_resource type="Environment" load_steps=3 format=3 uid="uid://cs2mpcwx6q2bp"]
[sub_resource type="Sky" id=1]
ground_bottom_color = Color( 0.839216, 0.917647, 0.980392, 1 )
ground_horizon_color = Color( 0.839216, 0.917647, 0.980392, 1 )
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_16la2"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_i64ko"]
sky_material = SubResource( "ProceduralSkyMaterial_16la2" )
[resource]
background_mode = 2
background_sky = SubResource( 1 )
ambient_light_color = Color( 0.560784, 0.560784, 0.560784, 1 )
ambient_light_sky_contribution = 0.3
fog_color = Color( 1, 1, 1, 1 )
fog_sun_color = Color( 1, 1, 1, 1 )
fog_depth_enabled = false
fog_depth_begin = 400.0
fog_depth_end = 1000.0
fog_depth_curve = 0.287175
fog_height_min = 2.0
sky = SubResource( "Sky_i64ko" )
tonemap_mode = 2
tonemap_white = 16.0
dof_blur_far_distance = 416.97
glow_intensity = 0.1
glow_enabled = true

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://dn1s0i63e08jh"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -2,15 +2,15 @@ extends CharacterBody3D
# Moves the player
@export var player_id: int, 1, 2 = 1
@export_range(1, 2) var player_id: int = 1
@export var walk_speed: float = 20.0
func _physics_process(_delta):
var velocity = Vector3.ZERO
velocity.z = -Input.get_action_strength("move_up_player" + str(player_id))
velocity.z += Input.get_action_strength("move_down_player" + str(player_id))
velocity.x = -Input.get_action_strength("move_left_player" + str(player_id))
velocity.x += Input.get_action_strength("move_right_player" + str(player_id))
move_and_slide(velocity.normalized() * walk_speed)
#var velocity = Vector3.ZERO
velocity.x = Input.get_action_strength("move_right_player" + str(player_id))
velocity.x -= Input.get_action_strength("move_left_player" + str(player_id))
velocity.z = Input.get_action_strength("move_down_player" + str(player_id))
velocity.z -= Input.get_action_strength("move_up_player" + str(player_id))
velocity = velocity.normalized() * walk_speed
move_and_slide()

View File

@@ -6,7 +6,7 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
[application]
@@ -15,6 +15,7 @@ config/description="This sample project showcases an implementation of dynamic
split screen, also called Voronoi split screen, using GDSL."
run/main_scene="res://split_screen.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[debug]

File diff suppressed because it is too large Load Diff

View File

@@ -19,15 +19,9 @@ func _ready():
node_area.connect(&"mouse_entered", self._mouse_entered_area)
# If the material is NOT set to use billboard settings, then avoid running billboard specific code
if node_quad.get_surface_material(0).params_billboard_mode == 0:
if node_quad.get_surface_override_material(0).billboard_mode == BaseMaterial3D.BillboardMode.BILLBOARD_DISABLED:
set_process(false)
if OS.get_current_video_driver() == OS.VIDEO_DRIVER_GLES2:
# Required to prevent the texture from being too dark when using GLES2.
# This should be left to `true` in GLES3 to prevent the texture from looking
# washed out there.
node_quad.get_surface_material(0).flags_albedo_tex_force_srgb = false
func _process(_delta):
# NOTE: Remove this function if you don't plan on using billboard settings.
@@ -52,7 +46,7 @@ func _unhandled_input(event):
if is_mouse_event and (is_mouse_inside or is_mouse_held):
handle_mouse(event)
elif not is_mouse_event:
node_viewport.input(event)
node_viewport.push_input(event)
# Handle mouse events inside Area3D. (Area3D.input_event had many issues with dragging)
@@ -115,20 +109,23 @@ func handle_mouse(event):
last_mouse_pos2D = mouse_pos2D
# Finally, send the processed input event to the viewport.
node_viewport.input(event)
node_viewport.push_input(event)
func find_mouse(global_position):
var camera = get_viewport().get_camera_3d()
# From camera center to the mouse position in the Area3D
var from = camera.project_ray_origin(global_position)
var dist = find_further_distance_to(camera.transform.origin)
var to = from + camera.project_ray_normal(global_position) * dist
# From camera center to the mouse position in the Area3D.
var parameters = PhysicsRayQueryParameters3D.new()
parameters.from = camera.project_ray_origin(global_position)
parameters.to = parameters.from + camera.project_ray_normal(global_position) * dist
# Manually raycasts the are to find the mouse position
var result = get_world_3d().direct_space_state.intersect_ray(from, to, [], node_area.collision_layer,false,true) #for 3.1 changes
# Manually raycasts the area to find the mouse position.
parameters.collision_mask = node_area.collision_layer
parameters.collide_with_bodies = false
parameters.collide_with_areas = true
var result = get_world_3d().direct_space_state.intersect_ray(parameters)
if result.size() > 0:
return result.position
@@ -156,7 +153,7 @@ func find_further_distance_to(origin):
func rotate_area_to_billboard():
var billboard_mode = node_quad.get_surface_material(0).params_billboard_mode
var billboard_mode = node_quad.get_surface_override_material(0).params_billboard_mode
# Try to match the area with the material's billboard setting, if enabled
if billboard_mode > 0:

View File

@@ -1,16 +1,28 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=9 format=3 uid="uid://0iek6ri88gkb"]
[ext_resource path="res://gui_panel_3d.tscn" type="PackedScene" id=1]
[ext_resource type="PackedScene" uid="uid://dvl383ispakmn" path="res://gui_panel_3d.tscn" id="1"]
[sub_resource type="Animation" id=1]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_1lgdv"]
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
[sub_resource type="Sky" id="Sky_pq42j"]
sky_material = SubResource( "ProceduralSkyMaterial_1lgdv" )
[sub_resource type="Environment" id="Environment_niyks"]
background_mode = 2
sky = SubResource( "Sky_pq42j" )
tonemap_mode = 2
glow_enabled = true
[sub_resource type="Animation" id="1"]
length = 6.0
loop = true
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Camera3D:transform")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 2, 4, 6),
"transitions": PackedFloat32Array(1, 1, 1, 1),
@@ -18,17 +30,20 @@ tracks/0/keys = {
"values": [Transform3D(0.994592, 0, 0.103856, 0, 1, 0, -0.103856, 0, 0.994592, 0.465682, 0, 1.78523), Transform3D(0.962984, 0, -0.269557, 0, 1, 0, 0.269557, 0, 0.962984, -0.462237, 0, 2.41934), Transform3D(0.806599, 0, -0.591098, 0, 1, 0, 0.591098, 0, 0.806599, -1.59502, 0, 2.05358), Transform3D(0.994592, 0, 0.103856, 0, 1, 0, -0.103856, 0, 0.994592, 0.465682, 0, 1.78523)]
}
[sub_resource type="PlaneMesh" id=2]
[sub_resource type="PlaneMesh" id="2"]
[sub_resource type="BoxMesh" id=3]
[sub_resource type="BoxMesh" id="3"]
[sub_resource type="StandardMaterial3D" id=4]
[sub_resource type="StandardMaterial3D" id="4"]
albedo_color = Color(0.722656, 0.791992, 1, 1)
roughness = 0.0
[node name="GUIin3D" type="Node3D"]
[node name="GUIPanel3D" parent="." instance=ExtResource( 1 )]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( "Environment_niyks" )
[node name="GUIPanel3D" parent="." instance=ExtResource( "1" )]
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 0.999999, 0, 0, 3)
@@ -43,41 +58,36 @@ omni_range = 10.0
[node name="Camera_Move" type="AnimationPlayer" parent="."]
autoplay = "Move_camera"
playback_speed = 0.25
anims/Move_camera = SubResource( 1 )
anims/Move_camera = SubResource( "1" )
[node name="Background" type="Node3D" parent="."]
[node name="Wall" type="MeshInstance3D" parent="Background"]
transform = Transform3D(4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, -2.60819, 0.589247, -2.08943)
mesh = SubResource( 2 )
surface_material_override/0 = null
mesh = SubResource( "2" )
[node name="Wall2" type="MeshInstance3D" parent="Background"]
transform = Transform3D(4, 0, 0, 0, -1.74846e-07, -4, 0, 4, -1.74846e-07, 5.08055, 0.589247, -2.08943)
mesh = SubResource( 2 )
surface_material_override/0 = null
mesh = SubResource( "2" )
[node name="Wall3" type="MeshInstance3D" parent="Background"]
transform = Transform3D(-1.74846e-07, -4, 0, -1.74846e-07, 7.64274e-15, -4, 4, -1.74846e-07, -1.74846e-07, 9.04446, 0.589247, 1.62058)
mesh = SubResource( 2 )
surface_material_override/0 = null
mesh = SubResource( "2" )
[node name="Floor" type="MeshInstance3D" parent="Background"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, -2.60819, -2.68765, 1.46502)
mesh = SubResource( 2 )
surface_material_override/0 = null
mesh = SubResource( "2" )
[node name="Floor2" type="MeshInstance3D" parent="Background"]
transform = Transform3D(4, 0, 0, 0, 4, 0, 0, 0, 4, 5.08055, -2.68765, 1.46502)
mesh = SubResource( 2 )
surface_material_override/0 = null
mesh = SubResource( "2" )
[node name="Cube" type="MeshInstance3D" parent="Background"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.25901, -0.598608, 0.374871)
mesh = SubResource( 3 )
surface_material_override/0 = SubResource( 4 )
mesh = SubResource( "3" )
surface_material_override/0 = SubResource( "4" )
[node name="Cube2" type="MeshInstance3D" parent="Background"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.88761, 2.01326, 0.374871)
mesh = SubResource( 3 )
surface_material_override/0 = SubResource( 4 )
mesh = SubResource( "3" )
surface_material_override/0 = SubResource( "4" )

View File

@@ -1,33 +1,30 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=7 format=3 uid="uid://dvl383ispakmn"]
[ext_resource path="res://gui_3d.gd" type="Script" id=1]
[ext_resource path="res://icon.png" type="Texture2D" id=2]
[ext_resource type="Script" path="res://gui_3d.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://dn04dlkwccjff" path="res://icon.png" id="2"]
[sub_resource type="QuadMesh" id=1]
[sub_resource type="QuadMesh" id="1"]
size = Vector2(3, 2)
[sub_resource type="ViewportTexture" id=2]
[sub_resource type="ViewportTexture" id="2"]
viewport_path = NodePath("SubViewport")
[sub_resource type="StandardMaterial3D" id=3]
[sub_resource type="StandardMaterial3D" id="3"]
resource_local_to_scene = true
flags_transparent = true
flags_unshaded = true
flags_albedo_tex_force_srgb = true
albedo_texture = SubResource( 2 )
transparency = 1
shading_mode = 0
albedo_texture = SubResource( "2" )
[sub_resource type="BoxShape3D" id=4]
extents = Vector3(1.5, 1, 0.05)
[sub_resource type="BoxShape3D" id="4"]
size = Vector3(3, 2, 0.1)
[node name="GUIPanel3D" type="Node3D"]
script = ExtResource( 1 )
script = ExtResource( "1" )
[node name="SubViewport" type="SubViewport" parent="."]
size = Vector2(280, 180)
hdr = false
usage = 0
render_target_v_flip = true
render_target_update_mode = 3
gui_embed_subwindows = true
size = Vector2i(280, 180)
render_target_update_mode = 4
[node name="GUI" type="Control" parent="SubViewport"]
offset_right = 280.0
@@ -38,74 +35,119 @@ mouse_filter = 1
anchor_right = 1.0
anchor_bottom = 1.0
[node name="Label" type="Label" parent="SubViewport/GUI/Panel"]
offset_left = 44.0
offset_top = 27.0
offset_right = 121.0
offset_bottom = 41.0
text = "Hello world!"
[node name="VBoxContainer" type="VBoxContainer" parent="SubViewport/GUI/Panel"]
anchor_bottom = 1.0
offset_left = 10.0
offset_top = 10.0
offset_right = 150.0
offset_bottom = -10.0
grow_vertical = 2
theme_override_constants/separation = 13
__meta__ = {
"_edit_layout_mode": 1,
"_edit_use_custom_anchors": false
}
[node name="Button" type="Button" parent="SubViewport/GUI/Panel"]
offset_left = 14.0
offset_top = 46.0
offset_right = 154.0
offset_bottom = 74.0
[node name="Label" type="Label" parent="SubViewport/GUI/Panel/VBoxContainer"]
offset_right = 140.0
offset_bottom = 26.0
text = "Hello world!"
horizontal_alignment = 1
__meta__ = {
"_edit_layout_mode": 0,
"_edit_use_custom_anchors": false
}
[node name="Button" type="Button" parent="SubViewport/GUI/Panel/VBoxContainer"]
offset_top = 39.0
offset_right = 140.0
offset_bottom = 70.0
text = "A button!"
[node name="TextEdit" type="LineEdit" parent="SubViewport/GUI/Panel"]
offset_left = 14.0
offset_top = 87.0
offset_right = 154.0
offset_bottom = 111.0
[node name="TextEdit" type="LineEdit" parent="SubViewport/GUI/Panel/VBoxContainer"]
offset_top = 83.0
offset_right = 140.0
offset_bottom = 114.0
[node name="HSlider" type="HSlider" parent="SubViewport/GUI/Panel"]
offset_left = 14.0
offset_top = 118.0
offset_right = 154.0
[node name="HSlider" type="HSlider" parent="SubViewport/GUI/Panel/VBoxContainer"]
offset_top = 127.0
offset_right = 140.0
offset_bottom = 143.0
ticks_on_borders = true
[node name="ColorRect" type="ColorRect" parent="SubViewport/GUI/Panel"]
offset_left = 180.0
offset_top = 26.0
offset_right = 244.0
offset_bottom = 90.0
anchor_left = 1.0
anchor_right = 1.0
offset_left = -110.0
offset_top = 16.0
offset_right = -46.0
offset_bottom = 80.0
color = Color(1, 0, 0, 1)
__meta__ = {
"_edit_layout_mode": 1,
"_edit_use_custom_anchors": true
}
[node name="TextureRect" type="TextureRect" parent="SubViewport/GUI/Panel"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = 52.0
offset_top = -52.0
offset_right = 92.0
offset_bottom = -12.0
texture = ExtResource( 2 )
expand = true
anchor_left = 1.0
anchor_right = 1.0
offset_left = -88.0
offset_top = 38.0
offset_right = -48.0
offset_bottom = 78.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource( "2" )
__meta__ = {
"_edit_layout_mode": 1,
"_edit_use_custom_anchors": true
}
[node name="VSlider" type="VSlider" parent="SubViewport/GUI/Panel"]
offset_left = 260.0
offset_top = 26.0
offset_right = 276.0
offset_bottom = 166.0
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -25.0
offset_top = 5.0
offset_right = -5.0
offset_bottom = -5.0
grow_horizontal = 0
grow_vertical = 2
__meta__ = {
"_edit_layout_mode": 1,
"_edit_use_custom_anchors": false
}
[node name="OptionButton" type="OptionButton" parent="SubViewport/GUI/Panel"]
offset_left = 170.0
offset_top = 111.0
offset_right = 252.0
offset_bottom = 165.0
text = "Item 0"
items = ["Item 0", null, false, 0, null, "Item 1", null, false, 1, null, "Item 2", null, false, 2, null]
selected = 0
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -120.0
offset_top = -80.0
offset_right = -28.0
offset_bottom = -26.0
grow_horizontal = 0
grow_vertical = 0
item_count = 3
popup/item_0/text = "Item 0"
popup/item_0/id = 0
popup/item_1/text = "Item 1"
popup/item_1/id = 1
popup/item_2/text = "Item 2"
popup/item_2/id = 2
__meta__ = {
"_edit_layout_mode": 1,
"_edit_use_custom_anchors": false
}
[node name="Quad" type="MeshInstance3D" parent="."]
mesh = SubResource( 1 )
surface_material_override/0 = SubResource( 3 )
mesh = SubResource( "1" )
surface_material_override/0 = SubResource( "3" )
[node name="Area3D" type="Area3D" parent="Quad"]
collision_layer = 2
input_capture_on_drag = true
[node name="CollisionShape3D" type="CollisionShape3D" parent="Quad/Area3D"]
shape = SubResource( 4 )
shape = SubResource( "4" )

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://dn04dlkwccjff"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -6,7 +6,7 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
[application]
@@ -15,6 +15,7 @@ config/description="A demo showing a GUI instanced within a 3D scene using viewp
as well as forwarding mouse and keyboard input to the GUI."
run/main_scene="res://gui_in_3d.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[gdnative]

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://dmk74aqn56w88"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/mountains.png-03f302fbd9195711fc86ea8f28ca435e.stex"
type="CompressedTexture2D"
uid="uid://tgwx64g0plcn"
path="res://.godot/imported/mountains.png-03f302fbd9195711fc86ea8f28ca435e.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,23 @@ metadata={
[deps]
source_file="res://mountains.png"
dest_files=["res://.godot/imported/mountains.png-03f302fbd9195711fc86ea8f28ca435e.stex"]
dest_files=["res://.godot/imported/mountains.png-03f302fbd9195711fc86ea8f28ca435e.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -6,7 +6,7 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
[application]
@@ -14,6 +14,7 @@ config/name="Screen Capture"
config/description="An example showing how to take screenshots of the screen."
run/main_scene="res://screen_capture.tscn"
config/icon="res://icon.png"
config/features=PackedStringArray("4.0")
[debug]
@@ -21,9 +22,7 @@ gdscript/warnings/return_value_discarded=false
[display]
window/dpi/allow_hidpi=true
window/stretch/mode="2d"
window/stretch/aspect="keep"
[gdnative]

View File

@@ -3,15 +3,8 @@ extends Node
@onready var captured_image = $CapturedImage
func _on_CaptureButton_pressed():
get_viewport().set_clear_mode(SubViewport.CLEAR_MODE_ONLY_NEXT_FRAME)
# Wait until the frame has finished before getting the texture.
await RenderingServer.frame_post_draw
# Retrieve the captured image.
var img = get_viewport().get_texture().get_data()
# Flip it on the y-axis (because it's flipped).
img.flip_y()
var img = get_viewport().get_texture().get_image()
# Create a texture for it.
var tex = ImageTexture.new()

View File

@@ -1,39 +1,41 @@
[gd_scene load_steps=3 format=2]
[gd_scene load_steps=3 format=3 uid="uid://d10mveb7aokfl"]
[ext_resource path="res://screen_capture.gd" type="Script" id=1]
[ext_resource path="res://mountains.png" type="Texture2D" id=2]
[ext_resource type="Script" path="res://screen_capture.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://tgwx64g0plcn" path="res://mountains.png" id="2"]
[node name="ScreenCapture" type="Control"]
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource( 1 )
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( "1" )
[node name="Background" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = 986.0
offset_bottom = 560.0
grow_horizontal = 0
grow_vertical = 0
texture = ExtResource( 2 )
expand = true
texture = ExtResource( "2" )
[node name="CapturedImage" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = 2013.0
offset_bottom = 1162.0
grow_horizontal = 0
grow_vertical = 0
rect_scale = Vector2(0.5, 0.5)
expand = true
offset_left = 128.0
offset_top = 75.0
offset_right = -128.0
offset_bottom = -75.0
grow_horizontal = 2
grow_vertical = 2
ignore_texture_size = true
stretch_mode = 4
__meta__ = {
"_edit_layout_mode": 1,
"_edit_use_custom_anchors": false
}
[node name="CaptureButton" type="Button" parent="."]
offset_left = 48.0
offset_top = 53.0
offset_right = 188.0
offset_bottom = 113.0
offset_left = 50.0
offset_top = 50.0
offset_right = 190.0
offset_bottom = 110.0
text = "Capture screen"
[connection signal="pressed" from="CaptureButton" to="." method="_on_CaptureButton_pressed"]