use nearest filter, simplify material setup
This commit is contained in:
@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user