Skip to main content

History: Simple SSAO

Source of version: 12 (current)

Copy to clipboard
            __Simple SSAO__  - A 1-class solution for SSAO.
{TOC()}{TOC}
!!Description
To have SSAO in OGRE usually you need tons of code and shaders, well nullsquared posted a [http://www.ogre3d.org/forums/viewtopic.php?t=42350|demo] that avoided that, and it provided a pretty decent quality, so this is his code, converted into 1 easy to use class, which can provide your application with SSAO with only 1 line of code (2 including the header "include" statement).

See [MOGRE Simple SSAO] for Mogre source code.

!!Download
You can find the full pre-compiled demo + source [https://bitbucket.org/iboshkov/simplessao/|here].

!!Usage Instructions

1. Add the sub-directories in the 'data/ssao/materials' directory to your resource locations.
2. Derive all your materials from diffuse_template like so:
{CODE(caption="Sample Material - Sibenik")}import diffuse_template from "diffuse.material"
material sibenik/poplocenje : diffuse_template
{
	technique
	{
		pass
		{
			ambient 0 0 0 1
			diffuse 0.65098 0.647059 0.596078 1

			texture_unit
			{
				texture KAMEN320x240.jpg
			}
		}

	}

}{CODE}

The above example uses one of sibenik's (the "church" in the Deferred Shading Demo) materials. (You need to do this for all of the materials you wish to be affected by the SSAO compositor.)
3. Add this to your code:
{CODE(caption="Initializing SimpleSSAO")}PFXSSAO* mSSAO = new PFXSSAO(mWindow, mCamera);{CODE}
Assuming that mWindow is the render window, and mCamera is of course - the camera. (And they're initialized)

That's it! After that, you've got SSAO on your scene.

!!Screenshots
{IMG(src="http://img156.imageshack.us/img156/1976/portalizednossaolt5.jpg",thumb="y",button="y",height="400",width="500",desc="SSAO Off",alt="SSAO Off")}{IMG}{IMG(src="http://img329.imageshack.us/img329/9673/portalizedssaoly3.jpg",thumb="y",button="y",height="400",width="500",desc="SSAO On",alt="SSAO On")}{IMG}
{IMG(src="http://img212.imageshack.us/img212/1651/portalizednossao3cj8.jpg",thumb="y",button="y",height="400",width="500",desc="SSAO Off",alt="SSAO Off")}{IMG}{IMG(src="http://img515.imageshack.us/img515/1889/portalizedssao3rd7.jpg",thumb="y",button="y",height="400",width="500",desc="SSAO On",alt="SSAO On")}{IMG}
{IMG(src="http://img212.imageshack.us/img212/1651/portalizednossao3cj8.jpg",thumb="y",button="y",height="400",width="500",desc="SSAO Off",alt="SSAO Off")}{IMG}{IMG(src="http://img515.imageshack.us/img515/1889/portalizedssao3rd7.jpg",thumb="y",button="y",height="400",width="500",desc="SSAO On",alt="SSAO On")}{IMG}

!!Credits and related Forum topics
[http://www.ogre3d.org/forums/viewtopic.php?f=11&t=68591|SimpleSSAO - 1 Line SSAO]
[http://www.ogre3d.org/forums/viewtopic.php?f=11&t=47927|SSAO (Screen Space Ambient Occlusion) Demo + Source]
[http://www.ogre3d.org/forums/viewtopic.php?f=11&t=47927|SSAO Compositor]

!!See Also
[http://www.craftworkgames.com/blog/implementing-ssao-in-mogre/|Implementing SSAO in Mogre]