use nearest filter, simplify material setup
This commit is contained in:
parent
6bb89a04fd
commit
270d9a0ce4
@ -41,33 +41,31 @@ func _generate_geometry(space: Space,
|
||||
var mesh := ArrayMesh.new()
|
||||
var surface_count: int = 0
|
||||
|
||||
var make_material := func(some_texture: Texture2D, cull_mode: int = BaseMaterial3D.CULL_BACK):
|
||||
var some_material := StandardMaterial3D.new()
|
||||
some_material.albedo_texture = some_texture
|
||||
some_material.cull_mode = cull_mode
|
||||
some_material.texture_filter = BaseMaterial3D.TEXTURE_FILTER_NEAREST
|
||||
return some_material
|
||||
|
||||
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, _generate_wall_arrays(space, looked_from_inside))
|
||||
mesh.surface_set_material(surface_count, make_material.call(wall_texture))
|
||||
surface_count += 1
|
||||
var wall_material := StandardMaterial3D.new()
|
||||
wall_material.albedo_texture = wall_texture
|
||||
mesh.surface_set_material(surface_count - 1, wall_material)
|
||||
|
||||
if (looked_from_inside):
|
||||
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, _generate_floor_arrays(space))
|
||||
mesh.surface_set_material(surface_count, make_material.call(floor_texture))
|
||||
surface_count += 1
|
||||
var floor_material := StandardMaterial3D.new()
|
||||
floor_material.albedo_texture = floor_texture
|
||||
mesh.surface_set_material(surface_count - 1, floor_material)
|
||||
|
||||
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, _generate_ceiling_arrays(space))
|
||||
mesh.surface_set_material(surface_count, make_material.call(ceiling_texture, BaseMaterial3D.CULL_FRONT))
|
||||
surface_count += 1
|
||||
var ceiling_material := StandardMaterial3D.new()
|
||||
ceiling_material.albedo_texture = ceiling_texture
|
||||
ceiling_material.cull_mode = BaseMaterial3D.CULL_FRONT # todo: Don't require state change
|
||||
mesh.surface_set_material(surface_count - 1, ceiling_material)
|
||||
|
||||
if parent_region and not parent_region._is_convex_cache:
|
||||
if parent_region.height > height:
|
||||
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, _generate_ceiling_arrays(space))
|
||||
mesh.surface_set_material(surface_count, make_material.call(top_texture))
|
||||
surface_count += 1
|
||||
var top_material := StandardMaterial3D.new()
|
||||
top_material.albedo_texture = top_texture
|
||||
mesh.surface_set_material(surface_count - 1, top_material)
|
||||
|
||||
geometry.mesh = mesh
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://deff7lt34nj0h"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://deff7lt34nj0h"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scripts/Space/Space.gd" id="1_ckp7u"]
|
||||
[ext_resource type="Script" path="res://Scripts/Space/SpaceRegion.gd" id="2_s3h7s"]
|
||||
@ -6,7 +6,6 @@
|
||||
[ext_resource type="Texture2D" uid="uid://icmmuqquxhq3" path="res://Art/Stone_06-128x128.png" id="3_ondo6"]
|
||||
[ext_resource type="Texture2D" uid="uid://eempmja460l5" path="res://Art/Stone_11-128x128.png" id="4_mnswr"]
|
||||
[ext_resource type="Script" path="res://Scripts/Space/SpaceSpawn.gd" id="4_rhl23"]
|
||||
[ext_resource type="Texture2D" uid="uid://buoupwtftxjse" path="res://Art/Stone_05-128x128.png" id="5_evp07"]
|
||||
|
||||
[node name="Dungeon" type="Node2D"]
|
||||
script = ExtResource("1_ckp7u")
|
||||
@ -14,37 +13,17 @@ unit_scale = 0.02
|
||||
|
||||
[node name="Room" type="Polygon2D" parent="."]
|
||||
texture_repeat = 2
|
||||
position = Vector2(440, 136)
|
||||
position = Vector2(104, 80)
|
||||
texture = ExtResource("4_mnswr")
|
||||
polygon = PackedVector2Array(-104, -80, 40, -112, 128, -16, 328, -56, 360, 16, 176, 56, 32, 96, -80, 64)
|
||||
polygon = PackedVector2Array(-104, -80, 128, -80, 128, 24, 328, 24, 328, 128, 240, 128, 240, 240, 128, 240, 128, 128, -104, 128, -104, 64)
|
||||
uv = PackedVector2Array(1.88, 5.28, 0.6, 1.44, 5.24, 0.64, 5.24, 0.64, 9.94, 3.84, 5.72, 6.56, 5.72, 6.56, 1.88, 5.28, 5.24, 0.64)
|
||||
script = ExtResource("2_s3h7s")
|
||||
wall_texture = ExtResource("3_ondo6")
|
||||
floor_texture = ExtResource("4_mnswr")
|
||||
ceiling_texture = ExtResource("4_mnswr")
|
||||
|
||||
[node name="Column" type="Polygon2D" parent="Room"]
|
||||
texture_repeat = 2
|
||||
texture = ExtResource("3_ondo6")
|
||||
polygon = PackedVector2Array(8, -40, 48, -64, 88, -40, 72, -8, 72, -32, 48, -48, 24, -32, 24, -8)
|
||||
uv = PackedVector2Array(1.88, 5.28, 0.6, 1.44, 5.24, 0.64, 5.24, 0.64, 9.94, 3.84, 5.72, 6.56, 5.72, 6.56, 1.88, 5.28, 5.24, 0.64)
|
||||
script = ExtResource("2_s3h7s")
|
||||
wall_texture = ExtResource("3_ondo6")
|
||||
floor_texture = ExtResource("3_ondo6")
|
||||
|
||||
[node name="Floor" type="Polygon2D" parent="Room/Column"]
|
||||
texture_repeat = 2
|
||||
texture = ExtResource("5_evp07")
|
||||
polygon = PackedVector2Array(72, -8, 72, -32, 48, -48, 24, -32, 24, -8)
|
||||
uv = PackedVector2Array(1.88, 5.28, 0.6, 1.44, 5.24, 0.64, 5.24, 0.64, 9.94, 3.84, 5.72, 6.56, 5.72, 6.56, 1.88, 5.28, 5.24, 0.64)
|
||||
script = ExtResource("2_s3h7s")
|
||||
height = 20.0
|
||||
wall_texture = ExtResource("3_ondo6")
|
||||
top_texture = ExtResource("5_evp07")
|
||||
|
||||
[node name="Spawn" type="Sprite2D" parent="Room"]
|
||||
position = Vector2(-48, 32)
|
||||
rotation = 1.83259
|
||||
scale = Vector2(0.25, 0.25)
|
||||
texture = ExtResource("3_7vff1")
|
||||
script = ExtResource("4_rhl23")
|
||||
|
Loading…
Reference in New Issue
Block a user