OGRE clipmaps terrain sample

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!

Postby Falagard » Fri May 04, 2007 8:57 pm

Thanks!
User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 2060
Kudos: 3
Joined: 26 Feb 2004
Location: Toronto, Canada

Postby Lord LoriK » Sat May 05, 2007 2:06 am

Great! Just tested it... 523k triangles @ 105fps IS something nice...

I've seen something strange, though. Some triangles seem to 'pop' for a frame, giving a noticeable noise. Some images with the triangles marked:
Image
Image
Image
I ran it under Windows XP, both OpenGL and D3D performed equally. I have an NVidia 7300 card.

Somebody else has the same issue?
Lord LoriK
Goblin
 
Posts: 254
Kudos: 0
Joined: 13 Feb 2007

Postby rotalever » Mon May 07, 2007 1:19 pm

I've read the post and it looks like that only the algorithm for the terrain itself was made. No texturing, no compression. I've done the same, not in ogre, but in C and with a Cg-Vertex-Shader (only for geomorphing) some months ago. I was really fast (around 200fps with a 4097² terrain on a Geforce 6800GS).

I am very interested in having a version for ogre with texturing and the suggested compression scheme.

Is there anything going on right now, or is the project dead?
I would be interested in doing a plugin but I am not an expert in compression and have problems in understanding the paper of malvar. If someone makes a C++ function/class available which uses the PTC-Image Coder would be a great help. Another possibility would be to tile the terrain in blocks and use jpg to compress each of the blocks.

The other thing that must be done is applying textures. What would be a good technique? Texture Splatting through shaders? The Alpha maps must be as large as the terrain, how to store them? I want to store the whole terrain in memory because it's very small due to compression, but can the alpha maps be compressed in a similar way?
rotalever
Gnoblar
 
Posts: 21
Kudos: 0
Joined: 06 May 2007

Postby Assaf Raman » Thu Jan 03, 2008 10:41 am

I found a directX implementation (with source) that I didn't know about of "GPU Geometry Clipmaps" on this site: http://filougk.blogspot.com/2007/03/gpu ... ource.html

Get the demo from here: http://www.box.net/shared/6kpclevjmo
And the latest code from here: http://www.box.net/shared/5tjxj2oq3i

There are some directX parts of it that I don't know how to translate to OGRE, it uses functions like "SetStreamSourceFreq" that the OGRE dx render system doesn't use – so it is not that easy to convert the project to OGRE.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
 
Posts: 3092
Kudos: 79
Joined: 11 Apr 2006
Location: TLV, Israel

Postby Falagard » Thu Jan 03, 2008 5:31 pm

Hrm, SetStreamSourceFrequency I've seen used for shader instancing - the true instancing version that only requires you to have one mesh loaded instead of multiple in the same VB.

I'm guessing that this is used for the clipmaps because it's always the same quad with same number of verts, just repeated within the scene a whole bunch of times, so it could probably be done the old fashioned way by creating separate copies of the mesh in question.

Oh yeah, I've seen that demo before. Under the Cecil license, some french license that I think is more restricted than LGPL - closer to GPL.

And I'm sorry, but those controls are so awkward... wow.
User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 2060
Kudos: 3
Joined: 26 Feb 2004
Location: Toronto, Canada

Postby nonifier » Wed Oct 22, 2008 2:56 pm

Hi everybody !



Assaf & Tuan, what's a greate work you have done !!

It's been a while since the last post, so I'm wondering if your projects are still in progress ?

I'm also working on the Gpu implementation of the Geometry Clipmap, so I'm very intresting in your projects :)




Cheers !
User avatar
nonifier
Gnoblar
 
Posts: 13
Kudos: 0
Joined: 21 Jul 2008
Location: Athis-Mons France

Postby Assaf Raman » Thu Oct 23, 2008 5:52 pm

Well, I only converted someone else's project to OGRE here.
I didn't continue on this.
You should look at the NVIDIA sdk for a newer code sample of this idea using DX10.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
 
Posts: 3092
Kudos: 79
Joined: 11 Apr 2006
Location: TLV, Israel

Postby jacmoe » Fri Dec 19, 2008 7:34 pm

Interestingly, someone put a clipmapterrain folder in my ogreaddons.. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Postby sinbad » Fri Dec 19, 2008 10:30 pm

Yep, hellcatv and shirsoft from Stanford have a project they're actively working on,so wanted an addon spot for it. I rarely say no to that kind of offer ;)
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
 
Posts: 19258
Kudos: 69
Joined: 06 Oct 2002
Location: Guernsey, Channel Islands

Postby bishopnator » Sat Dec 20, 2008 3:20 pm

There are some directX parts of it that I don't know how to translate to OGRE, it uses functions like "SetStreamSourceFreq" that the OGRE dx render system doesn't use – so it is not that easy to convert the project to OGRE.

I know that it is pretty old message from Assaf .. I am using SetStreamSourceFreq with DX render system in ogre for HW instancing - it's pretty easy to add support for that feature - I don't know if you need this.

You only need to modify ogre in 3 files:
1) OgreRenderOperation.h
add
Code: Select all
size_t            instancesCount; ///< use 0 for turn off instancing
and init it to 0 in c-tor

2) OgreSceneManager.cpp
in method SceneManager::renderSingleObject reset ro.instancesCount to 0 before calling const_cast<Renderable*>(rend)->getRenderOperation(ro); (little hack - better solution will be setup instancesCount in every getRenderOperation method)

3) OgreD3D9RenderSystem.cpp
turn-on HW instancing:
Code: Select all
      if(op.instancesCount > 0) {
         hr = mpD3DDevice->SetStreamSourceFreq(0, D3DSTREAMSOURCE_INDEXEDDATA | op.instancesCount);
         if(SUCCEEDED(hr)) {
            mpD3DDevice->SetStreamSourceFreq(1, D3DSTREAMSOURCE_INSTANCEDATA | 1);
         }
         if (FAILED(hr))
         {
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to setup geometry instancing", "D3D9RenderSystem::_render" );
         }
      }

turn-off HW instancing:
Code: Select all
      if(op.instancesCount > 0) {
         // finish instancing
         hr = mpD3DDevice->SetStreamSourceFreq(0, 1);
         if( SUCCEEDED( hr ) ) {
            mpD3DDevice->SetStreamSourceFreq(1, 1);
         }
         if (FAILED(hr))
         {
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to unbind geometry instancing", "D3D9RenderSystem::_render" );
         }
      }

Whole method:

Code: Select all
    //---------------------------------------------------------------------
    void D3D9RenderSystem::_render(const RenderOperation& op)
   {
        // Exit immediately if there is nothing to render
        // This caused a problem on FireGL 8800
        if (op.vertexData->vertexCount == 0)
            return;

        // Call super class
      RenderSystem::_render(op);

        // To think about: possibly remove setVertexDeclaration and
        // setVertexBufferBinding from RenderSystem since the sequence is
        // a bit too D3D9-specific?
      setVertexDeclaration(op.vertexData->vertexDeclaration);
        setVertexBufferBinding(op.vertexData->vertexBufferBinding);

      // Determine rendering operation
      D3DPRIMITIVETYPE primType = D3DPT_TRIANGLELIST;
      DWORD primCount = 0;
        switch( op.operationType )
      {
        case RenderOperation::OT_POINT_LIST:
         primType = D3DPT_POINTLIST;
         primCount = (DWORD)(op.useIndexes ? op.indexData->indexCount : op.vertexData->vertexCount);
         break;

      case RenderOperation::OT_LINE_LIST:
         primType = D3DPT_LINELIST;
         primCount = (DWORD)(op.useIndexes ? op.indexData->indexCount : op.vertexData->vertexCount) / 2;
         break;

      case RenderOperation::OT_LINE_STRIP:
         primType = D3DPT_LINESTRIP;
         primCount = (DWORD)(op.useIndexes ? op.indexData->indexCount : op.vertexData->vertexCount) - 1;
         break;

      case RenderOperation::OT_TRIANGLE_LIST:
         primType = D3DPT_TRIANGLELIST;
         primCount = (DWORD)(op.useIndexes ? op.indexData->indexCount : op.vertexData->vertexCount) / 3;
         break;

      case RenderOperation::OT_TRIANGLE_STRIP:
         primType = D3DPT_TRIANGLESTRIP;
         primCount = (DWORD)(op.useIndexes ? op.indexData->indexCount : op.vertexData->vertexCount) - 2;
         break;

      case RenderOperation::OT_TRIANGLE_FAN:
         primType = D3DPT_TRIANGLEFAN;
         primCount = (DWORD)(op.useIndexes ? op.indexData->indexCount : op.vertexData->vertexCount) - 2;
         break;
      }

        if (!primCount)
         return;

      HRESULT hr;
      if(op.instancesCount > 0) {
         hr = mpD3DDevice->SetStreamSourceFreq(0, D3DSTREAMSOURCE_INDEXEDDATA | op.instancesCount);
         if(SUCCEEDED(hr)) {
            mpD3DDevice->SetStreamSourceFreq(1, D3DSTREAMSOURCE_INSTANCEDATA | 1);
         }
         if (FAILED(hr))
         {
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to setup geometry instancing", "D3D9RenderSystem::_render" );
         }
      }

      // Issue the op
      if( op.useIndexes )
      {
            D3D9HardwareIndexBuffer* d3dIdxBuf =
                static_cast<D3D9HardwareIndexBuffer*>(op.indexData->indexBuffer.get());
         hr = mpD3DDevice->SetIndices( d3dIdxBuf->getD3DIndexBuffer() );
         if (FAILED(hr))
            {
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to set index buffer", "D3D9RenderSystem::_render" );
            }

            do
            {
                // do indexed draw operation
             hr = mpD3DDevice->DrawIndexedPrimitive(
                    primType,
                    static_cast<INT>(op.vertexData->vertexStart),
                    0, // Min vertex index - assume we can go right down to 0
                    static_cast<UINT>(op.vertexData->vertexCount),
                    static_cast<UINT>(op.indexData->indexStart),
                    static_cast<UINT>(primCount)
                    );

            } while (updatePassIterationRenderState());
      }
      else
        {
            // nfz: gpu_iterate
            do
            {
                // Unindexed, a little simpler!
             hr = mpD3DDevice->DrawPrimitive(
                    primType,
                    static_cast<UINT>(op.vertexData->vertexStart),
                    static_cast<UINT>(primCount)
                    );

            } while (updatePassIterationRenderState());
        }

      if(op.instancesCount > 0) {
         // finish instancing
         hr = mpD3DDevice->SetStreamSourceFreq(0, 1);
         if( SUCCEEDED( hr ) ) {
            mpD3DDevice->SetStreamSourceFreq(1, 1);
         }
         if (FAILED(hr))
         {
            OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Unable to unbind geometry instancing", "D3D9RenderSystem::_render" );
         }
      }

      if( FAILED( hr ) )
      {
         String msg = DXGetErrorDescription9(hr);
         OGRE_EXCEPT(Exception::ERR_RENDERINGAPI_ERROR, "Failed to DrawPrimitive : " + msg, "D3D9RenderSystem::_render" );
      }
       
   }


How to use HW instancing, just look into DX API - I studied it from this documetation (how to setup vertex buffers) - Efficiently Drawing Multiple Instances of Geometry
User avatar
bishopnator
Goblin
 
Posts: 217
Kudos: 4
Joined: 26 Apr 2007
Location: Slovakia / Switzerland

Re:

Postby jacmoe » Mon Dec 29, 2008 12:13 am

sinbad wrote:Yep, hellcatv and shirsoft from Stanford have a project they're actively working on,so wanted an addon spot for it. I rarely say no to that kind of offer ;)

What license is it under? BSD/MIT/LGPL? :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Re: OGRE clipmaps terrain sample

Postby shirsoft » Mon Jan 05, 2009 12:16 am

Somehow I landed up on this page. Its BSD license.
shirsoft
Gnoblar
 
Posts: 1
Kudos: 0
Joined: 05 Jan 2009

Re: OGRE clipmaps terrain sample

Postby jacmoe » Mon Jan 05, 2009 12:20 am

shirsoft wrote:Somehow I landed up on this page. Its BSD license.

I am following you with great interest! :D
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 20570
Kudos: 181
Joined: 22 Jan 2004
Location: Denmark

Re: OGRE clipmaps terrain sample

Postby stealth977 » Tue Jan 06, 2009 1:09 pm

Last year i worked on a little DirectX project using some kind of clipmapping. What i did was to create a static indexbuffer containing tristrip operations for all detail levels of clipmaps (usually 5 - 6 detail levels), then creating vertex buffers for patches (64 is ok, 128 gives much better detail but high poly count) and updating them when necessary, then its just 1 render call for every detail level of clipmap ( 5 - 6) (each detail level has twice the size of patch so 6 levels with 64 patch size means 4096x4096 terrain, or 5 levels with 128 patch size gives the same terrain size, of course you can decrease the detail to limit the actual rendering area (you can make 3 levels with 128 patch size, meaning the rendering rectangle contains 1024x1024 vertices - though it is reduced to 32768 tris for 0 level, 8192 tris for 1st level, 2048 for 2nd and 512 tris for 3rd level ) to render all terrain.

The application uses some kind of splatting (though its not perfect since it doesnt use alpha maps for layers, the alpha values for layers are contained in vertex data currently 4 layers used). Also i packed 4 terrain textures in 3 textures like ground_r, ground_g,ground_b each containing only 1 channel of every terrain texture so ground_r.r = 1st textures red, ground_r.g = 2nd textures red etc. which makes it only one multiplication with the vector containing layer alphas.

Anyway, on my laptop (2.0Ghz single core, Ati X600 128 MB) it gives around 150 FPS with splating and 4097x4097 16bit map.
Although there is an implementation in code it doesnt use vertex morphing at the moment.For anyone who wants to check how it works, the windows binaries and the full source with textures and data are at:

http://www.bafragroup.com/ogrefiles/clipmap.rar (25MB)
Ismail TARIM
Ogitor - Ogre Scene Editor
WWW:http://www.ogitor.org
Repository: https://bitbucket.org/ogitor
User avatar
stealth977
Gnoll
 
Posts: 637
Kudos: 40
Joined: 15 Dec 2008
Location: Istanbul, Turkey

Re: OGRE clipmaps terrain sample

Postby xiaohe771 » Sat Apr 18, 2009 7:20 am

Help me!
I got source code from svn, there is "Path=../../../bhm/bhm" in the terrain.txt. But Where are the folder "bhm" and the files "bhm*.*"? Help me!!
xiaohe771
Gnoblar
 
Posts: 1
Kudos: 0
Joined: 18 Apr 2009

Re: OGRE clipmaps terrain sample

Postby The_Andreyp » Mon Feb 07, 2011 3:03 pm

Hey Assaf . Mega respect. Can you help me ? I do not understand how to got it working:

1) i use clipmaps like you..
2) i use 6 box planes like you
3) i do not know what is next:

how to find that one shared 6 clipmaps center

i saw your function that tells faceID and coords in (0,1) range inside of this face.. and ?......... what is next ?

thanks
The_Andreyp
Gnoblar
 
Posts: 9
Kudos: 0
Joined: 20 Apr 2007

Re: OGRE clipmaps terrain sample

Postby Assaf Raman » Mon Feb 07, 2011 3:15 pm

Man, I created this thread years ago, I just tried to convert a sample I found, I can't really help you, I don't remember what is going on with this sample.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
 
Posts: 3092
Kudos: 79
Joined: 11 Apr 2006
Location: TLV, Israel

Re: OGRE clipmaps terrain sample

Postby The_Andreyp » Mon Feb 07, 2011 3:28 pm

hm... can you point me onto that sample ?
The_Andreyp
Gnoblar
 
Posts: 9
Kudos: 0
Joined: 20 Apr 2007

Re: OGRE clipmaps terrain sample

Postby Assaf Raman » Mon Feb 07, 2011 3:36 pm

What do you mean? All my work on this topic is on the first few posts on this thread.
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
 
Posts: 3092
Kudos: 79
Joined: 11 Apr 2006
Location: TLV, Israel

Re: OGRE clipmaps terrain sample

Postby The_Andreyp » Mon Feb 07, 2011 3:57 pm

you mentioned you used other sample..

i guess you took heightmapped clipmaps (in 2d)

and you made em as spherical self ? but you just do not remember how does it work ?
The_Andreyp
Gnoblar
 
Posts: 9
Kudos: 0
Joined: 20 Apr 2007

Re: OGRE clipmaps terrain sample

Postby Assaf Raman » Mon Feb 07, 2011 4:13 pm

heightmapped, I don't remember the spherical version of it, but - look for "clipmaps" on this page (not OGRE - but source code).
Watch out for my OGRE related tweets here.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
 
Posts: 3092
Kudos: 79
Joined: 11 Apr 2006
Location: TLV, Israel

Re: OGRE clipmaps terrain sample

Postby The_Andreyp » Tue Feb 08, 2011 7:33 am

thx
The_Andreyp
Gnoblar
 
Posts: 9
Kudos: 0
Joined: 20 Apr 2007

Previous

Return to Showcase

Who is online

Users browsing this forum: MSNbot Media and 2 guests