SomaZ / OpenJK

Community effort to maintain and improve Jedi Academy + Jedi Outcast released by Raven Software
GNU General Public License v2.0
11 stars 4 forks source link

Flares #40

Open SomaZ opened 4 years ago

SomaZ commented 4 years ago
SomaZ commented 1 year ago

Current implementation uses glRead to compare the view depth to the view distance of the flare to decide if you should render the flare or not. glRead is a blocking command though, as it needs to sync the gpu and the cpu to get the current view depth.

I want to replace this with an additional flare visibility FBO with an attached 1D texture. The 1D textures width would be the number of flares of the current map.

This FBO will be updated every frame after the depth prepass. We can bind the depth buffer to a texture unit and test in a fragment shader if the flare would be visable or not. If the flare is not visable, write a value of 0.0, else add some_magic_value/frame_time. Could also extend the depth testing to multiple pixels to account for partial occlusion of the flares.

Finally, the flare could be rendered with the rendered flare visibility texture.

Atlasing all the flare images per map would also be nice, so we can render all flares with one draw command.