SSAO Compositor

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: SSAO Compositor

Post by lukeneorm »

nullsquared wrote:That can't be the full log. I don't see any materials being parsed.
You can't remove "scheme lighting". What you're seeing there is an artifact - not actual shadows, but the shadow depth map is coming up as the "shadows." Either something is loading incorrectly (I need the full log), or you're not setting something up right as the demo does it.
You're right, something was loading incorrectly: there was a conflict in shaders names, and so the output was unpredictable. :? Now everything goes ok, though the performance is an issue for now. :?
I haven't read shader code in detail for now, so I'm trying to understand the more that is possible from the shader before add new post here about performance. :wink:
Thank you very much for your helpfulness for now. YOU ROCK MAN! :D
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

lukeneorm wrote:
nullsquared wrote:That can't be the full log. I don't see any materials being parsed.
You can't remove "scheme lighting". What you're seeing there is an artifact - not actual shadows, but the shadow depth map is coming up as the "shadows." Either something is loading incorrectly (I need the full log), or you're not setting something up right as the demo does it.
You're right, something was loading incorrectly: there was a conflict in shaders names, and so the output was unpredictable. :? Now everything goes ok, though the performance is an issue for now. :?
I haven't read shader code in detail for now, so I'm trying to understand the more that is possible from the shader before add new post here about performance. :wink:
Thank you very much for your helpfulness for now. YOU ROCK MAN! :D
Just out of curiosity, what card are you on?

I'm sure stuff can be optimized, but this was just a KISS demo :mrgreen:
tsmithtree
Gnoblar
Posts: 4
Joined: Sun May 10, 2009 12:05 am

Re: SSAO Compositor

Post by tsmithtree »

I've attempted to make this work under linux. It compiles, unfortunately I get the following error:

Code: Select all

Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
OverlayElementFactory for type Panel registered.
OverlayElementFactory for type BorderPanel registered.
OverlayElementFactory for type TextArea registered.
Registering ResourceManager for type Font
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
FreeImage version: 3.11.0
This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi,exr,j2k,j2c,jp2
DDS codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
*-*-* OGRE Initialising
*-*-* Version 1.6.2 (Shoggoth)
Loading library ./RenderSystem_GL
Installing plugin: GL RenderSystem
OpenGL Rendering Subsystem created.
Plugin successfully installed
Loading library ./Plugin_CgProgramManager
Installing plugin: Cg Program Manager
Plugin successfully installed
CPU Identifier & Features
-------------------------
 *   CPU ID: GenuineIntel: Intel(R) Core(TM)2 Quad CPU    Q6600  @ 2.40GHz
 *      SSE: yes
 *     SSE2: yes
 *     SSE3: yes
 *      MMX: yes
 *   MMXEXT: yes
 *    3DNOW: no
 * 3DNOWEXT: no
 *     CMOV: yes
 *      TSC: yes
 *      FPU: yes
 *      PRO: yes
 *       HT: no
-------------------------
******************************
*** Starting GLX Subsystem ***
******************************
GLRenderSystem::_createRenderWindow "Ogre SSAO Compositor and Soft Shadows", 1024x768 windowed  miscParams: FSAA=4 vsync=false 
GLXWindow::create used FBConfigID = 161
GL_VERSION = 3.0.0 NVIDIA 180.51
GL_VENDOR = NVIDIA Corporation
GL_RENDERER = GeForce 9800 GTX+/PCI/SSE2
GL_EXTENSIONS = GL_ARB_color_buffer_float GL_ARB_depth_buffer_float GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_draw_instanced GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_half_float_pixel GL_ARB_half_float_vertex GL_ARB_framebuffer_object GL_ARB_geometry_shader4 GL_ARB_imaging GL_ARB_map_buffer_range GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shadow GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_border_clamp GL_ARB_texture_buffer_object GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_texture_rg GL_ARB_transpose_matrix GL_ARB_vertex_array_object GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_bindable_uniform GL_EXT_depth_bounds_test GL_EXT_direct_state_access GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_object GL_EXTX_framebuffer_mixed_formats GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_latc GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_sRGB GL_EXT_texture_swizzle GL_EXT_texture_shared_exponent GL_EXT_timer_query GL_EXT_vertex_array GL_EXT_vertex_array_bgra GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_blend_square GL_NV_copy_depth_to_color GL_NV_depth_buffer_float GL_NV_conditional_render GL_NV_depth_clamp GL_NV_explicit_multisample GL_NV_fence GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragment_program GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_framebuffer_multisample_coverage GL_NV_geometry_shader4 GL_NV_gpu_program4 GL_NV_half_float GL_NV_light_max_exponent GL_NV_multisample_coverage GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_parameter_buffer_object GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_texgen_reflection GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_expand_normal GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_transform_feedback GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_NVX_conditional_render GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum 
Supported GLX extensions: GLX_EXT_visual_info GLX_EXT_visual_rating GLX_SGIX_fbconfig GLX_SGIX_pbuffer GLX_SGI_video_sync GLX_SGI_swap_control GLX_EXT_texture_from_pixmap GLX_ARB_create_context GLX_ARB_multisample GLX_NV_float_buffer GLX_ARB_fbconfig_float GLX_EXT_framebuffer_sRGB GLX_ARB_get_proc_address 
***************************
*** GL Renderer Started ***
***************************
Registering ResourceManager for type GpuProgram
GLSL support detected
GL: Using GL_EXT_framebuffer_object for rendering to textures (best)
FBO PF_UNKNOWN depth/stencil support: D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_L8 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_A8 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_A4L4 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_BYTE_LA depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_R5G6B5 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_B5G6R5 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_A1R5G5B5 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_R8G8B8 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_B8G8R8 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_A8R8G8B8 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_B8G8R8A8 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_A2R10G10B10 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_A2B10G10R10 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT16_RGB depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT16_RGBA depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT32_RGB depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT32_RGBA depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_X8R8G8B8 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_X8B8G8R8 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_SHORT_RGBA depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_R3G3B2 depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT16_R depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT32_R depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT16_GR depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_FLOAT32_GR depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
FBO PF_SHORT_RGB depth/stencil support: D0S0 D16S0 D24S0 D32S0 Packed-D24S8 
[GL] : Valid FBO targets PF_UNKNOWN PF_L8 PF_A8 PF_A4L4 PF_BYTE_LA PF_R5G6B5 PF_B5G6R5 PF_A1R5G5B5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_B8G8R8A8 PF_A2R10G10B10 PF_A2B10G10R10 PF_FLOAT16_RGB PF_FLOAT16_RGBA PF_FLOAT32_RGB PF_FLOAT32_RGBA PF_X8R8G8B8 PF_X8B8G8R8 PF_SHORT_RGBA PF_R3G3B2 PF_FLOAT16_R PF_FLOAT32_R PF_FLOAT16_GR PF_FLOAT32_GR PF_SHORT_RGB 
RenderSystem capabilities
-------------------------
RenderSystem Name: OpenGL Rendering Subsystem
GPU Vendor: nvidia
Device Name: GeForce 9800 GTX+/PCI/SSE2
Driver Version: 3.0.0.0
 * Fixed function pipeline: yes
 * Hardware generation of mipmaps: yes
 * Texture blending: yes
 * Anisotropic texture filtering: yes
 * Dot product texture operation: yes
 * Cube mapping: yes
 * Hardware stencil buffer: yes
   - Stencil depth: 8
   - Two sided stencil support: yes
   - Wrap stencil values: yes
 * Hardware vertex / index buffers: yes
 * Vertex programs: yes
 * Fragment programs: yes
 * Geometry programs: yes
 * Supported Shader Profiles: arbfp1 arbvp1 fp20 fp30 fp40 glsl gp4gp gpu_gp nvgp4 vp30 vp40
 * Texture Compression: yes
   - DXT: yes
   - VTC: yes
 * Scissor Rectangle: yes
 * Hardware Occlusion Query: yes
 * User clip planes: yes
 * VET_UBYTE4 vertex element type: yes
 * Infinite far plane projection: yes
 * Hardware render-to-texture: yes
 * Floating point textures: yes
 * Non-power-of-two textures: yes
 * Volume textures: yes
 * Multiple Render Targets: 8
   - With different bit depths: yes
 * Point Sprites: yes
 * Extended point parameters: yes
 * Max Point Size: 63.375
 * Vertex texture fetch: yes
   - Max vertex textures: 32
   - Vertex textures shared: yes
 * Render to Vertex Buffer : yes
 * GL 1.5 without VBO workaround: no
 * Frame Buffer objects: yes
 * Frame Buffer objects (ARB extension): no
 * Frame Buffer objects (ATI extension): no
 * PBuffer suppport: no
 * GL 1.5 without HW-occlusion workaround: no
Registering ResourceManager for type Texture
Using FSAA from GL_ARB_multisample extension.
ResourceBackgroundQueue - threading enabled, starting own thread
ResourceBackgroundQueue - thread starting.
Particle Renderer Type 'billboard' registered
Creating resource group Media
Added resource location '../../data' of type 'FileSystem' to resource group 'Media'
Initialising resource group Media
Parsing scripts for resource group Media
Parsing script shadow_caster.program
Parsing script ambient.program
Parsing script diffuse.program
Parsing script ogre.material
Parsing script metal.material
Parsing script shadow_caster.material
Parsing script colours.material
Parsing script ssao.material
Parsing script diffuse.material
Parsing script ssao.compositor
Finished parsing scripts for resource group Media
terminate called after throwing an instance of 'Ogre::ItemIdentityException'
  what():  OGRE EXCEPTION(5:ItemIdentityException): shadowIndex out of bounds in SceneManager::getShadowTexture at OgreSceneManager.cpp (line 5522)
Incidentally, the provided binary works under wine (including ssao/shadows).

edit: ok, I made it work by commenting out the rtt code in the initshadows function. The soft shadows work, but ssao is really messed up, but iirc people were having troubles with it in opengl on windows anyway. I can post screens is anyone is interested, but I was mostly concerned with the shadowing.
Last edited by tsmithtree on Mon May 25, 2009 1:58 am, edited 1 time in total.
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: SSAO Compositor

Post by lukeneorm »

nullsquared wrote: Just out of curiosity, what card are you on?
I'm sure stuff can be optimized, but this was just a KISS demo :mrgreen:
It was a BIG KISS demo, let me say it. :mrgreen:
I'm using a NVIDIA GeForce 9600M GT 512MB on a Intel Core Duo 2.6GHz. This is the piece of the Ogre log that you may want to look at to know about my configuration :wink:

Code: Select all

01:20:12: *-*-* OGRE Initialising
01:20:12: *-*-* Version 1.6.2 (Shoggoth)
01:20:12: Loading library RenderSystem_Direct3D9_d
01:20:12: Installing plugin: D3D9 RenderSystem
01:20:12: D3D9 : Direct3D9 Rendering Subsystem created.
01:20:12: D3D9: Driver Detection Starts
01:20:12: D3D9: Driver Detection Ends
01:20:12: Plugin successfully installed
01:20:12: Loading library Plugin_CgProgramManager_d
01:20:12: Installing plugin: Cg Program Manager
01:20:12: Plugin successfully installed
01:20:12: CPU Identifier & Features
01:20:12: -------------------------
01:20:12:  *   CPU ID: GenuineIntel: Intel(R) Core(TM)2 Duo CPU     T9400  @ 2.53GHz
01:20:12:  *      SSE: yes
01:20:12:  *     SSE2: yes
01:20:12:  *     SSE3: yes
01:20:12:  *      MMX: yes
01:20:12:  *   MMXEXT: yes
01:20:12:  *    3DNOW: no
01:20:12:  * 3DNOWEXT: no
01:20:12:  *     CMOV: yes
01:20:12:  *      TSC: yes
01:20:12:  *      FPU: yes
01:20:12:  *      PRO: yes
01:20:12:  *       HT: no
01:20:12: -------------------------
01:20:12: D3D9 : Subsystem Initialising
01:20:12: ***************************************
01:20:12: *** D3D9 : Subsystem Initialised OK ***
01:20:12: ***************************************
01:20:12: D3D9RenderSystem::_createRenderWindow "SSAO Compositor, Soft Shadows", 1024x768 windowed  miscParams: FSAA=4 vsync=false 
01:20:12: D3D9 : Created D3D9 Rendering Window 'SSAO Compositor, Soft Shadows' : 1024x768, 32bpp
01:20:12: D3D9 : WARNING - disabling VSync in windowed mode can cause timing issues at lower frame rates, turn VSync on if you observe this problem.
01:20:12: Registering ResourceManager for type Texture
01:20:12: Registering ResourceManager for type GpuProgram
01:20:12: D3D9: Vertex texture format supported - PF_FLOAT16_RGB
01:20:12: D3D9: Vertex texture format supported - PF_FLOAT16_RGBA
01:20:12: D3D9: Vertex texture format supported - PF_FLOAT32_RGB
01:20:12: D3D9: Vertex texture format supported - PF_FLOAT32_RGBA
01:20:12: D3D9: Vertex texture format supported - PF_FLOAT16_R
01:20:12: D3D9: Vertex texture format supported - PF_FLOAT32_R
01:20:12: D3D9: Vertex texture format supported - PF_FLOAT16_GR
01:20:12: D3D9: Vertex texture format supported - PF_FLOAT32_GR
01:20:12: RenderSystem capabilities
01:20:12: -------------------------
01:20:12: RenderSystem Name: Direct3D9 Rendering Subsystem
01:20:12: GPU Vendor: nvidia
01:20:12: Device Name: NVIDIA GeForce 9600M GT
01:20:12: Driver Version: 6.14.11.7644
01:20:12:  * Fixed function pipeline: yes
01:20:12:  * Hardware generation of mipmaps: yes
01:20:12:  * Texture blending: yes
01:20:12:  * Anisotropic texture filtering: yes
01:20:12:  * Dot product texture operation: yes
01:20:12:  * Cube mapping: yes
01:20:12:  * Hardware stencil buffer: yes
01:20:12:    - Stencil depth: 8
01:20:12:    - Two sided stencil support: yes
01:20:12:    - Wrap stencil values: yes
01:20:12:  * Hardware vertex / index buffers: yes
01:20:12:  * Vertex programs: yes
01:20:12:  * Fragment programs: yes
01:20:12:  * Geometry programs: no
01:20:12:  * Supported Shader Profiles: hlsl ps_1_1 ps_1_2 ps_1_3 ps_1_4 ps_2_0 ps_2_a ps_2_b ps_2_x ps_3_0 vs_1_1 vs_2_0 vs_2_a vs_2_x vs_3_0
01:20:12:  * Texture Compression: yes
01:20:12:    - DXT: yes
01:20:12:    - VTC: no
01:20:12:  * Scissor Rectangle: yes
01:20:12:  * Hardware Occlusion Query: yes
01:20:12:  * User clip planes: yes
01:20:12:  * VET_UBYTE4 vertex element type: yes
01:20:12:  * Infinite far plane projection: yes
01:20:12:  * Hardware render-to-texture: yes
01:20:12:  * Floating point textures: yes
01:20:12:  * Non-power-of-two textures: yes
01:20:12:  * Volume textures: yes
01:20:12:  * Multiple Render Targets: 4
01:20:12:    - With different bit depths: yes
01:20:12:  * Point Sprites: yes
01:20:12:  * Extended point parameters: yes
01:20:12:  * Max Point Size: 8192
01:20:12:  * Vertex texture fetch: yes
01:20:12:    - Max vertex textures: 4
01:20:12:    - Vertex textures shared: no
01:20:12:  * Render to Vertex Buffer : no
01:20:12:  * DirectX per stage constants: yes
01:20:12: ResourceBackgroundQueue - threading disabled
01:20:12: Particle Renderer Type 'billboard' registered
01:20:12: Creating resource group Media
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: SSAO Compositor

Post by lukeneorm »

Hi,
I just played around a bit with your shaders, trying to get better results in my scene, but I still have some artifacts:

with texturesize=2048, radius=0.01, steps=6, vsmEpsilon=0.0001
the shadows are pixelated and there are some artifacts of "light bleeding":
Image

If I decrease vsm_epsilon, I noticed no improvement.

If I increase the number of steps:
texturesize=2048, radius=0.01, steps=10, vsmEpsilon=0.0001
I obtain smoother penumbrae, and there are still "light bleeding" artifacts with objects far away from the light source:
Image

If I decrease the radius:
texturesize=2048, radius=0.001, steps=6, vsmEpsilon=0.0001
I obtain a sharper shadow, with little penumbrae, but the "light bleeding" artifact remains:
Image

Finally, if I use 512 texture size instead of 2048:
texturesize=512, radius=0.01, steps=6, vsmEpsilon=0.0001
Image
I obtain a smoother shadow without the additional cost of more steps (but also less realistic), but the artifact remains.

I read about this kind of problem: in VSM, along the penumbrae areas when tow or more occluders cover a receiver and one occluder is close to the receiver, we have areas that are fully occluded still receive light.
Is it possible to solve this issue? :?
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

Yes, it's possible to fix it, but you need to make use of layered VSM (LVSM) or exponential shadow maps (ESM), or another similar technique. They get a bit complicated so I didn't end up implementing them for the demo, sorry.
User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: SSAO Compositor

Post by boyamer »

Anyone can post out a guide on how to use it?
I know it comes in compositor but when i run the demo application doesn't run.

P.S: My graphic card is Intel Mobile Chipset 965 family with vertex/pixel shader 3.0 support
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

I'm pretty sure the integrated intel won't be able to run it. Doesn't matter if it reports PS 3.0 and VS 3.0 support, it usually doesn't support them or emulates them.
User avatar
Jerrith
Gnoblar
Posts: 13
Joined: Sat May 26, 2007 11:40 pm
Location: Hunt Valley, MD
Contact:

Re: SSAO Compositor

Post by Jerrith »

Hi everyone. Here's a screenshot (click for full size) of what I've been working on lately. I think it looks fairly good, but...

Image

I'm concerned about the lightness of the shadow on the floor compared to the darkness of it on the wall and posts. It seems like the shadow on the floor should be significantly darker than it is... Any suggestions as to what would be causing it, or how to "fix" it would be welcome.

Thanks. :)
User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: SSAO Compositor

Post by boyamer »

maybe you're right,but SSAO in render monkey or truevision3d which have shader support 3.0 works quite well
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

Jerrith wrote:Hi everyone. Here's a screenshot (click for full size) of what I've been working on lately. I think it looks fairly good, but...

Image

I'm concerned about the lightness of the shadow on the floor compared to the darkness of it on the wall and posts. It seems like the shadow on the floor should be significantly darker than it is... Any suggestions as to what would be causing it, or how to "fix" it would be welcome.

Thanks. :)
Hm... Could it possibly just be the contrast of the textures? One is white and the other is darker brown... what happens if you replace the ground texture with the wall texture, or the wall texture with the ground texture? Does the shadow still seem lighter on the ground (must be a shadowing error) or does it look good (must be just the textures)?
User avatar
Jerrith
Gnoblar
Posts: 13
Joined: Sat May 26, 2007 11:40 pm
Location: Hunt Valley, MD
Contact:

Re: SSAO Compositor

Post by Jerrith »

It isn't just the contrast of the textures. Here's a small shot of the same scene with the white wall material applied to the ground. The second pic is another interesting shot: Two shadows on the floor, the closer one is darker than the farther one. (Specular is also disabled in this shot.)

Image Image
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

Hm, that's weird. What happens if you only output the shadow value? No lighting, just use the shadow as the final colour for everything.

Also: what unit scale are you using? I used 1 unit : 1 meter in the demo, which works out pretty good for floating point precision. However, depending on your chosen units, you may have to tweak the VSM values. But first, let's see just the shadow colour.
User avatar
Jerrith
Gnoblar
Posts: 13
Joined: Sat May 26, 2007 11:40 pm
Location: Hunt Valley, MD
Contact:

Re: SSAO Compositor

Post by Jerrith »

I am using the same 1 unit : 1 meter scale as well. Here's a few images. 1) SSAO turned off, everything else on. I get the sort of shadow I expect (same brightness on the floor and wall). 2) Shadows only (SSAO off). Also as expected. 3) SSAO, Shadows, and ambient on. Brightness "issue".

ImageImageImage

4) SSAO Only (ambient set to white). This also shows one other thing that has concerned me. The circular banding pattern that seems to occur in various situations.
Image

Anyways, any additional thoughts on this are welcome. :) Thanks again.

Jerrith
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: SSAO Compositor

Post by lukeneorm »

Hi Jerrith,
regarding the circular banding pattern, I resolved that issue like nullsquared suggested in a previous post:
Open up your "geom" shader, and find the line

Code: Select all

OUT.c = float4(length(vp.xyz) / far, normalize(vn.xyz).xyz);
Change it to:

Code: Select all

float COEF = 1;
OUT.c = float4(length(vp.xyz) * COEF / far, normalize(vn.xyz).xyz);
play with COEF, like 0.5, or 2, etc.
for me the best choise was 1.5. It also helps to decrease the SSAO ghost effect, make it more realistic.
Hope it helps :)
User avatar
Jerrith
Gnoblar
Posts: 13
Joined: Sat May 26, 2007 11:40 pm
Location: Hunt Valley, MD
Contact:

Re: SSAO Compositor

Post by Jerrith »

Thanks for the reply, lukeneorm. I should have mentioned I'd already tried that out. I ended up going with a value of 2, however, no matter what I tried, I always seemed to have one of those circular banding patterns on the wall directly in front of me, when looking straight at it.

So, after doing some more reading on SSAO, and trying a few different things out, I ended up going with the following solution: In ssao_ps, where it's accumulating the occlusion factor, I added a check which is basically: If zd is greater than 0.075 or the dot product of the normals for the two points is less than 0.9, use the provided occlusion function, otherwise, add 1. It's not perfect by any means, but I think it's significantly better than what I had before. Here's a screenshot of the effect with the white plaster texture applied to the floor - the shadow on the wall and on the floor where there isn't SSAO is the same color, and the circular banding effect is virtually gone.

Image

Any other suggestions are welcome, but I think I'm happy enough with it, for now. Thanks for the help everyone. :)
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

Re: SSAO Compositor

Post by Noman »

Yo!

I'm integrating this cool compositor as part of my GSoC project, and its been a smooth transition except for one thing :
I'm using the current demo's full-scene rendering segment, which means that I'm not running the render_scene segment of your compositor. The problem it makes is that the current demo's full_scene render outputs the depth in a different way.

Your compositor does :
depth = length(viewPos.xyz) / far
While the current one does :
depth = projPos.w;
I don't want to change the way that deferred framework stores depth, cuz that means I'll have to change all of the post-processing shaders of it.
However, if I run your shader with this depth value without modifying it in any way, I get a completely white SSAO texture, so it doesn't modify the scene in any way.

Do you think its possible to make a slight calculation on the deferred framework's depth value to get something that will play along nicely with your SSAO shader?

Thanks!
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

Oh, you're integrating it into the deferred shading demo?

I actually suggest doing the opposite thing and changing the deferred shading demo to way the SSAO stores depth.

Right now it seems you're using post-projection depth - this requires a matrix multiply to get the final fragment position for the deferred renderer, am I correct? Well, with linear depth (what the SSAO does, length(viewSpacePosition), possibly divided by the far clip plane distance for compression into [0..1]), all you need is a single multiple. No matrix, no square roots, just a single ray * depth and you have the final fragment position. Besides, linear view-space depth is more precision-friendly than post-projection depth.

Anyways, I do not know of a way to make the SSAO work with mentioned depth metric (as I believe it's not linear, SSAO works best with a linear depth measurement). If you decide to change the depth metric of the demo, feel free to find me for help (my deferred shading uses the same linear depth metric).
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

Re: SSAO Compositor

Post by Noman »

Yea, I'm aware that view-space linear depth is a better idea, but was looking to change the minimal amount of shader code to get this up and running. If I change everything to linear depth, I'll have to change all the shaders (including the final color calculation ones) to use this new depth.
However, I might just go ahead and do that :) (seeing as sinbad gave me the heads up to take complete control of the deferred shading demo).
I'll probably go ahead and do it. I'll let you know if i need help.

Thanks!
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

Check out MJP's (from gamedev) blog post here: http://mynameismjp.wordpress.com/2009/0 ... rom-depth/
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: SSAO Compositor

Post by lukeneorm »

Hi to all!
I try to study the great nullsquare shader code to produce VSM shadows, both to improve my shader knowledge and as a starting point to know more about shadow texture algorithms.
As I'm not a GPU pro coder, I spent a lot of time trying to understand all the passages in the shader code (and I still have some questions), so I guess somebody can take this little explanation of VSM shader code as a starting point to understand more about GPU programming. :wink:
In this new topic [https://www.ogre3d.org/forums/viewtopic.php?f=2&t=50786] there is an explanation of what I understood, along with some questions about minor details that I still don't understand. If somebody can help me to answer my questions.. I'll be very happy. :D

Every kind of help will be very appreciated!
lukeneorm
Halfling
Posts: 61
Joined: Wed Apr 01, 2009 12:03 am

Re: SSAO Compositor

Post by lukeneorm »

Hi,
I'm trying to study SSAO compositor code, but I found a lot of problems just in the beginning of the ssao.cg code:

Code: Select all

	struct VIn
	{
		float4 p   : POSITION;
		float3 n   : NORMAL;
		float2 uv  : TEXCOORD0;
	};
	VOut ssao_vs(VIn IN, uniform float4x4 wvp, uniform float3 farCorner)
	{
		VOut OUT;
		OUT.p = mul(wvp, IN.p);
		// clean up inaccuracies for the UV coords
		float2 uv = sign(IN.p);
		// convert to image space
		uv = (float2(uv.x, -uv.y) + 1.0) * 0.5;
		OUT.uv = uv;
		// calculate the correct ray (modify XY parameters based on screen-space quad XY)
		OUT.ray = farCorner * float3(sign(IN.p.xy), 1);
		return OUT;
	}
-> I'm not sure about that, but the pixel POSITION sent to the vertex shader as input is in objecSpace, isn't it? To obtain its position in worldSpace, eyeSpace or clipSpace we should multiply IN.p by world_matrix, worldview_matrix or worldviewproj_matrix. If I am right, why we are using objectSpace coords as uv texture coords?
-> The sign(x) function returns 1 if (x) > 0, -1 if x < 0, 0 otherwise. If we apply sign() to IN.p and store the result in uv, we obtain a 2 component vector [sign(IN.p.x), sign(IN.p.y)]: is it right? If yes, uv values can be only -1, 0 or 1. With float2(uv.x, -uv.y) + 1.0) * 0.5 we transform that values to 0, 0.5 or 1: this makes no sense, since uv is used to sample the geomTexture in ssao_ps, and it can't point only at the border or at the center of the texture! Where was I wrong?
-> What is the function of OUT.ray? I really can't understand it..:(
-> farCorner is passed to the shader by the ssaoListener in the program: it is the far-top-right corner in viewSpace, but.. we calculate OUT.ray using IN.p, wich is in object space, and farCorner, wich is in viewSpace. How can it be right?

Thank you for any kind of help!
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

lukeneorm wrote: -> I'm not sure about that, but the pixel POSITION sent to the vertex shader as input is in objecSpace, isn't it? To obtain its position in worldSpace, eyeSpace or clipSpace we should multiply IN.p by world_matrix, worldview_matrix or worldviewproj_matrix. If I am right, why we are using objectSpace coords as uv texture coords?
wvp is the worldviewproj_matrix, which would put the position in clip-space (and is also used for odd things, like OpenGL render texture flipping). Since we don't want these oldnesses in the UVs, we simply use the object-space position to calculate the screen-space UVs. Technically, we can do the same thing for the final position, but like I said, worldviewproj_matrix is used for odd things.
-> The sign(x) function returns 1 if (x) > 0, -1 if x < 0, 0 otherwise. If we apply sign() to IN.p and store the result in uv, we obtain a 2 component vector [sign(IN.p.x), sign(IN.p.y)]: is it right? If yes, uv values can be only -1, 0 or 1. With float2(uv.x, -uv.y) + 1.0) * 0.5 we transform that values to 0, 0.5 or 1: this makes no sense, since uv is used to sample the geomTexture in ssao_ps, and it can't point only at the border or at the center of the texture! Where was I wrong?
Technically, you shouldn't need to use sign(). I just used it because the Ogre demos use it to "clean up inaccuracies" (for example, if the end position ends up as 0.999997, sign would clean it up to 1.0). Yes, the final UVs can only be 0 or 1. Remember that this is the vertex shader, which is run on a screen-space quadrilateral. There are only 4 vertices, which will have their UVs interpolated to the pixel shader.
-> What is the function of OUT.ray? I really can't understand it..:(
It's the ray from the origin that passes through the corresponding far-clip-plane corner of the camera (in view space). We multiply this by the pixel's depth to find the view-space position.
-> farCorner is passed to the shader by the ssaoListener in the program: it is the far-top-right corner in viewSpace, but.. we calculate OUT.ray using IN.p, wich is in object space, and farCorner, wich is in viewSpace. How can it be right?
We use IN.p to determine which corner we're processing (either left: IN.p.x == -1 or right: IN.p.x == 1; and either top: IN.p.y == 1 or bottom IN.p.y == -1) and multiply this by the far-clip-plane right-top corner to get the "corresponding" corner mentioned above.
User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
x 2
Contact:

Re: SSAO Compositor

Post by Noman »

Converting the DS demo to work with linear depth. Got most of the work done - the GBuffer already contains linear depth info using this formula.
The next step (and i think final one) is to let the light shaders access this info. Having a bit of trouble with this one.

The guide you linked me to says :
Extra-Extra Credit: you can use this technique with arbitrary geometry too, not just quads. You just need to figure out a texture coordinate for each pixel, which you can do by either interpolating the clip-space position and dividing x and y by w, or by using the VPOS semantic. Then for your frustum ray you just calculate the eye->vertex vector and scale it so that it points all the way back to the far-clip plane.
I can't get the geometric calculations straight currently. Lets say I'm currently rendering a sphere for a point light. How do I recreate the screen-space ray using the information i have there? (Lets say I have access to the far clip plane distance or the far corner if I want to)
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 11

Re: SSAO Compositor

Post by nullsquared »

Noman wrote:Converting the DS demo to work with linear depth. Got most of the work done - the GBuffer already contains linear depth info using this formula.
The next step (and i think final one) is to let the light shaders access this info. Having a bit of trouble with this one.

The guide you linked me to says :
Extra-Extra Credit: you can use this technique with arbitrary geometry too, not just quads. You just need to figure out a texture coordinate for each pixel, which you can do by either interpolating the clip-space position and dividing x and y by w, or by using the VPOS semantic. Then for your frustum ray you just calculate the eye->vertex vector and scale it so that it points all the way back to the far-clip plane.
I can't get the geometric calculations straight currently. Lets say I'm currently rendering a sphere for a point light. How do I recreate the screen-space ray using the information i have there? (Lets say I have access to the far clip plane distance or the far corner if I want to)
I linked you the article because I thought that guy did a better job at explaining things than I do :mrgreen:

Anyways, my method slightly deviates from his.

1) he stores viewSpacePos.z / far, but I store length(viewSpacePos.xyz) / far. Technically, you don't need to divide by far unless you need a normalized [0..1] depth (like I do, and like the SSAO compositor uses).

2) light proxy vertex shader:

Code: Select all

...
    vertOut OUT;

    OUT.p = mul(wvpMat, p); // final position = projection * view * world * p

    // nothing special needed

    OUT.uv = OUT.p; // 4 component, no divide by w

    return OUT;
...
light proxy fragment shader:

Code: Select all

...

    float2 fragPos = IN.uv.xy / IN.uv.w; // perspective divide

    // do offset here, after divide-by-W
    fragPos += uvOffset.xy; // uvOffset is 1.0 / float2(viewportWidth, viewportHeight) for Direct3D, float2(0, 0) for OpenGL

    float3 ray = float3(fragPos.x, fragPos.y * flip, 1) * farCorner; // flip is -1 if RenderTarget::requiresTextureFlipping() (for OpenGL), otherwise 1
    // farCorner is passed as a uniform to the pixel shader, it's the far-top-right corner of the camera in view space

    // -1 is because generally +Y is down for textures but up for the screen
    float2 uv = float2(fragPos.x, fragPos.y * -1 * flip) * 0.5 + 0.5; // then we can easily find the UVs to use for indexing

    // my depth is packed in a byte texture, so we need to unpack and "denormalize" by multiplying by the far distance
    float depth = unpack(TEX2DLOD(depthMap, uv)) * far;

    float3 nRay = normalize(ray); // normalize the ray
    float3 viewPos = nRay * depth; // and find the view-space position

    // trick: the vertex-to-eye direction is simply the negated normalized ray
    // (useful for specular)
    float3 viewDir = -nRay;
...

Post Reply