Illidanz
23-08-2008 07:46:08
I'm trying to get my game working with 1.0'21, however I'm stuck with the new terrain thing.
I have a 513x513 png heightmap, how should I convert it with flour? I guess I should convert it to .raw but I don't actually know how
Or better: there isn't a way to load png as heightmap with 1.0'21?
betajaen
23-08-2008 10:11:55
Bleeding uses a file format called "xhf" to read saved heightfields, these are converted from RAW with flour.
Of course, your welcome to write your own reader using the ManualHeightfield class if you so wish. I made NxOgre open like that for the many terrain systems we have for Ogre.
Prophet
23-08-2008 10:21:10
Okay, since I know close to nothing about this, I'm not sure if this works. I did like this anyway; I opened the .png in Photoshop, saved it as a .raw and then used
this (which I made) to convert it.
Illidanz
23-08-2008 10:45:55
Bleeding uses a file format called "xhf" to read saved heightfields, these are converted from RAW with flour.
Starting from my png heightmap, how should I export the raw from photoshop? 8 bit greyscale?
I've also read that Flour accepts only power-of-2 size, so I should also scale the image?
Prophet
23-08-2008 10:53:06
That's what I used. I used a 513x513 .png and I got a .nxs, so I just guessed it worked. If
this works, then so should the settings I used. I can't test it, since I don't know how it works.
Good luck!
Illidanz
23-08-2008 19:45:34
Thanks Prophet and betajaen, now at least it doesn't crash when loading the xhf, however I guess I'm doing something wrong with the parameters.
Here's the code I use for loading the heightmap:
NxOgre::Resources::ResourceSystem::getSingleton()->addHeightfieldAs("file://terrain_ps.xhf", "terrain");
NxOgre::Resources::Heightfield* hf = NxOgre::Resources::ResourceSystem::getSingleton()->getHeightfield("terrain");
NxOgre::Terrain* terrain = new NxOgre::Terrain(hf, NxOgre::float3(4096,512,4096), sp, "centering: xz-above, hole-material: 65535");
terrainActor = mScene->createActor("terrain_actor", terrain, Ogre::Vector3(4096,512,4096), "static: yes");
Here's terrain.cfg
# The main world texture (if you wish the terrain manager to create a material for you)
WorldTexture=terrain_texture.png
# The detail texture (if you wish the terrain manager to create a material for you)
DetailTexture=terrain_detail.png
#number of times the detail texture will tile in a terrain tile
DetailTile=50
# Heightmap source
PageSource=Heightmap
# Heightmap-source specific settings
Heightmap.image=terrain.png
# If you use RAW, fill in the below too
# RAW-specific setting - size (horizontal/vertical)
#Heightmap.raw.size=513
# RAW-specific setting - bytes per pixel (1 = 8bit, 2=16bit)
#Heightmap.raw.bpp=2
# How large is a page of tiles (in vertices)? Must be (2^n)+1
PageSize=1025
# How large is each tile? Must be (2^n)+1 and be smaller than PageSize
TileSize=33
# The maximum error allowed when determining which LOD to use
MaxPixelError=3
# The size of a terrain page, in world units
PageWorldX=4096
PageWorldZ=4096
# Maximum height of the terrain
MaxHeight=512
# Upper LOD limit
MaxMipMapLevel=5
VertexNormals=yes
#VertexColors=yes
#UseTriStrips=yes
# Use vertex program to morph LODs, if available
VertexProgramMorph=no
# The proportional distance range at which the LOD morph starts to take effect
# This is as a proportion of the distance between the current LODs effective range,
# and the effective range of the next lower LOD
LODMorphStart=0.2
# This following section is for if you want to provide your own terrain shading routine
# Note that since you define your textures within the material this makes the
# WorldTexture and DetailTexture settings redundant
# The name of the vertex program parameter you wish to bind the morph LOD factor to
# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely
# to the same position as the next lower LOD
# USE THIS IF YOU USE HIGH-LEVEL VERTEX PROGRAMS WITH LOD MORPHING
#MorphLODFactorParamName=morphFactor
# The index of the vertex program parameter you wish to bind the morph LOD factor to
# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely
# to the same position as the next lower LOD
# USE THIS IF YOU USE ASSEMBLER VERTEX PROGRAMS WITH LOD MORPHING
#MorphLODFactorParamIndex=4
# The name of the material you will define to shade the terrain
CustomMaterialName=terrain
The output of Flour was:
[NxOgre] NxOgre 1.0.22 Bleeding Edge started. Working with
[NxOgre] - PhysX => 2.8.0 (280)
[NxOgre] - Ogre => 1.4.6 (Eihort)
[NxOgre] - Hardware => Probably
[NxOgre] - Platform => Windows (Debug)
[NxOgre]
leng:1050625
Sqrt:591.784
Image is 724x724 px @ 16-bit.
Combined wh is 524176 (724, 724)
Byte = 2096704
Size of hfs = 4
[NxOgre] PhysX SDK has stopped.
Is this line correct "Image is 724x724 px @ 16-bit."? The png (converted to raw) was 1025x1025
I'm getting quite confused here, hope someone can help me
betajaen
23-08-2008 20:05:22
1025 isn't a power of two number; it tries to work out the size of the image (assuming it's square from the file size), obviously this doesn't work when you have none n^2 image width/height.
I have changed flour to accept width/height now but that will be out end of the month earliest; or you can modify flour now to accept width/height params, or if that's out of your league, just hardcode it into the heightfield conversion function for the heightfield.
Or you can just you can resize it to 1024 and accept the loss less of one pixel, and make the terrain 1025x1025 meters .
Prophet
23-08-2008 21:12:08
Ah, now I got what means with the power of 2 thing. Thanks betajaen!
SteelX
26-08-2008 03:14:44
i have problem with the xhf file, terrain heightmap is showed but is not collide with the vehicle i have.
there is flour conversion [NxOgre] NxOgre 1.0.22 Bleeding Edge started. Working with
[NxOgre] - PhysX => 2.8.0 (280)
[NxOgre] - Ogre => 1.4.6 (Eihort)
[NxOgre] - Hardware => Probably
[NxOgre] - Platform => Windows (Debug)
[NxOgre]
leng:132098
Sqrt:209.838
Image is 257x257 px @ 16-bit.
Combined wh is 66049 (257, 257)
Byte = 264196
Size of hfs = 4
[NxOgre] PhysX SDK has stopped.
and my terrain cfg file
# Heightmap source
PageSource=Heightmap
# Heightmap-source specific settings
Heightmap.image=heightmap.raw
# RAW-specific setting - size (horizontal/vertical)
Heightmap.raw.size=257
# RAW-specific setting - bytes per pixel (1 = 8bit, 2=16bit)
Heightmap.raw.bpp=2
# How large is a page of tiles (in vertices)? Must be (2^n)+1
PageSize=257
# How large is each tile? Must be (2^n)+1 and be smaller than PageSize
TileSize=33
# The maximum error allowed when determining which LOD to use
MaxPixelError=3
# The size of a terrain page, in world units
PageWorldX=257
PageWorldZ=257
# Maximum height of the terrain
MaxHeight=6.78126
# Upper LOD limit
MaxMipMapLevel=5
# Use vertex program to morph LODs, if available
VertexProgramMorph=yes
LODMorphStart=0.2
CustomMaterialName=Terrain_Shader
other question, can i show terrain xhf wireframe ?
Prophet
26-08-2008 09:58:40
I'm not sure if this is the problem, but the each side must the the power of 2, meaning that you must get an integer when you square root it. So, in your case, remove on pixel on each side, so it is 256x256 (sqrt=16). Try this, or wait for betajaen. (He's the man)
betajaen
26-08-2008 11:10:51
Apart from being the man.
You can also check what the terrain "looks" like in the remote debugger. I turned of rendering the terrain in the debug renderer as either the application crashes or the FPS is reduced to almost zero.
SteelX
03-09-2008 03:44:20
i was trying for a week working with raw format and now i hate that format.
i had tried with múltiple editors but i export raw using power of 2. For instance , i create a terrain with dimension 256x256 32 bits and flour detects 181x181 16 bits. if i export 256x256 16 bits flour parses well but when i take a look on remote debbuger tool and the heightfield repeats about 3 times.
may be is the way i'm trying to load the terrain, isn't enough info how set up heightfield.
could you give me some noob explanation how to get good config with a terrain with 256x256 and 16 bit??.
any help would be apreciated.