Can a shader be applied to a RTT ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
eye776
Posts: 94
Joined: Sun Dec 28, 2008 11:07 pm

Can a shader be applied to a RTT ?

Post by eye776 »

For a certain project I'm making I wanted to have hardware accelerated blurring (and other effects) using shaders.

I have an ITexture *Bitmap::Surface.

The problem is that the texture gets drawn but not it's blurred.

hblurpass, vblurpass are classes with a render() method that renders a quad.

Code: Select all

hblurpass->material.setMaterialType((video::E_MATERIAL_TYPE)gpu->addHighLevelShaderMaterial(0, 0, video::EVST_VS_1_1, "hblurpass.hlsl", "main"));

vblurpass->material.setMaterialType((video::E_MATERIAL_TYPE)gpu->addHighLevelShaderMaterial(0, 0, video::EVST_VS_1_1, "vblurpass.hlsl", "main"));
The Bitmap::blur() method goes something like (i don't have the code right now):

Code: Select all

void Bitmap::blur()
{
   // set perspective correction, the rest of the s**t... then

   driver->beginScene();
   driver->setRenderTarget(this->Surface);
   
   driver->draw2DImage(mytexture); //texture gets drawn
   
   hblurpass->render();
   vblurpass->render();
   
   driver->setRenderTarget(0);
   driver->endScene();
}
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

You can't render to an RTT that you are using. That's why you must use 2 RTTs and swap between them when you do the horizontal and the vertical pass and then render the final output.

If you want a source code example there are many bloom shaders in the Code Snippets forum that do the same.

Also you are only setting a vertex shader and not a pixel shader. I don't think you can achieve a blur with only a vertex shader, even if you supply more than one texture coord it will only do one or two reads, you must supply a pixel shader also...
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
eye776
Posts: 94
Joined: Sun Dec 28, 2008 11:07 pm

Post by eye776 »

You can't render to an RTT that you are using. That's why you must use 2 RTTs and swap between them when you do the horizontal and the vertical pass and then render the final output.
OK... that was dumb of me but I had no effing ideea... seriously. Thanks.

Also you are only setting a vertex shader and not a pixel shader. I don't think you can achieve a blur with only a vertex shader, even if you supply more than one texture coord it will only do one or two reads, you must supply a pixel shader also...
err.. my bad, I am setting the pixel shaders too, but the code was reconstructed from memory...
Post Reply