18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 04:47:06 +01:00

fix(render): EU07M review of #538: an instance with light colours of its own drawn alone, the light records locked only when stale

- An instance with lightcolors of its own isn't instanced: the colours go onto the shared submodels as the instance is
  prepared, which the instances of a bucket don't each get, so they all showed the colours of one of them.
- The walk takes the exclusive lock for the light records of a bucket only when they are stale in this frame
  (Refresh_Light_Records() checks again under it): the later passes of the frame no longer stop the other walkers.
- instance_cull.comp (both renderers) puts the word of the light parts into [0][3] after the product with the view, so a
  view with a translation can't stretch the first column of a lit instance.
- The spec: ls_Dark / ls_Home switch without the fade too, and the instances with light colours of their own.
This commit is contained in:
maj00r
2026-11-29 18:14:35 +01:00
parent 6cb66b8b35
commit 99bc0b125c
5 changed files with 22 additions and 5 deletions
+4 -1
View File
@@ -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.
+5
View File
@@ -15,6 +15,8 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "model/AnimModel.h"
#include <algorithm>
#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;
+3 -2
View File
@@ -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 ) ) {
+5 -1
View File
@@ -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()
+5 -1
View File
@@ -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()