Skip to content

Commit

Permalink
Improved reflections (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
TitanNano authored Feb 9, 2024
1 parent e3b31f5 commit 41853e6
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 91 deletions.
7 changes: 5 additions & 2 deletions resources/Environments/WorldEnv.tres
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ background_mode = 2
sky = SubResource("1")
tonemap_mode = 3
tonemap_exposure = 0.7
ssr_enabled = true
ssr_max_steps = 80
ssr_fade_out = 1.0
ssr_depth_tolerance = 0.51
ssao_enabled = true
sdfgi_enabled = true
sdfgi_cascades = 3
sdfgi_min_cell_size = 0.488281
glow_enabled = true
fog_light_color = Color(0.65, 0.84, 0.95, 1)
fog_density = 0.001
3 changes: 2 additions & 1 deletion resources/Materials/ocean_backdrop.tres
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
render_priority = 0
shader = ExtResource("2")
shader_parameter/Wave_Height = 0.0
shader_parameter/Albedo = Color(0.0235294, 0.101961, 0.231373, 1)
shader_parameter/Albedo = Color(0.129412, 0.180392, 0.262745, 1)
shader_parameter/IOR = 1.333
shader_parameter/Depth_Scale = 1.0
shader_parameter/Roughness = 0.5
shader_parameter/uv_aspectratio = Vector3(1, 1, 1)
shader_parameter/Normal_Resolution = 60.0
shader_parameter/TextureUniform = ExtResource("1")
3 changes: 2 additions & 1 deletion resources/Materials/ocean_material.tres
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
render_priority = 0
shader = ExtResource("2")
shader_parameter/Wave_Height = 2.0
shader_parameter/Albedo = Color(0.0235294, 0.101961, 0.231373, 1)
shader_parameter/Albedo = Color(0.129412, 0.180392, 0.262745, 1)
shader_parameter/IOR = 1.333
shader_parameter/Depth_Scale = 0.5
shader_parameter/Roughness = 0.2
shader_parameter/uv_aspectratio = Vector3(1, 1, 1)
shader_parameter/Normal_Resolution = 60.0
shader_parameter/TextureUniform = ExtResource("2_ycx5u")
25 changes: 14 additions & 11 deletions resources/Shaders/ocean_visualshader.tres
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ operator = 2
default_input_values = [0, 1.0, 1, 0.0]
operator = 1

[sub_resource type="VisualShaderNodeFloatParameter" id="VisualShaderNodeFloatParameter_vol2q"]
parameter_name = "Roughness"
hint = 1
default_value_enabled = true

[sub_resource type="VisualShaderNodeFloatConstant" id="8"]

[sub_resource type="VisualShaderNodeColorParameter" id="9"]
Expand All @@ -99,9 +104,6 @@ input_name = "screen_uv"
[sub_resource type="VisualShaderNodeTexture" id="14"]
source = 5

[sub_resource type="VisualShaderNodeFloatConstant" id="16"]
constant = 0.3

[sub_resource type="VisualShaderNodeMix" id="17"]
default_input_values = [0, Vector3(0, 0, 0), 1, Vector3(1, 1, 1), 2, Vector3(0, 0, 0)]
op_type = 3
Expand All @@ -111,7 +113,7 @@ default_input_values = [0, Vector3(0, 0, 0), 1, Vector3(0, 0, 0), 2, Vector3(0,
op_type = 3

[sub_resource type="VisualShaderNodeClamp" id="28"]
default_input_values = [0, 1.0, 1, 0.15, 2, 1.0]
default_input_values = [0, 1.0, 1, 2.08165e-12, 2, 1.0]

[sub_resource type="VisualShaderNodeFloatParameter" id="29"]
parameter_name = "Depth_Scale"
Expand Down Expand Up @@ -173,6 +175,7 @@ uniform float IOR;
uniform sampler2D screen_text : filter_linear_mipmap, hint_screen_texture;
uniform sampler2D depth_text : source_color, filter_nearest, repeat_disable, hint_depth_texture;
uniform float Depth_Scale;
uniform float Roughness : hint_range(0, 1) = 0;
uniform vec3 uv_aspectratio;
uniform float Normal_Resolution;
uniform sampler2D TextureUniform : hint_normal;
Expand Down Expand Up @@ -675,7 +678,7 @@ void fragment() {


// Clamp:59
float n_in59p1 = 0.15000;
float n_in59p1 = 0.00000;
float n_in59p2 = 1.00000;
float n_out59p0 = clamp(n_out140p0, n_in59p1, n_in59p2);

Expand All @@ -684,8 +687,8 @@ void fragment() {
vec3 n_out40p0 = mix(vec3(n_out18p0.xyz), n_out19p0, vec3(n_out59p0));


// FloatConstant:39
float n_out39p0 = 0.300000;
// FloatParameter:141
float n_out141p0 = Roughness;


// Mix:41
Expand Down Expand Up @@ -746,7 +749,7 @@ void fragment() {

// Output:0
ALBEDO = n_out40p0;
ROUGHNESS = n_out39p0;
ROUGHNESS = n_out141p0;
EMISSION = n_out41p0;
NORMAL_MAP = vec3(n_out111p0.xyz);
NORMAL_MAP_DEPTH = n_out95p0;
Expand Down Expand Up @@ -795,8 +798,6 @@ nodes/fragment/33/node = SubResource("13")
nodes/fragment/33/position = Vector2(800, -1660)
nodes/fragment/35/node = SubResource("14")
nodes/fragment/35/position = Vector2(1520, -1660)
nodes/fragment/39/node = SubResource("16")
nodes/fragment/39/position = Vector2(7540, -1640)
nodes/fragment/40/node = SubResource("17")
nodes/fragment/40/position = Vector2(7180, -1840)
nodes/fragment/41/node = SubResource("18")
Expand Down Expand Up @@ -856,4 +857,6 @@ nodes/fragment/139/node = SubResource("VisualShaderNodeFloatOp_f51ga")
nodes/fragment/139/position = Vector2(5220, -1980)
nodes/fragment/140/node = SubResource("VisualShaderNodeFloatOp_msonu")
nodes/fragment/140/position = Vector2(5680, -1980)
nodes/fragment/connections = PackedInt32Array(17, 0, 19, 2, 20, 0, 19, 0, 33, 0, 35, 0, 26, 0, 19, 3, 39, 0, 0, 3, 102, 0, 101, 1, 101, 0, 103, 0, 104, 0, 106, 0, 104, 0, 105, 0, 106, 0, 105, 1, 105, 0, 103, 1, 108, 0, 101, 0, 100, 0, 108, 0, 107, 0, 108, 1, 109, 0, 19, 7, 110, 0, 19, 8, 59, 0, 40, 2, 19, 0, 40, 1, 18, 0, 40, 0, 19, 1, 41, 1, 59, 0, 41, 2, 95, 0, 0, 10, 99, 0, 111, 2, 103, 0, 111, 0, 111, 0, 0, 9, 110, 0, 35, 2, 35, 0, 125, 0, 133, 0, 134, 0, 125, 0, 134, 1, 136, 0, 137, 0, 137, 2, 138, 0, 134, 0, 138, 1, 138, 0, 139, 1, 61, 0, 139, 0, 40, 0, 0, 0, 41, 0, 0, 5, 140, 0, 59, 0, 139, 0, 140, 1)
nodes/fragment/141/node = SubResource("VisualShaderNodeFloatParameter_vol2q")
nodes/fragment/141/position = Vector2(7520, -2300)
nodes/fragment/connections = PackedInt32Array(17, 0, 19, 2, 20, 0, 19, 0, 33, 0, 35, 0, 26, 0, 19, 3, 102, 0, 101, 1, 101, 0, 103, 0, 104, 0, 106, 0, 104, 0, 105, 0, 106, 0, 105, 1, 105, 0, 103, 1, 108, 0, 101, 0, 100, 0, 108, 0, 107, 0, 108, 1, 109, 0, 19, 7, 110, 0, 19, 8, 59, 0, 40, 2, 19, 0, 40, 1, 18, 0, 40, 0, 19, 1, 41, 1, 59, 0, 41, 2, 95, 0, 0, 10, 99, 0, 111, 2, 103, 0, 111, 0, 111, 0, 0, 9, 110, 0, 35, 2, 35, 0, 125, 0, 133, 0, 134, 0, 125, 0, 134, 1, 136, 0, 137, 0, 137, 2, 138, 0, 134, 0, 138, 1, 138, 0, 139, 1, 61, 0, 139, 0, 40, 0, 0, 0, 41, 0, 0, 5, 140, 0, 59, 0, 139, 0, 140, 1, 141, 0, 0, 3)
6 changes: 1 addition & 5 deletions resources/main.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[gd_scene load_steps=20 format=3 uid="uid://cvh54xiw8586b"]
[gd_scene load_steps=19 format=3 uid="uid://cvh54xiw8586b"]

[ext_resource type="Script" path="res://src/HUD/HUDController.gd" id="1"]
[ext_resource type="Script" path="res://src/Objects/World/World.gd" id="3"]
[ext_resource type="Script" path="res://src/ViewPort.gd" id="3_2c332"]
[ext_resource type="Script" path="res://src/HUD/LoadingScreen.gd" id="4"]
[ext_resource type="Script" path="res://src/Objects/World/ReflectionManager.gd" id="5"]
[ext_resource type="Script" path="res://src/Objects/World/Backdrop.gd" id="6"]
[ext_resource type="PackedScene" uid="uid://csuvlu656dwm4" path="res://resources/Objects/Buildings/hangar_2.tscn" id="7"]
[ext_resource type="Environment" uid="uid://bl607wqoa882d" path="res://resources/Environments/WorldEnv.tres" id="8"]
Expand Down Expand Up @@ -131,9 +130,6 @@ world_constants = ExtResource("15")
script = ExtResource("17")
world_constants = ExtResource("15")

[node name="Reflections" type="Node3D" parent="SubViewportContainer/SubViewport/World"]
script = ExtResource("5")

[node name="Buildings" type="Node" parent="SubViewportContainer/SubViewport/World"]
script = ExtResource("15_23gpq")
world_constants = ExtResource("15")
Expand Down
59 changes: 0 additions & 59 deletions src/Objects/World/ReflectionManager.gd

This file was deleted.

12 changes: 0 additions & 12 deletions src/Objects/World/World.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const Logger := preload("res://src/util/Logger.gd")
const Terrain := preload("res://src/Objects/Terrain/Terrain.gd")
const Backdrop := preload("res://src/Objects/World/Backdrop.gd")
const Helicopter := preload("res://src/Objects/Helicopters/Helicopter.gd")
const ReflectionManager := preload("res://src/Objects/World/ReflectionManager.gd")

signal loading_progress(count)
signal loading_scale(count)
Expand All @@ -18,7 +17,6 @@ signal loading_scale(count)

@onready var terrain: Terrain = $Terrain
@onready var networks: Networks = $Networks
@onready var reflections: ReflectionManager = $Reflections
@onready var buildings: Buildings = $Buildings
@onready var backdrop: Backdrop = $Backdrop

Expand Down Expand Up @@ -72,7 +70,6 @@ func _load_map_async(city: Dictionary):

var city_size: int = city.get("city_size")

self._setup_probing(city_size)
self.backdrop.build(
city_size,
self.world_constants.tile_size,
Expand Down Expand Up @@ -113,12 +110,3 @@ func _insert_spawn_point(building_coords: Array[int], building_size: int, altitu

spawn_host.translate(location)
self.add_child(spawn_host)


func _setup_probing(city_size: int) -> void:
self.reflections.sea_level = self.sea_level * self.world_constants.tile_height
self.reflections.tile_size = self.world_constants.tile_size
self.reflections.tile_height = self.world_constants.tile_height
self.reflections.city_size = city_size

self.reflections.build_probes()

0 comments on commit 41853e6

Please sign in to comment.