support for multi-pass shader

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Mancuso Raffaele
Posts: 70
Joined: Sat Dec 17, 2005 4:43 pm
Location: licata (AG) italy
Contact:

support for multi-pass shader

Post by Mancuso Raffaele »

is irrlicht able to process multi-pass shader?
Bye all,
Mancuso Raffaele (Ares FPS game)
thespecial1
Posts: 135
Joined: Thu Oct 30, 2008 11:56 am
Location: UK
Contact:

Post by thespecial1 »

not yet ;0)
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Render targets are your friends... It is possible.
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

thespecial1 wrote:not yet ;0)
Well, how do you think I implemented this fur multipass shader in Irrlicht, like three years ago?

Image
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Post by ACE247 »

Render Targets... :lol:
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

Maybe show us some code how is this done?
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Without giving you code (I'm about to leave for somewhere at the moment), basically you render your object to a render target texture. Then you set that texture to the material of a quad (a pair of triangles), and you set your second pass shader to the material type of that quad. If you need additional passes, you just keep rendering to a render target texture and applying it to a quad, then re-rendering.
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

Isn't that how post-effect shaders are done?
What if I'd like to use 2 shaders: one for terrain rendering and another one for lighting? I assume you have to do at least 2 passes, one for every shader. But then, how do you combine the two resulting textures? Do you just take pixel[0,0] from first texture, then the same pixel from second texture and just * them? Or is this blending done in next, third shader pass?
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

I know with multipass lighting, one method is to render each lighting pass to a texture and then blend all the pass textures with additive blending. Worked like a charm for me.
Kalango
Posts: 157
Joined: Thu Apr 26, 2007 12:46 am

Post by Kalango »

The only poblem is that this is slower thandefault multipassing or backbuffer acess.
Here is Sio2's examples:
http://sio2.g0dsoft.com/modules/wmpdown ... .php?cid=1
Some are open sourced, other are not.
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

OK, so I'm trying to do a very simple thing: draw entire scene onto a plane before the camera. But it somehow does not render the plane, or the plane is transparent. The plane is right before the camera, I checked.

Code: Select all

class CRenderer{
private:
  ISceneManager* smgr;
  IVideoDriver* video;
  IGPUProgrammingServices* gpu;

  ISceneNode* plane;
  ITexture* finalRender;

public:
  CRenderer(stringc folderPath, ISceneManager* nsmgr)
  {
    smgr= nsmgr;
    video= smgr->getVideoDriver();
    gpu= video->getGPUProgrammingServices();

    finalRender= video->addRenderTargetTexture(video->getCurrentRenderTargetSize());

    SMaterial* planeMat= new SMaterial;
    planeMat->setTexture(0, finalRender);

    IMesh* planeMesh= smgr->getGeometryCreator()->createPlaneMesh(dimension2d<f32>(1.94,1.94* (3.0/4.0)), dimension2d<u32>(1,1), planeMat, dimension2d<f32>(1,1));
    plane= smgr->addMeshSceneNode(planeMesh, smgr->getActiveCamera());
    plane->setMaterialFlag(EMF_LIGHTING, false);
    plane->setPosition(vector3df(0, 0, 1));
    plane->setRotation(vector3df(-90, 180, 0));
  }

  void render()
  {
    //array<ISceneNode*>nodes;
    //smgr->getSceneNodesFromType(ESNT_ANY, nodes);

    video->beginScene(true, true);


    video->setRenderTarget(finalRender, true, true, SColor(255,100,0,0));
    plane->setVisible(false);
    smgr->drawAll();

    video->setRenderTarget(0, true, true, SColor(255,0,0,100));
    plane->setVisible(true);
    plane->render();
    smgr->getGUIEnvironment()->drawAll();


    video->endScene();
  }

};
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
ent1ty
Competition winner
Posts: 1106
Joined: Sun Nov 08, 2009 11:09 am

Post by ent1ty »

Could this be caused by 'Unsupported texture format' which is printed out when trying to do finalRender= video->addRenderTargetTexture(video->getCurrentRenderTargetSize());
irrRenderer 1.0
Height2Normal v. 2.1 - convert height maps to normal maps

Step back! I have a void pointer, and I'm not afraid to use it!
sio2
Competition winner
Posts: 1003
Joined: Thu Sep 21, 2006 5:33 pm
Location: UK

Post by sio2 »

ACE247 wrote:Render Targets... :lol:
NO! I used a mulipass material. I even put it in bold! :wink:

NO RENDER TARGETS.
Kalango
Posts: 157
Joined: Thu Apr 26, 2007 12:46 am

Post by Kalango »

Also, rtts ou can simulate post processing via software...its slow tho...
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

sio2 wrote:
ACE247 wrote:Render Targets... :lol:
NO! I used a mulipass material. I even put it in bold! :wink:

NO RENDER TARGETS.
Can you explain what you mean by this? How did you go about it?

Also,
Kalango wrote:Also, rtts ou can simulate post processing via software...its slow tho...
What do you mean by this?
Post Reply