Problem with RTT plus billboard

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
ClownieTheMalicious
Posts: 28
Joined: Sun Sep 17, 2006 3:59 pm
Location: iraq

Problem with RTT plus billboard

Post by ClownieTheMalicious »

Alright, I think this was touched on earlier, and i tried the search tool, im sorry im terrible at using it!

The issue is, I created a RTT to a billboard, and the texture appears on the billboard, but upside down!
I'm pretty sure this was an easy fix, I know I've read about it sowhere before. But I'm using 1.3.1 and I am not sure if it's going to be a different fix now.

Any help?

ALSO, to make a circle shaped billboard, do i need to create my own circle billboard scene node? or is there one hiding somewhere (the docs don't exactly have the best of organization...)?

Thanks for the help!
Irme
Posts: 55
Joined: Sat Jul 16, 2005 8:24 am

Post by Irme »

Well for the circle, you can just create a circle image, with the outside of it a color that will be safe to set as the transparency key.

That way it will appear circular.
ClownieTheMalicious
Posts: 28
Joined: Sun Sep 17, 2006 3:59 pm
Location: iraq

Post by ClownieTheMalicious »

yeah, that's true, but then i wouldn't be able to put a render to texture on that, since it would still appear as a square or rectangular shape.
The whole billboard would be taken up.
My final goal is to have an actual circle billboard so i can construct a portal (using a render to texture) similar to the one shown in another thread that has a youtube video.

Right now, if anyone know how to flip the image of the render to texture on a billboard, that would behelpful.
The circular billboard issue is something ill figure out on my own, thanks for the idea though!
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

for a really easy way you can render to a sphere it looks a bit funky but maybe you will like it?

For billbroad:

Umm but I think you should do some texture operations on it, you can set all the alpha value of the mask to 0 in the RTT before applying it to the billboard if you want.
ClownieTheMalicious
Posts: 28
Joined: Sun Sep 17, 2006 3:59 pm
Location: iraq

Post by ClownieTheMalicious »

I already tried the sphere, it was an interesting effect, but not really what i was going for.

To truly get the effect I'm looking for i'd need a flat circular billboard (instead of the flat square one that irrlicht currently has).
That way the image won't be distorted when i render to the circle using the Render to Texture technique.

However, the issue I'm currently having is that when I render a texture (an animation) to the target (the flat square billboard) the image appear upside down, I'm not sure if it's something I did wrong in the creation or what.

here's what i did (it's just a mod of the RTT example)

Code: Select all


...
scene::ISceneNode* test2LightWithBB = smgr->addLightSceneNode(0, core::vector3df(50,50,0), video::SColorf(1.0f, 0.6f, 0.7f, 1.0f), 600.0f);
    
    test2LightWithBB = smgr->addBillboardSceneNode(test2LightWithBB, core::dimension2d<f32>(50, 50));
    
    test2LightWithBB->setMaterialFlag(video::EMF_LIGHTING, false);
	test2LightWithBB->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);
	
    //-----------------------------------------------------------------------//
	
    	// set window caption
	device->setWindowCaption(L"Irrlicht Engine - Render to Texture and Specular Highlights example");
	

	// create render target
	video::ITexture* rt = 0;
	scene::ICameraSceneNode* fixedCam = 0;
	

	if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET))
	{
		rt = driver->createRenderTargetTexture(core::dimension2d<s32>(256,256));
		
        test->setMaterialTexture(0, rt); // set material of sphere to render target
        test2LightWithBB->setMaterialTexture(0,	rt);
        
		// add fixed camera
		fixedCam = smgr->addCameraSceneNode(0, core::vector3df(10,10,-80),
			core::vector3df(-10,10,-100));
	}
	else
	{
		// create problem text
		gui::IGUISkin* skin = env->getSkin();
		gui::IGUIFont* font = env->getFont("../../media/fonthaettenschweiler.bmp");
		if (font)
			skin->setFont(font);

		gui::IGUIStaticText* text = env->addStaticText(
			L"Your hardware or this renderer is not able to use the "\
			L"render to texture feature. RTT Disabled.",
			core::rect<s32>(150,20,470,60));

		text->setOverrideColor(video::SColor(100,255,255,255));
	}
	
	int lastFPS = -1;

	while(device->run())
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, 0);

		if (rt)
		{
			// draw scene into render target
			
			// set render target texture
			driver->setRenderTarget(rt, true, true, video::SColor(0,0,0,255));     

			// make sphere invisible and set fixed camera as active camera
			test->setVisible(false);
			test2LightWithBB->setVisible(false);
			smgr->setActiveCamera(fixedCam);

			// draw whole scene into render buffer
			smgr->drawAll();                 

			// set back old render target
			driver->setRenderTarget(0);      

			// make the sphere visible and set the user controlled camera as active one
			test->setVisible(true);
            test2LightWithBB->setVisible(true);
			smgr->setActiveCamera(fpsCamera);
		}
		
		// draw scene normally
		smgr->drawAll(); 
		env->drawAll();

		driver->endScene();
...

I know it's justa matter of messing with the texture settings, but I can't seem to figure it out...
Is it the way i made the billboard? Or do I need to modify the material settings somehow to flip the image?
Is there a method to flip the rendertotexture target image?
ClownieTheMalicious
Posts: 28
Joined: Sun Sep 17, 2006 3:59 pm
Location: iraq

Post by ClownieTheMalicious »

AND YES, i understand this topic is covered in the documentation.

It says to flip the texture coordinates of the geometry that the render target is created on.
That's great, but that doesn't mean much to me when it's a billboard that I'm displaying the RT on, and I don't know how to flip it's texture coordinates.
Perhaps im merely asking the wrong question- how do you flip the texture coordinates on a billboard?
Post Reply