A simple, robust and extendible postprocessing class

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

Haven't tried the latest version yet, but i have been trying my program(with last version and new #define GL_OLDMONITOR ) on a lot of different computers. I noticed that it works about 50% of the time and the other 50% it only shows the top 1/4 of the screen.
multum in parvo
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

Bug in Irrlicht or my code?
saw this in the example.

Instead of device->drop(); try calling device->closeDevice(); instead.
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

I tried the latest version. It compiles fine, but when i start it up, it crashes(my project and the example). Not sure what is going on.
multum in parvo
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

FuzzYspo0N; thanks, I'll try it next time I'm on a windows box

Adler1337; eek.. I guess you mean all the examples? I can think of a few things I changed so I'll see if I can work out what's going on. Have you tried switching it to DIRECT3D9 instead of OPENGL?
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

I guess you mean all the examples?
Yeah it happens to all of the examples and my project.
Have you tried switching it to DIRECT3D9 instead of OPENGL?
When i use DIRECT3D9 and run, it says "HLSL vertex shader compilation failed: error X3501: 'main': entrypoint not found". It displays that 3 times.

When i use opengl it doesn't display anything. It just crashes. And this is what it displays in the call stack:
> Mars.exe!CEffectPostProc::setShader(const char * prog_gl=0x0043db18, const char * prog_dx=0x0043dbb0, irr::video::E_PIXEL_SHADER_TYPE gl_ps=EPST_PS_1_1, irr::video::E_PIXEL_SHADER_TYPE dx_ps=EPST_PS_2_0, irr::video::SMaterial * tgt=0x022d3dcc) Line 496 + 0xa bytes C++

Mars.exe!CEffectPostProc::setShader(const char * prog_gl=0x0043db18, const char * prog_dx=0x0043dbb0, irr::video::E_PIXEL_SHADER_TYPE gl_ps=EPST_PS_1_1, irr::video::E_PIXEL_SHADER_TYPE dx_ps=EPST_PS_2_0) Line 86 + 0x44 bytes C++

Mars.exe!CEffectPostProc::CEffectPostProc(IPostProc * follow1=0x0034dc98, irr::core::dimension2d<int> sOut={...}, POSTPROC_EFFECTID effectID=PP_RANGE, float para1=0.00000000, float para2=1.0000000, float para3=7285624.0, float para4=7285624.0, float para5=7285624.0, float para6=7285624.0, float para7=7285624.0, float para8=7285624.0) Line 190 C++

Mars.exe!CEffectPostProc::CEffectPostProc(IPostProc * follow1=0x0034dc98, irr::core::dimension2d<int> sOut={...}, POSTPROC_EFFECTID effectID=PP_NIGHTVISION, float para1=0.50000000, float para2=0.0049999999, float para3=0.30000001, float para4=7285624.0, float para5=7285624.0, float para6=7285624.0, float para7=7285624.0, float para8=7285624.0) Line 109 + 0x89 bytes C++

Mars.exe!wmain(int argc=1, wchar_t * * argv=0x003459e8) Line 269 + 0xbc bytes C++
(This changes to where ever an effect is.)

Mars.exe!__tmainCRTStartup() Line 583 + 0x19 bytes C

Mars.exe!wmainCRTStartup() Line 403 C


I tried changing my code around, but it still does the same thing. I don't know what is happening. :(
multum in parvo
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

ok, FuzzYspo0N - thanks, that seems to have removed the error, although I'm not sure if closeDevice is doing everything that's needed - it now behaves as though I'd simply removed the drop line (not sure what more I expected it to do!)

Adler1337 - I've tidied up some constructors (before I wasn't initializing everything properly) which may fix your problem. Do you get any errors like "An unhandled exception of type 'System.NullReferenceException' occurred in PostProcessor.exe"? because the bug you're seeing is in some code which is nearly identical to another bit which is apparently working! Confusing.
I also made the incomplete directX shaders act like a PP_DIRECT shader, so you'll be able to run your program in DIRECT3D9 mode now, though some effects won't work.

New version's at the same place as always.
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

Thanks! Everything seems to be working now, even the old monitor effect. :D
multum in parvo
Tannz0rz
Posts: 35
Joined: Fri May 08, 2009 12:25 am
Location: Orlando FL, USA

Post by Tannz0rz »

Just downloaded this, everything compiles correctly, I think that I might implementing the code correctly, yet the shaders do not work.

I'm not sure what the problem is, it might be the fact that I'm not using it correctly. Could anyone display how to properly use the motion blur shader?
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

Code: Select all

	IPostProc* ppRenderer = new CRendererPostProc(smgr, dimension2di( 1024, 512 ), true, true, SColor( 255, 100, 101, 140 ) );
	CEffectPostProc* ppMotionBlur = new CEffectPostProc( ppRenderer, dimension2di( 1024, 512 ), PP_MOTIONBLUR);
while(device->run())
	{
			driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9);
			ppMotionBlur->render(NULL);
			guienv->drawAll();
			driver->endScene();	

   }
Hope this helps. Also there is main.cpp to look at.
multum in parvo
Tannz0rz
Posts: 35
Joined: Fri May 08, 2009 12:25 am
Location: Orlando FL, USA

Post by Tannz0rz »

Adler1337 wrote:

Code: Select all

	IPostProc* ppRenderer = new CRendererPostProc(smgr, dimension2di( 1024, 512 ), true, true, SColor( 255, 100, 101, 140 ) );
	CEffectPostProc* ppMotionBlur = new CEffectPostProc( ppRenderer, dimension2di( 1024, 512 ), PP_MOTIONBLUR);
while(device->run())
	{
			driver->beginScene( false, driver->getDriverType( ) == video::EDT_DIRECT3D9);
			ppMotionBlur->render(NULL);
			guienv->drawAll();
			driver->endScene();	

   }
Hope this helps. Also there is main.cpp to look at.
It's still not working for some reason.
Last edited by Tannz0rz on Sun Sep 27, 2009 11:36 pm, edited 2 times in total.
Adler1337
Posts: 471
Joined: Sat Aug 09, 2008 6:10 pm
Location: In your base.

Post by Adler1337 »

It might be that your computer can't handle the shaders. What are your specs? If you post some code or any error messages i might be able to help you more.
multum in parvo
Tannz0rz
Posts: 35
Joined: Fri May 08, 2009 12:25 am
Location: Orlando FL, USA

Post by Tannz0rz »

Adler1337 wrote:It might be that your computer can't handle the shaders. What are your specs? If you post some code or any error messages i might be able to help you more.
Found the problem, apparently the skybox I was using was somehow stopping the shaders, anyone else have this problem?
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

Tannz0rz wrote:Found the problem, apparently the skybox I was using was somehow stopping the shaders, anyone else have this problem?
odd - if you can post the code you're using I may be able to fix that.
(I think m_krzywy uses a skybox in his project with this. Probably a problem with a specific type of skybox)

Adler1337;
hurrah! glad it's all working :D
Tannz0rz
Posts: 35
Joined: Fri May 08, 2009 12:25 am
Location: Orlando FL, USA

Post by Tannz0rz »

DavidJE13 wrote:
Tannz0rz wrote:Found the problem, apparently the skybox I was using was somehow stopping the shaders, anyone else have this problem?
odd - if you can post the code you're using I may be able to fix that.
(I think m_krzywy uses a skybox in his project with this. Probably a problem with a specific type of skybox)

Adler1337;
hurrah! glad it's all working :D
Well, I've found that it won't work with any skybox nor skydome that I have whatsoever.
I'll just toss in the main portion of the code:

Code: Select all

int main(int argc, char** argv) 
{ 
	MyEventReceiver receiver; 
	IrrlichtDevice *device = 
	createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 16, 
	false, false, false, &receiver); 

	IVideoDriver* driver = device->getVideoDriver(); 
	ISceneManager* smgr = device->getSceneManager(); 
	IGUIEnvironment* guienv = device->getGUIEnvironment(); 
	ply = smgr->addCubeSceneNode(); 
	IAnimatedMesh * movingplane; 

	movingplane = smgr->addHillPlaneMesh("floor", 
	core::dimension2d<f32>(20,20), 
	core::dimension2d<u32>(40,40), 0, 0, 
	core::dimension2d<f32>(0,0), 
	core::dimension2d<f32>(10,10)); 
/*
	scene::ISceneNode* skybox=smgr->addSkyBoxSceneNode(
	driver->getTexture("media/skybox/nightsky_up2.png"),
	driver->getTexture("media/skybox/nightsky_down.png"),
	driver->getTexture("media/skybox/nightsky_north.png"),
	driver->getTexture("media/skybox/nightsky_south.png"),
	driver->getTexture("media/skybox/nightsky_east.png"),
	driver->getTexture("media/skybox/nightsky_west.png"));

	smgr->addSkyDomeSceneNode(driver->getTexture("media/SKY_DOME.jpg"));
*/
	IAnimatedMeshSceneNode *floor=smgr->addAnimatedMeshSceneNode(movingplane);
	if (ply) 
	{ 
		ply->setMaterialFlag(EMF_LIGHTING, false);
		ply->setPosition(vector3df(100,0,100));
	} 

	camera = smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));

	IPostProc* ppRenderer = new CRendererPostProc(smgr, dimension2di( 640, 480 ), true, true, SColor( 255, 100, 101, 140 ) ); 
    CEffectPostProc* ppMotionBlur = new CEffectPostProc( ppRenderer, dimension2di( 640, 480 ), PP_MOTIONBLUR);

	while(device->run()) 
	{ 

		UpdateCamera();
		driver->beginScene(true, true, SColor(0,200,200,200)); 
		ppMotionBlur->render( NULL );
		smgr->drawAll(); 
		guienv->drawAll(); 

		driver->endScene(); 
	}

	return 0; 
}
DavidJE13
Posts: 165
Joined: Tue Jan 09, 2007 7:17 pm

Post by DavidJE13 »

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!
Post Reply