Join us at the Oolite Anniversary Party -- London, 7th July 2024, 1pm
More details in this thread.

Render to Framebuffer

An area for discussing new ideas and additions to Oolite.

Moderators: another_commander, winston

User avatar
tsoj
Deadly
Deadly
Posts: 199
Joined: Wed May 18, 2016 8:19 pm
Location: Berlin
Contact:

Re: Render to Framebuffer

Post by tsoj »

Works fine for me. I have to say, I find the current gamma correction also a bit too bright, I prefer a value of 1.0/1.3. I think this should be added later as an option in the option menu for easy customization (probably in a future pull request). I already looked into it, but I am not sure what exactly the current gamma option does, so I don't have anything right now.

I also barely notice the bloom effect. Could it be because I still use stations and ships with Griffs shaders? Is there a way I can make the bloom effect more pronounced?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6559
Joined: Wed Feb 28, 2007 7:54 am

Re: Render to Framebuffer

Post by another_commander »

tsoj wrote: Sat Aug 27, 2022 3:53 pm
Works fine for me. I have to say, I find the current gamma correction also a bit too bright, I prefer a value of 1.0/1.3. I think this should be added later as an option in the option menu for easy customization (probably in a future pull request). I already looked into it, but I am not sure what exactly the current gamma option does, so I don't have anything right now.
The gamma correction value 1.0/2.2 is not a randomly selected one. Due to the way monitors work, you have to use this value to transit from the linear colorspace used for the shader calculations to the sRGB colorspace for display on screen. Random values like 1.0/1.3 are not physically correct (regardless of what they look like) and contradict also the initial (and necessary) sRGB to linear colorspace transition we do in our shaders at the beginning of our PBR workflow. As for the gamma option we currently have in Game Options, it is something irrelevant to the concept of gamma correction. This blog post here is really an excellent source of information on the subject, it explains very nicely where that 2.2 comes from and contains links to further knowledge if one is interested: https://learnopengl.com/Advanced-Lighti ... Correction
I also barely notice the bloom effect. Could it be because I still use stations and ships with Griffs shaders? Is there a way I can make the bloom effect more pronounced?
Yes, that is most likely it You can try to get this to work a bit better by trying these two optins:
1. Install the 1.88+ specglossed ships OXP. They are still Griff core shipset, but using the new lighting systen,
2. Try adjusting the bloom strength in the oolite-texture.fragment shader. You can change it from 0.05 to something like 0.2 or higher until the effect becomes more noticeable. However, bloom works best when it is barely noticeable.

If you really want to go overboard and see the full bloom in all its extravagant glory, go to the oolite-texture.fragment shader and change the threshold to 0.0 and the strength to 1.0. This will result in the entire scene becoming drenched with the effect - every single pixel will receive some amount of bloom based on its luminance and it will look like Prince of Persia, the Sands of Time. Thanks to your latest code, at least the HUD and GUI will not get bloom-bombed though. :-)
User avatar
Mauiby de Fug
---- E L I T E ----
---- E L I T E ----
Posts: 847
Joined: Tue Sep 07, 2010 2:23 pm

Re: Render to Framebuffer

Post by Mauiby de Fug »

Well, I can honestly say that this might be my favourite PR that I've ever seen on GitHub. Well done everyone!

I've been struggling to see the bloom, although to be fair, I struggled to see it on the screenshots in this thread too. But it is indeed there - I eventually managed to wrangle an external camera into a position where I could see a difference toggling bloom on or off.

I'm also super pleased that you've separated out rendering the HUD and the universe into different passes. I think in an ideal world we'd end up with something like

Code: Select all

Render universe -> Iterate through a set of specified PPFX for the universe in a specified order -> Add HUD+GUI -> Iterate through a set of specified PPFX for the final display in a specified order
where the user can apply multiple post-processing effects in a chosen order at both stages, and they can be added by oxp. However, I think that's beyond the scope of this fantastic initial PR, much more complicated, and something that can be investigated later. What we have here is ideal for the moment.

I notice that the addition of the key_bloom_toggle in PlayerEntityKeyMapper.m is commented out. Presumably it'll be added in when this is merged?

Playing devil's advocate, it might be possible (I have not tested) to add this all without raising the minimum GL version all the way to 3.3, if one uses the older style syntax for MRT, i.e.

Code: Select all

glFragData[0] = out_color
glFragData[1] = bright_color
And then coupling that with only rendering to frame buffers if the user has the valid extension available i.e. GL_EXT_framebuffer_object or GL_ARB_framebuffer_object. But of course this would lead to multiple code paths, not doing the gamma stuff properly, and generally being more complicated and ugly. I think it's obvious though that I am personally definitely in favour of bringing up the minimum version, and if it does get raised then there's the opportunity to work through and gradually attempt to bring the rest of the codebase up to the same level.

Anyway, once more, congratulations! It sets up the capability for some very exciting changes in the future!
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6559
Joined: Wed Feb 28, 2007 7:54 am

Re: Render to Framebuffer

Post by another_commander »

And... it's done. Rendering to framebuffer is now in trunk and the nightly build containing its implementation is available from here.

Just to recap, this is what has just been implemented:
  • Full HDR support. We now render the full scene to a floating point framebuffer, then apply ACES tonemapping and gamma correction before sending off to screen for display.
  • Bloom. The effect can be toggled on and off with the F9 key.
  • Post processing effects. We have seven post processing effects available: 1. cloak vision, 2., 3., 4. colorblindness correction filters for protanopia, deuteranopia and tritanopia, 5. grayscale, 6. old silent film and 7. CRT. The effects can be controlled by script by means of the JSGlobal object postFX and by setting it to equal the corresponding effect number Use postFX=0 to return to standard rendering without post porcessing effects.
  • The cloaking device is now using the cloak vision post effect when activated.
  • The minimum required OpenGL version has been raised to 3.3. Should be OK for all today's computers.
One more thing: Due to the framerate cost of some of the implemented features, there has been a re-arrangement of the detail level settings. The detail level "Shaders Enabled" now contains everything that was present in the trunk until now, including shadered planet atmospheres. The Extras detail level has by default bloom on and can hold other effects that might be added in the future,


Cloaking device activated...
Image
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2478
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Re: Render to Framebuffer

Post by Griff »

Awesome work on all of this guys, been seeing the new bloom effect appear in game over the last few days whilst testing an oxp ship i was trying to get working - it looks awesome when the sunlight catches it just right
Post Reply