[Zlib/libPNG] SimpleSSAO - 1 Line SSAO | Now on BitBucket!
- Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
[Zlib/libPNG] SimpleSSAO - 1 Line SSAO | Now on BitBucket!
Hello guys and gals of the OGRE Community!
So, this is my first thread in the Showcase forum, I hope anyone finds it useful.
This is a simple class I made for simple implementation of SSAO in anyone's application.
It's based on nullsquared's SSAO demo (Well it's basically the same I just cleaned up the code and made it portable). (Thanks null!)
On:
Off:
<Moved instructions to the BitBucket repository page.>
BitBucket repository: here.
Precompiled demo: here.
Wiki Page: SimpleSSAO.
Hope you find this useful!
Any comments are much appreciated.
Update 20/11/2012: Made some changes that should fix some problems, thanks to ppClarity
Update 1/6/2013: Refactored the source, made some directory changes for the demos and added a few fixes. Changed license to zlib/libpng, now hosting on BitBucket. Also updated to Ogre 1.8.
Update 28/8/2015: Fixed broken repo links from changing my BitBucket username.
So, this is my first thread in the Showcase forum, I hope anyone finds it useful.
This is a simple class I made for simple implementation of SSAO in anyone's application.
It's based on nullsquared's SSAO demo (Well it's basically the same I just cleaned up the code and made it portable). (Thanks null!)
On:
Off:
<Moved instructions to the BitBucket repository page.>
BitBucket repository: here.
Precompiled demo: here.
Wiki Page: SimpleSSAO.
Hope you find this useful!
Any comments are much appreciated.
Update 20/11/2012: Made some changes that should fix some problems, thanks to ppClarity
Update 1/6/2013: Refactored the source, made some directory changes for the demos and added a few fixes. Changed license to zlib/libpng, now hosting on BitBucket. Also updated to Ogre 1.8.
Update 28/8/2015: Fixed broken repo links from changing my BitBucket username.
Last edited by Mind Calamity on Fri Aug 28, 2015 9:53 am, edited 9 times in total.
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
- KungFooMasta
- OGRE Contributor
- Posts: 2087
- Joined: Thu Mar 03, 2005 7:11 am
- Location: WA, USA
- x 16
- Contact:
Re: SimpleSSAO - 1 Line SSAO
Wow! That is super simple! I'm still aways from using fancy effects like SSAO in my projects, but this will definately be of use when I get to that stage. Thanks for the simple release.
Creator of QuickGUI!
-
- Kobold
- Posts: 25
- Joined: Sat Jan 15, 2011 7:11 pm
- x 3
Re: SimpleSSAO - 1 Line SSAO
Can I use Normal and Specular maps too ?
- Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
Re: SimpleSSAO - 1 Line SSAO
Thanks KungFooMasta, the simplicity of your 2D renderer inspired me to do something simple, light and easy-to-use.
You should be able to, although I haven't tried it yet myself.macleod wrote:Can I use Normal and Specular maps too ?
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
- madmarx
- OGRE Expert User
- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 50
Re: SimpleSSAO - 1 Line SSAO
Yeah, null was doing really great stuff with Ogre. Very good that you have put this one in 1 class.
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
- Tubulii
- Gnoblar
- Posts: 5
- Joined: Tue Jul 19, 2011 11:52 am
Re: SimpleSSAO - 1 Line SSAO
Thanks for the release,
but I get several errors when I try to start the precompiled demo:
The plugin file contains to much plugins (which do not exist)
And finally:
Could you fix this?
but I get several errors when I try to start the precompiled demo:
The plugin file contains to much plugins (which do not exist)
And finally:
Code: Select all
OGRE EXCEPTION(7:InternalErrorException): Unable to Set create State: CG ERROR : The parameter used is invalid. in CgFxScriptLoader::CgStateListener::init at D:/Libraries/ogre/PlugIns/CgProgramManager\src/OgreCgProgramManagerDll.cpp (line 67)
- Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
Re: SimpleSSAO - 1 Line SSAO
@Tubulii:
Thanks for reporting that, I didn't notice because I have the Cg toolkit installed.
I included the cg.dll file and removed all the unnecessary plugins that were not included anyway.
So, now it should work.
To save you a sec: Click!
@madmarx:
Yeah, seems so.
Thanks for reporting that, I didn't notice because I have the Cg toolkit installed.
I included the cg.dll file and removed all the unnecessary plugins that were not included anyway.
So, now it should work.
To save you a sec: Click!
@madmarx:
Yeah, seems so.
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
-
- Gremlin
- Posts: 193
- Joined: Sat Aug 06, 2011 11:02 pm
- x 6
Re: SimpleSSAO - 1 Line SSAO
This is pretty awesome. We're still a long ways away from polishing the game and graphics, but once we get there I'm definitely going to try to include this. Great work
I have a few questions:
1.) What do you have to do for shutdown and when is a good time to delete the created PFXSSAO object?
2.) Any idea how to make this work with the depth shadowmap PCF shadows that come with Ogre? Or is it you can only use one or the other? I'm still kind of new to the world of shadow rendering.
I have a few questions:
1.) What do you have to do for shutdown and when is a good time to delete the created PFXSSAO object?
2.) Any idea how to make this work with the depth shadowmap PCF shadows that come with Ogre? Or is it you can only use one or the other? I'm still kind of new to the world of shadow rendering.
- zarfius
- Gnome
- Posts: 367
- Joined: Wed Jan 03, 2007 12:44 pm
- Location: Brisbane, Australia
- x 13
- Contact:
Re: SimpleSSAO - 1 Line SSAO
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
http://www.craftworkgames.com/
- Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
Re: SimpleSSAO - 1 Line SSAO
1. You don't need to delete it at all, as I didn't even create a destructor, but in any case I think OGRE will take care for the shutdown of the compositors, which is what PFXSSAO contains, also I don't even think you need to remove it as a listener from the scene manager either.shenjoku wrote:This is pretty awesome. We're still a long ways away from polishing the game and graphics, but once we get there I'm definitely going to try to include this. Great work
I have a few questions:
1.) What do you have to do for shutdown and when is a good time to delete the created PFXSSAO object?
2.) Any idea how to make this work with the depth shadowmap PCF shadows that come with Ogre? Or is it you can only use one or the other? I'm still kind of new to the world of shadow rendering.
2. I couldn't even implement shadows properly, so I couldn't really try it, I did want to try it with PSSM though, it would look really awesome!
- You can try messing with the diffuse.material to try and make it use shadows too.
Glad you liked it! Good job porting it to C#/MOGRE! Also, any particular reason not to post the code to the wiki directly ?zarfius wrote:I converted this to Mogre. Code is available on my blog.
Thanks Mind Calamity you made it very easy
BTW - Guys since I suck at shader programming, did anyone find how to increase the SSAO range in the shader ?
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
- duststorm
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
- Contact:
Re: SimpleSSAO - 1 Line SSAO
Thanks! I haven't experimented with a lot of these effects either. But with a nice package like this I might be tempted to throw it in my codebase just to try it out. Who know, it might just end up in there.
Just setup your normal/spec material shaders like you would normally, and add SSAO using the compositor framework.
Since normal and spec mapping are regular fragment shaders, and SSAO is a compositor effect applied to the whole image after it is rendered, you can easily use them together without having to combine them into one single shader.macleod wrote:Can I use Normal and Specular maps too ?
Just setup your normal/spec material shaders like you would normally, and add SSAO using the compositor framework.
Developer @ MakeHuman.org
- zarfius
- Gnome
- Posts: 367
- Joined: Wed Jan 03, 2007 12:44 pm
- Location: Brisbane, Australia
- x 13
- Contact:
Re: SimpleSSAO - 1 Line SSAO
Not really, I wanted it on my blog and it's a lot of effort to type it up in both places. I did add a link to it at the bottom of the wiki page though.Mind Calamity wrote:Glad you liked it! Good job porting it to C#/MOGRE! Also, any particular reason not to post the code to the wiki directly ?
Craftwork Games - hand crafted entertainment.
http://www.craftworkgames.com/
http://www.craftworkgames.com/
- duststorm
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
- Contact:
Re: SimpleSSAO - 1 Line SSAO
Does anyone know what the difference is between those two SSAO posts from nullqsuared?
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=42350
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=47927
I can't compare since one of them is offline.
Maybe it's a good idea to post all code examples and demos on the wiki as attachments, so we don't lose them in the future.
Concerning the other SSAO (compositor) implementation of nullsquared, lordsme contributed an improvement that makes it work for semi transparent materials. It's very interesting, have a look here:
http://ogre3d.org/forums/viewtopic.php?p=446784#p446784
Does this version work with semi transparent textures?
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=42350
http://www.ogre3d.org/forums/viewtopic.php?f=11&t=47927
I can't compare since one of them is offline.
Maybe it's a good idea to post all code examples and demos on the wiki as attachments, so we don't lose them in the future.
Concerning the other SSAO (compositor) implementation of nullsquared, lordsme contributed an improvement that makes it work for semi transparent materials. It's very interesting, have a look here:
http://ogre3d.org/forums/viewtopic.php?p=446784#p446784
Does this version work with semi transparent textures?
Developer @ MakeHuman.org
- Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
Re: SimpleSSAO - 1 Line SSAO
I couldn't see the difference between the two (there is a mirrored link at the last page), and it's exactly the same as the one before.
As for that patch by lordsme, I did see it, but unfortunately I don't know how to implement it, if anyone is shader savvy please make the needed modifications.
As for that patch by lordsme, I did see it, but unfortunately I don't know how to implement it, if anyone is shader savvy please make the needed modifications.
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
-
- Kobold
- Posts: 35
- Joined: Mon Jul 18, 2011 2:56 pm
Re: SimpleSSAO - 1 Line SSAO
I'm impressed.
but I got a one problem that all shadows in my game turn blue.
I also fixed shadowTexturePixelFormat to PF_R8G8B8 but no help.
And is there any quick way to modify all material I have?
This SSAOmethod is really good (simplest I've seen) except one fact that need to do modify all the materials.
anyone help?
but I got a one problem that all shadows in my game turn blue.
I also fixed shadowTexturePixelFormat to PF_R8G8B8 but no help.
And is there any quick way to modify all material I have?
This SSAOmethod is really good (simplest I've seen) except one fact that need to do modify all the materials.
anyone help?
- duststorm
- Minaton
- Posts: 921
- Joined: Sat Jul 31, 2010 6:29 pm
- Location: Belgium
- x 80
- Contact:
Re: SimpleSSAO - 1 Line SSAO
You could specify a different material scheme name for the compositor effect, that none of your materials have defined in their .material file.
Then you create a custom MaterialListener and implement your own handleSchemeNotFound() method, where you pass the renderer the correct material. So you create your SSAO materials using code. I experimented with this and gave an example here: http://www.ogre3d.org/forums/viewtopic. ... 75#p437175
Then you create a custom MaterialListener and implement your own handleSchemeNotFound() method, where you pass the renderer the correct material. So you create your SSAO materials using code. I experimented with this and gave an example here: http://www.ogre3d.org/forums/viewtopic. ... 75#p437175
Developer @ MakeHuman.org
-
- Gnome
- Posts: 334
- Joined: Thu Jun 28, 2007 2:12 pm
- Location: Brazil
- x 5
- Contact:
Re: SimpleSSAO - 1 Line SSAO
AFAIK the second one comes as a compositor, easier to integrate.
i wonder what happed to nullsquared, he did some awesome things
i wonder what happed to nullsquared, he did some awesome things
-
- Kobold
- Posts: 35
- Joined: Mon Jul 18, 2011 2:56 pm
Re: SimpleSSAO - 1 Line SSAO
dudeabot//
plz tell me where is second one. I want to try.
BTW, What do you mean for second one?
It's second one of nullsquare's ? or this post's one?
thanks
plz tell me where is second one. I want to try.
BTW, What do you mean for second one?
It's second one of nullsquare's ? or this post's one?
thanks
- Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
Re: SimpleSSAO - 1 Line SSAO
Yeah, the second one is by nullsquared, but I couldn't really get that (or maybe this is the adaption of the second one ?), either way, this code uses a compositor too, it's just that it, and the material and compositor listeners are automatically created.satchigi wrote:dudeabot//
plz tell me where is second one. I want to try.
BTW, What do you mean for second one?
It's second one of nullsquare's ? or this post's one?
thanks
I forgot to add a function to retrieve the compositor instance, but I will in the next patch (I may redo the whole thing).
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
-
- Halfling
- Posts: 75
- Joined: Wed Apr 20, 2011 9:55 pm
- Location: Helsinki, Finland
- x 3
Re: SimpleSSAO - 1 Line SSAO
This looks promising
If you're interested in taking the project further... what about the advanced SSAO algorithms demonstrated with Ogre here?
If you're interested in taking the project further... what about the advanced SSAO algorithms demonstrated with Ogre here?
- Wolfmanfx
- OGRE Team Member
- Posts: 1525
- Joined: Fri Feb 03, 2006 10:37 pm
- Location: Austria - Leoben
- x 99
- Contact:
Re: SimpleSSAO - 1 Line SSAO
This sample is already incorporated in 1.8 Samplebrowser
-
- Gnoblar
- Posts: 19
- Joined: Sun Aug 03, 2008 9:56 pm
- x 1
Re: SimpleSSAO - 1 Line SSAO
Excellent work.
I've incorporated it into my engine.
There are several issues with the shadow as the video below demonstrates.
(1) I added this line to make the shadow shown (otherwise, it doesn't show when light is further away then the objects.)
(2) only point light casts shadows. No shadow from spot or directional light.
(3) When I move camera, shadow gets clipped.
(4) at certain angle, shadow has rough edges.
(5) halo effect.
I've incorporated it into my engine.
There are several issues with the shadow as the video below demonstrates.
(1) I added this line to make the shadow shown (otherwise, it doesn't show when light is further away then the objects.)
Code: Select all
mSceneMgr->setShadowFarDistance( mCamera->getFarClipDistance()+1000 );
(3) When I move camera, shadow gets clipped.
(4) at certain angle, shadow has rough edges.
(5) halo effect.
- Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
Re: SimpleSSAO - 1 Line SSAO
As soon as I finish my current project, I'll see what I can do on improving this (and my knowledge on shaders) and fixing the bugs.
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
-
- Gremlin
- Posts: 194
- Joined: Sat Sep 02, 2006 12:27 am
- x 2
Re: SimpleSSAO - 1 Line SSAO
In shadowTextureCasterPreViewProj() on line 127, the argument passed to setFarClipDistance() is a constant 99990. In nullsquared's original code it uses the range variable set on line 125.
Another thing, his materials look like this:
Changing the farClipDistance back to range and using the above format fixed some problems I was having with illumination and shadows. However I still get some odd shadowing artifacts that I'm trying to hunt down.
Another thing, his materials look like this:
Code: Select all
import diffuse_template from "diffuse.material"
material metal : diffuse_template
{
set_texture_alias ambient_tex RustedMetal.jpg
set_texture_alias diffuse_tex RustedMetal.jpg
}
- Mind Calamity
- Ogre Magi
- Posts: 1255
- Joined: Sat Dec 25, 2010 2:55 pm
- Location: Macedonia
- x 81
Re: SimpleSSAO - 1 Line SSAO
I updated the code and the original post above with the changes you suggested.
Updated code: http://pastebin.com/uSBLgM4X (same link as in the original post, just edited)
Please test it if you can, I don't have OGRE setup properly right now.
Updated code: http://pastebin.com/uSBLgM4X (same link as in the original post, just edited)
Please test it if you can, I don't have OGRE setup properly right now.
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt