XEffects - Reloaded - New Release (V 1.4)

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

Post by BlindSide »

Theres no obvious way to do that without tweaking the shader. It's not an implementation flaw but a logical one, XEffects operates on the principle that a shadow is a lack of light, therefore rather than darkening shadowed areas it "lights" unshadowed areas, producing the yellow blend in the first demo.

For someone like you it should be pretty easy to tweak this in the shader, and instead of return the light value just return 1.0.

More specifically, look for SHADOW_PASS_2P and remove all parts that say:

Code: Select all

 * MVar.y
For OpenGL and

Code: Select all

 * MVar[1]
For Direct3D.

(MVar.y is the light product)
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

Ok thanks.
Thats perfect :wink:

Edit : exept when I'm using 2 lights or more :
This video shows:
1/ one light : the shadow is OK
2/ two lights : kind of glish with the shadow, it desapears and do some strange things.

http://www.youtube.com/watch?v=tyV0PJxeIpQ

I just changed Mval[0] to 1 to get full white + shadow instead of per vertex lighting + shadow. (for the shadows part)

I think (it's what I saw) only shadow1 UNION shadow2 are displayed, shadow1 only or shadow2 only are not. I added a simple line to the shader, after calculating the finalColor.
if(finalColor.xyz==vec3(1,1,1) finalColor=vec4(1,0,0,0);
So full white is rendered red and all other stay like it was. I did that to see if I wasn't missing a very bright shadow over the full white room. But no, however it showed shadows edges, and we can see there is black only at {shadow1 U shadow2}. Note : I have painted an object in green because we couldn't see him clearly.
The second screen shows the original shader finalColor result, including Mval[0], but we can see some shadows artefacts too.

Image

Do you know why it's doing that ?
I just modified :
finalCol = LightColour * lightFactor * MVar.y;
by
finalCol = lightFactor;
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You know what would be cool is if you integrated your shaders with my shadow shader, so instead of doing your lighting seperately, you can put it in the same shader, and you get unlimited lights (Performance will be a bit bad though) with nicer "additive" shadows which look more realistic. I hope you try it.

EDIT: I think you mean Mvar[1] instead of MVar[0]?

To integrate just replace MVar[1] with a value of a white light of your version + add specular to that line.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

I've sucessfully integrated XEffect.
However I had to multiply lightFactor by about 0.8 to let bright shadows appear. When using 1.0, they disapear, so I think lightFactor>1 and then as all values are clamped to 0...1, if bright shadows are >1 then they are clamped to 1 like the lighted environment.
I'll post a screenshot in screenshots topic, however shadows are not clearly visibles when using 3 lights, and the FPS is low (80fps with geforce 260gtx) so I'll make my light manager able to switch on/off shadows and switch from per pixel or hybrid per pixel/vertex to full per vertex lighting. So every user will be happy :roll:

Thanks for all your help, and this really cool XEffect code.
I'll have to make my own soft shadows later, but I would like to move on with my game for now. Thanks again!
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Did you do it like I said by passing your light color in, try with different light colors for each light and I think you will get a nicer effect.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Looks like the download link is broken, it says the domain expired on the 24th.

I've been away for a while and XEffects 1.3 looks really great. I'm excited to see some of it get integrated into Irrlicht in the future.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Ion Dune wrote:domain expired on the 24th.
Oh shi-

EDIT: Ok I renewed the domain but it may take up to 24 hours to propagate. If it takes longer than I probably screwed something up...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
MontyTRC
Posts: 5
Joined: Tue Jun 29, 2010 11:16 am

Post by MontyTRC »

Hi :)

I've a problem with X-Effect: simply I see only a black window when using effect->update() but if I use smgr->DrawAll() my scene is rendered.

I followed the same passes of example 1 for shadow maps but it doesn't work.

Here's my code:

Code: Select all

int main()
{
	int i;

	// crea il device di Irrlicht
	IrrlichtDevice* device=createDevice(E_DRIVER_TYPE::EDT_DIRECT3D9,dimension2d<u32>(800,600),32);
	
	if (!device) 
		return 1;

	device->setWindowCaption(L"OpenTomb Alpha");

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

	EffectHandler* effect = new EffectHandler(device, driver->getScreenSize(), true, true);
	
	bool b=device->getFileSystem()->addFileArchive("C:/Users/Marco/Desktop/Progetti/OpenTomb/Debug/test.zip",true,true,E_FILE_ARCHIVE_TYPE::EFAT_ZIP,"");
	
	IAnimatedMesh* msh=smgr->getMesh("rooms.x");
	IMeshSceneNode* node=0;

	if(msh)
		node=smgr->addOctreeSceneNode(msh->getMesh(0),0,1);

	ITriangleSelector* selector=0;

	if(node)
	{
		selector=smgr->createOctreeTriangleSelector(node->getMesh(),node,1);
		node->setTriangleSelector(selector);
	}

	scene::ICameraSceneNode* camera =
    smgr->addCameraSceneNodeFPS(0, 100.0f, .03f, 0, 0, 0, true, 3.f);
        camera->setPosition(core::vector3df(-410,20,400));
        camera->setTarget(core::vector3df(-490,20,500));

        if (selector)
        {
                scene::ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
                        selector, camera, core::vector3df(5,5,5),
                        core::vector3df(0,-10,0), core::vector3df(0,10,0));
                selector->drop(); // As soon as we're done with the selector, drop it.
                camera->addAnimator(anim);
                anim->drop();  // And likewise, drop the animator when we're done referring to it.
        }
	
	for (i=0;i<node->getMaterialCount();i++)
		node->getMaterial(0).Lighting=false;

	effect->addShadowToNode(node,E_FILTER_TYPE::EFT_NONE);
	effect->setAmbientColor(SColor(255, 64, 64, 64));

	const stringc shaderExt = (driver->getDriverType() == EDT_DIRECT3D9) ? ".hlsl" : ".glsl";

	effect->addPostProcessingEffectFromFile(core::stringc("C:/irrlicht/XEffects/Bin/shaders/BrightPass") + shaderExt);
	effect->addPostProcessingEffectFromFile(core::stringc("C:/irrlicht/XEffects/Bin/shaders/BlurHP") + shaderExt);
	effect->addPostProcessingEffectFromFile(core::stringc("C:/irrlicht/XEffects/Bin/shaders/BlurVP") + shaderExt);
	effect->addPostProcessingEffectFromFile(core::stringc("C:/irrlicht/XEffects/Bin/shaders/BloomP") + shaderExt);

		ILightSceneNode* node2 = smgr->addLightSceneNode(0,core::vector3df(-410,20,400),
                video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 800.0f);

		effect->addShadowLight(SShadowLight(512, vector3df(-410,20,400), vector3df(-49,2,50), 
		SColor(0, 255, 0, 0), 2.0f, 6000.0f, 30.0f * DEGTORAD));
	

	
	// rendering
	while(device->run())
	{
		driver->beginScene(true,true,SColor(0x0));
		effect->getShadowLight(0).setPosition(node2->getPosition());
		effect->update();
		//smgr->drawAll();
		driver->endScene();
	}

	device->drop();

	return 0;
}
Thanks

:)
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

First, is there any error in the console about shaders not being compiled or found? Otherwise it's possible that your light is not positioned or rotated correctly.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
MontyTRC
Posts: 5
Joined: Tue Jun 29, 2010 11:16 am

Post by MontyTRC »

I looked in the output window of Visual C++ and I've found this error message many times:

error X3506: unrecognized compiler target 'vs_3_0'

My videocard is ATI mobility radeon HD4650, that supports shader model 4.1... Very strange :?
MontyTRC
Posts: 5
Joined: Tue Jun 29, 2010 11:16 am

Post by MontyTRC »

OK I've solved. I downloaded DirectX 8 SDK and just recompiled Irrlicht DLL.

It works fine, you've done a nice job :)

Thanks

:D
MikeDee
Posts: 35
Joined: Wed Nov 18, 2009 11:41 pm

Post by MikeDee »

wow really impressive, stefbuet !
Any chance of releasing the source ? :)
MontyTRC
Posts: 5
Joined: Tue Jun 29, 2010 11:16 am

Post by MontyTRC »

How can I integrate normal mapping or parallax mapping with shadows?

Thanks

:D
wing64
Competition winner
Posts: 242
Joined: Wed Jul 23, 2008 2:35 am
Location: Thailand
Contact:

Post by wing64 »

@MontyTRC:
Easy way to combine normal map with shadow ->
1. Rendering normal map to rt0
2. Rendering shadow to rt1
3. Then combine both rt0 and rt1.
Cheers. :D
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

BlindSide, I think you can make your water shader going faster.
When getting the current point position from depth map in world space, you're doing it like this :

Code: Select all

vec3 lVec = LEnd - LStart;
vec3 lDir = normalize(lVec);
float lLenght = length(lVec);
float currentDepth = getDepthAt(TexCoords) * lLenght;
vec3 currentWPos = LStart + currentDepth * lDir;
->getDepthAt return Z/cameraFarZ in view space.

What I don't anderstand is that :

Code: Select all

//you do that:
vec3 currentWPos = LStart + currentDepth * lDir

//which is equal to:
vec3 currentWPos = Lstart + getDepthAt(TextCoords) * normalize(lVec) * lenght(lVec);

//but :
// normalize(lVec) * lenght(lVec) == lVec !

So instead of :
vec3 currentWPos = LStart +getDepthAt(TexCoords) * lLenght * lDir;

Why donc you just do:
vec3 currentWPos = LStart + getDepthAt(TexCoords) * lVec; ?

You save a normalize + lenght operation which is expansive ?
Alright tell me if I'm wrong :P
Post Reply