diff --git a/Pot.tres b/Pot.tres index f9915cf..96142c9 100644 --- a/Pot.tres +++ b/Pot.tres @@ -35,7 +35,6 @@ void fragment() { } " -graph_offset = Vector2(-323.167, 182.894) nodes/fragment/2/node = SubResource("VisualShaderNodeInput_k82ey") nodes/fragment/2/position = Vector2(-140, 280) nodes/fragment/3/node = SubResource("VisualShaderNodeTransformOp_k82ey") diff --git a/Scenes/Prefabs/Battery.tscn b/Scenes/Prefabs/Battery.tscn index 0e5475c..efdc4fb 100644 --- a/Scenes/Prefabs/Battery.tscn +++ b/Scenes/Prefabs/Battery.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://wr21rggawosn"] +[gd_scene load_steps=21 format=3 uid="uid://wr21rggawosn"] [ext_resource type="Script" uid="uid://c61rr6to3q566" path="res://Scripts/build_object.gd" id="1_c0yqx"] [ext_resource type="ArrayMesh" uid="uid://cvgyv0qygl2g2" path="res://Blends/Battery/Battery.obj" id="1_lt2ya"] @@ -9,13 +9,20 @@ [ext_resource type="Shader" uid="uid://csc12sk3jp67" path="res://Shaders/battery_handle.gdshader" id="5_6tv3k"] [ext_resource type="Shader" uid="uid://xn2eixgmefs8" path="res://Shaders/battery_glass.gdshader" id="6_b5dta"] [ext_resource type="Shader" uid="uid://4m7bv5x2pfnr" path="res://Shaders/Fuse.gdshader" id="7_hr37j"] +[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="10_pigwg"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_6tv3k"] render_priority = 0 shader = ExtResource("2_pigwg") shader_parameter/color = Vector3(0, 0, 0) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_pigwg"] +render_priority = 0 +shader = ExtResource("10_pigwg") +shader_parameter/is_active = false + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_byy4f"] +next_pass = SubResource("ShaderMaterial_pigwg") albedo_texture = ExtResource("2_teewy") metallic = 1.0 roughness = 0.5 @@ -39,6 +46,7 @@ shader_parameter/normal = ExtResource("3_c0yqx") [sub_resource type="FastNoiseLite" id="FastNoiseLite_8a881"] [sub_resource type="NoiseTexture2D" id="NoiseTexture2D_fdnlq"] +seamless = true noise = SubResource("FastNoiseLite_8a881") [sub_resource type="ShaderMaterial" id="ShaderMaterial_hnq8j"] @@ -46,6 +54,9 @@ render_priority = 0 shader = ExtResource("7_hr37j") shader_parameter/noise = SubResource("NoiseTexture2D_fdnlq") +[sub_resource type="BoxShape3D" id="BoxShape3D_pigwg"] +size = Vector3(6.92554, 2.55286, 2.97417) + [node name="Battery" type="Node3D" node_paths=PackedStringArray("meshInstance")] script = ExtResource("1_c0yqx") meshInstance = NodePath("Battery") @@ -63,3 +74,9 @@ surface_material_override/5 = SubResource("StandardMaterial3D_byy4f") surface_material_override/6 = SubResource("ShaderMaterial_wr5rf") surface_material_override/7 = SubResource("ShaderMaterial_hnq8j") surface_material_override/8 = SubResource("StandardMaterial3D_byy4f") + +[node name="StaticBody3D" type="StaticBody3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.053833, -0.776428, 0.0276413) +shape = SubResource("BoxShape3D_pigwg") diff --git a/Scenes/Prefabs/DoubleBeds.tscn b/Scenes/Prefabs/DoubleBeds.tscn index 07ca86c..780aca2 100644 --- a/Scenes/Prefabs/DoubleBeds.tscn +++ b/Scenes/Prefabs/DoubleBeds.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=11 format=3 uid="uid://0t0cvsitlfmm"] +[gd_scene load_steps=16 format=3 uid="uid://0t0cvsitlfmm"] [ext_resource type="Script" uid="uid://c61rr6to3q566" path="res://Scripts/build_object.gd" id="1_nn5da"] [ext_resource type="ArrayMesh" uid="uid://cahq2fdeqqwhx" path="res://Blends/Mobel/DoubleBeds.obj" id="2_8ssp7"] [ext_resource type="Texture2D" uid="uid://84bnb4rnuhuq" path="res://Blends/Mobel/textures/double_bed_metal.png" id="3_nn5da"] [ext_resource type="Shader" uid="uid://bfv6ckihralab" path="res://Shaders/build_transparent.gdshader" id="3_pdq8c"] [ext_resource type="Texture2D" uid="uid://lbbig7lpdun3" path="res://Blends/Mobel/textures/Material.003 Roughness.png" id="4_dn7et"] +[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="5_c1046"] [ext_resource type="Texture2D" uid="uid://kl1jplui8wfq" path="res://Blends/Mobel/textures/Material.003 Base Color.png" id="5_sp2kd"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_dn7et"] @@ -12,16 +13,37 @@ render_priority = 0 shader = ExtResource("3_pdq8c") shader_parameter/color = Vector3(0, 0, 0) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_k1k40"] +render_priority = 0 +shader = ExtResource("5_c1046") +shader_parameter/is_active = false + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_c1046"] +next_pass = SubResource("ShaderMaterial_k1k40") albedo_texture = ExtResource("3_nn5da") roughness_texture = ExtResource("4_dn7et") +[sub_resource type="ShaderMaterial" id="ShaderMaterial_tma46"] +render_priority = 0 +shader = ExtResource("5_c1046") +shader_parameter/is_active = false + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_k1k40"] +next_pass = SubResource("ShaderMaterial_tma46") albedo_texture = ExtResource("5_sp2kd") +[sub_resource type="ShaderMaterial" id="ShaderMaterial_8tdb8"] +render_priority = 0 +shader = ExtResource("5_c1046") +shader_parameter/is_active = false + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_tma46"] +next_pass = SubResource("ShaderMaterial_8tdb8") albedo_texture = ExtResource("5_sp2kd") +[sub_resource type="BoxShape3D" id="BoxShape3D_sp2kd"] +size = Vector3(5.62061, 2.52063, 2.12427) + [node name="DoubleBeds" type="Node3D" node_paths=PackedStringArray("meshInstance")] script = ExtResource("1_nn5da") meshInstance = NodePath("DoubleBeds") @@ -33,3 +55,9 @@ mesh = ExtResource("2_8ssp7") surface_material_override/0 = SubResource("StandardMaterial3D_c1046") surface_material_override/1 = SubResource("StandardMaterial3D_k1k40") surface_material_override/2 = SubResource("StandardMaterial3D_tma46") + +[node name="StaticBody3D" type="StaticBody3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.218994, -0.287048, 0.10144) +shape = SubResource("BoxShape3D_sp2kd") diff --git a/Scenes/Prefabs/Pot.tscn b/Scenes/Prefabs/Pot.tscn index 17cecad..fe37ddb 100644 --- a/Scenes/Prefabs/Pot.tscn +++ b/Scenes/Prefabs/Pot.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=15 format=3 uid="uid://bcme5mx8nf5kf"] +[gd_scene load_steps=20 format=3 uid="uid://bcme5mx8nf5kf"] [ext_resource type="Script" uid="uid://c61rr6to3q566" path="res://Scripts/build_object.gd" id="1_c5d30"] [ext_resource type="ArrayMesh" uid="uid://dqs5joeucls8u" path="res://Blends/Pot/pot.obj" id="1_ps8qt"] @@ -10,13 +10,23 @@ [ext_resource type="Texture2D" uid="uid://8qyuw0q5luju" path="res://Blends/Pot/pot_uv.jpg" id="5_vv7mx"] [ext_resource type="Texture2D" uid="uid://bxgm6oovlxdjq" path="res://Blends/Pot/wood_n.png" id="6_r71lq"] [ext_resource type="Texture2D" uid="uid://run700pxmcyc" path="res://Blends/Pot/brick_t.png" id="7_e7ek7"] +[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="7_gtq0i"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_vv7mx"] render_priority = 0 shader = ExtResource("2_ocdig") shader_parameter/color = Vector3(0, 0, 0) +[sub_resource type="BoxShape3D" id="BoxShape3D_gtq0i"] +size = Vector3(3.78918, 3.11292, 1.9624) + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_r71lq"] +render_priority = 0 +shader = ExtResource("7_gtq0i") +shader_parameter/is_active = false + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dn6sd"] +next_pass = SubResource("ShaderMaterial_r71lq") albedo_texture = ExtResource("2_c5d30") roughness = 0.4 roughness_texture = ExtResource("4_vv7mx") @@ -27,12 +37,24 @@ detail_albedo = ExtResource("5_vv7mx") detail_normal = ExtResource("3_ocdig") uv1_scale = Vector3(0.5, 0.4, 1) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_e7ek7"] +render_priority = 0 +shader = ExtResource("7_gtq0i") +shader_parameter/is_active = false + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_uhv8u"] +next_pass = SubResource("ShaderMaterial_e7ek7") albedo_texture = ExtResource("5_gtq0i") normal_enabled = true normal_texture = ExtResource("6_r71lq") +[sub_resource type="ShaderMaterial" id="ShaderMaterial_dn6sd"] +render_priority = 0 +shader = ExtResource("7_gtq0i") +shader_parameter/is_active = false + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rbvpf"] +next_pass = SubResource("ShaderMaterial_dn6sd") albedo_texture = ExtResource("7_e7ek7") [node name="Pot" type="Node3D" node_paths=PackedStringArray("meshInstance")] @@ -41,6 +63,12 @@ script = ExtResource("1_c5d30") meshInstance = NodePath("Pot") preview_shader = SubResource("ShaderMaterial_vv7mx") +[node name="StaticBody3D" type="StaticBody3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0180054, -1.83221, -0.481201) +shape = SubResource("BoxShape3D_gtq0i") + [node name="Pot" type="MeshInstance3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -3.41814, 0) mesh = ExtResource("1_ps8qt") diff --git a/Scenes/Prefabs/Shelf.tscn b/Scenes/Prefabs/Shelf.tscn index 389e571..ce9e59d 100644 --- a/Scenes/Prefabs/Shelf.tscn +++ b/Scenes/Prefabs/Shelf.tscn @@ -1,22 +1,32 @@ -[gd_scene load_steps=8 format=3 uid="uid://c0gypplbklc3i"] +[gd_scene load_steps=11 format=3 uid="uid://c0gypplbklc3i"] [ext_resource type="ArrayMesh" uid="uid://k2k1ppv3ycsv" path="res://Blends/Shelf/Shelf.obj" id="1_usf1u"] [ext_resource type="Script" uid="uid://c61rr6to3q566" path="res://Scripts/build_object.gd" id="1_ya6sq"] [ext_resource type="Shader" uid="uid://bfv6ckihralab" path="res://Shaders/build_transparent.gdshader" id="2_jbe2f"] [ext_resource type="Texture2D" uid="uid://5gmmgg4cmefr" path="res://Blends/Shelf/color.png" id="2_x70sl"] [ext_resource type="Texture2D" uid="uid://q0duenho1u2x" path="res://Blends/Shelf/normal.png" id="3_ya6sq"] +[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="5_jbe2f"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_4318v"] render_priority = 0 shader = ExtResource("2_jbe2f") shader_parameter/color = Vector3(0, 0, 0) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_0dtcx"] +render_priority = 0 +shader = ExtResource("5_jbe2f") +shader_parameter/is_active = false + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jbe2f"] +next_pass = SubResource("ShaderMaterial_0dtcx") albedo_texture = ExtResource("2_x70sl") normal_enabled = true normal_scale = -1.88 normal_texture = ExtResource("3_ya6sq") +[sub_resource type="BoxShape3D" id="BoxShape3D_jbe2f"] +size = Vector3(4.40356, 3.34375, 1.28992) + [node name="Shelf" type="Node3D" node_paths=PackedStringArray("meshInstance")] script = ExtResource("1_ya6sq") meshInstance = NodePath("Shelf") @@ -26,3 +36,9 @@ preview_shader = SubResource("ShaderMaterial_4318v") transform = Transform3D(-2.18557e-08, 0, -0.5, 0, 0.5, 0, 0.5, 0, -2.18557e-08, 0, -1.53245, 0) mesh = ExtResource("1_usf1u") surface_material_override/0 = SubResource("StandardMaterial3D_jbe2f") + +[node name="StaticBody3D" type="StaticBody3D" parent="."] + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0545654, 0.0981445, -0.0205688) +shape = SubResource("BoxShape3D_jbe2f") diff --git a/Scripts/build_object.gd b/Scripts/build_object.gd index fad531c..4662a79 100644 --- a/Scripts/build_object.gd +++ b/Scripts/build_object.gd @@ -1,15 +1,23 @@ extends Node3D + @export var meshInstance: MeshInstance3D @export var preview_shader: ShaderMaterial var default_shaders: Array +var staic_body: StaticBody3D + func _ready() -> void: Global.preview_created.connect(_on_preview_create) Global.object_placed.connect(_on_object_placed) set_default_shaders() + + staic_body = $StaticBody3D + staic_body.mouse_entered.connect(_on_mouse_enter) + staic_body.mouse_exited.connect(_on_mouse_exit) + print(staic_body) func set_default_shaders(): @@ -46,3 +54,22 @@ func _on_preview_create(): func _on_object_placed(): restore_default_shaders() + + +func enable_outline(): + for i in meshInstance.get_surface_override_material_count(): + var material = meshInstance.get_surface_override_material(i) + if material.next_pass != null: + meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", true) +func disable_outline(): + for i in meshInstance.get_surface_override_material_count(): + var material = meshInstance.get_surface_override_material(i) + if material.next_pass != null: + meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", false) + + + +func _on_mouse_enter(): + enable_outline() +func _on_mouse_exit(): + disable_outline() diff --git a/Scripts/building_area.gd b/Scripts/building_area.gd index fccbfb6..94fdd46 100644 --- a/Scripts/building_area.gd +++ b/Scripts/building_area.gd @@ -1,8 +1,5 @@ extends StaticBody3D - - -@onready var beds = preload("res://Scenes/Prefabs/DoubleBeds.tscn") @export var buildTransparentPreivew: MeshInstance3D @@ -49,6 +46,7 @@ func place_object(): is_placed = true buildTransparentPreivew.visible = false Global.object_placed.emit() + self.queue_free() func _on_enter_build_mode(): if !is_placed: diff --git a/Scripts/global_script.gd b/Scripts/global_script.gd index 376c5b7..2435cfd 100644 --- a/Scripts/global_script.gd +++ b/Scripts/global_script.gd @@ -1,4 +1,7 @@ extends Node3D + +@onready var outline_shader = preload("res://Shaders/outline.gdshader") + @export var debugLabel1: Label signal exit_build_mode @@ -11,6 +14,8 @@ signal object_placed var build_mode: bool = false +func _ready() -> void: + print(outline_shader) func _input(event: InputEvent) -> void: if event.is_action_released("enter_build_mode"): diff --git a/Shaders/Fuse.gdshader b/Shaders/Fuse.gdshader index d59ac91..a3e5aab 100644 --- a/Shaders/Fuse.gdshader +++ b/Shaders/Fuse.gdshader @@ -1,18 +1,25 @@ shader_type spatial; uniform sampler2D noise; + +varying float pos_y; + void vertex() { - // Called for every vertex the material is visible on. + pos_y = VERTEX.y; + //pos_y = POSITION.y; + //POSITION.y = 0.0; } void fragment() { //ALBEDO = vec3(0.000275,0.0,0.665027); - EMISSION = vec3(0.0,0.0,1.0); + EMISSION = vec3(0.0,0.0,10.0); if( TIME < 1800.0 ) { ALBEDO = texture(noise,UV + TIME / 5.0).rgb; } else { - ALBEDO = texture(noise,UV - TIME).rgb; + ALBEDO = texture(noise,UV - TIME / 5.0).rgb; } + CLEARCOAT = 5.0; + } diff --git a/Shaders/battery_button.gdshader b/Shaders/battery_button.gdshader index 6614732..0bd560f 100644 --- a/Shaders/battery_button.gdshader +++ b/Shaders/battery_button.gdshader @@ -6,7 +6,7 @@ void vertex() { void fragment() { ALBEDO = vec3(1.0,0.0,0.0); - EMISSION = vec3(1.0,0.0,0.0); + EMISSION = vec3(5.0,0.0,0.0); } //void light() { diff --git a/Shaders/battery_handle.gdshader b/Shaders/battery_handle.gdshader index f67e643..50832c2 100644 --- a/Shaders/battery_handle.gdshader +++ b/Shaders/battery_handle.gdshader @@ -8,8 +8,8 @@ void fragment() { ALBEDO = vec3(0.5,0.5,0.5); METALLIC = 1.0; ROUGHNESS = 0.3; - -} + +} //void light() { // // Called for every pixel for every light affecting the material. diff --git a/Shaders/outline.gdshader b/Shaders/outline.gdshader new file mode 100644 index 0000000..0568d3b --- /dev/null +++ b/Shaders/outline.gdshader @@ -0,0 +1,25 @@ +shader_type spatial; +render_mode cull_front, unshaded; + +uniform bool is_active; + +const vec3 color = vec3(0.95, 0.71, 0.01); +const float thickness = 0.1; + +void vertex() { + if(is_active) { + VERTEX += NORMAL * thickness; + } +} + +void fragment() { + if (is_active) { + ALBEDO = color; + ALPHA = 0.5; + } +} + +//void light() { +// // Called for every pixel for every light affecting the material. +// // Uncomment to replace the default light processing function with this one. +//} diff --git a/Shaders/outline.gdshader.uid b/Shaders/outline.gdshader.uid new file mode 100644 index 0000000..fa5a108 --- /dev/null +++ b/Shaders/outline.gdshader.uid @@ -0,0 +1 @@ +uid://c08eg1piwoy3t