Uberlod Vegetation Documentation
This article is about our system for distant tree lods in general and especially how to create it.
- 1 Vegetation BB LODs
- 3 Creating uberlods from BB LODs
- 4 Exporting uberlods into engine
Vegetation BB LODs
Uberlod node for single vegetation has to be a BB LOD.
What does it do?
This system uses Vertex deformation of shader to expand small square into sizes of big trees and makes them face the camera. The usual billboarding solution wouldn't work because we need this to work and uberlods that has multiple elements that needs to face the camera separately. To achieve this we create tiny squares of geometry with the desired vertex position data in 2nd UV channel and then expand them in realtime in the engine by shifting vertices for the amount specified by 2nd UV position times per material constant.
Manual approach (worse)
3DS MAX side
This is what you need to do in 3ds Max so this system works for you. Bake lod0 into plane using CryENGINE's LOD Generator:
Do that for all the trees that shares the same lod material:
Once you have it, create second UVs for all of them together:
The vertex shader will expand the vertices by the value measured from the center of the uv space with y axis flipped. So first of all mirror everything horizontaly and place it so it is centered on the drawn X axis with bottoms aligned on the Y axis. The uvs for the largest tree of those should touch the bottom of the uv space. Just like on the picture.
Now that we have the position and size data safely stored in second UV channel, we can discard it from the geometry. Just shrink the geometry to the tiny rectangle:
Make sure that it sits in correct relation to the pivot:
And you should end up with something like that:
Just export it and remember to check Additional UVs channel 2 in exporter.
Now in the engine it's pretty simple. Just set the material vertex deform correctly and you're good to go.
Creating uberlods from BB LODs
Run script WH Tools -> Misc -> UberlodImport
Export uberlods from folder and sub
Path From – path including subfolders where to search for max files in order to export them into FBX
Path To – Where to put exported FBX files
Import uberlods FBX
Directory from which to import FBX uberlods (same as "Path To"?)
Path to the exported vegetation data XML.
How to export vegetation data XML:
In Editor, run console command wh_veg_ExportUberlods Foldername, where Foldername is path relative to WH ("testfolder" represents path "WH/testfolder")
Generated XML files have name in the format:
- CELL_Y, CELL_X - coordinates of vegetation cell
- BOUNDS_MIN_X, BOUNDS_MIN_Y, BOUNDS_MAX_X, BOUNDS_MAX_Y - axis-aligned bounding box of vegetation cell
Vegetation cell index could be calculated: VegetationCell = (CELL_Y * (TerrainSize / wh_e_vegetationCellSize)) + CELL_X, where
- TerrainSize is 4096 for Rataje
- wh_e_vegetationCellSize is cvar with defaul value of 64 (i.e. TerrainSize / wh_e_vegetationCellSize = 64)
From, To - pick square between coordinates
Save Frequency - how often to autosave (every nth square)
If generation process gets frozen, there is probably problem with vegetation max files – there is missing GrowFX plugin. How to fix it: open "broken" max file and run scriptand then save max file.
Exporting uberlods into engine
Sync and assign material \Objects\vegetation\trees\uberlod_veg.mtl
Export cgf files, make sure you check on Additional UVs: Channel 2:
Select Scene node in 3ds Max:
In property click to Export Scene: