Ogre post processing fog question for a mod
Posted: Tue Jan 29, 2019 10:23 pm
I created a shader for SSAO in Kenshi within the RTT post processing pipeline.
The problem I have is, the atmosphere fog is also in post processing and started by the main compositor in a late render queue for the scene, before any other post processing.
My effect is therefore applied and can be seen through the fog, which does not look so bad if I clip the shader near around the camera. The fog is more or less in certain areas and the SSAO should cut off with the fog-line.
I see parameters like fog-density which I could grab from the engine. For example change the alpha level in regard to the "foglevel" and then blend my shader in (I tried this, but with more or less effect because fog level seems to be hard to apply and seems sometimes random). My guess is they are particles and not fog?
Is this the way to go or is there a fancy Ogre option to just put everything 'fog' in front of my shader? Like the opposite of fog_override? Does this even apply if the fog is post processing?
Default is "false" and the engine does not seem to recognise the option.
I also tested culling and hoped the fog would be seen as something in front of my pixels... nope.
Since this is a mod, I have no access to change anything outside the pipeline. I also don't want to change the fog shader or touch the main compositor.
p.s. picture of the problem:
There should be fog in the background, where only the AO effect is visible
here my compositor:
And the material (the fragprogram only returns the colour)
The problem I have is, the atmosphere fog is also in post processing and started by the main compositor in a late render queue for the scene, before any other post processing.
My effect is therefore applied and can be seen through the fog, which does not look so bad if I clip the shader near around the camera. The fog is more or less in certain areas and the SSAO should cut off with the fog-line.
I see parameters like fog-density which I could grab from the engine. For example change the alpha level in regard to the "foglevel" and then blend my shader in (I tried this, but with more or less effect because fog level seems to be hard to apply and seems sometimes random). My guess is they are particles and not fog?
Is this the way to go or is there a fancy Ogre option to just put everything 'fog' in front of my shader? Like the opposite of fog_override? Does this even apply if the fog is post processing?
Default is "false" and the engine does not seem to recognise the option.
I also tested culling and hoped the fog would be seen as something in front of my pixels... nope.
Since this is a mod, I have no access to change anything outside the pipeline. I also don't want to change the fog shader or touch the main compositor.
p.s. picture of the problem:
There should be fog in the background, where only the AO effect is visible
here my compositor:
Code: Select all
compositor_node SSSAO {
in 0 rt_output
in 1 rt_input
// Temporary textures as buffer
texture rt0 target_width_scaled 0.5 target_height_scaled 0.5 PF_A8R8G8B8
texture rt1 target_width_scaled 0.5 target_height_scaled 0.5 PF_A8R8G8B8
texture rt2 target_width target_height PF_A8R8G8B8
// create AO
target rt0 {
pass clear {
colour_value 1 1 1 1
}
pass render_quad {
material SSSAO
input 1 global_gbuffer 1 // normal
input 2 global_gbuffer 2 // depth
}
}
// blur the AO
target rt1 {
pass clear {
colour_value 1 1 1 1
}
pass render_quad {
material SSAOB
input 0 rt0 // pure ssao output
}
}
// put original texture back in buffer
target rt_output {
pass clear {}
pass render_quad {
material SSAOC
input 0 rt_input // original texture
}
}
// combine rt_input and rt1
target rt_output {
pass render_quad {
material SSAOF
input 0 rt1 // pure ssao output
}
}
out 0 rt_output
out 1 rt_input
}
Code: Select all
fragment_program ssaof_ps hlsl
{
source SSAOF.hlsl
target ps_4_0
entry_point main
enable_backwards_compatibility true
default_params {
shared_params_ref SharedDeferredParams
}
}
material SSAOF
{
technique
{
pass
{
cull_hardware clockwise // this is post processing, we want everything rendered
cull_software none // this is post processing, we want everything rendered
depth_check on // this is post processing, we want everything rendered
scene_blend modulate // multiply the colours
depth_func less // less = only terrain, equal = OK, greater = off
depth_write off // this is post processing, we want everything rendered
//alpha_rejection greater_equal 128 // here you could filter for bright textures, use with care or stuff may not be drawn at all :)
vertex_program_ref Posteffects/StdQuad_vp{}
fragment_program_ref ssaof_ps {}
texture_unit {
tex_address_mode clamp
filtering none
colour_op modulate
}
}
}
}