Page 1 of 1

Can a shader be applied to a RTT ?

Posted: Wed Jun 16, 2010 10:53 am
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();
}

Posted: Wed Jun 16, 2010 11:24 am
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...

Posted: Wed Jun 16, 2010 12:18 pm
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...