Page MenuHomeWildfire Games

Discrete LOD
Changes PlannedPublic

Authored by Angen on Sun, Nov 24, 8:14 PM.
Tags
None
Subscribers
Restricted Owners Package, Restricted Owners Package, Stan and 3 others
Tokens
"Like" token, awarded by nani."Love" token, awarded by Stan.

Details

Reviewers
None
Summary

Implementing Discrete Level of detail for models based on the distance from camera.

Before submitting model to the renderer, it calculates distance from camera. Based on that computed distance, is switched to another variant of the model.
To not rebuild model everytime, there is member variable LOD, which is true, if lower level of detail have been chosen to not rebuild models when it is staying the same.

In actor, main model (not props) can introduce variant with name "low" and that will be chosen. It will switch back to or frequency = "1" or name = "high" variant in the same group.

What we can do with this is, that we can hide all small props that do not need to be visible from distance and it does not matter. Another thing we can do is to switch to meshes with lower number of vertices.

Current distance to switch models is hardcoded and kind of small for showcase (maybe it is enough, dont know actually).

I am also hiding projectiles at some distance entirely, because units have high rate of fire and they stay at ground quite long so with bigg frustrum range, there is really a lot of them so that might help perf too. (I ll split this to another diff if someone suggests it)

Another usage: Hyrule Conquest would like to have that.


I ll remove actor changes for another diff after feature is complete.
Also I would like to do profiling but i need find out why profiler2 is failing for me.

Btw. That units edited are in combat demo huge
I do not expect too much improvement since I removed just some random props.

Test Plan

Suggest better names
Check logic

Event Timeline

Angen created this revision.Sun, Nov 24, 8:14 PM
Owners added subscribers: Restricted Owners Package, Restricted Owners Package.Sun, Nov 24, 8:14 PM
Stan awarded a token.Sun, Nov 24, 8:16 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/639/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1155/display/redirect

elexis added a comment.EditedSun, Nov 24, 8:27 PM

The intervals should probably not be buried in the code but specified somewhere, probably ideally in some model related art file or template (and ideally support more than two levels).
Perhaps std::pair<CStr, CStr>("lod", "low")) / selections can be constructed only once per program launch instead of once per call.
{ on a separate line.
Hiding projectiles after a set distance means it will fail for some projectiles of a given size, so it should be moved to data files as well.
It would be a good feature, although I guess in the average case only high level of detail will be shown, since the camera is top down on average?

Angen planned changes to this revision.EditedSun, Nov 24, 8:49 PM

move interval to each actor
check distance only if actor defines that it has lod versions
disable/enable lod from graphic options
remove projectile manager changes as not exactly related

Angen added a comment.Sun, Nov 24, 8:50 PM

It would be a good feature, although I guess in the average case only high level of detail will be shown, since the camera is top down on average?

With reasonable distance one can have high level models with close camera and low level in normal

vladislavbelov added inline comments.Sun, Nov 24, 9:01 PM
binaries/data/mods/public/art/actors/structures/athenians/civil_centre.xml
28

I think it'd be better to use numbers here, because it's easier to pick (no need to store strings in C++) and sometimes we need more levels of LODs and then we'd have a problem with new naming.

source/simulation2/components/CCmpProjectileManager.cpp
378

It's not needed to calculate inverse of a camera matrix for each model. For many models it might be noticeable for performance (see implementation of GetInverse).

source/simulation2/components/CCmpUnitRenderer.cpp
74

What does the LOD name mean? It's not obvious from the name.

nani awarded a token.Sun, Nov 24, 9:28 PM
Stan added a comment.Mon, Nov 25, 2:27 PM

Lods should be in the template visual actor. Else actors will become a great mess. Also there will be warnings everywhere or missing props.