From b833aac9ffdb6b45743433fbbe7e41179c018447 Mon Sep 17 00:00:00 2001 From: Quantum Date: Wed, 27 Sep 2023 00:05:42 -0400 Subject: [PATCH] Started adding interaction, worked a bit on cardboard shader --- Player.gd | 8 ++++++++ cardboard_shader.tres | 43 +++++++++++++++++++++++++++++++++---------- project.godot | 5 +++++ world.tscn | 8 ++++++-- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/Player.gd b/Player.gd index 300bedd..3f90e07 100644 --- a/Player.gd +++ b/Player.gd @@ -69,3 +69,11 @@ func _input(event): camera.transform.basis = Basis() # reset rotation camera.rotate_object_local(Vector3(0, 1, 0), rot_x) # first rotate in Y camera.rotate_object_local(Vector3(1, 0, 0), rot_y) # then rotate in X + + if event.is_action_pressed("interact"): + var space_state = get_world_3d().direct_space_state + # use global coordinates, not local to node + print(camera.basis) + var query = PhysicsRayQueryParameters3D.create(camera.position, camera.position + camera.basis.z * 2.0) + var result = space_state.intersect_ray(query) + print(result) diff --git a/cardboard_shader.tres b/cardboard_shader.tres index ca7285c..bbc7d98 100644 --- a/cardboard_shader.tres +++ b/cardboard_shader.tres @@ -1,9 +1,13 @@ -[gd_resource type="VisualShader" load_steps=11 format=3 uid="uid://dwd2vgoqby6rd"] +[gd_resource type="VisualShader" load_steps=13 format=3 uid="uid://dwd2vgoqby6rd"] [ext_resource type="Texture2D" uid="uid://cffsdo4cit4i1" path="res://kreb.png" id="1_mkqvf"] [ext_resource type="Texture2D" uid="uid://d0l1mjrgq6wrq" path="res://paper_tex/paper_0025_color_1k.jpg" id="2_1g1lb"] [ext_resource type="Texture2D" uid="uid://dke8hdaqyfnsn" path="res://paper_tex/paper_0025_normal_opengl_1k.png" id="3_qtx1j"] +[sub_resource type="VisualShaderNodeVectorOp" id="VisualShaderNodeVectorOp_xrdx0"] +default_input_values = [0, Vector3(0, 0, 0), 1, Vector3(2, 2, 2)] +operator = 2 + [sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_o5oup"] expanded_output_ports = [0] texture = ExtResource("1_mkqvf") @@ -13,6 +17,8 @@ texture_type = 1 texture = ExtResource("2_1g1lb") [sub_resource type="VisualShaderNodeTexture" id="VisualShaderNodeTexture_kox8j"] +output_port_for_preview = 1 +expanded_output_ports = [0] texture = ExtResource("3_qtx1j") texture_type = 2 @@ -29,13 +35,16 @@ op_type = 4 [sub_resource type="VisualShaderNodeInput" id="VisualShaderNodeInput_6nghl"] input_name = "front_facing" +[sub_resource type="VisualShaderNodeVectorOp" id="VisualShaderNodeVectorOp_mvcqe"] +operator = 2 + [resource] code = "shader_type spatial; render_mode blend_mix, depth_draw_opaque, cull_disabled, diffuse_lambert, specular_schlick_ggx; uniform sampler2D tex_frg_2 : source_color; -uniform sampler2D tex_frg_3; uniform sampler2D tex_frg_4 : hint_normal; +uniform sampler2D tex_frg_3; @@ -49,6 +58,20 @@ void fragment() { float n_out2p4 = n_out2p0.a; +// VectorOp:10 + vec3 n_in10p1 = vec3(2.00000, 2.00000, 2.00000); + vec3 n_out10p0 = vec3(n_out2p0.xyz) * n_in10p1; + + +// Texture2D:4 + vec4 n_out4p0 = texture(tex_frg_4, UV); + float n_out4p1 = n_out4p0.r; + + +// VectorOp:9 + vec3 n_out9p0 = n_out10p0 * vec3(n_out4p1); + + // Texture2D:3 vec4 n_out3p0 = texture(tex_frg_3, UV); @@ -59,11 +82,7 @@ void fragment() { vec3 n_out7p0; // Switch:7 - n_out7p0 = mix(n_out5p0, vec3(n_out2p0.xyz), float(n_out8p0)); - - -// Texture2D:4 - vec4 n_out4p0 = texture(tex_frg_4, UV); + n_out7p0 = mix(n_out5p0, n_out9p0, float(n_out8p0)); // VectorOp:6 @@ -73,12 +92,12 @@ void fragment() { // Output:0 ALBEDO = n_out7p0; ALPHA = n_out2p4; - NORMAL = n_out6p0; + NORMAL_MAP = n_out6p0; } " -graph_offset = Vector2(-111.967, -22.6899) +graph_offset = Vector2(-400.806, 286.904) modes/cull = 2 nodes/fragment/0/position = Vector2(800, 100) nodes/fragment/2/node = SubResource("VisualShaderNodeTexture_o5oup") @@ -95,4 +114,8 @@ nodes/fragment/7/node = SubResource("VisualShaderNodeSwitch_fvm22") nodes/fragment/7/position = Vector2(540, 240) nodes/fragment/8/node = SubResource("VisualShaderNodeInput_6nghl") nodes/fragment/8/position = Vector2(200, 120) -nodes/fragment/connections = PackedInt32Array(2, 4, 5, 0, 3, 0, 5, 1, 4, 0, 6, 1, 2, 4, 6, 0, 2, 0, 7, 1, 5, 0, 7, 2, 7, 0, 0, 0, 8, 0, 7, 0, 2, 4, 0, 1, 6, 0, 0, 8) +nodes/fragment/9/node = SubResource("VisualShaderNodeVectorOp_mvcqe") +nodes/fragment/9/position = Vector2(480, 460) +nodes/fragment/10/node = SubResource("VisualShaderNodeVectorOp_xrdx0") +nodes/fragment/10/position = Vector2(520, 640) +nodes/fragment/connections = PackedInt32Array(2, 4, 5, 0, 3, 0, 5, 1, 4, 0, 6, 1, 2, 4, 6, 0, 5, 0, 7, 2, 8, 0, 7, 0, 2, 4, 0, 1, 7, 0, 0, 0, 6, 0, 0, 9, 9, 0, 7, 1, 4, 1, 9, 1, 10, 0, 9, 0, 2, 0, 10, 0) diff --git a/project.godot b/project.godot index 5f991e0..4d66e6b 100644 --- a/project.godot +++ b/project.godot @@ -42,3 +42,8 @@ jump={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null) ] } +interact={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"echo":false,"script":null) +] +} diff --git a/world.tscn b/world.tscn index a82f976..70fec16 100644 --- a/world.tscn +++ b/world.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=3 uid="uid://cv8621s5oukrb"] +[gd_scene load_steps=5 format=3 uid="uid://cv8621s5oukrb"] [ext_resource type="ArrayMesh" uid="uid://dtqoe5wik1u38" path="res://fmlmap.obj" id="1_2cian"] [ext_resource type="PackedScene" uid="uid://dyyf1q12dchhq" path="res://Player.tscn" id="2_jba6q"] +[ext_resource type="PackedScene" uid="uid://cp4rwojl3c3y3" path="res://test.tscn" id="3_wlkcu"] [sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_8mh8b"] data = PackedVector3Array(-504, -64, 256, -504, -64, 128, -504, -192, 128, -504, -192, 256, -504, -64, 256, -504, -192, 128, -504, -64, 256, -512, -64, 256, -512, -64, 128, -504, -64, 128, -504, -64, 256, -512, -64, 128, -504, -64, 256, -504, -192, 256, -512, -192, 256, -512, -64, 256, -504, -64, 256, -512, -192, 256, -504, -64, 128, -512, -64, 128, -512, -192, 128, -504, -192, 128, -504, -64, 128, -512, -192, 128, -504, -192, 256, -504, -192, 128, -512, -192, 128, -512, -192, 256, -504, -192, 256, -512, -192, 128, -512, -64, 256, -512, -192, 256, -512, -192, 128, -512, -64, 128, -512, -64, 256, -512, -192, 128, -128, 64, 8, -128, 64, 0, -128, -320, 0, -128, -320, 8, -128, 64, 8, -128, -320, 0, -128, 64, 8, -512, 64, 8, -512, 64, 0, -128, 64, 0, -128, 64, 8, -512, 64, 0, -128, 64, 8, -128, -320, 8, -512, -320, 8, -512, 64, 8, -128, 64, 8, -512, -320, 8, -128, 64, 0, -512, 64, 0, -512, -320, 0, -128, -320, 0, -128, 64, 0, -512, -320, 0, -128, -320, 8, -128, -320, 0, -512, -320, 0, -512, -320, 8, -128, -320, 8, -512, -320, 0, -512, 64, 8, -512, -320, 8, -512, -320, 0, -512, 64, 0, -512, 64, 8, -512, -320, 0, -512, 64, 392, -512, 64, 8, -512, -320, 8, -512, -320, 392, -512, 64, 392, -512, -320, 8, -512, 64, 392, -520, 64, 392, -520, 64, 8, -512, 64, 8, -512, 64, 392, -520, 64, 8, -512, 64, 392, -512, -320, 392, -520, -320, 392, -520, 64, 392, -512, 64, 392, -520, -320, 392, -512, 64, 8, -520, 64, 8, -520, -320, 8, -512, -320, 8, -512, 64, 8, -520, -320, 8, -520, 64, 392, -520, -320, 392, -520, -320, 8, -520, 64, 8, -520, 64, 392, -520, -320, 8, -512, -320, 392, -512, -320, 8, -520, -320, 8, -520, -320, 392, -512, -320, 392, -520, -320, 8, 64, 960, 320, 64, 960, 192, 64, 948, 192, 64, 948, 320, 64, 960, 320, 64, 948, 192, 64, 960, 320, -64, 960, 320, -64, 960, 192, 64, 960, 192, 64, 960, 320, -64, 960, 192, 64, 960, 320, 64, 948, 320, -64, 948, 320, -64, 960, 320, 64, 960, 320, -64, 948, 320, 64, 960, 192, -64, 960, 192, -64, 948, 192, 64, 948, 192, 64, 960, 192, -64, 948, 192, 64, 948, 320, 64, 948, 192, -64, 948, 192, -64, 948, 320, 64, 948, 320, -64, 948, 192, -64, 960, 320, -64, 948, 320, -64, 948, 192, -64, 960, 192, -64, 960, 320, -64, 948, 192, 32, 996, 96, 32, 996, 0, 32, 988, 0, 32, 988, 96, 32, 996, 96, 32, 988, 0, -16, 496, 76, -16, 496, 8, -16, 464, 8, -16, 464, 76, -16, 496, 76, -16, 464, 8, 32, 996, 96, -32, 996, 96, -32, 996, 0, 32, 996, 0, 32, 996, 96, -32, 996, 0, 32, 996, 96, 32, 988, 96, -32, 988, 96, -32, 996, 96, 32, 996, 96, -32, 988, 96, 32, 996, 0, -32, 996, 0, -32, 988, 0, 32, 988, 0, 32, 996, 0, -32, 988, 0, 32, 988, 96, 32, 988, 0, -32, 988, 0, -32, 988, 96, 32, 988, 96, -32, 988, 0, -32, 996, 96, -32, 988, 96, -32, 988, 0, -32, 996, 0, -32, 996, 96, -32, 988, 0, -16, 496, 76, -48, 496, 76, -48, 496, 8, -16, 496, 8, -16, 496, 76, -48, 496, 8, -16, 496, 76, -16, 464, 76, -48, 464, 76, -48, 496, 76, -16, 496, 76, -48, 464, 76, -16, 496, 8, -48, 496, 8, -48, 464, 8, -16, 464, 8, -16, 496, 8, -48, 464, 8, -16, 464, 76, -16, 464, 8, -48, 464, 8, -48, 464, 76, -16, 464, 76, -48, 464, 8, -48, 496, 76, -48, 464, 76, -48, 464, 8, -48, 496, 8, -48, 496, 76, -48, 464, 8, 512, 1024, 416, 512, 1024, 96, 512, 960, 96, 512, 960, 416, 512, 1024, 416, 512, 960, 96, 512, 960, 96, 512, 1024, 96, 512, 960, 0, 512, 1024, 96, 512, 1024, 0, 512, 960, 0, -512, 1024, 96, 512, 1024, 96, 512, 1024, 416, 512, 1024, 96, 32, 1024, 96, 32, 1024, 0, 512, 1024, 96, 32, 1024, 0, 512, 1024, 0, -512, 1024, 96, 512, 1024, 416, -512, 1024, 416, -32, 1024, 96, -512, 1024, 96, -512, 1024, 0, -32, 1024, 96, -512, 1024, 0, -32, 1024, 0, 512, 1024, 96, 512, 960, 96, 32, 960, 96, 32, 1024, 96, 512, 1024, 96, 32, 960, 96, 512, 1024, 0, 32, 1024, 0, 32, 960, 0, 512, 960, 0, 512, 1024, 0, 32, 960, 0, 512, 960, 416, 512, 960, 96, -512, 960, 96, 512, 960, 96, 512, 960, 0, 32, 960, 0, 512, 960, 96, 32, 960, 0, 32, 960, 96, 512, 960, 416, -512, 960, 96, -512, 960, 416, -512, 960, 0, -512, 960, 96, -32, 960, 96, -512, 960, 0, -32, 960, 96, -32, 960, 0, 32, 1024, 96, 32, 960, 96, 32, 960, 0, 32, 1024, 0, 32, 1024, 96, 32, 960, 0, -32, 1024, 96, -32, 1024, 0, -32, 960, 0, -32, 960, 96, -32, 1024, 96, -32, 960, 0, 512, 1024, 416, 512, 960, 416, -512, 960, 416, -512, 1024, 416, 512, 1024, 416, -512, 960, 416, -32, 1024, 96, -32, 960, 96, -512, 960, 96, -512, 1024, 96, -32, 1024, 96, -512, 960, 96, 512, 1024, 96, -512, 1024, 96, -512, 960, 96, 512, 960, 96, 512, 1024, 96, -512, 960, 96, -512, 1024, 416, -512, 960, 416, -512, 960, 96, -512, 1024, 96, -512, 1024, 416, -512, 960, 96, -512, 1024, 96, -512, 960, 96, -512, 960, 0, -512, 1024, 0, -512, 1024, 96, -512, 960, 0, -32, 1024, 0, -512, 1024, 0, -512, 960, 0, -32, 960, 0, -32, 1024, 0, -512, 960, 0, 1024, 1024, 0, 1024, 1024, -64, 1024, -1024, -64, 1024, -1024, 0, 1024, 1024, 0, 1024, -1024, -64, 1024, 1024, 0, -1024, 1024, 0, -1024, 1024, -64, 1024, 1024, -64, 1024, 1024, 0, -1024, 1024, -64, 1024, 1024, 0, 1024, -1024, 0, -1024, -1024, 0, -1024, 1024, 0, 1024, 1024, 0, -1024, -1024, 0, 1024, 1024, -64, -1024, 1024, -64, -1024, -1024, -64, 1024, -1024, -64, 1024, 1024, -64, -1024, -1024, -64, 1024, -1024, 0, 1024, -1024, -64, -1024, -1024, -64, -1024, -1024, 0, 1024, -1024, 0, -1024, -1024, -64, -1024, 1024, 0, -1024, -1024, 0, -1024, -1024, -64, -1024, 1024, -64, -1024, 1024, 0, -1024, -1024, -64) @@ -23,6 +24,9 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6, 0, 1.077) [node name="OmniLight3D" type="OmniLight3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 18.9032, 0) light_color = Color(1, 0.862745, 0.721569, 1) -light_energy = 64.0 +light_energy = 16.0 light_size = 400.0 omni_range = 100.656 + +[node name="CardboardKreb" parent="." instance=ExtResource("3_wlkcu")] +transform = Transform3D(1.79237, 0, 2.4057, 0, 3, 0, -2.4057, 0, 1.79237, -9.69573, 0.367563, -0.222977)