Xeffects and CEffectPostProc
Xeffects and CEffectPostProc
Hello
I am using Xeffects and CEffectPostProc. My problem is that both have there own method for rendering that replaces smgr->drawAll(). Xeffects has effect->update() and CEffectPostProc has ppEffect->render(NULL). If i call both, wouldn't that draw the scene twice? Is their an easy way to use both without drawing the scene twice?
I am using Xeffects and CEffectPostProc. My problem is that both have there own method for rendering that replaces smgr->drawAll(). Xeffects has effect->update() and CEffectPostProc has ppEffect->render(NULL). If i call both, wouldn't that draw the scene twice? Is their an easy way to use both without drawing the scene twice?
multum in parvo
What are you using XEffects for and what are you using CPostEffectProc for?
If I'm guessing right that you're using XEffects for shadows and CPostEffectProc for post processing effects then this can be solved in 2 ways (All of which involve me doing something... ):
1. I was thinking to enhance the post processing system in XEffects, the next version in the making will already have some before/after callbacks and the ability to set custom shader constants. In that case you could transfer the post processing stuff to XEffects.
2. I will be implementing shadow maps into Irrlicht sometime in the future. In this case you could just scrap XEffects entirely and just use CPost EffectProc and rely on Irrlicht to do the shadows.
Cheers
If I'm guessing right that you're using XEffects for shadows and CPostEffectProc for post processing effects then this can be solved in 2 ways (All of which involve me doing something... ):
1. I was thinking to enhance the post processing system in XEffects, the next version in the making will already have some before/after callbacks and the ability to set custom shader constants. In that case you could transfer the post processing stuff to XEffects.
2. I will be implementing shadow maps into Irrlicht sometime in the future. In this case you could just scrap XEffects entirely and just use CPost EffectProc and rely on Irrlicht to do the shadows.
Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Thanks for the reply
What would I have to change in the code in order to use both with out rendering everything twice?
You are correct. I am using Xeffects for shadows and CEffectPostProc for its effects.Blindside wrote:What are you using XEffects for and what are you using CPostEffectProc for?
I think it would be awesome if you could enhance Xeffects' post processing effects, but i was really hoping to use CEffectPostProc.Blindside wrote:1. I was thinking to enhance the post processing system in XEffects, the next version in the making will already have some before/after callbacks and the ability to set custom shader constants. In that case you could transfer the post processing stuff to XEffects.
It was be amazing if irrlicht could do shadowmaps, but when is "sometime in the future". If "sometime in the future" is soon then that sounds like my best option, but if it isn't I don't want to use irrlicht's shadows it has now.Blindside wrote:2. I will be implementing shadow maps into Irrlicht sometime in the future. In this case you could just scrap XEffects entirely and just use CPost EffectProc and rely on Irrlicht to do the shadows.
What would I have to change in the code in order to use both with out rendering everything twice?
multum in parvo
-
FuzzYspo0N
- Posts: 914
- Joined: Fri Aug 03, 2007 12:43 pm
- Location: South Africa
- Contact:
Why is changing the code a little the last resort? To me its a couple of lines : Add the effects->update() from XEffects INSIDE of the ppEffect->Render, or vice versa. The most work it would take is including headers or passing a parameter for either of them.
It would make more sense to render shadows first, thats why i suggest adding it to the CEffectPostProc render instead of the other way around
It would make more sense to render shadows first, thats why i suggest adding it to the CEffectPostProc render instead of the other way around
And make sure to set the Output render target param of XEffects to be the one that CEffectPostProc needs to render to.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
No, I think that the param is the output texture not the input texture...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
hi - you'll need to change the code in CRendererPostProc.cpp. Look for smgr->drawAll( ) near the bottom and replace it with whatever code you need to use for XEffects. If it needs a target texture, use target.
(remember to include XEffects headers in the file too!)
You may also need to add some more bits to the code, such as a pointer to the XEffects device (with a function to set it) and maybe an enable/disable flag for convenience.
Hope that helps
(remember to include XEffects headers in the file too!)
You may also need to add some more bits to the code, such as a pointer to the XEffects device (with a function to set it) and maybe an enable/disable flag for convenience.
Hope that helps
Thanks everybody I got it working.
Here is the modified code if anyone wants it.
CRendererPostProc.cpp:
CRendererPostProc.h:
And now your main should look something like this if you want to use XEffects and CEffectPostProc:
And you render same as before:
Here is the modified code if anyone wants it.
CRendererPostProc.cpp:
Code: Select all
#include <irrlicht.h>
#include "CRendererPostProc.h"
#include "XEffects.h"
CRendererPostProc::CRendererPostProc( irr::scene::ISceneManager* sm, DIMENSION2D sOut, bool clearBackBuffer, bool clearZBuffer, irr::video::SColor color ) : IPostProc( sm, sOut ) {
cbb = clearBackBuffer;
czb = clearZBuffer;
setColor( color );
}
void CRendererPostProc::renderEffect( irr::video::ITexture* target ) {
irr::video::IVideoDriver* driver = smgr->getVideoDriver( );
if( enabled ) {
if( supported )
driver->setRenderTarget( target, cbb, czb, c );
else {
if( cbb ) {
if( driver->getViewPort( ).UpperLeftCorner.X <= 0 && driver->getViewPort( ).UpperLeftCorner.Y <= 0 && driver->getViewPort( ).LowerRightCorner.X >= (irr::s32) driver->getCurrentRenderTargetSize( ).Width && driver->getViewPort( ).LowerRightCorner.Y >= (irr::s32) driver->getCurrentRenderTargetSize( ).Height )
driver->beginScene( true, false, c );
else
driver->draw2DRectangle( c, irr::core::rect<irr::s32>( irr::core::position2d<irr::s32>( 0, 0 ), (irr::core::dimension2d<irr::s32>) driver->getCurrentRenderTargetSize( ) ) );
}
if( czb )
driver->clearZBuffer( );
}
if(enableEffects == true)
{
effect->update(target);
}
else
{
smgr->drawAll();
}
}
}
Code: Select all
// PostProcessing framework - Renderer
// Created by David Evans, 2009
#ifndef __C_RENDERER_POST_PROC_H_INCLUDED__
#define __C_RENDERER_POST_PROC_H_INCLUDED__
#include "IPostProc.h"
#include "XEffects.h"
class CRendererPostProc : public IPostProc {
private:
bool cbb;
bool czb;
irr::video::SColor c;
EffectHandler* effect;
bool enableEffects;
public:
CRendererPostProc( irr::scene::ISceneManager* sm, DIMENSION2D sOut, bool clearBackBuffer = true, bool clearZBuffer = true, irr::video::SColor color = irr::video::SColor( 0u, 0u, 0u, 0u ) );
virtual void renderEffect( irr::video::ITexture* target );
bool isClearBackBuffer( ) { return cbb; }
bool isClearZBuffer( ) { return czb; }
irr::video::SColor getColor( ) { return c; }
void setClearBackBuffer( bool on = true ) { cbb = on; }
void setClearZBuffer( bool on = true ) { czb = on; }
void setColor( irr::video::SColor to ) { c = to; c.setAlpha( 0u ); }
void setParameters( bool cb, bool cz, irr::video::SColor col ) { setClearBackBuffer( cbb ); setClearZBuffer( cz ); setColor( col ); }
void setXEffects(EffectHandler* inputXEffect) { effect = inputXEffect; }
void useXEffects(bool useEffects) { enableEffects = useEffects; }
};
#endif
Code: Select all
EffectHandler* effect = new EffectHandler(device, "shaders", ScreenRTT, true);
CRendererPostProc* ppRenderer = new CRendererPostProc(smgr, dimension2d<u32>( 1024, 512 ), true, true, SColor( 255, 100, 101, 140 ));
CEffectPostProc* ppMotionBlur = new CEffectPostProc(ppRenderer, dimension2d<u32>( 1024, 512 ), PP_MOTIONBLUR);
ppRenderer->useXEffects(true);
ppRenderer->setXEffects(effect);
Code: Select all
ppMotionBlur->render(NULL);multum in parvo