I think he actually is talking about post-processing, but doesn't know how to re-render the texture that he had previously rendered to the texture. If that's the case, tank202, here is a ScreenQuad SceneNode that you can use. I'm pretty sure this comes courtesy of Mel, but I may be wrong.
Code: Select all
#pragma once
#include <irrlicht.h>
using namespace irr;
class CScreenQuadSceneNode : public scene::ISceneNode{
core::aabbox3df aabb; //An axis aligned bounding box. Actually not needed.
video::SMaterial material; //The material used to render the Scene Node
video::S3DVertex2TCoords vertices[4]; //The vertices of the Scene Node.
//Normally we wouldn't need more
//than one set of UV coordinates.
//But if we are to use the builtin materials, this is necesary
public:
CScreenQuadSceneNode::CScreenQuadSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id)
:ISceneNode(parent,mgr,id)
{
f32 shiftX,shiftY;
core::dimension2d<u32> currentResolution;
/**Here we initialize the vertices of the screen Aligned quad*/
currentResolution = mgr->getVideoDriver()->getScreenSize();
aabb.reset(0,0,0);
shiftX = 0; //This small shift is necesary to compensate the texture sampling bias
shiftY = 0; //It avoids that our effect becomes too blurry.
vertices[0] = video::S3DVertex2TCoords(
-1.0f,-1.0f,0.0f,
0.0f,0.0f,-1.0f,
video::SColor(255,255,255,255),
shiftX,1+shiftY,
shiftX,1+shiftY);
vertices[1] = video::S3DVertex2TCoords(
1.0f,-1.0,0.0f,
0.0f,0.0f,-1.0f,
video::SColor(255,255,255,255),
1.0f+shiftX,1+shiftY,
1.0f+shiftX,1+shiftY);
vertices[2] = video::S3DVertex2TCoords(
-1.0f,1.0,0.0f,
0.0f,0.0f,-1.0f,
video::SColor(255,255,255,255),
shiftX,shiftY,
shiftX,shiftY);
vertices[3] = video::S3DVertex2TCoords(
1.0f,1.0f,0.0f,
0.0f,0.0f,-1.0f,
video::SColor(255,255,255,255),
1.0f+shiftX,shiftY,
1.0f+shiftX,shiftY);
/**Now we proceed to initialize the appropriate settings for the material we are going to use
We can alter these later, but for the time being, initializing then here will do no harm*/
material.Lighting = false; //No need for lighting.
material.MaterialType = video::EMT_LIGHTMAP_ADD; //This will add both first and second textures :)
material.BackfaceCulling=false; //not needed, but simplifies things
setAutomaticCulling(scene::EAC_OFF); //We don't need this scene
//node to be culled because we render it in screen space.
}
CScreenQuadSceneNode::~CScreenQuadSceneNode()
{
}
const core::aabbox3df& CScreenQuadSceneNode::getBoundingBox() const
{
return aabb;
}
void CScreenQuadSceneNode::OnRegisterSceneNode()
{
//This method is empty because it is best for us to render this scene node manually.
//So, it is never really rendered on its own, if we don't tell it to do so.
}
void CScreenQuadSceneNode::render()
{
video::IVideoDriver* drv = getSceneManager()->getVideoDriver();
core::matrix4 proj;
u16 indices[] = {0,1,2,3,1,2};
//A triangle list
drv->setMaterial(material);
drv->setTransform(video::ETS_PROJECTION, core::IdentityMatrix);
drv->setTransform(video::ETS_VIEW, core::IdentityMatrix);
drv->setTransform(video::ETS_WORLD, core::IdentityMatrix);
drv->drawIndexedTriangleList(&vertices[0],4,&indices[0],2);
}
u32 CScreenQuadSceneNode::getMaterialCount()
{
return 1; //There is only one material
}
video::SMaterial& CScreenQuadSceneNode::getMaterial(irr::u32 i)
{
return material;//We always return the same material, so there is no need for more.
}
};
To use it, you just need to create an instance of it like so:
Code: Select all
CScreenQuadSceneNode* screenQuad = new CScreenQuadSceneNode(smgr->getRootSceneNode(),smgr,-1);
You will need to set it's texture to your RTT, and then set the material type to some Material type that you've defined for your shader:
Code: Select all
screenQuad->getMaterial(0).setTexture(0,rtt);
screenQuad->getMaterial(0).MaterialType = (E_MATERIAL_TYPE) yourMaterial;
And then when you render, you need to first render your scene to the RTT, then you can change the render target back to the framebuffer (or I guess another RTT, if you want to do another step), and render your Screen Quad:
Code: Select all
driver->setRenderTarget(rtt, true, true, SColor(0,0,0,255));
smgr->drawAll();
driver->setRenderTarget(ERT_FRAME_BUFFER, true, false, SColor(0,0,0,255));
screenQuad->render();
Please note, I don't really do this stuff very much, so it might not be wholly accurate! However, I think it shows the general idea, and I think it works
![Laughing :lol:](./images/smilies/icon_lol.gif)