OS1 Post Processing
OS2 Post Processing Alpha
Since this is taking a while to develop i've figured i'd put out an alpha build for you to look at.
As such this comes with no guarantees of any kind, parts are unfinished, it might not run, exceptions may be had etc.
>>Download Here<<
Here's a rundown of what's going on. This project isn't exclusively about post processing anymore, it can be split into two projects. One is some major additions to the DxWrapper part of OS and a number of components it now relies upon, and the post processing system that relies upon the DxWrapper modifications.
DxWrapper
The DxWrapper now has the ability to create a screen space position texture, a screen space velocity texture and a screen space normals texture, which are all exposed to other components though a DxWrapper namespace (as well as some other things). These outputs are used by the PostProcessing component for special effects.
I've added a hs_global "rasterizer_rt_display <short>" which allows you to see these outputs in action (which is handy for debugging too!). The values you can use are below.
0 - Default. Just renders the scene as normal.
1 - Shows you what is in the position output texture.
2 - Shows you what is in the velocity output texture. You'll need to have something moving to see something, Warthog tires will glow!
3 - Shows you what is in the normals output texture (between -1 and +1, so blackness will occur).
4 - Shows you what is in the normals output texture (between 0 and +1, so blackness won't occur).
-1 - All of the above, except 0.
Post Processing
The post processing system now has 4 sub sections.
- Per pixel motion blur
- Fake HDR
- External global shaders, and
- Internal map cache shaders.
Per pixel motion blur
Yes, i'm determined to get per pixel motion blur working. It uses the screen space velocity to blur the scene depending on how fast and in what direction an object is moving. This heavily relies on the DxWrapper velocity output so i'll discuss that instead. As far as the Velocity output goes, currently BSP velocity is fine, but object velocity isn't quite right. It will flicker everytime an object is added or removed from the object pool. Or at least I think that is what's happening. This is a bit annoying as the motion blur will distort the objects on screen when this happens, so i've disabled the velocity output for objects by default and added another HS global bool 'rasterizer_object_velocity' so that you can turn it on so see what progress has been made on it. The blur shader itself is pretty resource intensive so don't be suprised if you get a big droop in FPS when the shader is enabled. Regarding the motion blur effect, the shader isn't framerate independent so at the moment if you have a really high FPS you might not notice much. I test it at 30 FPS as my baseline so you'll get the full effect at that speed.
Fake HDR
Disable by default, enabled via the console. I don't like it much to be honest.
External global shaders/Internal map cache shaders.
These are together as their capabilities are be identical. External shaders work the same as in the OS1 version. They are defined in "shaders/PostProcessingSettings.txt" and loaded from the "shaders" directory. The variable names that are used in the shaders have changed so shaders from OS1 will need updating to work. Otherwise they are largely the same, but with a few additions. Shaders can now use up to 4 external textures to create more interesting effects, an example being a pencil sketch effect which is included in the download. They also have access to the textures DxWrapper now outputs. Which means that some interesting effects can be achieved such as depth of field (included), VISR-esque edge detection (included) and plausibly SSAO. Also, up to 8 animated floats are now available for whatever reason you deem fitting.
So, on top of the effects that can be done purely with the rendered scene (Bloom, Sepia, etc.) more cool things are possible .
A much needed addition is the ability to chose when an effect is applied, which can now be defined in the settings file. These are listed in order of application.
0 - Pre blur Applied before the motion blur takes place.
1 - Pre alpha blended Applied after the motion blur but before the alpha blended faces.
2 - Pre HUD Default. Applied after the alpha blended faces but before the HUD.
3 - Pre menu Applied after the HUD is rendered.
4 - Post menu Applied after the menu is rendered.
Motion blur is applied before alpha blended faces are rendered as it's nigh impossible to blur a pixel for both the transparent surface and the surface behind it at the same time.
Internal map cache shaders are a completely new feature which is now possible thanks to the wonders of OS2. I have made two new tags (included in this release but used them at your own peril dun Dun DUNNN!!). "shader_post_process" and "shader_post_process_collection" which will allow map makers to create post process effects for their maps, giving them a completly unique look. They have the same capabilities as the external shaders with a few changes.
- If I can ever figure out how to make functions with arguments work, they will be partially controllable with HScript.
- They can be set to not be applied during cutscenes.
- External bitmaps are currently available in the same way as external shaders, however, if I can find out how to load bitmaps from the cache, they will take their place. An interesting application of this would be to have a refractive effect behind the HUD ala Halo3/ODST.
shader_post_process
shader_post_process_collection
I have included the current tag_groups.map file and the definition file for the new tags so you can give it a go, but while I think i'm done changing it, and i've left space to add things if I want to, there's no guarantee that no tag breaking changes will be made in future.
The current post processing console commands are as follows:
pp_load function Loads everything if not already loaded
pp_unload function Unloads everything if not already loaded
pp_fake_hdr_enabled bool Turns fake HDR on/off
pp_fake_hdr_target_luminance real Adjust fake HDR target luminosity
pp_post_processing_enabled bool Turns effects on/off
pp_motion_blur_enabled bool Turns motion blur on/off
pp_motion_blur_amount real Motion blur amount ~40 works well at 30FPS
With regards to settings, all standard settings are stored in the OpenSauce settings file. They are changed by the console commands and save when you close the game. The shader and effect setup however is in the PostProcessingSettings file mentioned previously. You can change things in this file then unload-load the post processing system while the game is running to see your changes. The way the file is laid out is very specific so stick to it!
So, I think thats covers everything added/changed, so onto the dreaded problems.
Known problems:
- Alpha blended faces such as tree leaves are a bit messed up in the Position/Velocity/Normals output. This therefore affects all post processing shaders that use them.
- In the Velocity texture flickering occurs when you move and look around, and sometimes objects just look wrong.
- Using the Yelo menu to disable and re-enable the HUD will permanently disable a number of features because it replaces a pointer that my code replaces, with the original Halo pointer. I need to find a way around this.
- Sometimes using the flashlight or picking up active camo will make the screen go black for a split second.
- For the first frame when you load a map or when the camera changes in SP motion blur will be crazy.
UserTool
Along with the internal shaders I am also working on a "usertool" which is a simple command line program that looks and operates in the same way as tool, but will allow developers to add their own commands so that they can compile data into their own tag formats. For instance currently the shader_post_process tag stores the shader in text format, but once the map maker is happy with the shader they will be able to use usertool to compile and replace it with a smaller binary format.
Source
Source is included in the download if your interested. I'm probably going to be re-writing DxWrapper once i've got a fully working velocity output and I need to add internal bitmap loading to the PostProcessing component but the other components should be pretty much done.
Like I said at the beginning of theessaypost this is an alpha build so any problems i'd like to know about but don't be expecting a rapid fire fix for anything. It would be handy to know your video card if you do have problems. Performance wise, this is a far more expensive system than previously so some FPS drops shouldn't be unexpected.
Also, as this is built with the original OS2 source any problems with that initial release might be present here. You'll need the latest DirectX too.
Any questions you have are obviously welcome .
As far as credits go, obviously Kornman deserves his own cookie mountain for OS itself and the help he's given, complete with warm milk and honey.
Skarma also needs a hearty mention for reversing the code that helped getting screen space normals and velocity working.
Bookmarks