IrrRPG Builder

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: IrrRPG Builder

Post by christianclavet »

Hi, Thanks. I understand more your idea. It would be a single texture for the whole tile. It could be a problem in the "long" term, as I actually plan to have more than one type of camera, but for the current mecanic it would work ok I suppose.

Current: point & click fixed following the player (Still need for little improvements)
To implement later: Variation that permit the rotation around the player (neverwinter style)
To implement later: 3Rd person style with variations (Uncharted, etc)
To implement later: First person with variations (Skyrim, Fallout, etc)

Perhap if the hardware can handle it, we could render LOD for the textures, but this could take a lot of video RAM to render a big terrain. With shader, you only have to have the masks in memory. (I could take a 32 bit pic and use 4 channels, so 4 mask). Still this ideas could be used, just need to figure out a way to do it in a way we could change the method for the shaders.

Also implementing the changes you would like to do for the terrain might be not perfect at the moment, as the terrain geometry right now is only a mesh that the engine load. I would like to generate the terrain directly from the engine. (Using smgr->addHillPlaneMesh) That I've not tried yet for this but could really be adequate for the job. Just need to see if the UV coordinates are also properly generated, then would replace the way IRB does the terrain mesh.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: IrrRPG Builder

Post by REDDemon »

Yeah baked terrains can't be used for First person camera. :) (at least they can't without using much vram)

here's some fast coded example

Code: Select all

 
 
#include <irrlicht.h>
#include <cassert>
 
using namespace irr;
 
//simple node for drawing a quad. Based on the irrlicth example of a custom scene node
class CQuadNode : public virtual scene::ISceneNode
{
        core::aabbox3d<f32> Box;
        video::S3DVertex Vertices[4];
        video::SMaterial Material;
        bool Textured;
 
public:
 
        CQuadNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id=-1)
                : scene::ISceneNode(parent, mgr, id)
        {
                Material.Wireframe = false;
                Material.Lighting = false;
                //important!
                Material.TextureLayer[0].TextureWrapU=video::ETC_CLAMP_TO_EDGE;
                Material.TextureLayer[0].TextureWrapV=video::ETC_CLAMP_TO_EDGE;
 
                Textured = false;
 
                Vertices[0] = video::S3DVertex(0,0,0,
                                  0,1,0,
                                video::SColor(255,255,255,255), 0, 0);
 
                Vertices[1] = video::S3DVertex(16,0,0,
                                  0,1,0,
                                video::SColor(255,255,255,255), 1, 0);
                Vertices[2] = video::S3DVertex(16,0,16,
                                  0,1,0,
                                video::SColor(255,255,255,255), 1, 1);
                Vertices[3] = video::S3DVertex(0,0,16,
                                  0,1,0,
                                video::SColor(255,255,255,255), 0, 1);
 
                Box.reset(Vertices[0].Pos);
                for (s32 i=1; i<4; ++i)
                        Box.addInternalPoint(Vertices[i].Pos);
        }
 
        ~CQuadNode()
        {
            if(Material.getTexture(0)!=0)
            Material.getTexture(0)->drop();
        }
 
        void setRenderSurface(irr::video::ITexture * rt)
        {
            assert(rt!=0);
            assert( rt->isRenderTarget()); //we early catch user errors if they forget to provide a render target.
            Material.setTexture(0,rt);
            rt->grab();
            Textured = true;
        }
 
        virtual void OnRegisterSceneNode()
        {
                if (IsVisible)
                        SceneManager->registerNodeForRendering(this);
 
                ISceneNode::OnRegisterSceneNode();
        }
 
        virtual void render()
        {
                u16 indices[] = {       2,1,0, 3,2,0   };
                video::IVideoDriver* driver = SceneManager->getVideoDriver();
 
                driver->setMaterial(Material);
                driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
                driver->drawVertexPrimitiveList(&Vertices[0], 4, &indices[0], 2, video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
        }
 
        virtual const core::aabbox3d<f32>& getBoundingBox() const
        {
                return Box;
        }
 
        virtual u32 getMaterialCount() const
        {
                return 1;
        }
 
        virtual video::SMaterial& getMaterial(u32 i)
        {
                return Material;
        }
};
 
//This demo will show a possible usage of RTT textures.
//We will draw few items on a texture once and then we will use the texture forever.
//This tecnique can be used for updating terrain tiles in a way to achieve high high quality and
//detail thus with high performance. Artist will do great things with this.
 
video::ITexture * splat1 = 0;
video::ITexture * splat2 = 0;
video::ITexture * splat3 = 0;
 
void draw1(irr::video::IVideoDriver* driver);
void draw2(irr::video::IVideoDriver* driver);
 
int main()
{
    IrrlichtDevice *device = createDevice(video::EDT_OPENGL,
                        core::dimension2d<u32>(1000, 600), 32, false);
 
    assert(device!=0);
 
    device->setWindowCaption(L"Example of splatting.");
 
        video::IVideoDriver* driver = device->getVideoDriver();
        scene::ISceneManager* smgr = device->getSceneManager();
 
        ///this example will work only with Render to texture.
        assert(  driver->queryFeature(video::EVDF_RENDER_TO_TARGET)  );
 
        scene::ICameraSceneNode* camera =
                smgr->addCameraSceneNodeFPS(0,15.0f,0.5f);
 
        camera->setPosition(core::vector3df(130,70,11));
        camera->setTarget(core::vector3df(0,0,0));
        camera->setFarValue(1000.0f);
        camera->setNearValue(10.f);
 
 
        // disable mouse cursor
        device->getCursorControl()->setVisible(false);
 
        video::ITexture* rt1 = driver->addRenderTargetTexture(core::dimension2d<u32>(512,512), "RTT1", video::ECF_R8G8B8);
        video::ITexture* rt2 = driver->addRenderTargetTexture(core::dimension2d<u32>(512,512), "RTT2", video::ECF_R8G8B8);
 
        assert(rt1!=0);
        assert(rt2!=0);
 
    splat1 = driver->getTexture("media/stones2.png"); //128x128 image
    splat2 = driver->getTexture("media/wall.png"); //512x512 image
    splat3 = driver->getTexture("media/water.png"); //256x256 image
 
    assert(splat1!=0);
    assert(splat2!=0);
    assert(splat3!=0);
 
 
        CQuadNode *tile1 =
                new CQuadNode(smgr->getRootSceneNode(), smgr);
 
    CQuadNode *tile2 =
        new CQuadNode(smgr->getRootSceneNode(), smgr);
 
 
    tile1->setPosition(core::vector3df(0,0,0));
    tile2->setPosition(core::vector3df(16,0,0)); //place the 2nd tile next to the 1st
    tile1->setScale(core::vector3df(1.0005,1,1.0005));
    tile2->setScale(core::vector3df(1.0005,1,1.0005));
    //is possible that some videocard will show seams on edges (very common bug)
    //so it is better to scale the node in X,Z dimensions by a very small factor (1/1000 or similiar)
 
    tile1->setRenderSurface(rt1);
    tile2->setRenderSurface(rt2);
 
    tile1->drop();
    tile2->drop();
 
    bool Render=true;
    while(device->run())
        {
                driver->beginScene(true, true, video::SColor(0,100,100,100));
 
 
                if(Render)
                {
 
            driver->setRenderTarget(rt1, true, false, video::SColor(0,0,0,0));
            draw1(driver);
 
            driver->setRenderTarget(rt2, true, false, video::SColor(0,0,0,0));
            draw2(driver);
 
            Render = false; //we need just to draw once for this demo.
 
            //you can still draw more often if you want to render to terrain tiles for example
            // but usually there's abosolutely no need for render to tetxures each frame.
            //anyway unless you are going to render 1000 objects to each texture you can
            //do RTT at each frame. (but why upating every frame if not really needed? :D)
            driver->setRenderTarget(0,true,true);
                }
 
                smgr->drawAll();
 
                driver->endScene();
        }
 
        device->drop();
 
        return 0;
}
 
//2 drawing lists. There is only 1 list needed for each RT
void draw1(irr::video::IVideoDriver* driver)
{
    driver->draw2DImage(splat1,core::position2di(110,50),core::recti(0,0,128,128),0,video::SColor(255,255,255,255),true);
    driver->draw2DImage(splat2,core::position2di(256,0),core::recti(0,0,512,512),0,video::SColor(255,255,255,255),true);
}
 
void draw2(irr::video::IVideoDriver* driver)
{
    driver->draw2DImage(splat2,core::position2di(-256,0),core::recti(0,0,512,512),0,video::SColor(255,255,255,255),true);
    driver->draw2DImage(splat3,core::position2di(30,30),core::recti(0,0,256,256),0,video::SColor(255,255,255,255),true);
}
 
and a screen shot ( I modified a bit 3 of the irrlicht's media files with GIMP for adding an alpha layer and some transparency, you can see the wall through the water)
Image
in this example there are 2 tiles of 512x512 size (can be bigger as well) and 3 textures splatted. 1 Texture is splatted twice.


well I worked a lot also with masks and texture atlas . This depends on if you implement new cameras or not :). You can use a mixed approach so that far textures uses a mask while near textures uses few baked terrains with a shader for smooth transition (a bit complex XD but viable). At you the choice. The terrain system you are using now seems enough for baked terrains. You need just to wrap 1 texture across 1 or more tiles (if the tile are small then wrap UV to group of 4 tiles instead of 1 tile).
Textures bigger than 2048x2048 are not needed since most monitors don't have more than 1366 in width.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: IrrRPG Builder

Post by christianclavet »

Hey, Thanks a lot for the demo example!

I will surely experiment with that code after my presentation (31 Jan) to see how I could use it.

Looking at your code, it doest seem too hard to implement. I could perhaps render the basic shader I'm using right now for doing the base texture of the terrain in a RTT then add the stuff the player wants on the texture. Since I'm 100% sure I will add new controls later (with their corresponding camera views), this will not be used everywhere, but I could offer a toggle switch on the application.

I've just read from the internet that RTT's are really slow on Intel hardware, and that I will have to disable the mipmapping on the texture (or render it less frequently) Could be disabled while editing and re-enabled when the tile is no longer worked on...
rubenwardy
Posts: 91
Joined: Mon Mar 05, 2012 4:51 pm
Location: Bristol, UK
Contact:

Re: IrrRPG Builder

Post by rubenwardy »

Very good!

Just tried it.
In the IrrRPG player, when you click stop is goes into an edit mode?
You need to make an exportor for it!

Overwise it is a very program!
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: IrrRPG Builder

Post by christianclavet »

Hi, Rubenwardy!

It goes in "pause" mode. I will have to add GUI for the player (as "new game", "options", and "quit"). That's why the button is still there (play/pause) as in the editor.
In the editor, I would like to have a way to customize thoses Gui when they will be present.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: IrrRPG Builder

Post by REDDemon »

you mean customize with Lua right?
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
christianclavet
Posts: 1638
Joined: Mon Apr 30, 2007 3:24 am
Location: Montreal, CANADA
Contact:

Re: IrrRPG Builder

Post by christianclavet »

REDDemon wrote:you mean customize with Lua right?
I've not decided yet. The first idea, I had was only to change the images assets and text with a simple GUI Editor interface. Doing it with a Lua script could prove useful as it could allow the use to create a new game GUI's... Still, I would like at least to start with my first idea and add scripting later.
eejin
Posts: 97
Joined: Sun Jul 24, 2011 11:50 am

Re: IrrRPG Builder

Post by eejin »

REDDemon wrote:Textures bigger than 2048x2048 are not needed since most monitors don't have more than 1366 in width.
Well its becoming common to see full hd monitors. Btw my old monitor from 5 years ago was already 1650x1050 and thats also a very common resolution.
So I'd just make sure you support full hd screens :P.
Post Reply