Merge pull request #163 from Nitwel/imp2

Add ambient occlusion shader to mini view
This commit is contained in:
Nitwel 2024-05-27 11:21:49 +02:00 committed by GitHub
commit cd96865711
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 301 additions and 83 deletions

View File

@ -1 +1 @@
4.3.dev
4.3.beta

Binary file not shown.

View File

@ -0,0 +1,39 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://drsixxc4tmvjf"
path="res://.godot/imported/Montserrat-Medium.ttf-9322cac81db17d2f033bd26b2a37967f.fontdata"
[deps]
source_file="res://assets/fonts/Montserrat-Medium.ttf"
dest_files=["res://.godot/imported/Montserrat-Medium.ttf-9322cac81db17d2f033bd26b2a37967f.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=true
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=4.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[{
"chars": [],
"glyphs": [],
"name": "New Configuration",
"size": Vector2i(16, 0)
}]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View File

@ -0,0 +1,40 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://cg50jsgpda2en"
path="res://.godot/imported/Montserrat-Regular.ttf-15e5248c373097bdb910cdf2cfc29eaa.fontdata"
[deps]
source_file="res://assets/fonts/Montserrat-Regular.ttf"
dest_files=["res://.godot/imported/Montserrat-Regular.ttf-15e5248c373097bdb910cdf2cfc29eaa.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=true
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=100
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=4.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[{
"chars": [],
"glyphs": [],
"name": "New Configuration",
"size": Vector2i(16, 0),
"variation_embolden": 0.0
}]
language_support={}
script_support={}
opentype_features={}

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://rexpxwrqdt8f"
path="res://.godot/imported/Montserrat-SemiBold.ttf-6086a97dc2fcb684054d9f5bbbb469a2.fontdata"
[deps]
source_file="res://assets/fonts/Montserrat-SemiBold.ttf"
dest_files=["res://.godot/imported/Montserrat-SemiBold.ttf-6086a97dc2fcb684054d9f5bbbb469a2.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

View File

@ -13,10 +13,10 @@ dest_files=["res://.godot/imported/Montserrat-VariableFont_wght.ttf-e7d36c45e6f3
[params]
Rendering=null
antialiasing=1
antialiasing=0
generate_mipmaps=true
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
multichannel_signed_distance_field=true
msdf_pixel_range=8
msdf_size=100
allow_system_fallback=true

Binary file not shown.

View File

@ -0,0 +1,40 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://cs508knjj1lnw"
path="res://.godot/imported/Raleway-Medium.ttf-e6b827b5e551ebf6c5a60ff4992e2aba.fontdata"
[deps]
source_file="res://assets/fonts/Raleway-Medium.ttf"
dest_files=["res://.godot/imported/Raleway-Medium.ttf-e6b827b5e551ebf6c5a60ff4992e2aba.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=true
disable_embedded_bitmaps=true
multichannel_signed_distance_field=true
msdf_pixel_range=8
msdf_size=100
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[{
"chars": [],
"glyphs": [],
"name": "New Configuration",
"size": Vector2i(16, 0),
"variation_embolden": 0.0
}]
language_support={}
script_support={}
opentype_features={}

View File

@ -23,7 +23,7 @@ vec2 sdf_repeat(vec2 position) {
void fragment() {
float total_dist = 0.0;
for(int i = 0; i < supersampling; i++) {
float center_dist = distance(UV, vec2(0.5, 0.5));
vec2 rand = random(vec2(float(i))) * 0.004 * (0.5 - center_dist);
@ -32,10 +32,10 @@ void fragment() {
total_dist += 1.0 / float(supersampling);
}
}
ALBEDO = vec3(1.0);
ALPHA = total_dist;
//if(dist <= 0.0) {
//ALBEDO = vec3(1.0);
//} else {

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=6 format=3 uid="uid://xsiy71rsqulj"]
[ext_resource type="Script" path="res://content/entities/sensor/sensor.gd" id="1_57ac8"]
[ext_resource type="FontVariation" uid="uid://d2ofyimg5s65q" path="res://assets/fonts/ui_font_500.tres" id="2_4np3x"]
[ext_resource type="FontFile" uid="uid://drsixxc4tmvjf" path="res://assets/fonts/Montserrat-Medium.ttf" id="2_3sfs5"]
[ext_resource type="Script" path="res://content/functions/movable.gd" id="2_fpq5q"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="5_bmtkc"]
@ -21,8 +21,9 @@ transform = Transform3D(0.4, 0, 0, 0, 0.4, 0, 0, 0, 0.4, 0, 0, 0)
pixel_size = 0.001
text = "some text
"
font = ExtResource("2_4np3x")
font = ExtResource("2_3sfs5")
font_size = 80
outline_size = 0
[node name="Movable" type="Node" parent="."]
script = ExtResource("2_fpq5q")

View File

@ -36,15 +36,6 @@ unique_name_in_owner = true
unique_name_in_owner = true
transform = Transform3D(0.999999, -1.39633e-11, 0, 9.48075e-12, 1, 0, 0, 0, 1, -0.355145, 0.550439, -0.477945)
[node name="IndexTip" parent="XROrigin3D/XRControllerLeft" index="4"]
transform = Transform3D(0.967526, 0.252326, -0.0150302, -0.0150302, 0.116784, 0.993043, 0.252326, -0.960569, 0.116784, -0.00665802, 0.0427912, -0.169868)
[node name="ThumbTip" parent="XROrigin3D/XRControllerLeft" index="5"]
transform = Transform3D(0.967043, 0.24582, -0.0663439, -0.0663439, 0.494837, 0.866449, 0.24582, -0.833492, 0.494837, 0.0261569, 0.0891963, -0.0934418)
[node name="MiddleTip" parent="XROrigin3D/XRControllerLeft" index="6"]
transform = Transform3D(0.98042, 0.196912, 0.00149799, 0.001498, -0.015065, 0.999885, 0.196912, -0.980305, -0.0150651, -0.00327212, -0.00771427, -0.176318)
[node name="XRControllerRight" parent="XROrigin3D" instance=ExtResource("7_0b3tc")]
unique_name_in_owner = true
transform = Transform3D(0.999999, -1.39635e-11, 0, 1.31553e-10, 1, 0, 0, 0, 1, 0.336726, 0.575093, -0.437942)
@ -66,6 +57,3 @@ transform = Transform3D(1, -1.39636e-11, 0, 4.42413e-11, 1, 0, 0, 0, 1, -0.57679
[node name="Screenshot" type="Node" parent="."]
script = ExtResource("12_e13ym")
[editable path="XROrigin3D/XRControllerLeft"]
[editable path="XROrigin3D/XRControllerLeft/hand_l"]

View File

@ -1,5 +1,7 @@
extends Node3D
const RoomMaterial = preload ("res://content/system/house/room/room_next.tres")
const Room = preload ("./room/room.tscn")
const RoomType = preload ("./room/room.gd")
const Doors = preload ("./doors/doors.gd")
@ -213,6 +215,7 @@ func fix_reference():
align_reference.disabled = false
align_reference.visible = true
align_reference.update_initial_positions()
RoomMaterial.set_shader_parameter("show_border", true)
func save_reference():
if fixing_reference:
@ -235,6 +238,7 @@ func save_reference():
align_reference.update_initial_positions()
Store.house.save_local()
RoomMaterial.set_shader_parameter("show_border", false)
func save_all_entities():
Store.house.state.entities.clear()

View File

@ -21,6 +21,8 @@ var editable: bool = false:
update()
var _show_border: bool = false
func _ready():
Update.props(self, ["editable"])

View File

@ -0,0 +1,6 @@
shader_type spatial;
render_mode blend_sub, depth_draw_always, cull_disabled, diffuse_burley, specular_schlick_ggx, unshaded;
void fragment() {
ALBEDO = vec3(1.0);
}

View File

@ -1,14 +1,24 @@
[gd_scene load_steps=9 format=3 uid="uid://bswgmclohuqui"]
[gd_scene load_steps=12 format=3 uid="uid://bswgmclohuqui"]
[ext_resource type="Script" path="res://content/system/house/room/room.gd" id="1_fccq0"]
[ext_resource type="Script" path="res://content/functions/clickable.gd" id="1_ugebq"]
[ext_resource type="Material" uid="uid://bbx6fv7jq50tr" path="res://content/system/house/room/wall.tres" id="3_w4vos"]
[ext_resource type="Material" uid="uid://xehjkoeofqc" path="res://content/system/house/room/room_next.tres" id="3_4q8ik"]
[ext_resource type="Shader" path="res://content/system/house/room/room.gdshader" id="3_lwge0"]
[ext_resource type="Script" path="res://lib/utils/state_machine/state_machine.gd" id="4_nbbo6"]
[ext_resource type="Script" path="res://content/system/house/room/states/view.gd" id="6_g066t"]
[ext_resource type="Script" path="res://content/system/house/room/states/edit.gd" id="7_ap14h"]
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_08sv0"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_rqpss"]
render_priority = -100
next_pass = ExtResource("3_4q8ik")
shader = ExtResource("3_lwge0")
[sub_resource type="ShaderMaterial" id="ShaderMaterial_1hn7n"]
render_priority = -100
shader = ExtResource("3_lwge0")
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_ap613"]
plane = Plane(0, -1, 0, 0)
@ -26,10 +36,10 @@ shape = SubResource("WorldBoundaryShape3D_08sv0")
script = ExtResource("1_ugebq")
[node name="WallMesh" type="MeshInstance3D" parent="."]
material_override = ExtResource("3_w4vos")
material_override = SubResource("ShaderMaterial_rqpss")
[node name="CeilingMesh" type="MeshInstance3D" parent="."]
material_override = ExtResource("3_w4vos")
material_override = SubResource("ShaderMaterial_1hn7n")
[node name="WallCollision" type="StaticBody3D" parent="."]
collision_layer = 24

View File

@ -0,0 +1,37 @@
shader_type spatial;
render_mode blend_add,depth_draw_always, cull_disabled, diffuse_burley, specular_schlick_ggx, unshaded;
uniform vec3 border_color: source_color = vec3(0.0);
uniform bool show_border = false;
varying vec2 aspect_ratio;
void vertex() {
aspect_ratio = CUSTOM0.rg;
}
void fragment() {
ALBEDO = border_color;
ALPHA = 0.0;
vec2 pos = vec2(UV.x * aspect_ratio.x, UV.y * aspect_ratio.y);
float border = 0.05;
if( show_border ) {
if (pos.x <= border) {
ALPHA = mix(ALPHA, 1.0, 1.0 - pos.x / border);
}
if (pos.x >= aspect_ratio.x - border) {
ALPHA = mix(ALPHA, 1.0, (pos.x - (aspect_ratio.x - border)) / border);
}
if (pos.y <= border) {
ALPHA = mix(ALPHA, 1.0, 1.0 - pos.y / border);
}
if (pos.y >= aspect_ratio.y - border) {
ALPHA = mix(ALPHA, 1.0, (pos.y - (aspect_ratio.y - border)) / border);
}
}
}

View File

@ -0,0 +1,9 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://xehjkoeofqc"]
[ext_resource type="Shader" path="res://content/system/house/room/room_next.gdshader" id="1_hwtkw"]
[resource]
render_priority = -99
shader = ExtResource("1_hwtkw")
shader_parameter/border_color = Color(0, 0, 0.564706, 1)
shader_parameter/show_border = false

View File

@ -1,8 +0,0 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://bbx6fv7jq50tr"]
[resource]
render_priority = -100
blend_mode = 2
cull_mode = 2
depth_draw_mode = 1
shading_mode = 0

View File

@ -1,14 +1,7 @@
[gd_resource type="ShaderMaterial" load_steps=3 format=3 uid="uid://bcfcough6ucvc"]
[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://bcfcough6ucvc"]
[ext_resource type="Shader" path="res://content/system/miniature/mini_wall_shader.gdshader" id="1_sbr3e"]
[ext_resource type="Texture2D" uid="uid://bbuq4wn7e5o2q" path="res://content/system/miniature/temp_gradient.tres" id="2_3lwi8"]
[resource]
render_priority = 0
shader = ExtResource("1_sbr3e")
shader_parameter/data = PackedFloat32Array()
shader_parameter/data_size = 0
shader_parameter/alpha = 1.0
shader_parameter/roughness = 0.15
shader_parameter/edge_color = Color(0, 0, 0, 1)
shader_parameter/color_gradient = ExtResource("2_3lwi8")

View File

@ -1,15 +1,16 @@
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, diffuse_burley, specular_schlick_ggx, shadows_disabled;
render_mode blend_mix, cull_back, diffuse_burley, specular_schlick_ggx;
uniform vec4 data[100];
uniform int data_size: hint_range(0, 100, 1);
uniform float alpha: hint_range(0.0, 1.0, 0.1) = 0.3;
uniform sampler2D color_gradient;
uniform float roughness : hint_range(0.0, 1.0) = 0.15;
uniform float roughness : hint_range(0.0, 1.0) = 0.85;
uniform vec4 edge_color : source_color = vec4(0.0, 0.0, 0.0, 1.0);
varying vec3 color;
varying vec2 aspect_ratio;
float simple_weight(int index, vec3 world_pos, float p) {
return 1.0 / pow(distance(data[index].xyz, world_pos), p);
@ -20,14 +21,9 @@ float sphere_weight(int index, vec3 world_pos, float r) {
return pow(max(0, r - dist) / (r * dist), 2);
}
float SchlickFresnel(float u) {
float m = 1.0 - u;
float m2 = m * m;
return m2 * m2 * m;
}
void vertex() {
color = vec3(0.9, 0.9, 0.9);
aspect_ratio = CUSTOM0.rg;
if(data_size > 0) {
float distances[100];
@ -37,9 +33,6 @@ void vertex() {
float closest_dist = -1.0;
int closest_index = 0;
// Calculate Global Coordinates
//vec3 world_position = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
closest_dist = distance(data[0].xyz, VERTEX);
// Inverse distance weighting using Shepard's method
@ -67,17 +60,26 @@ void vertex() {
}
void fragment() {
ALBEDO = vec3(color.xyz);
//ALPHA = alpha;
float VdotN = dot(VIEW, NORMAL);
float fresnel = clamp(SchlickFresnel(VdotN), 0.0, 1.0);
// apply glass look
//float a = mix(0.001, 1.0, ALPHA);
//ALPHA = mix(fresnel * edge_color.a, 1.0, a);
//ALBEDO = mix(edge_color.rgb * edge_color.a, ALBEDO, a);
ROUGHNESS = roughness;
//SPECULAR = 0.5 * inversesqrt(ALPHA);
DEPTH = FRAGCOORD.z + 0.0001;
ALBEDO = vec3(color.xyz);
vec2 pos = vec2(UV.x * aspect_ratio.x, UV.y * aspect_ratio.y);
float border = 0.05;
if (pos.x <= border) {
ALBEDO = mix(vec3(0.0), ALBEDO, pos.x / border);
}
if (pos.x >= aspect_ratio.x - border) {
ALBEDO = mix(vec3(0.0), ALBEDO, 1.0 - (pos.x - (aspect_ratio.x - border)) / border);
}
if (pos.y <= border) {
ALBEDO = mix(vec3(0.0), ALBEDO, pos.y / border);
}
if (pos.y >= aspect_ratio.y - border) {
ALBEDO = mix(vec3(0.0), ALBEDO, 1.0 - (pos.y - (aspect_ratio.y - border)) / border);
}
}

View File

@ -89,7 +89,7 @@ func _ready():
tween.set_parallel(true)
if small.value:
var aabb=App.house.get_level_aabb(0)
var aabb=App.house.get_rooms_aabb()
var height=aabb.size.y
aabb.position.y=- 0.03

View File

@ -1,8 +1,9 @@
[gd_scene load_steps=7 format=3 uid="uid://ds60i5n211hi3"]
[gd_scene load_steps=9 format=3 uid="uid://ds60i5n211hi3"]
[ext_resource type="Script" path="res://content/system/miniature/miniature.gd" id="1_b53yn"]
[ext_resource type="Script" path="res://content/functions/movable.gd" id="2_x7oed"]
[ext_resource type="Script" path="res://content/system/miniature/entity_select.gd" id="3_tgpny"]
[ext_resource type="Material" uid="uid://bcfcough6ucvc" path="res://content/system/miniature/mini_wall.tres" id="4_be66c"]
[sub_resource type="BoxShape3D" id="BoxShape3D_bckw3"]
@ -15,6 +16,8 @@ albedo_color = Color(0.404, 0.22, 0.627, 0.5)
radius = 0.3
height = 1.75
[sub_resource type="QuadMesh" id="QuadMesh_4asi8"]
[node name="Miniature" type="Node3D"]
script = ExtResource("1_b53yn")
@ -43,3 +46,8 @@ mesh = SubResource("CapsuleMesh_f3avi")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.757576, 0)
gizmo_extents = 0.1
script = ExtResource("3_tgpny")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.92, 0, 0)
material_override = ExtResource("4_be66c")
mesh = SubResource("QuadMesh_4asi8")

View File

@ -2,10 +2,10 @@
[ext_resource type="Script" path="res://content/ui/components/input/input.gd" id="1_uml3t"]
[ext_resource type="Script" path="res://content/ui/components/panel/panel.gd" id="3_3bvrj"]
[ext_resource type="FontVariation" uid="uid://d2ofyimg5s65q" path="res://assets/fonts/ui_font_500.tres" id="3_ij5fh"]
[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_nl02b"]
[ext_resource type="FontFile" uid="uid://drsixxc4tmvjf" path="res://assets/fonts/Montserrat-Medium.ttf" id="4_yukbj"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_46adm"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_j4b8n"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("3_nl02b")
@ -20,7 +20,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_1me1o"]
[sub_resource type="QuadMesh" id="QuadMesh_ltwsx"]
size = Vector2(0.15, 0.03)
[sub_resource type="BoxShape3D" id="BoxShape3D_x4yp8"]
@ -83,8 +83,8 @@ collision_mask = 6
[node name="Panel3D" type="MeshInstance3D" parent="Body"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0.005)
material_override = SubResource("ShaderMaterial_46adm")
mesh = SubResource("QuadMesh_1me1o")
material_override = SubResource("ShaderMaterial_j4b8n")
mesh = SubResource("QuadMesh_ltwsx")
script = ExtResource("3_3bvrj")
size = Vector2(0.15, 0.03)
@ -98,7 +98,7 @@ double_sided = false
render_priority = 30
outline_render_priority = 29
text = "Example Text"
font = ExtResource("3_ij5fh")
font = ExtResource("4_yukbj")
font_size = 18
outline_size = 0
horizontal_alignment = 0
@ -118,7 +118,7 @@ render_priority = 30
outline_render_priority = 29
modulate = Color(0.470076, 0.470076, 0.470076, 1)
text = "Placeholder"
font = ExtResource("3_ij5fh")
font = ExtResource("4_yukbj")
font_size = 18
outline_size = 0
horizontal_alignment = 0

View File

@ -33,18 +33,18 @@ float SchlickFresnel(float u) {
}
void fragment() {
float VdotN = dot(VIEW, NORMAL);
float fresnel = clamp(SchlickFresnel(VdotN), 0.0, 1.0);
ALBEDO = border_color.xyz;
ALPHA = 0.0;
float border_scale = 1.0 + 2.0 * corner_radius;
float d = rectangle((UV - 0.5) * size * border_scale);
float border_width = (border_size + border_fade_in + border_fade_out) * border_scale;
bool inside = false;
if (d >= corner_radius - border_width && d <= corner_radius) {
// Border
float rel_d = (d - corner_radius + border_width) / border_width;
@ -65,15 +65,15 @@ void fragment() {
ALPHA = color.w;
inside = true;
}
if (inside) {
float a = mix(0.001, 1.0, ALPHA);
ALPHA = mix(fresnel * edge_color.a, 1.0, a);
ALBEDO = mix(edge_color.rgb * edge_color.a, ALBEDO.rgb, a);
ROUGHNESS = roughness;
SPECULAR = 0.5 * inversesqrt(ALPHA);
float noise = (fract(sin(dot(UV, vec2(12.9898, 78.233))) * 43758.5453) - 0.5) * 2.0;
ALBEDO += noise * grain_amount;

View File

@ -42,6 +42,7 @@ static func generate_wall_mesh_with_doors(corners, height, doors):
var corner = corners[i]
var next_corner = corners[(i + 1) % corners.size()]
var width = corner.distance_to(next_corner)
var forward = Vector3(next_corner.x - corner.x, 0, next_corner.y - corner.y).normalized()
var points := PackedVector2Array()
@ -98,11 +99,14 @@ static func generate_wall_mesh_with_doors(corners, height, doors):
var triangles: PackedInt32Array = cdt.get_all_triangles()
var points_3d = PackedVector3Array()
var points_uv = PackedVector2Array()
for k in range(points.size()):
points_3d.append(Vector3(corner.x, 0, corner.y) + points[k].x * forward + Vector3(0, points[k].y, 0))
var point = Vector3(corner.x, 0, corner.y) + points[k].x * forward + Vector3(0, points[k].y, 0)
points_3d.append(point)
points_uv.append(Vector2(points[k].x / width, points[k].y / height))
mesh = _create_mesh_3d(points_3d, triangles, mesh)
mesh = _create_mesh_3d(points_3d, triangles, points_uv, width, height, mesh)
return mesh
@ -144,6 +148,7 @@ static func generate_wall_mesh_with_doors_grid(corners, height, doors, grid:=0.1
var corner = corners[i]
var next_corner = corners[(i + 1) % corners.size()]
var width = corner.distance_to(next_corner)
var forward = Vector3(next_corner.x - corner.x, 0, next_corner.y - corner.y).normalized()
var points := PackedVector2Array()
@ -226,11 +231,13 @@ static func generate_wall_mesh_with_doors_grid(corners, height, doors, grid:=0.1
var triangles: PackedInt32Array = cdt.get_all_triangles()
var points_3d = PackedVector3Array()
var points_uv = PackedVector2Array()
for k in range(points.size()):
points_3d.append(Vector3(corner.x, 0, corner.y) + points[k].x * forward + Vector3(0, points[k].y, 0))
points_uv.append(Vector2(points[k].x / width, points[k].y / height))
mesh = _create_mesh_3d(points_3d, triangles, mesh)
mesh = _create_mesh_3d(points_3d, triangles, points_uv, width, height, mesh)
return mesh
@ -369,12 +376,15 @@ static func generate_ceiling_mesh_grid(corners, grid: Vector2=Vector2(0.1, 0.1))
return _create_mesh_2d(points, triangles)
static func _create_mesh_3d(points: PackedVector3Array, triangles: PackedInt32Array, existing=null):
static func _create_mesh_3d(points: PackedVector3Array, triangles: PackedInt32Array, points_uv, width: float, height: float, existing=null):
var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.set_custom_format(0, SurfaceTool.CUSTOM_RG_FLOAT)
for i in range(points.size()):
st.set_uv(points_uv[i])
st.set_custom(0, Color(width, height, 0, 0))
st.add_vertex(Vector3(points[i].x, points[i].y, points[i].z))
for i in range(triangles.size()):
@ -393,8 +403,11 @@ static func _create_mesh_2d(points: PackedVector2Array, triangles: PackedInt32Ar
var st = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.set_custom_format(0, SurfaceTool.CUSTOM_RG_FLOAT)
for i in range(points.size()):
st.set_uv(Vector2(0.5, 0.5))
st.set_custom(0, Color(1.0, 1.0, 0, 0))
st.add_vertex(Vector3(points[i].x, 0, points[i].y))
for i in range(triangles.size()):

View File

@ -51,7 +51,7 @@ import/fbx/enabled=false
[gui]
theme/custom_font="res://assets/fonts/ui_font_500.tres"
theme/custom_font="res://assets/fonts/Montserrat-Medium.ttf"
[layer_names]