Difference between revisions of "Terrain Extension"
(some fixes: more headers, removed table (tables are not for formatting and fixed width is a no-no), image texts are for describing images.) |
|||
Line 1: | Line 1: | ||
− | [[ | + | [[Category: Extensions]] |
− | {| | + | |
− | | | + | {{Extension_Summary |
− | The Terrain Extension extends Horde3D with the capability to render large landscapes. A special level of detail algorithm adapts the resolution of the terrain mesh so that near regions get more details than remote ones. The algorithm | + | |name = Terrain Extension |
− | + | |screenshot = H3Dterrain.jpg | |
− | A height map is used to define the altitude of the terrain. The height map is a usual texture map that encodes 16 bit height information in two channels. The red channel of the texture contains the coarse height, while the green channel encodes finer graduations. The encoding of the information is usually done with an appropriate tool. If you just want to use 8 bit height information, you can simply copy the greyscale image to the red channel of the height map and leave the green channel black. | + | |description = Terrain Extension in use |
+ | |version = 0.1.0 | ||
+ | |horde3dversion = 0.15 | ||
+ | |released = 2008-03-30 | ||
+ | |author = Nicolas Schulz and Volker Wiendl | ||
+ | }} | ||
+ | |||
+ | The Terrain Extension extends Horde3D with the capability to render large landscapes. | ||
+ | |||
+ | == Features == | ||
+ | |||
+ | === Level of Detail === | ||
+ | |||
+ | A special level of detail algorithm adapts the resolution of the terrain mesh so that near regions get more details than remote ones. The algorithm considers the geometric complexity of the terrain to increase the resolution solely where this is required. This makes the rendering fast and provides a high quality with a minimum of popping artifacts. | ||
+ | |||
+ | === Height map === | ||
+ | |||
+ | A height map is used to define the altitude of the terrain. | ||
+ | |||
+ | The height map is a usual texture map that encodes 16 bit height information in two channels. The red channel of the texture contains the coarse height, while the green channel encodes finer graduations. The encoding of the information is usually done with an appropriate tool. If you just want to use 8 bit height information, you can simply copy the greyscale image to the red channel of the height map and leave the green channel black. | ||
+ | |||
+ | == Installation on Windows == | ||
− | |||
To install the extension, simply copy the contents of the extension root directory to the Horde3D SDK folder and merge the directories. In Visual Studio, add the extension and sample projects to the solution. Then add the extension project to the project dependencies of the Horde3D Engine and the Horde3D Engine to the dependencies of the Terrain Sample. After that, include 'Terrain/extension.h' in 'egExtensions.cpp' of the engine and add '#pragma comment( lib, "Extension_Terrain.lib" )' to link against the terrain extension (under Windows). Finally, add the following line to ExtensionManager::installExtensions to register the extension: | To install the extension, simply copy the contents of the extension root directory to the Horde3D SDK folder and merge the directories. In Visual Studio, add the extension and sample projects to the solution. Then add the extension project to the project dependencies of the Horde3D Engine and the Horde3D Engine to the dependencies of the Terrain Sample. After that, include 'Terrain/extension.h' in 'egExtensions.cpp' of the engine and add '#pragma comment( lib, "Extension_Terrain.lib" )' to link against the terrain extension (under Windows). Finally, add the following line to ExtensionManager::installExtensions to register the extension: | ||
Line 16: | Line 36: | ||
The extension is then part of the Horde3D DLL and can be used with the Horde3DTerrain.h header file. | The extension is then part of the Horde3D DLL and can be used with the Horde3DTerrain.h header file. | ||
− | = Installation Linux = | + | == Installation on Linux == |
Go to your target directory where you want to install Horde3D. Then extract the files, replace versions as needed. | Go to your target directory where you want to install Horde3D. Then extract the files, replace versions as needed. | ||
<pre> | <pre> | ||
Line 97: | Line 117: | ||
Now everything should be working. Go to Horde3D/Binaries/Linux_x86 to try the samples. | Now everything should be working. Go to Horde3D/Binaries/Linux_x86 to try the samples. | ||
− | = Using the extension = | + | == Using the extension == |
The extension defines the uniform *terBlockParams* and the attribute *terHeight* that can be used in a shader to render the terrain. To see how this is working in detail, have a look at the included sample shader. | The extension defines the uniform *terBlockParams* and the attribute *terHeight* that can be used in a shader to render the terrain. To see how this is working in detail, have a look at the included sample shader. | ||
Line 103: | Line 123: | ||
In the Terrain Sample distributed with the extension, there's also a normal map encoded in the heightmap texture. The data for the | In the Terrain Sample distributed with the extension, there's also a normal map encoded in the heightmap texture. The data for the | ||
normal map is encoded in the blue and alpha channel. A simple tool to create such a combined normal height map is integrated in the Horde3D Scene Editor. It can use 8-bit or 16-bit images as heightmap input. In case of 8-bit images you can also specify a smoothing operator to convert the 8-bit heightmap into a more smooth 16-bit one. | normal map is encoded in the blue and alpha channel. A simple tool to create such a combined normal height map is integrated in the Horde3D Scene Editor. It can use 8-bit or 16-bit images as heightmap input. In case of 8-bit images you can also specify a smoothing operator to convert the 8-bit heightmap into a more smooth 16-bit one. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 16:25, 7 June 2008
Terrain Extension | |
Terrain Extension in use | |
Version: | 0.1.0 |
Compatible with Horde3D: | 0.15 |
Release date: | 2008-03-30 |
Author(s): | Nicolas Schulz and Volker Wiendl |
The Terrain Extension extends Horde3D with the capability to render large landscapes.
Contents
Features
Level of Detail
A special level of detail algorithm adapts the resolution of the terrain mesh so that near regions get more details than remote ones. The algorithm considers the geometric complexity of the terrain to increase the resolution solely where this is required. This makes the rendering fast and provides a high quality with a minimum of popping artifacts.
Height map
A height map is used to define the altitude of the terrain.
The height map is a usual texture map that encodes 16 bit height information in two channels. The red channel of the texture contains the coarse height, while the green channel encodes finer graduations. The encoding of the information is usually done with an appropriate tool. If you just want to use 8 bit height information, you can simply copy the greyscale image to the red channel of the height map and leave the green channel black.
Installation on Windows
To install the extension, simply copy the contents of the extension root directory to the Horde3D SDK folder and merge the directories. In Visual Studio, add the extension and sample projects to the solution. Then add the extension project to the project dependencies of the Horde3D Engine and the Horde3D Engine to the dependencies of the Terrain Sample. After that, include 'Terrain/extension.h' in 'egExtensions.cpp' of the engine and add '#pragma comment( lib, "Extension_Terrain.lib" )' to link against the terrain extension (under Windows). Finally, add the following line to ExtensionManager::installExtensions to register the extension:
installExtension( Horde3DTerrain::getExtensionName, Horde3DTerrain::initExtension, Horde3DTerrain::releaseExtension );
The extension is then part of the Horde3D DLL and can be used with the Horde3DTerrain.h header file.
Installation on Linux
Go to your target directory where you want to install Horde3D. Then extract the files, replace versions as needed.
unzip Horde3D_SDK_1.0.0_Beta1.zip unzip Horde3D_ExtTerrain_0.1.1.zip
Now change Horde3D/Source/Horde3D Engine/egExtensions.cpp. Basically just uncomment all lines with code regarding the terrain extension:
--- Horde3D/Source/Horde3D Engine/egExtensions.cpp.old 2008-04-14 23:19:44.000000000 +0200 +++ Horde3D/Source/Horde3D Engine/egExtensions.cpp 2008-04-14 22:56:19.000000000 +0200 @@ -25,16 +25,16 @@ #include "egExtensions.h" // Include files for extensions -//#include "Terrain/Source/extension.h" +#include "Terrain/Source/extension.h" // Lib files for extensions -//#pragma comment( lib, "Extension_Terrain.lib" ) +#pragma comment( lib, "Extension_Terrain.lib" ) bool ExtensionManager::installExtensions() { // Install desired extensions here - //installExtension( Horde3DTerrain::getExtensionName, Horde3DTerrain::initExtension, Horde3DTerrain::releaseExtension ); + installExtension( Horde3DTerrain::getExtensionName, Horde3DTerrain::initExtension, Horde3DTerrain::releaseExtension ); return true; }
Now fix Horde3D/Source/Horde3D Engine/makefile:
--- Horde3D/Source/Horde3D Engine/makefile.old 2008-04-01 20:42:58.000000000 +0200 +++ Horde3D/Source/Horde3D Engine/makefile 2008-04-14 23:09:49.000000000 +0200 @@ -6,13 +6,15 @@ egRenderer.o egResource.o egScene.o egSceneGraphRes.o egShader.o egTextures.o \ utImage.o utOpenGL.o ../Shared/utXMLParser.o +TERRAIN_OBJECTS = ../../../Extensions/Terrain/Source/extension.o ../../../Extensions/Terrain/Source/terrain.o + libHorde3D: $(OBJECTS) - g++ $(OBJECTS) -olibHorde3D.so -lGL -shared + g++ $(OBJECTS) $(TERRAIN_OBJECTS) -olibHorde3D.so -lGL -shared mv libHorde3D.so ../../Binaries/Linux_x86 %.o: %.cpp - g++ -c $< -o$@ -I../Shared -I../../Extensions -fPIC ${CFLAGS} + g++ -c $< -o$@ -I../Shared -I../../../Extensions -fPIC ${CFLAGS} clean:
If you are using the 1.0.0 Beta1 on a 64 bit system you have to fix Horde3D/Source/Horde3D Engine/utImage.cpp:
--- Horde3D/Source/Horde3D Engine/utImage.cpp.old 2008-04-01 23:28:22.000000000 +0200 +++ Horde3D/Source/Horde3D Engine/utImage.cpp 2008-04-14 23:03:28.000000000 +0200 @@ -1257,7 +1257,7 @@ } return e("outofmem", "Out of memory"); } - img_comp[i].data = (uint8*) (((int) img_comp[i].raw_data + 15) & ~15); + img_comp[i].data = (uint8*) (((size_t) img_comp[i].raw_data + 15) & ~15); img_comp[i].linebuf = NULL; }
Now we can compile the project: Call make in the following directories in the specified order:
Extensions/Terrain/Source Horde3D Extensions/Terrain/Sample
Now everything should be working. Go to Horde3D/Binaries/Linux_x86 to try the samples.
Using the extension
The extension defines the uniform *terBlockParams* and the attribute *terHeight* that can be used in a shader to render the terrain. To see how this is working in detail, have a look at the included sample shader.
In the Terrain Sample distributed with the extension, there's also a normal map encoded in the heightmap texture. The data for the normal map is encoded in the blue and alpha channel. A simple tool to create such a combined normal height map is integrated in the Horde3D Scene Editor. It can use 8-bit or 16-bit images as heightmap input. In case of 8-bit images you can also specify a smoothing operator to convert the 8-bit heightmap into a more smooth 16-bit one.