Page 1 of 8

Deferred Rendering

Posted: Mon Mar 22, 2010 5:45 pm
by sudi
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:
  • -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);
 
and when everything is done

Code: Select all

 
irr::deferred::deinitDeferredRendering();
 
example code:

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);
        }
    }
}
 
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):
Image[/list]

Posted: Mon Mar 22, 2010 7:39 pm
by shadowslair
Lol! The screenshot is a killer, but what I get strating the binary is not even close- before compiling the shaders I get a "unsupported texture format" thingy and I get some flat per-vertex lighted scene. Well, using crappy ATI 9550...

Ah, and hell YES! I wanna see more of this!!! :wink:

Posted: Mon Mar 22, 2010 10:25 pm
by sudi
shadowslair wrote:Lol! The screenshot is a killer, but what I get strating the binary is not even close- before compiling the shaders I get a "unsupported texture format" thingy and I get some flat per-vertex lighted scene. Well, using crappy ATI 9550...

Ah, and hell YES! I wanna see more of this!!! :wink:
Indeed it looks crazy with the standard example.irr change to lightradius in the irrFile to 100 or something like that. it will look way better.

Posted: Tue Mar 23, 2010 3:20 am
by sudi
update:
-now spotlights are avaible and working
-started working on transparent refraction

stuff to come:
-shadow maps
-automatic normal/parallax mapping

Posted: Tue Mar 23, 2010 2:00 pm
by ent1ty
Ok, I'm not very familiar with all the technologies used in games, so maybe, tell us what are the advantages/disadvantages of using this lighting instead of the irrlicht's default.

Oh, and what do you mean by "automatic normal/parallax mapping"? something like
IMeshSceneNode* mNode= smgr->addMeshSceneNode(blah blah);
mNode->makeParallaxMappingFromHeightMap("heightmap.bmp");
?

Also, I think, maybe it could be later added to base Irrlicht?

Posted: Tue Mar 23, 2010 3:37 pm
by sudi
ent1ty wrote:Ok, I'm not very familiar with all the technologies used in games, so maybe, tell us what are the advantages/disadvantages of using this lighting instead of the irrlicht's default.
Visual quality? u can have an unlimited ammount of lights contributing to the same scenenode. normal irrlicht rendering is forward rendering which only supports 8 active lights with vertex lightning. the normal_map material is ofcourse per pixel but at max again 8 lights. irrlicht automaticly chooses to activate the 8 closests lights to the camera. The included lightmanager example shows how you can change this behaviour with for example 8 closest lights to scenenode or areas. but all this only works for small objects. Something like the picture i posted is impossible with forward rendering without taking a major performance hit. in that case you would have to draw the mesh for every light. My example scene has more than 200 lights so you would have to draw everything 200times.
ent1ty wrote: Oh, and what do you mean by "automatic normal/parallax mapping"? something like
IMeshSceneNode* mNode= smgr->addMeshSceneNode(blah blah);
mNode->makeParallaxMappingFromHeightMap("heightmap.bmp");
?

Also, I think, maybe it could be later added to base Irrlicht?
well obviusly i am not using the standard irrlicht materialtype behaviour. right now only solid, transparent and transparent_add are fully supported.
Next i will add normalmap/parallax reading for solids so it will support normal/parallax mapping without using tangent meshes. maybe automatic was the wrong word.

Posted: Tue Mar 23, 2010 4:52 pm
by ent1ty
Ok, thanks.

Posted: Tue Mar 23, 2010 8:04 pm
by devsh
I'm only curious how you fitted 200 lights in your shader (i could only put 110 something because i supported diffuse, specular, spot lights etc.)

My lightning was done in world space and Shadow Mapping too (Deffered Cascaded Variance Shadow Maps)

Image Which gives a pretty cool effect

Here you can see mindless lightning
http://www.youtube.com/watch?v=3-r88vbo-LE

Posted: Tue Mar 23, 2010 8:09 pm
by sudi
devsh wrote:I'm only curious how you fitted 200 lights in your shader (i could only put 110 something because i supported diffuse, specular, spot lights etc.)

My lightning was done in world space and Shadow Mapping too (Deffered Cascaded Variance Shadow Maps)
huh? i didn't fit any light in a shader...
Paper
Edit: basicly unlimited ammount of dynamic lights.

Posted: Wed Mar 24, 2010 2:13 am
by sudi
Update added shadowmaps.
Image

download is also in first post

Posted: Wed Mar 24, 2010 3:50 am
by Kalango
Good stuff...
Maybe the devs should start thinking put things like this in the next release... since a big amount of people dont want to "get too serious" with shaders and such...
Its not my case tho |:)

Posted: Wed Mar 24, 2010 4:32 am
by pippy3
Kalango wrote:Good stuff...
Maybe the devs should start thinking put things like this in the next release... since a big amount of people dont want to "get too serious" with shaders and such...
Its not my case tho |:)
this

I'd love for irrlicht to have a smarter lighting system by default

Posted: Wed Mar 24, 2010 6:53 pm
by sudi
ok i think i got it. only problem is my laptop is not fast enough for shadows :wink:
Image
Image

Posted: Wed Mar 24, 2010 10:27 pm
by sudi
ok update uploaded the last posted pictures can now be made with the new version. next thing will be directional shadowmapping and then normalmapping.

Download

Posted: Thu Mar 25, 2010 1:21 am
by etal2009
Will you be adding support for win32-visual studio, linux, and macosx?