Fyrox icon indicating copy to clipboard operation
Fyrox copied to clipboard

Incorrect rendering of transparent objects

Open martin-t opened this issue 3 years ago • 4 comments

My game has a floor with 3 transparent layers, each with a progressively finer grid of green lines. In my game, it usually displays all 3 layers but sometimes (1 in 10 runs) the middle one is missing. In the editor, it never displays the middle layer.

The game is https://github.com/rustcycles/rustcycles/ on commit a44da58 but it's been happening for a bit longer. TBH i am not entirely sure when it started - I think I reworked the models in blender (including renaming some objects) and reexported them, maybe without editing the scene in rusty-editor so this might not be a rusty-editor regression.

It's however certainly a bug in the engine because the same scene loads differently in-game on some runs. Note that you might need to run it like 20 times to get the bugged result without the middle layer. I have no idea what the editor is doing that it always triggers the bug.

Note: it might not even be a bug in the editor - maybe what the editor is showing is the correct result and the 3 layers in-game are the bug. The objects used to be called Floor, Floor.001 and Floor.002 (i think) but i renamed them. The editor is still showing a remnant of this - Floor.001. So what might be happening is that the engine somehow mixes up the models/textures and which nodes they belong to.

This is what is should look like (the bottom layer is faint in this screenshot but you can see all 3 layers) - usually it loads like this in my game but not always: 2021-12-06-145351_1581x913_scrot

2021-12-06-145339_1919x1079_scrot

This is how it sometimes loads in my game (maybe 1 in 10 runs). It also always loads this way in the editor: 2021-12-06-145253_1640x885_scrot

2021-12-06-145307_1919x1079_scrot

martin-t avatar Dec 06 '21 16:12 martin-t

Could you please create a minimal working example for this (for example a scene with one "block", that allows to reproduce the bug)? It is somewhat hard to fix the bug in the large scene.

mrDIMAS avatar Dec 08 '21 07:12 mrDIMAS

I was hoping I could avoid that - I am not entirely sure what triggered it, I think it was the renaming but I am not sure how exactly because I renamed 3 layers and only 1 remained duplicated. The real bug is the indeterminism and i thought the engine should have some instrumentation that would allow you to dump the loaded scene or other data and see what gets loaded differently on the different runs.

martin-t avatar Dec 08 '21 17:12 martin-t

It is most likely happened because of renaming, because engine resolves a lot of stuff from FBX models using names of nodes. It is done a bit differently in case if you're loading scene directly in the engine (which is rusty-editor does) and if you're embedding scene into some other scene. But if the result is different in your game from run to run then it could be some interesting memory issues.

mrDIMAS avatar Dec 09 '21 18:12 mrDIMAS

As we've discussed in Discord, this is the forward renderer bug, it does not sort transparent objects back-to-front which leads to incorrect blending.

mrDIMAS avatar Jan 14 '22 18:01 mrDIMAS