I have a game where there a multiple floor levels between the player switches. The floor is not present everywhere, so you can look through it. When 'working' (playing, building stuff, etc.) on a specific floor I want to add a transparency value to everything that is NOT on the current floor. Ho can I accomplish that, and what is the best/most efficient way to do that?
Draw the floor (transparent part) after drawing the rest of the objects with transparency blending turned on.
Otherwise you can pass a currentFloor uniform to the fragment shader and a floor attribute to the objects so you can add the extra shade conditionally.
Order of rendering is important.
You need to draw the objects in order, draw objects far away first. Using alpha values ofc, for an example alpha = 0.5.
Think this is called back to fron rendering.
So if you stand at X, floor is |, object are 1,2,4...
X | 1 2 3 4
Then you render 4, 3, 2, 1 and finally the floor |.