Guide:Creating Tree LOD Models

From Step Mods | Change The Game
Revision as of 22:42, January 15, 2022 by Z929669 (talk | contribs)
Delta c.png

Creating Tree LOD Models

A Quick Start to One Approach

by: The Step Team  | Forum Topic

Weapon.png

WIP

This process requires DynDOLOD 3 and is only partly applicable to the DynDOLOD 2 procedure (standard LOD models only). Disclaimer: The following procedure is what I (z929669) picked up in figuring this out for myself, but a 'standard' method may be a bit different. I will update this process if/when I better understand sheson's approach. Click the forum topic link above to see that discussion.

Purpose & Background[edit | edit source]

For complete reference, see the official DynDOLOD documentation describing this process. This is meant to be a simplified, quick-start guide. The goal is to aid other mod authors in operationalizing the methods described in the official documentation in order to produce LOD for their tree mods or for updates to existing tree mods.

Like most object LOD, DynDOLOD-compatible tree LOD uses a simplified LOD model 'imposter' or 'dummy' version of the full model in order to render trees in object LOD while keeping the performance hit to a minimum. In order to accomplish this, DynDOLOD must be able to associate the LOD model with its corresponding full model, which can be problematic with the "rule of one", because these are 'paired' assets (each tree mesh has a single corresponding LOD mesh). This can be done in one of three ways (in order of descending preference):

  • Option 1 - Incorporating the CRC32 checksum of the full tree model into the LOD asset names - LOD asset conflicts are not possible. This is the de facto standard, since most existing tree mods reuse vanilla tree names or those from other tree mods. It is also the preferred approach, according to sheson.
  • Option 2 - Using unique (new) tree names via plugin and for LOD assets - LOD asset conflicts with other mods are not possible.

If LOD models are saved using the base tree file names only (e.g., treeaspen01_passthru_lod.nif), then any load order with multiple treeaspen01 LOD will generate LOD according to the "rule of one" for the LOD tree model (independently of the base tree model). This will eventually lead to improper paring of base model with an incompatible LOD model. Using CRC32 of the base model in the LOD model file name and texture paths guarantees unique pairing of base-LOD models.

General Procedure[edit | edit source]

LOD models should contain only BSTriShape or NiTriShape blocks containing static trunk and crown (and on rare occasions, NiNode). This can be done in NifSkope by either copying these blocks into an 'empty' NIF containing only a single root block or by stripping the base model down to these blocks and using "save as" into a new file. Each method has its pros and cons in terms of time and points of error.

  • The "copy to" method is more work manually adding tree names and CRCs to files on save.
  • The "strip from" method is more work running xEdit and applying the script, ..\DynDOLOD\docs\trees.ultra\tools\DynDOLOD_CRC32Gen.pas, to add CRC32 to the base models followed by stripping extraneous blocks and data in NifSkope before saving.

The LOD models are saved out in either case. There are two choices for accomplishing this, and each has it's advantages:

  • Standard LOD models (less work, lower in-game performance) can be created by simply copying each block (or stripping down the base model) and saving into meshes\DynDOLOD\lod\trees\[TreeName]_[CRC32]passthru_lod.nif. The tree LOD model is ready for use by DynDOLOD end users.
  • Hybrid LOD models (more work, better in-gameperformance):
    1. Copy trunk blocks (or strip) into DynDOLOD\Render\Billboards\DynDOLOD\lod\trees\[TreeName]_[CRC32]_trunk.nif of the target mod in the mod list.
    2. Copy crown blocks (or strip) into meshes\DynDOLOD\lod\trees\[TreeName]_[CRC32]passthru_lod.nif of the target mod in the mod list.
    3. Run TexGen 3 with only the "Render" option ticked to generate output containing the new trunk billboard textures. NOTE: The tree mod with added trunks must be enabled in the mod list.
    4. Use ..\DynDOLOD\docs\trees.ultra\tools\hybrids\hybrid.bat to combine the crown and flat trunks into the final LOD model, and place this into meshes\DynDOLOD\lod\trees\[TreeName]_[CRC32]passthru_lod.nif of the tree mod. The tree LOD model is ready for use by DynDOLOD end users.

Given the gist of the process outlined, any number of workflows can be devised based upon tools, resources, and methods used. Below, one such approach is outlined in detail.

Specific Workflow[edit | edit source]

Before beginning work on creating LOD for a tree mod, it's best to first verify that the base models are 'final', because any changes to these meshes will obviate all LOD work, since the reference CRC32 will change with updates to base models. Work with the mod author to correct any potential issues with UV, alpha threshold, lighting, unused strings, block name, etc. if there are any. Running trees through a NIF optimizer is fine, but this can 'break' some tree models, depending on their complexity. If this step is done, be certain to test the mod afterward and keep in mind that the author of the tree mod should be hosting these files (and no other versions!), or permissions must be granted by the author to upload these with the corresponding LOD models where applicable.

The following is what works best for me. If you have a better workflow, please share on the forum thread linked at the top of this article. ~z929669 Ixian Insignia.png Talk 19:26, January 13, 2022 (UTC)

Prepare Working Environment[edit | edit source]

  1. Download NifSkope, and extract the archive into any location. This is a portable application, so it has no installer.
  2. Download SSE NIF Optimizer, and extract the archive into any location. Like NifSkope, this is a portable application.
  3. Optional: Install WinMerge for comparing like-named tree meshes.
  4. Configure 7-zip Explorer shell context menu options to provide a CRC32 lookup (see image at right).
  5. Use a MO profile that is lightly modded without a bunch of replacers that could conflict with the tree mod (TexGen may also run a bit faster):
    • Configure relevant Tools, and consider reviewing the System Setup Guide to configure the modding environment.
    • Install SKSE and any desired "engine-level" Extender mods and Resource mods.
    • The profile will obviously need DynDOLOD configured with DynDOLOD Resources mod.
    • Install/enable the relevant tree mod. If the mod has many different options for trees that use different model variants with same file name, or if texture paths are different, then each variation must be installed into a different mod.
    Example: EVT has Basic and Lush options, and both have SFO and RAT options as well as dark mesh options, while only the Lush option has large trees, so the mods installed might be ...
    • EVT-Basic
    • EVT-Basic-Darker
    • EVT-Lush
    • EVT-Lush-Darker
    • EVT-Lush-Large
    • EVT-Lush-Large-Darker
    • EVT-SFO
    • EVT-RAT
  6. Create the following directories in the tree mod(s). Right-click on the mod in MO left pane, and select "Open in Explorer".
    • meshes\DynDOLOD\lod\trees
    • DynDOLOD\Render\Billboards\DynDOLOD\lod\trees
  7. Open ..\DynDOLOD\docs\trees.ultra\tools\emptypassthru_lod.nif, and change the Header / BS Header / BS Version from 83 to 100 (converts to SSE format), and save into the following new files. These will be used as templates for the trunks/crowns. Replicating them here makes them reusable in the future:
    • ..\DynDOLOD\docs\trees.ultra\tools\empty_trunk.nif
    • ..\DynDOLOD\docs\trees.ultra\tools\empty_passthru_lod.nif
  8. Now copy each of these into the working directories so they remain conveniently available while working on each tree model. When finished, there will be three Exporer windows open (keep these Explorer windows open throughout this process):
    1. In MO, right click on the relevant tree mod in MO left pane, and select "Open in Explorer"
    2. Right-click meshes\landscape\trees directory, and select "Open in new window".
    3. Create path, and paste: DynDOLOD\Render\Billboards\DynDOLOD\lod\trees\empty_trunk.nif
    4. Paste into DynDOLOD directory: ..\DynDOLOD\docs\trees.ultra\tools\hybrids\{ModNameWithoutSpaces}\empty_passthru_lod.nif NOTE: In the case of the EVT example above, each of the mod 'flavors' must have a corresponding folder at this location.
  9. Arrange the three Explorer instances of these working directories in a way that facilitates ease of access to each (base tree models at left, and the two LOD directories at right with trunks at top and crowns at bottom).

Copy Mesh Parts Into Empty NIFs[edit | edit source]

As mentioned in the General Procedure section above, a "copy to" or "strip from" procedure can be used to create the LOD models. The former is described here.

Again, LOD models can be either:

  • Hybrid LOD models - Applies ONLY to symmetrical trees with 1) branchy or leafy crowns AND 2) relatively straight trunks (more work to create, better performance, equal quality to 'standard')
  • Standard LOD models - Applies to any tree type (less work to create, higher performance cost)

Additionally, only trees roughly ≥ 500 units tall (on the Z axis) should be considered for LOD models. Ignore the remainder, since they really can't be seen amidst other trees in the distance. Keep in mind the scale of the tree. Obviously, if the tree is 1.5 scale, the the threshold height is roughly 500 / 1.5 = 333 units tall. Note that some trees are scaled via plugin (e.g., Happy Little Trees) and not the mesh directly, so height is more of a guessing game. Suffice it to say that large trees should have LOD and small trees are optional, since they will be hard to notice unless other trees and plants are sparse. Aside from this, ANY tree (or tree part) can have a LOD model and a slight increase to performance cost for the end user.

Info-Logo.png

NOTE

When creating 'standard' LOD models, all of the following step having to do with trunk meshes should be ignored. Instead, only follow the steps dealing with crowns. Instead of saving only tree crowns, all applicable mesh parts will be saved into the 'passthu' NIF, which will essentially be the final LOD models for packaging into the mod.
Since *.NIF files are associated with NifSkope ...
  1. Double-click on the empty crown NIF, and drag this to lower left.
  2. Double-click on the empty trunk NIF, and drag this to the (nearly) top of the right (the trunks Explorer window should be slightly exposed above this NifSkope instance).
  3. Double-click on the base model in the left window to open the model, and drag this to the left.
  4. Click on the trunk in the NifSkope viewer of the base model (it should be the active window). This will expose the *TriShape block in the left pane of NifSkope.
  5. Click on the *Trishape block to select it, and use Ctrl+c to copy to clipboard.
  6. Bring the empty trunk NIF info focus via the desktop or the taskbar.
  7. Click on the BSFadeNode in the left pane of NifSkope to select it, and use Ctrl+v to paste. The tree part should appear in the NifSkope viewer. Ignore the fact that it is off center or if it seems too small. Some trunks have > 1 mesh, so be sure to copy/paste each one likewise if it will likely be evident in LOD.
    NOTE: If it is a branchy tree and much of the crown is also selected, the tree should NOT have a trunk component. It will need to be treated as a "standard LOD model" by pasting all blocks into the empty crown NIF (see following step).
  8. Back in the base model instance of NifSkope, click on the crown. This will expose the *TriShape block in the left pane of NifSkope. The corresponding mesh should become highlighted in the NifSkope viewer.
  9. Click on the *Trishape block to select it, and use Ctrl+c to copy to clipboard.
  10. Bring the empty 'passthru' (crown) NIF info focus via the desktop or the taskbar.
  11. Click on the BSFadeNode in the left pane of NifSkope to select it, and use Ctrl+v to paste. Many crowns have > 1 mesh, so be sure to copy/paste them all in the same manner. The crown mesh(es) should appear in the NifSkope viewer and should align proportionately with the others if there are multiple meshes. If they don't, align, then this is likely a *TriShape block under another block. Expand blocks in the left pane and click on each one to inspect it in the viewer to find alternative *TriShapes. Skinned trees have duplicate meshes, so getting the correct one can be tricky and this nuance is beyond the scope of this article (and the author's knowlege). Just know that the 'correct' *TriShapes will become more evident with experience.
    NOTE: If any mistakes are made when pasting a mesh into the empty NIF, close and start over with another copy of the empty NIF (available in the working Explorer windows). This is simpler than deleting blocks or cleaning up unused strings and the like.
  12. Once all crown meshes are pasted into the empty passthru NIF, it's time to save the LOD models. If the trunk NIF wasn't needed or used (due to the model requiring the "standard LOD model" or if using the faster and more performance UNfriendly approach described previously), then the model is essentially created and should be saved ... read on.
  13. Close the NifSkope instance of the base model (without saving!). The Explorer instance with the base models will appear at left with the model chosen faintly highlighted.
  14. Slow-click the faintly-highlighted base model to bring up the name editor (which should highlight the entire file name without the '.nif' suffix).
  15. Right-click and copy this string.
  16. In the crown NIF that should still be visible at right, click on the save icon > "Save as". This brings up the "Save as" dialog with the file name of the crown NIF (empty_passthru_lod.nif.
  17. Select 'empty' in the string and Ctrl+v to paste/replace.
  18. Back in the Explorer instance with the base models, right click on the same file from which the tree name was copied, and select "CRC SHA" > "CRC32" (Tip: the last file clicked on will be faintly highlighted). This will open up the CRC32 dialog (thanks to 7-zip).
  19. In the CRC32 dialog, double click the CRC32 value to open it in a new window from which it can be copied by double clicking and selecting Ctrl+c.
  20. Paste this just before 'passthru' in the file string of the "Save as" dialog in NifSkope (e.g., TreeName_XCRC32XXpassthru_lod.nif).
  21. After pasting, the cursor will be just to the right of the last CRC32 character and just before the 'p' in 'passthru'. Hold Shift and click just before the beginning of 'TreeName', and select Ctrl+c to copy the unique string to be used in the trunk file name.
  22. Save the crown to close the dialog, and then close the 'crown' NifSkope instance.
  23. Go to the 'trunk' NifSkope instance at upper right, click the file icon > "Save as", select 'enpty' again from the file name (empty_trunk.nif), and Ctrl+v to paste the unique string and close the dialog.
  24. Close the 'trunk' NifSkope instance.
Info-Logo.png

NOTE

The three Explorer instances should again all be visible (with more/less overlap, depending on screen size of the desktop). Note that in the instance with the base models, the last tree completed should be faintly highlighted, which is convenient, since it's easy to lose one's place when many files are present.

Rinse and repeat all preceding steps for the remaining trees. Skip trees that are not LOD candidates (logs, most stumps, etc.). Throughout this process, the empty NIFs will always be available in the folders to shich the crowns/trunks are saved and NifSkope will conveniently save these assets to their correct respective directory locations.

If at any time, a tree opened in NifSkope is not a candidate for a hybrid model, save all LOD-worthy trunk/branch parts into ..\DynDOLOD\docs\trees.ultra\tools\hybrids\output instead of ..\DynDOLOD\docs\trees.ultra\tools\hybrids\crowns (where the hybrid LOD models will be assembled). These will be standard LOD models.

Auto-Generate the Hybrids[edit | edit source]

After all trees mesh parts have been copied into the empty NIFs and renamed as described, the crowns (and/or standard LOD models) located in ..\DynDOLOD\docs\trees.ultra\tools\hybrids\{ModNameWithoutSpaces} should be run through SSE NIF Optimizer to clean up redundancies and reduce file sizes where possible for better in-game performance. This is completely safe to do on the LOD crowns (and/or standard LOD models). NOTE: DO NOT do this on the base models, since that will change the CRC32 of models affected and render all LOD work meaningless for those models.

  1. First, delete the empty NIFs in the two Explorer instances at right.
  2. Run SSE NIF Optimizer on the folder (using default settings with SSE toggled), ..\DynDOLOD\docs\trees.ultra\tools\hybrids\{ModNameWithoutSpaces}. Check the log for this program to ensure no issues, which should be adjacent to the EXE. It's entirely possible that no changes will be made, but look at the modifies on date and the log to verify.
  3. Open ..\DynDOLOD\docs\trees.ultra\tools\hybrids\hybrid.txt, and change /input/ string to /{ModNameWithoutSpaces}/. If this directory does not contain an 'output' folder, create it.
  4. Refresh MO by hitting F5 or by activating the mod (recall that the trunk NIFs were saved to that mod, which should be overriding all other conflicting mods).
  5. Run Texgen 3 (DynDOLOD 3 required!), and ONLY tick the "Render" option. Other settings don't matter. TexGen will 'render' the trunk models and create multiple trunk billboard textures for each tree with a trunk model using information in the relevant plugin and Texconv.exe. This should take less than 10 minutes.
  6. Once TexGen 3 completes, carefully check for warning about missing textures or other errors pertaining to the trees in question. These issues will likely be due to the base model pointing to missing textures. It's simplest to find (or create) the textures and rename them to the paths indicated by the base model. These will need to be shared with the original MA, who should be notified anyway. Otherwise, they will need to be packaged with the LOD (which will effectively fix the tree mod as well).
  7. Execute ..\DynDOLOD\docs\trees.ultra\tools\hybrids\hybrid.bat, which will produce the hybrid LOD models in ..\DynDOLOD\docs\trees.ultra\tools\hybrids\output (along side any standard LOD models that may or may not exist there from earlier work).
  8. Check ..\DynDOLOD\docs\trees.ultra\tools\hybrids\LODGen_log.txt for errors, and resolve them as necessary. It will usually be about a missing asset (TexGen/user issue), but it could be that file paths defined in ..\DynDOLOD\docs\trees.ultra\tools\hybrids\hybrid.txt are incorrect. TexGen by default sends its output to ..\DynDOLOD\TexGen_Output, and ..\DynDOLOD\docs\trees.ultra\tools\hybrids\hybrid.txt expects this as well.
  9. Copy all LOD models from ..\DynDOLOD\docs\trees.ultra\tools\hybrids\output into meshes\DynDOLOD\lod\trees\ folder of the mod where the trunks were stored.
  10. The LOD mod is now complete and will produce tree LOD as expected when loaded with or after the tree mod.