A simple, robust and extendible postprocessing class

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Tannz0rz
Posts: 35
Joined: Fri May 08, 2009 12:25 am
Location: Orlando FL, USA

Post by Tannz0rz »

DavidJE13 wrote:

Code: Select all

      ppMotionBlur->render( NULL ); 
      smgr->drawAll();
I think this is your problem - ppWhatever->render(NULL) replaces smgr->drawAll(). So remove the drawAll and it should be fine. Not sure why it's working without the skybox.
edit: worked it out; it's working when the skybox is disabled because smgr->drawAll isn't filling the screen, so transparent areas are showing the blur. With the skybox, nowhere is transparent during this second render.

btw, you're using non-power-of-two sizes for your post-processing render targets, which is fine but might cause slowdown on some cards (I'm not sure on the details). I'd recommend using 1024x512, unless graphics memory usage is important. This also gives you anti-aliasing on almost all setups for free!
Ohhhh, thanks a lot! It's working perfectly fine now.
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

great :D

So I think now the only things left to do are the final directX conversions and fixing the water. If I've forgotten some bug or feature request please tell me!

Also I'm thinking of adding an XML format for loading shaders (no experience with making such things, but I imagine irrlicht's XML reading is simple enough to use)

Here's a sample of the type of XML I'm thinking of - if anyone has any comments on ways to improve it / can see a limitation it would bring, please tell me.

Code: Select all

<postprocessor name="myEffect" output="pointless">
 <stage name="scene1" type="renderer" clearbackbuffer="yes" clearzbuffer="yes" background="140,120,180" />
 <stage name="fuzzy" type="effect" effect="blur" input="scene1" param1="0.005" quality="fast" />
 <stage name="flare" type="lensFlare" input="fuzzy" />
 <stage name="pointless" type="effect" effect="overlay" input="flare,weird" param1="1.0" disabled="yes" />
 <stage name="weird" type="effect" effect="custom" input="scene1">
  <shader quality="default" language="glsl" version="2.0">(GLSL shader here)</shader>
  <shader quality="default" language="hlsl" src="shader.hlsl" version="2.0" />
  <shader quality="crude" language="glsl" version="1.1">(crude GLSL shader here)</shader>
  <shader quality="crude" language="hlsl" version="1.1">(crude HLSL shader here)</shader>
  <!-- etc -->
 </stage>
</postprocessor>
which would then be set up with;

Code: Select all

IPostProc* ppChain = new CPostProcChain( smgr, "pp.xml", "myEffect" );
((CLensFlarePostProc*) ppChain->find( "flare" ))->setTarget( myObject );
ppChain would be a special node, which usually points to the last effect (as set by the "output" in the xml) which in this case is the pointless overlay. So calling ppChain->render( ); is like calling ppChain->find( "pointless" )->render( );
The renderer will render smgr. To have more than one scene, you would need to specify the others in code, like;

Code: Select all

IPostProc* ppChain = new CPostProcChain( smgr, "pp.xml", "myEffect" );
((CRendererPostProc*) ppChain->find( "scene1" ))->setSceneManager( smgr2 );
To have the chain link to an existing chain, smgr would be replaced with the existing last post processor, and the xml would have input="name1,name2,etc" near output="whatever". So anywhere "name1" appears, the first input is used. "name2" etc. can be set using ppChain->setInput( whatever ); This is another way to allow multiple scene managers.
calling delete ppChain; will delete all effects loaded from the xml file. Calling delete ppChain->find( "pointless" ); will delete only the output, and update ppChain's last effect to be "flare" in this case. Hence ppChain->render( ); will still be valid.
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

If I've forgotten some bug or feature request please tell me!
I have a feature request if you have time. I would like effects like the pen and ink effect and the juicy effect that you can get on some Halo maps(forge). Sorry, no pictures. I am currently at school and can not get to any gaming sites :(
multum in parvo
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

I'd be happy to add them, but I don't know what either would look like, so I'll need some screenshots / shader code!
P1SQ4M
Posts: 66
Joined: Sat Sep 19, 2009 1:47 am

Post by P1SQ4M »

an ACSII render would be sweet, I've seen it done in the demos at Ogre. They have a great list of filters, take a look at there demo, it's sweet.
Edit:
Oh, no... I had most of the effects working from your version last week, but this week I just added the files to a project and the version I downloaded today won't compile. VS++ v9
1>------ Build started: Project: teste, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>IPostProc.cpp
1>CWaterPostProc.cpp
1>CTransitionPostProc.cpp
1>CSplitPostProc.cpp
1>CRendererPostProc.cpp
1>CLensFlarePostProc.cpp
1>Generating Code...
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(264) : warning C4793: 'irr::core::array<irr::video::S3DVertex,irr::core::irrAllocator<irr::video::S3DVertex> >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(264) : warning C4793: 'irr::core::array<float,irr::core::irrAllocator<float> >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(273) : warning C4793: 'irr::core::array<irr::video::S3DVertex,irr::core::irrAllocator<irr::video::S3DVertex> >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(264) : warning C4793: 'irr::core::array<irr::core::rect<float>,irr::core::irrAllocator<irr::core::rect<float> > >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(264) : warning C4793: 'irr::core::array<irr::video::S3DVertex,irr::core::irrAllocator<irr::video::S3DVertex> >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(273) : warning C4793: 'irr::core::array<irr::video::S3DVertex,irr::core::irrAllocator<irr::video::S3DVertex> >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(264) : warning C4793: 'irr::core::array<IPostProc::PSConnector,irr::core::irrAllocator<IPostProc::PSConnector> >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(273) : warning C4793: 'irr::core::array<irr::video::S3DVertex,irr::core::irrAllocator<irr::video::S3DVertex> >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>c:\users\admin\projet\irrlicht-1.5.1\include\irrarray.h(264) : warning C4793: 'irr::core::array<irr::video::S3DVertex,irr::core::irrAllocator<irr::video::S3DVertex> >::operator[]' : function compiled as native :
1> Inline native assembly not supported in managed code
1>Linking...
1>main.obj : error LNK2028: unresolved token (0A0004EA) "public: __thiscall CEffectPostProc::CEffectPostProc(class IPostProc *,class irr::core::dimension2d<int>,enum POSTPROC_EFFECTID,float,float,float,float,float,float,float,float)" (??0CEffectPostProc@@$$FQAE@PAVIPostProc@@V?$dimension2d@H@core@irr@@W4POSTPROC_EFFECTID@@MMMMMMMM@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall CEffectPostProc::CEffectPostProc(class IPostProc *,class irr::core::dimension2d<int>,enum POSTPROC_EFFECTID,float,float,float,float,float,float,float,float)" (??0CEffectPostProc@@$$FQAE@PAVIPostProc@@V?$dimension2d@H@core@irr@@W4POSTPROC_EFFECTID@@MMMMMMMM@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
1>C:\Users\Admin\Desktop\irrlicht-1.5.1\examples\teste\Debug\teste.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://c:\Users\Admin\Desktop\irrlicht-1.5.1\examples\teste\teste\Debug\BuildLog.htm"
1>teste - 3 error(s), 9 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

hmm, looks exactly the same as the problem you had before; have you tried the same fix?
Switch the compiler to /clr and it should work (Go into Project->Properties-> C++, and turn it from clr:pure or clr:safe to just 'Common Language Runtime support')
edit: actually, it would be helpful if some guru could explain what this error means - maybe I can change something in the code so that this setting isn't necessary.

ASCII.. interesting, doubt it can be done in a shader, although I could make a special node for it. I'll take a look at their demo
sp00n
Posts: 114
Joined: Wed Sep 13, 2006 9:39 am

Post by sp00n »

no, no, no David Blane :)
he just forgot to include .cpp and .h files to the project with class CEffectPostProc, it's a typical error for VS development
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

I'd be happy to add them, but I don't know what either would look like, so I'll need some screenshots / shader code!
Sorry no pictures again, i am at school. If you go to bungie.net or google/youtube "Halo 3 forge filters"(I think that's what they call them) you should be able to find something. There are about 5 of them, but most of them have already been implemented, except for the pen and ink one(which looks awesome). Sorry, i don't have the shader code, i am not very good with shaders. I wouldn't even know where to start. :(
multum in parvo
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

What about a watercolor rendering filter?
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Murloc992
Posts: 272
Joined: Mon Apr 13, 2009 2:45 pm
Location: Utena,Lithuania

Post by Murloc992 »

Won't build with SVN Irrlicht :(

Code: Select all

1>------ Build started: Project: Postp, Configuration: Debug Win32 ------
1>Compiling...
1>CSplitPostProc.cpp
1>e:\documents and settings\kompiuterius\my documents\downloads\postprocessor\postprocessor\ipostproc.h(78) : error C2664: 'irr::core::dimension2d<T>::dimension2d(const irr::core::vector2d<T> &)' : cannot convert parameter 1 from 'const irr::core::dimension2d<T>' to 'const irr::core::vector2d<T> &'
1>        with
1>        [
1>            T=irr::s32
1>        ]
1>        and
1>        [
1>            T=irr::u32
1>        ]
1>        and
1>        [
1>            T=irr::s32
1>        ]
1>        Reason: cannot convert from 'const irr::core::dimension2d<T>' to 'const irr::core::vector2d<T>'
1>        with
1>        [
1>            T=irr::u32
1>        ]
1>        and
1>        [
1>            T=irr::s32
1>        ]
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

Same error over and over and over again.

1>e:\documents and settings\kompiuterius\my documents\downloads\postprocessor\postprocessor\crendererpostproc.cpp(17) : warning C4018: '>=' : signed/unsigned mismatch
1>e:\documents and settings\kompiuterius\my documents\downloads\postprocessor\postprocessor\crendererpostproc.cpp(17) : warning C4018: '>=' : signed/unsigned mismatch
1>Generating Code...
1>Build log was saved at "file://e:\Andriaus\CPP Projektai\Postp\Postp\Debug\BuildLog.htm"
1>Postp - 13 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
P1SQ4M
Posts: 66
Joined: Sat Sep 19, 2009 1:47 am

Post by P1SQ4M »

I think I have it setup right (I simply had all the files except main as headers), now I have the cpp as you can see in source. When I run the effects they crash.

Image
Image
sp00n
Posts: 114
Joined: Wed Sep 13, 2006 9:39 am

Post by sp00n »

P1SQ4M
as i see you're using .Net project
sad, but in this case i can't help you :(

but if you want to use a Native C++(not managed), then i could help ;)
also in your screen i see a "for" cycle. can you show this part of code?

edit: just i haven't right now an irrlicht sources, but looks like you have an uninitialised node using
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

ok, a fair bit this time;

sp00n;
are you sure? it doesn't look like that to me. Oh well, I'm not very experienced with VS

Adler1337;
ah yes, I see them. (for anyone else interested, I found a good reference here http://hawtymcbloggy.com/2008/04/05/hal ... e-filters/ ) I think they could all be achieved with the effects I already included... let's see;
* gloomy ~= PP_SATURATE( 0.3 ) + PP_RANGE( 0.3, 0.8 )
* juicy ~= PP_SATURATE( 1.5 )
* old timey ~= PP_SEPIA( )
* pen & ink ~= PP_GREYSCALE( 0.8 ) + PP_BLOOM( 8.0, 0.01, 6.0 ) + PP_RANGE( 0.0, 0.95 )
* nova ~= PP_LIGHTEN( 0.6 ) + PP_BLUR( 0.005 ) + PP_BLOOM( 2.0, 0.003, 2.0 )
* colorblind ~= PP_TINT( 1.0, 1.0, 1.1, 1.0 )
haven't tested these, but that's what they look like to me. You may need to play with the numbers a little.

3DModelerMan;
I can think of a way to do this - I'll give it a go and see how it looks.

Murloc992;
I need to check some things with the new version of Irrlicht to see what's going on. I'll get back to you shortly.
As for the warnings, looks like the new Irrlicht is using unsigned integers for dimensions, which is far more logical than before. I've added a fix for them in the next version.

P1SQ4M;
That error means the MEDIA_DIRECTORY constant is wrong. I set it up to work for my environment, but I guess yours is different. Just change this line in main.cpp;

Code: Select all

#define MEDIA_DIRECTORY "media/"
to

Code: Select all

#define MEDIA_DIRECTORY "../../media/"
(which is what it used to be)

edit: sp00n - yes, you're right about using a NULL node - it's a bit of lazy code in the example, it doesn't test that the sydney model loaded correctly, so the first error is when trying to set the texture.
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

ah yes, I see them. (for anyone else interested, I found a good reference here http://hawtymcbloggy.com/2008/04/05/hal ... e-filters/ ) I think they could all be achieved with the effects I already included... let's see;
* gloomy ~= PP_SATURATE( 0.3 ) + PP_RANGE( 0.3, 0.8 )
* juicy ~= PP_SATURATE( 1.5 )
* old timey ~= PP_SEPIA( )
* pen & ink ~= PP_GREYSCALE( 0.8 ) + PP_BLOOM( 8.0, 0.01, 6.0 ) + PP_RANGE( 0.0, 0.95 )
* nova ~= PP_LIGHTEN( 0.6 ) + PP_BLUR( 0.005 ) + PP_BLOOM( 2.0, 0.003, 2.0 )
* colorblind ~= PP_TINT( 1.0, 1.0, 1.1, 1.0 )
haven't tested these, but that's what they look like to me. You may need to play with the numbers a little.
Thanks, I didn't realize they were already implemented.
multum in parvo
P1SQ4M
Posts: 66
Joined: Sat Sep 19, 2009 1:47 am

Post by P1SQ4M »

It was the media, I moved it once before, I don't know why I didn't think of it...

The effects look great and all seem to work fine :) I think this might be the biggest effect bundle to hit the irrlicht forums! :)
Post Reply