目錄

PLSM2

    假設(shè),你可能已經(jīng)對(duì)你的選擇進(jìn)行了評(píng)估,并決定開(kāi)始使用Paging Scene Manager。

    如果你對(duì)怎樣編譯并安裝Paging Scene Manager感興趣, 參見(jiàn) Paging Scene Manager Installation。如果你對(duì)使用PLSM2創(chuàng)建新的應(yīng)用程序感興趣,參見(jiàn) Creating a PLSM Application

    Paging Scene Manager 允許將場(chǎng)景分割成多個(gè)pages。這些pages只有在需要被加載的時(shí)刻才會(huì)被加載到內(nèi)存中,當(dāng)然也允許你武斷地加載一塊非常大的場(chǎng)景。每個(gè)page使用自己的heightmap,每個(gè) heightmap可以使用多層紋理。(例如:你可以為大雪覆蓋的山頂單獨(dú)應(yīng)用一塊表示積雪的紋理。)

    目前的最新版本是paging landscape manager 2 (PLSM2),好像PLSM3還需要等待一段時(shí)間。(我對(duì)這個(gè)比較擔(dān)憂)

    A good Introduction to PLSM2 use is Terrain Scene Manager, from which PLSM2 is derived and why would you use heightmaps

   關(guān)于PLSM2的一些幫助,bug,請(qǐng)求,及較集中的討論在 這里 可以看到,在發(fā)帖之前請(qǐng)閱讀已經(jīng)發(fā)過(guò)的帖子。
    最新的win32二進(jìn)制Demo和示例地圖在 這里 (03/07/2005)
    SVN上的PLSM2代碼是最新版本的源代碼, 僅僅與最新的Ogre (1.6 及更高版本)兼容。
    已經(jīng)打包的可供下載的源代碼與OGRE v1.2兼容,可以在 這里 下載。

    SVN上目前有4個(gè)部分可以使用:

    你可能還會(huì)看到其它一些文件夾:WIP (IPLSM) 或者老版本的PLSM1

Plugin

介紹

    plugin包含了所有你需要的關(guān)于terrain scene manager的東西,而不僅僅是"分頁(yè)":

  • 優(yōu)化的渲染過(guò)程,包括內(nèi)存的使用(vertex compression aka displacment mapping, texture coordinates sharing) 和運(yùn)行速度(LOD).
  • Real-Time Deformations
  • Quality render with splatting, morphing, real-time mountain shadows, 超大紋理 (可以比高度圖heightmap的尺寸更大(比如用2048x2048的紋理作為513x513的 page 已經(jīng)變得可能))
  • Its flexibility, as all texture modes and datasource can be plugged in and out, tilesize and page size
  • Map loading, unloading and changing at the speed of light.
  • Build on top of an octree scene manager it handles all sort of queries (ray, sphere, box, etc...)
  • Offers software horizon occlusion culling. (Hardware occlusion query is to come)
  • To be used with maptool and mapeditor, that splits map generates automatically, at the resolution choosen, normal map, horizon maps, texture maps, etc... in order to help you texturize the terrain.
  • Paging.
  • Coherent Occlusion Culling : 意味著觀察者看不見(jiàn)的objects根本就不會(huì)渲染,節(jié)省了寶貴的FPS。

特性

  • Real-Time Deformations (Craters predefined, user can submit a Float Array containing Delta to apply to terrain, like a Brush in a paint tool.)
  • 10 different texturing methods :
    • Splatting (using multi-texture, multi-pass or using shaders)
    • Real-Time Texturing (creates Textures on the fly, or updates it upon deformations)
  • Geomipmaping LOD (LOD choice comes upon tile complexity, screen size and camera to tile distance)
  • GeoMorphing between Lod transition (using vertex shaders, it's visually great but is slower and takes more GPU memory. I would consider using it with 128 memory GPU card at least of one years old GPU ( ATI 9800, NVIDIA geforce fx 5,6 or when wihtout it, and you have at least 140 fps in windowed mode. (be aware that fullscreen mode is faster.)
  • Octree Culling .
  • Horizon Culling (do not show tiles hidden by moutains)
  • Displacement mapping : defining a point only by its Y instead of X,Y,Z (using vertex shaders, divides GPU memory by 3, named VertexCompression in cfg files)
  • Buffer Sharing Texture coordinates and IndexBuffers sharing across pages (saves GPU memory by number of pages)
  • Tiles and Renderables Pooling.
  • Load Queues : Data, Texture and uploading to GPU are done separatly and not at the same time, preventing frame hits. Pages are queued and loaded using a distance to cam sort (nearest pages loaded first).
  • Paging Event Listener that gives you Load, unload, deformed events, along with a pointer to heighfield data.
  • Perfect Ray Scene Queries that interpolates between terrain vertices even near boundaries of tile/page (stitching make it harder on this case.)

數(shù)據(jù)資源加載模式

    數(shù)據(jù)資源加載模式定義了怎么加載你的地形數(shù)據(jù)。你可以使用8bits的圖像(OGRE支持的任何格式),或者16bits的Raw格式(可以通過(guò)terragen導(dǎo)出)。It can transform heights on Load (TC) or loads land Normals along with land heights. Raw is recommended for best details.

  • Ogre::PagingLandScapeData2D_HeightField : 從8bits灰度圖加載地形;
  • Ogre::PagingLandScapeData2D_HeightFieldN : Loads data from a 8bits grey image, and Normals from 32bits image
  • Ogre::PagingLandScapeData2D_HeightFieldRaw : 從16bits raw格式加載;
  • Ogre::PagingLandScapeData2D_HeightFieldRawTC : Loads data from 16bits rawimage and expands heights using TC algo.
  • Ogre::PagingLandScapeData2D_HeightFieldTC : Loads data from 8bits grey image and expands heights using TC algo.
  • Ogre::PagingLandScapeData2D_HeightFieldNTC : Loads data from 8bits grey image and expands heights using TC algo, and Normals from 32bits image
  • Ogre::PagingLandScapeData2D_Spline : create on the fly spline terrain
  • Ogre::PagingLandScapeData2D_HeightFieldBlendNeighbor: Loads data from a 8bits grey image, and blend it with already loaded neighbors. (dynamically created pages)
  • intensively tested and supported.

紋理模式

    紋理模式?jīng)Q定了你的地形將被怎么著色。你可以為每個(gè)Page使用很大尺寸的紋理文件 (彩色紋理模式), 或者使用splatting 以得到更好的地形細(xì)節(jié), 但是這樣會(huì)消耗更多的GPU和內(nèi)存資源。

PLSM2 提供的紋理模式

彩色紋理模式:

固定管線:

  • Image : 使用給定的Map(例如:用terragen生成)
  • BaseTexture : Computes a Color Map based on height and slope
  • BaseTexture2 : 和BaseTexture差不多,但是是預(yù)計(jì)算的。
  • InstantBase : like BaseTexture but using precomputed map, and reflect deformation on terrain dynamically.

shader:

  • InstantBaseShadowed : like BaseTexture but using precomputed map, with dynamically shadow changes upon sun position.


Splatting Modes :

fixed pipeline :

  • Splatting : Computes 4 alpha maps (one for each splats, based on height and slope) => 4 passes 2 texture unit
  • Splatting2 : like "splatting" (using precomputed 4 alpha maps) ) => 4 passes 2 texture unit
  • Splatting4 : like splatting2 but 7 texture units per pass (using precomputed 4 alpha maps) => 1 passes 7 texture unit

shader :

  • Splatting5 : like splatting4 but 4 texture units 1 pass, use of a Pixel Shader (arbfp1 or ps_2_0) 1 passes 4 texture unit all real-time (no alpha maps, so uses less texture units)
  • SplattingShader : like splatting4 but 4 texture units 1 pass, use of a Pixel Shader (arbfp1 or ps_2_0) 1 passes 7 texture (using alpha maps.)


Splatting Lighted Modes :

  • splatting3 : One pass, 3 Texture Units + one for light = 4. (using precomputed 3 alpha maps)
  • Splatting6 : like splatting2 but 3 texture units per Pass, 4 Pass (using precomputed 4 alpha maps)
  • Splatting7 : multitexturing splatting using 6 Texture Unit in one Pass (using precomputed 3 alpha maps)

用戶自定義紋理模式

    Provide the Plugin the material script you want to use using CFG file or setOption mechanism. Inside the material script you provide, just use keyword inside material scripts : Splatting, Alpha, Coverage, Horizon, Image, Light and those keywords will be dynamically replaced by the related page texture (Coverage will become coverage.1.2.0.png if page X is 1 and page Z is 2 and Coverage keyword is read for the first time in this material technique.)(case sensitive.)

Best may be to have a look on plsm2 provided texture mode material scripts to read some samples on how to do that.

速度優(yōu)化

  • MaxPixelError : The maximum error allowed when determining which LOD to use. That would determine complexity on screen. More Precise means slower.
  • PageSize : determines how 'GPU batched' your terrain will be, as it determines the size of the texture per page. Bigger is Better, but not all video card would support too big texture. (note that plsm2 demos uses small pagesize like 257, mainly for page management testing), that can lead to false impression that PLSM2 is slower than TSM. At same pagesize and number of page, you'd get same results or faster. try 1025, 2049.
  • TileSize : Difficult to tweak, 決定了頂點(diǎn)緩沖區(qū)的大小。使用太大的Tilesize (> 193),將使plsm2使用32位索引緩沖區(qū)(減慢速度或者得不到所有顯卡的支持)。使用太小的Tilesize (<65) 將使plsm2在每一幀里處理數(shù)以千計(jì)的tiles并帶來(lái)很高的GPU渲染批次,但是可以得到更多的裁減優(yōu)化(視錐裁減, 地平線裁減,八叉樹(shù)裁減...)
  • 頂點(diǎn)壓縮:如果你的顯卡支持該技術(shù),請(qǐng)打開(kāi)它 (如果顯卡不支持,將會(huì)被忽略). It divides GPU Memory usage by at least factor 3.
  • VertexProgramMorph : If you notice too much popping when tiles changes Lod, this reduce it a lot. But it has a big performance cost, so in case of bad performance, be sure to diable it. (on ATI opengl, it leads to a driver bug.)
  • HorizonVisibilityComputing : enable it if your map have moutains, cliffs... not if it's mainly a plane. Everything (for now just other terrain tiles, soon also any objects) hidden by Terrain Tiles will not be send to GPU, saving massive amounts of framerates, but in particular case. (didn't cost much if enabled anyway.)

Coherent Occlusion Culling (CHC)

  • Using setOption, getOption Mechanism, per camera, you set the occlusion mechanism.

ie : scenemgr->setOption ("NextCullMode", myCamObject); scenemgr->setOption ("setCullingMode", "VIEW_FRUSTUM_DIRECT") scenemgr->setOption ("setCullingMode", "CHC") scenemgr->setOption ("setCullingMode", "CHC_CONSERVATIVE")

  • Nodes are now either static or movable (use static in entity names), so they're either in Octree or loose octree.Nodes are either Occluders, Occludee or none (skipping tests.).
    • A node is a static if containing only entities that name begins with "Static".
    • They're Occluders only if containing entities that begins with "StaticOccluder".

(StaticGeometry, Terrain Renderables are static occluder by default.)

    • They're Occludees only if containing entities that begins with "Occludee".

Run Time Option and Scene Manager Features Uses

Paging Scene Manager Option

Demo Application

Usage:

  • F1 = cycle Help / debug panels
  • M = Switch between camera mode and cursor mode (that enable deformation, and sphere test)
  • K = Texture Mode changes, 'n', 'p' or 'l' for map changes.
  • N, P or L, = Load Next, Previous or reload map.
  • LEFT CONTROL = Increase the moving speed
  • A = Move Left
  • D = Move Right
  • W = Move Forward
  • S = Move Backward
  • PgUp = Move Up
  • PgDn = Move Down
  • Cursor Right = Rotate Right
  • Cursor Left = Rotate Left
  • ESC = Exit
  • F = Show/Hide the debug overlay
  • T = render terrain Solid/Wireframe
  • PrtSc = Makes a Screenshot
  • F2 = Display the terrain height at the current position.

Mapsplitter應(yīng)用程序

    map splitter 將地形分割成sections,這些sections可以被PLSM作為page載入,預(yù)計(jì)算和生成基本紋理和splatting textures。也可以計(jì)算光照?qǐng)D和blur heightmaps。所有的參數(shù)都來(lái)自配置文件: maptool.cfg 和為每一張圖配置的配置文件。maptool.cfg 文件"DefaultMap"指明了將要生成的每一張地圖的配置文件的名字。maptool.cfg 基本上就是將要分割成的地圖的列表,in batch mode or one at a time.

    既然MapSplitter是一個(gè)Ogre應(yīng)用程序的plugins,資源配置文件就必須設(shè)置正確。在運(yùn)行時(shí),程序?qū)?huì)生成.log格式的文件。在調(diào)試時(shí)如果程序出現(xiàn)問(wèn)題,log文件里將會(huì)記錄詳細(xì)的信息。

高度圖

    作為mapsplitter的輸入的是一個(gè)單個(gè)的大的地形高度圖,該高度圖將會(huì)被分割成很多尺寸和格式都正確的pages,以使你可以運(yùn)行plugin。 (如果沒(méi)有分割高度圖,將不能正常運(yùn)行 (除非你僅僅使用一個(gè)page。))

Config

    見(jiàn) PLSM 配置文件介紹

安裝

    見(jiàn) PLSM安裝過(guò)程介紹

與物理引擎的集成

與PagedGeometry的集成

Todo

PLSM2 Todo

PLSM3 roadmap

Known Bugs

- searching ! - Please Report plsm2 ogre addon forum

Faqs

Faq

Projects

Projects using PLSM

Reference