Render: intro pose, preview hair, tree LOD and terrain seams

- chrRender collects intro draws with hardware skinning off (CPU scene path
  ignores GPU palettes, so the select-screen character stayed in T-pose).
- Preview player hair: warrior/hair/hair_1_1.gr2 (old path did not exist).
- SpeedTree: always draw full geometry like CSpeedTreeWrapper::Advance
  (SetLodLevel(1.0f)); resolve SPT texture names as GetPath+NoExtension+.dds.
- Terrain patches get edge skirts to hide step-1/step-2 T-junction cracks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-13 12:19:44 +09:00
co-authored by Claude Opus 5.5
parent e0b97c2099
commit 29f33b289a
7 changed files with 77 additions and 37 deletions
+27
View File
@@ -1647,3 +1647,30 @@ Outstanding:
hidden; SDL shows it again without restarting text input.
- Verified on the device (login board): Back hides the keyboard; tapping ID or Password
brings it back; tapping the background does not. Desktop ctest 59/59.
### 2026-10-13 Render: intro pose, preview hair, tree LOD, terrain seams
All four issues reproduced on desktop too (`--phone ... --phase select|game --preview-data`).
- Select screen T-pose: `chrRender` draws intro characters through the CPU scene renderer,
which ignores GPU skinning palettes, so with hardware skinning on they stayed in bind pose.
It now turns hardware skinning off while it collects those draws. The intro character plays
`intro/wait` again.
- Missing head on the preview player: its hair path
(`plechito/summer2020_costume/hair/warrior_m.gr2`) does not exist, and the body models carry no
head. It now uses `ymir work/pc/warrior/hair/hair_1_1.gr2` (warrior_m.msm HairData00).
Network actors already went through the original `SetHair` logic.
- Trees: `CSpeedTreeWrapper::Advance` calls `ComputeLodLevel()` and then always
`SetLodLevel(1.0f)`, so the original draws full geometry at alpha ref 84 and never shows the
billboards. Our integration compared the camera distance with the raw .spt lod_near/far
(100/1100), so nearby trees dropped to their billboards (dark composite silhouettes, pine
needle quads). `SpeedTreeRT.cpp` now always builds trunk, leaf and frond geometry. Texture
names resolve like `LoadTree`: GetPath(spt) + NoExtension(name) + ".dds"
(`CompositeMap`, `plant_grass` had no extension and stayed untextured).
Leaf density and branch shape come from the SDK generator, which is still being worked on.
- Terrain white seams/blocks: far patches (step 2) next to near ones (step 1) left T-junction
cracks that showed the cleared background. Each patch now hangs a vertical skirt
(2 cells deep) below its edges. Forcing step 1 everywhere removed the seam the same way.
- Desktop ctest 59/59. Device (OnePlus PJZ110): select screen shows the warrior and ninja in
their intro idle with heads; the game preview shows full-geometry trees and no terrain seam.
The preview player stands inside a pine, so its head was not visible in the game shot.
+2 -1
View File
@@ -832,7 +832,8 @@ ava2::app::AppLoop::Frame RunClient(ava2::app::AppLoop* loop, int argc, char** a
player_actor.SetModel(model3d_path);
std::string weapon_path = "ymir work/item/weapon/set_11_sword.gr2";
player_actor.SetWeapon(weapon_path, "equip_right_hand");
std::string hair_path = "ymir work/pc/plechito/summer2020_costume/hair/warrior_m.gr2";
// warrior_m.msm HairData00 (HairIndex 0); the body models carry no head.
std::string hair_path = "ymir work/pc/warrior/hair/hair_1_1.gr2";
player_actor.AttachPart(hair_path);
player_actor.SetScale(0.85f);
player_actor.SetSpeed(340.0f);
+1
View File
@@ -186,6 +186,7 @@ const std::string& Gr2ModelInstance::GetFilePath() const {
}
void Gr2ModelInstance::SetHardwareSkinningEnabled(bool enabled){hardwareSkinningEnabled=enabled;}
bool Gr2ModelInstance::IsHardwareSkinningEnabled(){return hardwareSkinningEnabled;}
std::vector<Render3DDraw> Gr2ModelInstance::BuildDrawCommands(float animation_time, const float* world_matrix, bool forceCPU) {
std::vector<Render3DDraw> out;
+1
View File
@@ -16,6 +16,7 @@ class Gr2ModelInstance {
public:
Gr2ModelInstance() = default;
static void SetHardwareSkinningEnabled(bool enabled);
static bool IsHardwareSkinningEnabled();
explicit Gr2ModelInstance(std::shared_ptr<gr2_render::Gr2ModelInstance> impl)
: m_impl(std::move(impl)) {}
+16 -36
View File
@@ -44,10 +44,14 @@ std::vector<Render3DDraw> SpeedTreeModel::BuildDrawCommands(float worldX, float
Render3DDraw draw;
draw.texture0 = mesh.texture;
if (!m_textureDirectory.empty() && !mesh.texture.empty()) {
// SPT materials often contain only a filename, relative to the tree file.
// CSpeedTreeWrapper::LoadTree: GetPath(spt) + NoExtension(texture name) + ".dds". SPT
// materials hold a bare name, often without extension ("CompositeMap", "plant_grass").
auto name = CResourceManager::NormalizePath(mesh.texture.c_str());
auto candidate = std::filesystem::path(m_textureDirectory) / std::filesystem::path(name).filename();
if (std::filesystem::is_regular_file(candidate)) draw.texture0 = candidate.string();
auto file = std::filesystem::path(name).filename();
for (const auto& leaf : {file.replace_extension(".dds"), std::filesystem::path(name).filename()}) {
auto candidate = std::filesystem::path(m_textureDirectory) / leaf;
if (std::filesystem::is_regular_file(candidate)) { draw.texture0 = candidate.string(); break; }
}
}
draw.indices = mesh.indices;
@@ -79,39 +83,15 @@ std::vector<Render3DDraw> SpeedTreeModel::BuildDrawCommands(float worldX, float
results.push_back(std::move(draw));
};
float geometryAlpha=84, billboardAlpha=255;
std::array<float,3> localCamera{};
const auto& info=m_impl->GetSptInfo();
if(camera && std::all_of(camera->begin(),camera->end(),[](float value){return std::isfinite(value);})
&& scale>0 && std::isfinite(scale) && info.lod_far>info.lod_near
&& !info.billboard_uv_quads.empty() && info.leaf_lod_levels>0 && info.leaf_lod_levels<32767) {
float dx=(*camera)[0]-worldX,dy=(*camera)[1]-worldY,dz=(*camera)[2]-worldZ;
float angle=yawDeg*speedtree::kPI/180,c=std::cos(angle),s=std::sin(angle);
localCamera={(dx*c-dz*s)/scale,dy/scale,(dx*s+dz*c)/scale};
float lod=info.EvaluateLod(std::sqrt(dx*dx+dy*dy+dz*dz));
auto transition=speedtree::SelectLodTransition(lod,info.leaf_lod_levels+1,
info.lod_transition_width,info.lod_transition_overlap,info.lod_alpha_exponent);
// Detailed per-level meshes are not yet recovered. Keep the generated
// geometry until the last leaf level transitions to the billboard.
geometryAlpha=255;
auto select=[&](int level,float alpha) {
if(level<0) return;
if(level==int(info.leaf_lod_levels)) billboardAlpha=std::min(billboardAlpha,alpha);
else geometryAlpha=std::min(geometryAlpha,alpha);
};
select(transition.first,transition.first_alpha);
select(transition.second,transition.second_alpha);
}
if(geometryAlpha<255) {
build_draw(m_impl->GetTrunkMesh(),false,geometryAlpha);
build_draw(m_impl->GetLeafMesh(),true,geometryAlpha);
for(const auto& mesh:m_impl->GetFrondMeshes()) build_draw(mesh,true,geometryAlpha);
}
if(billboardAlpha<255) {
for(const auto& mesh:m_impl->BuildBillboardMeshes(localCamera,billboardAlpha))
build_draw(mesh,true,mesh.alpha_ref*255);
}
// CSpeedTreeWrapper::Advance calls ComputeLodLevel() and then always
// SetLodLevel(1.0f), so the original client draws the full geometry at
// c_nDefaultAlphaTestValue (84) and never shows the billboards. Comparing
// the world camera distance with the raw .spt lod_near/lod_far (100/1100)
// dropped nearby trees to their billboards (dark composite silhouettes).
constexpr float geometryAlpha=84;
build_draw(m_impl->GetTrunkMesh(),false,geometryAlpha);
build_draw(m_impl->GetLeafMesh(),true,geometryAlpha);
for(const auto& mesh:m_impl->GetFrondMeshes()) build_draw(mesh,true,geometryAlpha);
return results;
}
+25
View File
@@ -729,6 +729,31 @@ Render3DDraw TerrainHeightmap::BuildPatchDraw(int patch_x, int patch_y, int step
}
}
// A step-2 patch next to a step-1 patch leaves T-junction cracks along the shared edge, which
// showed the cleared background as white seams/blocks. Hang a vertical skirt below each edge.
const float skirt = m_cell_scale * 2.0f;
auto add_skirt = [&](uint32_t first, uint32_t stride, int count) {
const auto base = static_cast<uint32_t>(draw.positions.size() / 3);
for (int k = 0; k < count; ++k) {
const uint32_t v = first + static_cast<uint32_t>(k) * stride;
draw.positions.insert(draw.positions.end(), {draw.positions[v * 3], draw.positions[v * 3 + 1] - skirt, draw.positions[v * 3 + 2]});
draw.normals.insert(draw.normals.end(), {draw.normals[v * 3], draw.normals[v * 3 + 1], draw.normals[v * 3 + 2]});
draw.uv0.insert(draw.uv0.end(), {draw.uv0[v * 2], draw.uv0[v * 2 + 1]});
draw.diffuse.push_back(draw.diffuse[v]);
}
for (int k = 0; k + 1 < count; ++k) {
const uint32_t a = first + static_cast<uint32_t>(k) * stride, b = a + stride;
const uint32_t sa = base + static_cast<uint32_t>(k), sb = sa + 1;
draw.indices.insert(draw.indices.end(), {a, sa, b, b, sa, sb});
}
};
if (grid_w > 1 && grid_h > 1) {
add_skirt(0, 1, grid_w);
add_skirt(static_cast<uint32_t>((grid_h - 1) * grid_w), 1, grid_w);
add_skirt(0, static_cast<uint32_t>(grid_w), grid_h);
add_skirt(static_cast<uint32_t>(grid_w - 1), static_cast<uint32_t>(grid_w), grid_h);
}
return draw;
}
+5
View File
@@ -471,7 +471,12 @@ PyObject* chrRender(PyObject*, PyObject*) {
SDL_Renderer* renderer = CGraphicDevice::Instance().GetRenderer();
if (!renderer) renderer = TextTailManager::Instance().GetCurrentRenderer();
if (sceneRenderer && renderer) {
// RenderScene below rasterizes on the CPU and ignores GPU skinning palettes; with
// hardware skinning on, every intro character would draw in its bind (T) pose.
const bool gpuSkinning = Gr2ModelInstance::IsHardwareSkinningEnabled();
Gr2ModelInstance::SetHardwareSkinningEnabled(false);
auto draws = GetAllActiveChrDraws();
Gr2ModelInstance::SetHardwareSkinningEnabled(gpuSkinning);
if (!draws.empty()) {
for (auto& d : draws) {
d.material_ambient[0] = 0.85f;