2V2-e.4: render 40250 pack terrain with map lighting

This commit is contained in:
shenlei
2026-09-23 21:19:14 +09:00
parent ac4c2aa4e0
commit cb43091f79
9 changed files with 226 additions and 24 deletions
+32
View File
@@ -107,6 +107,24 @@ func run() -> void:
await process_frame
report["draw_count"] = world.draw_count
report["unlit_stand_in_count"] = world.unlit_stand_in_count
report["terrain"] = world.terrain_report
report["atlas_entries"] = world._atlas.size()
_check(world._atlas.size() > 0, "40250 AtlasInfo chooses the current map")
if world.terrain:
report["terrain_base_cm"] = str(world.terrain.call("get_map_base_cm"))
var tile_bounds := []
for tile in world.terrain.find_children("Terrain*", "MeshInstance3D", true, false):
if tile_bounds.size() >= 4:
break
tile_bounds.append(str(tile.global_transform * tile.mesh.get_aabb()))
report["terrain_camera_bounds"] = tile_bounds
_check(world.terrain != null and int(world.terrain_report.get("chunks_built", 0)) > 0,
"40250 terrain height tiles loaded")
_check(int(world.terrain_report.get("chunks_splatted", 0)) > 0,
"40250 terrain textures applied")
_check(bool(world.terrain_report.get("env_ok", false)) and world.light.visible,
"map .msenv lights the character")
_check(world.unlit_stand_in_count == 0, "unlit stand-in removed")
report["camera_fov"] = world.camera.fov
report["camera_near"] = world.camera.near
report["camera_far"] = world.camera.far
@@ -138,6 +156,7 @@ func run() -> void:
textures.append(draw["texture0"])
report["textures"] = textures
var surfaces_textured := 0
var lit_surfaces := 0
var distinct_textures := {}
for instance in world.find_children("Draw*", "MeshInstance3D", false, false):
if instance.visible and instance.mesh:
@@ -145,7 +164,10 @@ func run() -> void:
if material and material.albedo_texture:
surfaces_textured += 1
distinct_textures[material.albedo_texture] = true
if material and material.shading_mode == BaseMaterial3D.SHADING_MODE_PER_VERTEX:
lit_surfaces += 1
report["surfaces_textured"] = surfaces_textured
report["lit_surfaces"] = lit_surfaces
report["distinct_textures"] = distinct_textures.size()
# Every texture name gets its own texture (face, body, hair are not one material).
_check(distinct_textures.size() == textures.size(),
@@ -156,6 +178,7 @@ func run() -> void:
bounds.append(str(instance.transform * instance.mesh.get_aabb()))
report["camera_space_bounds"] = bounds
_check(not drawn or surfaces_textured > 0, "character surfaces have their diffuse textures (%d)" % surfaces_textured)
_check(lit_surfaces > 0, "character surfaces use directional lighting (%d)" % lit_surfaces)
if DisplayServer.get_name() != "headless":
await RenderingServer.frame_post_draw
var image := root.get_texture().get_image()
@@ -170,6 +193,15 @@ func run() -> void:
lit += 1
report["centre_lit_samples"] = lit
_check(lit > 50, "character pixels in the middle of the screen (%d samples)" % lit)
var ground_low := 1.0
var ground_high := 0.0
for y in range(image.get_height() * 3 / 4, image.get_height() - 20, 17):
for x in range(30, image.get_width() - 30, 23):
var luminance := image.get_pixel(x, y).get_luminance()
ground_low = minf(ground_low, luminance)
ground_high = maxf(ground_high, luminance)
report["ground_luminance_range"] = ground_high - ground_low
_check(ground_high - ground_low > 0.08, "textured ground visible in screenshot")
# The 3D pass alone, for looking at the character without the UI.
ui.visible = false
await RenderingServer.frame_post_draw