Deferred Rendering
Posted: Mon Mar 22, 2010 5:45 pm
Ok this is the first beta release.
Download (mingw32 and visualstudio) (offline
)
Source Download (offline
)
Kindly packaged by someone else (collection of releases, no idea whats in there actually)
Features:
when u want to use it copy the dll and the shader to your executeable.
and ofcourse link the lib and add the include file.
then just call once
and when everything is done
example code:
picture(note this image doesn't use the standard irr file. i adjusted ambient lightning, particle textures and the radius of the big light so it looks better):
[/list]
Download (mingw32 and visualstudio) (offline

Source Download (offline

Kindly packaged by someone else (collection of releases, no idea whats in there actually)
Features:
- -OpenGL only (dunno if that is really a feature
)
-Pointlights
-Spotlights (with soft shadowmapping(VSM) also transparent objects cast shadows)
-Directionallights
when u want to use it copy the dll and the shader to your executeable.
and ofcourse link the lib and add the include file.
then just call once
Code: Select all
irr::deferred::initDeferredRendering(SceneManager);
Code: Select all
irr::deferred::deinitDeferredRendering();
Code: Select all
#include <irrlicht.h>
#include "IrrlichtDeferredRendering.h"
using namespace irr;
///this is used for the particle lights
class particleLights : public irr::scene::IParticleAffector
{
public:
particleLights(irr::scene::ISceneManager* smgr);
~particleLights(void);
irr::scene::E_PARTICLE_AFFECTOR_TYPE getType() const;
void affect(irr::u32 now, irr::scene::SParticle* particlearray, irr::u32 count);
irr::core::array<irr::scene::ILightSceneNode*> Lights;
irr::scene::ISceneManager* SceneManager;
};
int main(int argc, char** argv)
{
IrrlichtDevice* device = createDevice(irr::video::EDT_OPENGL, core::dimension2d<u32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
device->setWindowCaption(L"Load .irr file example");
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
smgr->loadScene("../../media/example.irr");
scene::ICameraSceneNode * camera = smgr->addCameraSceneNodeFPS(0, 50.f, 0.1f);
camera->setPosition(core::vector3df(0.f, 20.f, 0.f));
///Special code starts here
///Activate deferred rendering
irr::deferred::initDeferredRendering(smgr);
///activate lightning for particles
irr::scene::IParticleSystemSceneNode* particle = (irr::scene::IParticleSystemSceneNode*)smgr->getSceneNodeFromType(irr::scene::ESNT_PARTICLE_SYSTEM);
if (particle)
{
particle->addAffector(new particleLights(smgr));
particle->setParticlesAreGlobal(true);
}
///and ends here
int lastFPS = -1;
while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(0,200,200,200));
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
core::stringw str = L"Load Irrlicht File example - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}
device->drop();
irr::deferred::deinitDeferredRendering();
return 0;
}
///affector implementation
particleLights::particleLights(irr::scene::ISceneManager* smgr) : SceneManager(smgr)
{
for (irr::u32 i=0; i<200; i++)
{
Lights.push_back(SceneManager->addLightSceneNode(NULL, irr::core::vector3df(0,0,0), irr::video::SColor(0,0,0,0)));
Lights[Lights.size()-1]->setVisible(false);
}
}
particleLights::~particleLights(void)
{
for (irr::u32 i=0; i<Lights.size(); i++)
{
Lights[i]->remove();
}
}
irr::scene::E_PARTICLE_AFFECTOR_TYPE particleLights::getType() const
{
return irr::scene::EPAT_NONE;
}
void particleLights::affect(irr::u32 now, irr::scene::SParticle* particlearray, irr::u32 count)
{
//printf("Particle count: %i\n", count);
for (irr::u32 i=0; i<Lights.size(); i++)
{
if (i < count)
{
irr::video::SLight data;
data.DiffuseColor = particlearray[i].color;
data.Radius = particlearray[i].size.Width*2;
Lights[i]->setLightData(data);
Lights[i]->setPosition(particlearray[i].pos);
Lights[i]->setVisible(true);
}
else
{
Lights[i]->setVisible(false);
}
}
}
