diff --git a/docs/eu07m-format.md b/docs/eu07m-format.md index 8723fd89e..514a08cfb 100644 --- a/docs/eu07m-format.md +++ b/docs/eu07m-format.md @@ -257,7 +257,10 @@ egzemplarz osobno. Dotyczy to modeli EU07M i E3D tak samo. w shaderze macierz zerową (`instance_hides_part()` w `common.glsl`). - Egzemplarz pokazuje całą część zapaloną albo całą zgaszoną. Przy miganiu i przy przełączaniu (`ls_On` / `ls_Off` / `ls_Blink`) zamiana następuje w połowie przejścia (krycie 0,5), a nie płynnym przenikaniem jak bez instancjonowania. - Stany stałe wyglądają tak samo jak bez instancjonowania. + Stany stałe wyglądają tak samo jak bez instancjonowania. Tak samo bez płynnego przejścia (`fVisible`) zmieniają się + `ls_Dark` i `ls_Home`. +- Egzemplarz z własnymi kolorami świateł (`lightcolors` węzła) jest rysowany osobno: kolory są nadawane wspólnym + submodelom przy przygotowaniu egzemplarza, którego egzemplarze kubełka nie dostają każdy z osobna. - Pomiar (Vulkan, 200 głowic `s4ipcpb_dd`): z `gfx.gpucull 0` klatka 9,2 ms → 1,5–2,5 ms i 2400 → 16 drawcalli, z `gfx.gpucull 1` 9,1 ms → 3,0 ms i 2410 → 26 drawcalli. diff --git a/model/AnimModel.cpp b/model/AnimModel.cpp index 91cf164d1..8c347163b 100644 --- a/model/AnimModel.cpp +++ b/model/AnimModel.cpp @@ -15,6 +15,8 @@ http://mozilla.org/MPL/2.0/. #include "stdafx.h" #include "model/AnimModel.h" +#include + #include "rendering/renderer.h" #include "model/MdlMngr.h" #include "simulation/simulation.h" @@ -569,6 +571,9 @@ void TAnimModel::update_instanceable_flag() { // gfx.instancedlights: the lights go with the matrix of each instance (instance_light_bits()), and the instanced walk // animates each instance (RaAnimate) and prepares the model with all the parts of the lights shown (RaPrepareInstanced) if( ( iNumLights != 0 ) && ( false == Global.gfx_instancedlights ) ) { ++s_rejected_lights; return; } + // light colours of its own (lightcolors of the node) go onto the shared submodels as the instance is prepared (RaPrepare), + // which the instances of a bucket don't each get: such an instance is drawn on its own + if( std::ranges::any_of( m_lightcolors, []( glm::vec3 const &Colour ) { return Colour.r >= 0.f; } ) ) { ++s_rejected_lights; return; } if( !m_animlist.empty() ) { ++s_rejected_animlist; return; } if( submodel_tree_blocks_instancing( pModel->Root ) ) { ++s_rejected_animated_submodel; return; } m_instanceable = true; diff --git a/rendering/common/scenewalk.cpp b/rendering/common/scenewalk.cpp index 1b348c25d..0e69fad1b 100644 --- a/rendering/common/scenewalk.cpp +++ b/rendering/common/scenewalk.cpp @@ -1034,8 +1034,9 @@ void scene_walk::Queue_Instances( scene::basic_cell const *Cell ) } } if( m_instancecullpass && bucket_has_lights( instancebucket ) ) { - // the culling of the gpu takes the light states of the instances from their records - gfx::walk_sync::change change; + // the culling of the gpu takes the light states of the instances from their records. only the first pass of the frame has + // them to refresh (Refresh_Light_Records() checks again under the lock), so the others don't stop the walkers for it + gfx::walk_sync::change change { instancebucket.lightsframe != m_framestamp }; Refresh_Light_Records( instancebucket ); } if( buckettests && Bucket_Culled( instancebucket ) ) { diff --git a/shaders/ogl46/instance_cull.comp b/shaders/ogl46/instance_cull.comp index 5a6fd6ca4..c874d880e 100644 --- a/shaders/ogl46/instance_cull.comp +++ b/shaders/ogl46/instance_cull.comp @@ -226,7 +226,11 @@ void write(uint entry, instance_record record, vec3 location, instance_cull_job modelviews[slot] = originview * mat4(record.rotationscale[0], record.rotationscale[1], record.rotationscale[2], vec4(record.position, 1.0)); return; } - modelviews[slot] = view * mat4(record.rotationscale[0], record.rotationscale[1], record.rotationscale[2], vec4(location, 1.0)); + // the word of the light parts (w of the first column, instance_light_bits()) is put back after the product, so a view with a + // translation can't add to the first column with it + mat4 modelview = view * mat4(vec4(record.rotationscale[0].xyz, 0.0), record.rotationscale[1], record.rotationscale[2], vec4(location, 1.0)); + modelview[0][3] = record.rotationscale[0].w; + modelviews[slot] = modelview; } void main() diff --git a/shaders/vk14/instance_cull.comp b/shaders/vk14/instance_cull.comp index c6b8e0983..b07a59b48 100644 --- a/shaders/vk14/instance_cull.comp +++ b/shaders/vk14/instance_cull.comp @@ -234,7 +234,11 @@ void write(uint entry, instance_record record, vec3 location, instance_cull_job modelviews[slot] = originview * mat4(record.rotationscale[0], record.rotationscale[1], record.rotationscale[2], vec4(record.position, 1.0)); return; } - modelviews[slot] = view * mat4(record.rotationscale[0], record.rotationscale[1], record.rotationscale[2], vec4(location, 1.0)); + // the word of the light parts (w of the first column, instance_light_bits()) is put back after the product, so a view with a + // translation can't add to the first column with it + mat4 modelview = view * mat4(vec4(record.rotationscale[0].xyz, 0.0), record.rotationscale[1], record.rotationscale[2], vec4(location, 1.0)); + modelview[0][3] = record.rotationscale[0].w; + modelviews[slot] = modelview; } void main()