XEffects - (Indoor Soft-Shadows + Post-Processing)

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Thanks Halan, the only obvious change I can see (regarding the material types) is the switch for 1 or 2 layers.

I already fixed the material type in that struct into an array, and made a whole new system for defining recievers/casters etc.

I'll improve support for transparent materials (Your version still uses EMT_SOLID as the base material so it wont work on transparent objects), and then make a new release.

PS: Its a bit messy to quote the whole thing, could you use pastebin or upload a file next time?

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
lantis
Posts: 64
Joined: Thu Jun 17, 2004 2:46 pm

Post by lantis »

Hello!
How to use XEffects? ;-)
Small demo work fine, but if im make large terrain and set position
for dwarf for example to 100,100 then all shadows disappear ;(
Also if im make setScale 1,1,1 then only half of shadow visible
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You have to position the camera correctly and set the far value appropriately. If you don't know why, I recommend you google Shadow Maps and read a decent faq.

On another note: Please PM me for inquiries people, theres no use clogging up the announcements forum.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

Post by porcus »

If I use this with OpenGL there are ugly shadow-mistakes. Maybe they are
because the lighting is only per vertex and not per pixel in OpenGL ?
If i use Direct3D9 it works fine.

So, is there any chance to correct this ?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I get identical results for both OpenGL and Direct3D, what video card are you running and also what operating system?
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

Post by porcus »

I have a Geforce 7600GS (with OpenGL 2.1 Support) and Windows XP.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Can you email me some comparison photos to "monstrobishi@gmail.com", I am interested.

Thanks
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
elvman
Posts: 253
Joined: Sun Sep 17, 2006 9:37 am
Location: Riga, Latvia
Contact:

Post by elvman »

Finally got time to test XEffects. The problem is that I didn't manage it to work. Here is the code:

Code: Select all

gEffect =  new effectHandler(gIrrlichtDevice,mSceneManager,dimension2d<s32>(512,512));
	
	gEffect->getLightCamera()->addAnimator(mSceneManager->createFlyCircleAnimator(vector3df(0,20,12),30,0.001f));
	gEffect->getLightCamera()->setPosition(vector3df(3,8,3));
	gEffect->getLightCamera()->setNearValue(1);
	gEffect->setMaxShadowDistanceFromLight(200);
	mSceneManager->addLightSceneNode(gEffect->getLightCamera());

	gEffect->setShadowDarkness(1.0f);
	gEffect->setClearColour(SColor(255,250,255,255));

        mTerrain = sceneManager->addTerrainSceneNode("../media/heightmap.bmp", 0, -1, position);

	mTerrain->setMaterialTexture(0, gVideoDriver->getTexture("../media/newplank.png"));
	mTerrain->setMaterialType(EMT_LIGHTMAP);

	gEffect->addShadowToNode(mTerrain,EFT_8PCF);

	IAnimatedMeshSceneNode* table = sceneManager->addAnimatedMeshSceneNode(sceneManager->getMesh("../meshes/table.x"));
	table->setAutomaticCulling(EAC_FRUSTUM_BOX);
	table->setMaterialType(EMT_SOLID);

	gEffect->addNodeToDepthPass(table);
And here is what I get:
Image
On the left you can see the shadow texture, and on the right: the final rendering.

Plus I have some suggestions:
* You should add a way to pass custom scene manager to effectHandler, because not always Irrlicht users (like me) use default scene manager. It took me about an hour to figure this out (light camera was rendering nothing).
* You should replace std::cout with device->getLogger()->log
* You should allow to select a custom shaders folder. For example, I have a seperate system folder with all the exes and dlls, media, shaders etc. is located at the same level as system, so I had to add "../" to effectHandler.
*You have a this code in effectHandler.cpp:

Code: Select all

driver->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, false);
	ShadowMapTex = driver->createRenderTargetTexture(mapSize);
	driver->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS, true);
You should reset the previous mip map creation state
* And I suggest renaming AddShadowToSceneNode to ReceiveShadows or something like that.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Thank you for the suggestions :D
The problem is that I didn't manage it to work.
I can't see any obvious problem except you are doing "DETAIL_MAP" material but without a detail texture! This will result in a black colour because the first texture is multiplied by 0 (It is not signed-add like it should be, I might change that.) Set a second texture, or use EMT_SOLID (You must set the material before adding the shadow). Also try disabling the lighting on the terrain and check the results, but I doubt that would make too much of a difference.
* You should add a way to pass custom scene manager to effectHandler, because not always Irrlicht users (like me) use default scene manager. It took me about an hour to figure this out (light camera was rendering nothing).
Actually I have recently changed the wrapper to render the scene nodes independently using node->render(). (And I might change it again to driver->drawMeshBuffer()), so what scene manager it belongs to will become irrelevant. (You also will not need to do "excludeNodeFromDepthPass" etc...). This will be included with the next release.
* You should replace std::cout with device->getLogger()->log
Haha, I was actually trying to do this from the start but I only knew of the unexposed static method from inside Irrlicht and didn't know you can access it from the user-app.
* You should allow to select a custom shaders folder. For example, I have a seperate system folder with all the exes and dlls, media, shaders etc. is located at the same level as system, so I had to add "../" to effectHandler.
Yes that was a silly oversight. I might just convert all of the shaders to strings so the user doesn't have to bother with distributing them etc.
You should reset the previous mip map creation state
Will do.
* And I suggest renaming AddShadowToSceneNode to ReceiveShadows or something like that.
I have already changed this system a while ago, but lack of motivation to update documentation etc so that people will not get confused has put me off releasing it. Right now it offers some enums like ESM_CAST, ESM_RECIEVE, ESM_BOTH and when you add a shadow to a node you can do ->addShadowToSceneNode(node,filtertype, ESM_RECIEVE, or cast, etc);
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

Post by porcus »

@BlindSide: Did you get my email ?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Update. Implemented the stuff I promised to elvman (Or most of it at the very least.). The API usage is very very different (There is no need for excludeNodeFromDepthPass, and addNodeToDepthPass is not even related to shadow maps anymore! :shock: )

New features are:
- 16 bit depth support for both DX and OGL.
- New shadow modes for easy configuration of casting/recieving shadows.
- effect->update() now replaces smgr->drawAll(), so remember to not use smgr->drawAll() and instead use effect->update() in its place.
- New post processing support with double buffering, read docs for more info. (Require atleast PS 2.0).
- Demo features bloom effect.
- Screen depth pass for recording screen space depth information to a depth buffer for use in post processing effects such as DOF or SSAO.
- Probably alot of other stuff which I am forgetting to mention.

Have fun.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post by Halifax »

Wow, great stuff BlindSide. Have you ever considered implementing this into the engine, for use in a release or something like that?
TheQuestion = 2B || !2B
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

This shader pack looks really nice:) New features are very good. Thanks BlindSide for Your good work:)

OpenGL mode don't work on my Radeon 2600 PRO. In DirectX all it's ok, but in OpenGL I have many errors in GLSL shader structure.

Code: Select all

rt[0] = driver->createRenderTargetTexture(driver->getScreenSize());
rt[1] = driver->createRenderTargetTexture(driver->getScreenSize());
RTT use in Bloom Effect may cause problem on Graphic Cards without non power of 2 textures if You use getScreenSize(), I think that better options is use predefined resolution for RTT eg, 1024x1024 for 1024x768 screen size etc.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
xray
Posts: 231
Joined: Fri Feb 02, 2007 1:06 pm
Location: Germany, Munich
Contact:

Post by xray »

Awesome Blindside, I will definitely use this in my project!

But I have some problems like Nadro with opengl, here is the output of my console:

Code: Select all

Welcome to the X-Platform Effect Wrapper Demo
Please select the driver type:
1 - OpenGL
2 - Direct3D9
1

Please select the ShadowMap resolution:
1 - 512x512
2 - 1024x1024
3 - 2048x2048
4 - 4096x4096
1

Please select the ShadowMap filtering:
1 - none
2 - 4 PCF
3 - 8 PCF
4 - 12 PCF
5 - 16 PCF
1
Irrlicht Engine version 1.4
Microsoft Windows XP Professional Service Pack 2 (Build 2600)
Using renderer: OpenGL 2.0.6287
Radeon X1900 GT x86/SSE2: ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
GLSL version: 1.2
Loaded texture: wall.bmp
Loaded mesh: ShadRoom.b3d
Loaded texture: axe.jpg
Loaded texture: dwarf.jpg
Could not open file of texture: dwarf2.jpg
Could not open file of texture: dwarf2.jpg
Could not open file of texture: dwarf2.jpg
Loaded mesh: dwarf.x
Loaded texture: red.bmp
GLSL shader failed to compile
ERROR: 0:18: '+' :  wrong operand types  no operation '+' exists that takes a le
ft-hand operand of type '4-component vector of float' and a right operand of typ
e '2-component vector of float' (or there is no acceptable conversion)
ERROR: 0:18: 'texture2D' : no matching overloaded function found
ERROR: 2 compilation errors.  No code generated.


GLSL shader failed to compile
ERROR: 0:18: '+' :  wrong operand types  no operation '+' exists that takes a le
ft-hand operand of type '4-component vector of float' and a right operand of typ
e '2-component vector of float' (or there is no acceptable conversion)
ERROR: 0:18: 'texture2D' : no matching overloaded function found
ERROR: 2 compilation errors.  No code generated.


GLSL shader failed to compile
ERROR: 0:11: 'texture2D' : no matching overloaded function found
ERROR: 0:11: '=' :  cannot convert from 'const float' to '4-component vector of
float'
ERROR: 0:12: 'texture2D' : no matching overloaded function found
ERROR: 0:12: '=' :  cannot convert from 'const float' to '4-component vector of
float'
ERROR: 0:16: 'float4' : no matching overloaded function found
ERROR: 0:18: 'float4' : no matching overloaded function found
ERROR: 6 compilation errors.  No code generated.
My video card is a Radeon X1900GT 256 MB
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

This is what I get for not testing the code on an ATI first :roll: I'll post a fixed bloom shader soon.
RTT use in Bloom Effect may cause problem on Graphic Cards without non power of 2 textures if You use getScreenSize(), I think that better options is use predefined resolution for RTT eg, 1024x1024 for 1024x768 screen size etc.
Hmmm yes I was worrying about this also. I think most cards do support npot rtt, except maybe some ATI cards right? The best solution I think is to make the screen rtt res user-definable, then its up to them to worry about what hardware to support and whether to scale to the nearest power of two etc.

I'll add userdefinable screen rtt, fix bloom shader on the ATI in OGL, then post the updated version soon.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply