jdolan / quetoo

Quetoo ("Q2") is a free first person shooter based on id Tech2. GPL v2 license.

Home Page:http://quetoo.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add bloom stage to materials

jdolan opened this issue · comments

Our renderer is finally clean and stable enough to be easily extended for post effects. Some low-hanging fruit in this regard would be light bloom. We could use the more modern technique of having two separate color attachments: the default one that we currently have, and a new color attachment where only bloom stages are written to. At the end of the frame, we then simply blur the bloom color attachment and render it over the framebuffer with additive blending. This is described in detail here:

https://learnopengl.com/Advanced-Lighting/Bloom

We don't have HDR to select which colors are over-bright and should go to the bloom attachment, but that's where our materials system can help. A material stage effect STAGE_BLOOM should be added. It could optionally take a scalar or 3-component color as a multiplier we could pass as a uniform to up-scale the diffusemap color for the final bloom color.

We could also experiment with auto-blooming any SURF_LIGHT draw elements, as this would be desirable default behavior, I think. But having STAGE_BLOOM available explicitly via materials will give us the ability to bloom mesh models, or BSP elements that aren't emissive but should still glow (e.g. a bright skybox?).

@SpineyPete or @Paril I'm sure you have thoughts on this. Let's hear 'em :)

This is now underway. The approach I'm taking is to add a simple scalar bloom to all materials (like hardness and roughness). This will multiply the diffuse color when that material is rendered. If the color exceeds a threshold, it is written to a separate color attachment. I'll then blur and blit the bloom color attachment over the primary color attachment towards the end of the frame. Mappers will be able to play with bloom in the in-game materials editor.

A first pass at this is done. I'm sure it could use more tweaking, but I think it's a good start. Materials for the maps we have so far have also been updated.