From 7fe94906b883c915210e6359e55727b768962a93 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 9 Oct 2026 11:20:47 +0000 Subject: [PATCH] engine: no static prop disk lighting on web (in-game crash, garbage colors) New Game now loads testchmb_a_00 and renders the chamber on iPhone, but props drew with green/blue garbage and the frame crashed in CMeshDX8::SetColorStreamState <- CMeshDX8::Draw <- R_StudioDrawGroupHWSkin <- DrawModelStaticProp <- CStaticPropMgr::DrawStaticProps: the static prop's color mesh pointer was invalid. Static prop vertex lighting (.vhv) is read through the async filesystem into DataCache-managed, pooled color meshes; in the browser build props were drawn with color meshes that were not valid yet or already released. On the web build r_proplightingfromdisk now defaults to 0, so no color meshes are created and props use regular model lighting. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Qy5DKdwTqGQqScWvJyNcft --- engine/l_studio.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/engine/l_studio.cpp b/engine/l_studio.cpp index 24c8da7e48..6a71336047 100644 --- a/engine/l_studio.cpp +++ b/engine/l_studio.cpp @@ -91,7 +91,17 @@ ConVar r_rootlod( "r_rootlod", "0", FCVAR_MATERIAL_SYSTEM_THREAD | FCVAR_ARCHIVE static ConVar r_decalstaticprops( "r_decalstaticprops", "1", 0, "Decal static props test" ); static ConCommand r_flushlod( "r_flushlod", FlushLOD_f, "Flush and reload LODs." ); ConVar r_debugrandomstaticlighting( "r_debugrandomstaticlighting", "0", FCVAR_CHEAT, "Set to 1 to randomize static lighting for debugging. Must restart for change to take affect." ); +#ifdef __EMSCRIPTEN__ +// Static prop vertex lighting (.vhv) arrives through the async filesystem into +// DataCache-managed color meshes. In the browser build props were drawn with +// color meshes that were not valid yet or already released: garbage +// green/blue lighting on props and an out-of-bounds crash in +// CMeshDX8::SetColorStreamState on iPhone. Props fall back to regular model +// lighting instead. +ConVar r_proplightingfromdisk( "r_proplightingfromdisk", "0", FCVAR_CHEAT, "0=Off, 1=On, 2=Show Errors" ); +#else ConVar r_proplightingfromdisk( "r_proplightingfromdisk", "1", FCVAR_CHEAT, "0=Off, 1=On, 2=Show Errors" ); +#endif static ConVar r_itemblinkmax( "r_itemblinkmax", ".3", FCVAR_CHEAT ); static ConVar r_itemblinkrate( "r_itemblinkrate", "4.5", FCVAR_CHEAT ); static ConVar r_proplightingpooling( "r_proplightingpooling", "-1.0", FCVAR_CHEAT, "0 - off, 1 - static prop color meshes are allocated from a single shared vertex buffer (on hardware that supports stream offset)" );