ensure all Material2d rendering happen in order
Objective
Material2drendering order is random- This can be seen in example
wireframe_2d, wireframe is randomly visible 50% of the time
Solution
- Add a temp resource counting the materials added
- Add sets to materials with a unique value
- Order each material to be after those added before
- This means rendering order is dependent on plugin addition order
Testing
steps=10; git restore .;
echo "wireframe_2d" > test
cargo run -p example-showcase -- run --stop-frame 250 --screenshot-frame 100 --fixed-frame-time 0.05 --example-list test --in-ci;
mv screenshots base;
for prefix in `seq 0 $steps`;
do
echo step $prefix;
cargo run -p example-showcase -- run --stop-frame 250 --screenshot-frame 100 --fixed-frame-time 0.05 --example-list test;
mv screenshots $prefix-screenshots;
done;
mv base screenshots
for prefix in `seq 0 $steps`;
do
echo check $prefix
for file in screenshots/*/*;
do
echo $file;
diff $file $prefix-$file;
done;
done;
I'm not sure how I feel about this. I think the issue is wireframes being wrong. It doesn't feel like that's the rigth fix for the issue. I need to think about this more.
I'm not happy about making it dependent on plugin order, but the fact that Material2d order is random is wrong
The problem with wireframes is that they break the 1:1 mapping between entities and meshes/materials, which breaks things in lots of ways that can't be fully covered up by forcing the rendering order. One way to fix wireframes properly would be to add a WireframePass and treat wireframes as a sort of prepass-like thing.
Yeah, at the time I ported the wireframe from their own pass to the current wireframe material thing because it simplified a lot of the code, but in hindsight that isn't as ideal of a solution. It's nice that the code is a bit simpler but it's probably less efficient than it could be.