About Store Forum Documentation Contact



Post Reply 
16,24,32-bit Height Maps?
Author Message
XeonXT Offline
Member

Post: #1
16,24,32-bit Height Maps?
Hello,

I am trying to create height maps with higher bit depth than the IMAGE_I8 used in a heavily-modified version of the Terrain.cpp demo. The heightmap is generated procedurally using loops of .pixel(x,y,height), a .blur, and, finally, mesh.displaceZ.

One or more of these functions, however, is screwing up when I switch to anything other than IMAGE_I8 (IMAGE_I16, IMAGE_I24, IMAGE_I32). My nice terrain suddenly becomes completely flat.

Any ideas on what is going on here/how to do a higher-depth heightmap? The default IMAGE_I8 is showing noticeable artifacts when I create large terrains.

Thanks!
01-18-2010 03:49 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
RE: 16,24,32-bit Height Maps?
Hi,

please wait for the next EE release

I'll enable there bicubic filtering inside displaceZ method (probably it will solve the problem even with only 8-bit heightmaps)

I'll also enable blurring in full precision of 16,24,32 bit formats (currently they are blurred with only 8-bit precision)

And why your terrain is completely flat: when you're using 8-bit formats, the range is from 0..255 which is mapped to 0..1 float
in 16-bit formats range 0..65535 is mapped also to 0..1 float
so you maybe need to increase the scale,

but still please wait for next EE update, I hope to make these new features today
01-18-2010 05:40 PM
Find all posts by this user Quote this message in a reply
XeonXT Offline
Member

Post: #3
RE: 16,24,32-bit Height Maps?
Fantastic, that sounds great and explains the behavior I have been observing.

One more question: is displaceZ incremental? Or does it just "set" the position of each vertex to the image's pixel value?

If displaceZ is not incremental, do you think you could make a version of it that is? In other words, if you call displaceZ with a map, it will create the terrain...but then you could call it with a different map, and it would "add" that map to the terrain that is already there, so you could layer heightmaps.

Thanks very much!
01-18-2010 09:23 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #4
RE: 16,24,32-bit Height Maps?
Hi,

nope its not incremental, its just setting the value,

but it's fairly simple, you can create your own function:

Code:
MeshBase& MeshBase::displaceZ(Image &map,FILTER_TYPE filter)
{
   quadToTri();
   Flt  mulx=map.x()-1,
        muly=map.y()-1;
   Vec *pos =vtx.pos;
   if(map.lock(0,true))
   {
      switch(filter)
      {
         case FILTER_NONE   : REP(vtx.num)(pos++)->z=map.pixelF  (Round(mulx*pos->x),Round(muly*pos->y)); break;
         default            : REP(vtx.num)(pos++)->z=map.pixelFI (      mulx*pos->x ,      muly*pos->y ); break;
         case FILTER_BICUBIC: REP(vtx.num)(pos++)->z=map.pixelFIC(      mulx*pos->x ,      muly*pos->y ); break;
      }
      map.unlock();
   }
   return T;
}
01-18-2010 09:24 PM
Find all posts by this user Quote this message in a reply
XeonXT Offline
Member

Post: #5
RE: 16,24,32-bit Height Maps?
Gotcha, thanks smile
01-18-2010 11:31 PM
Find all posts by this user Quote this message in a reply
Post Reply