Creating ''infinite LOD'' on a static object

Ask questions, discuss ideas, get answers
Post Reply
Diamondback
Posts: 590
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Creating ''infinite LOD'' on a static object

Post by Diamondback »

This idea came to my mind after looking at objects which include other objects in them (object bundles), as well as the bundles themselves. I haven't done any kind of practical experiments with this theory, I'm just laying it down.

Now, I know of a few statics in vanilla BF that have other objects ''addTemplated'' to them, such as the ''supplyde_m1'' depot object in Wake Island (has a few crates inside as well as a locker). Using the same principle, can one create an almost infinite level of detail for an object? I was thinking perhaps taller and bigger structures such as food marts, malls, churches, skyscrapers, restaurants, movie theaters, and other structures of the kind.

One would, at first, create a ''base object'' which has the general shape of the desired object, and then, gradually addTemplate some smaller ''child objects'' to the ''mother object'', in order to achieve the desired level of detail. Is there a specific number of objects you can addTemplate to another? Is it also possible to addTemplate an object or object bundle to another object or object bundle?

Share your thoughts.
See my Strasbourg map project here.
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Creating ''infinite LOD'' on a static object

Post by Swaffy »

I guess, you'd have to load the 3D object into a program such as 3DS Max 7. Then, when you go to save the object, you can change the LOD number. Usually it is 6 or 3, but I'm sure you can change it to a high number such as 50. But then you'd have to edit the Geometry.con file for the StaticObject to have 50 levels and their distances.
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Creating ''infinite LOD'' on a static object

Post by Senshi »

You are mixing two different things up here.

LODs are different level of detail meshes, all incorporated in a single .sm file.

The "addtemplate" stuff is intended to add optional functionality to objects. This makes perfect sense for e.g. the supplyde, as you once might want the interiors added and sometimes not. This has not much to do with perfomance optimization, which is what LODs are for.
Diamondback
Posts: 590
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Creating ''infinite LOD'' on a static object

Post by Diamondback »

That is why I put quote marks around it.

But for an object such as a church interior, or even a cathedral, using the addTemplate method to add successively smaller child objects to bigger mother objects, could one achieve almost a 1:1 replica of the detail?
See my Strasbourg map project here.
User avatar
Swaffy
Posts: 1715
Joined: Sun Aug 29, 2010 9:25 pm
Location: Cibolo, Texas

Re: Creating ''infinite LOD'' on a static object

Post by Swaffy »

You're thinking of mipmaps, which are a part of the textures. You're asking for a way to reduce detail as a person gets further from an object, but you want much more detail when up close. So because you want such a large difference in changes in detail, are you asking if you want an unlimited amount of mipmaps for a texture?

A LOD (level of detail, like Senshi said) changes the actual 3D object, removing faces from the object as the player gets further from the object.

You need some 3D modeling and texturing knowledge to do so.
(Forum Thread|Download) Swaffy'sMod v0.34 | Download link to come Soon™
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Creating ''infinite LOD'' on a static object

Post by Senshi »

He's not talking about mipmaps, he's talking about actually reducing polycount ;) being rendered .

Yes, what you mean is possible by using a LodSelector. The LodSelector usually is used for 1p/3p cameras, but can be (to a limit) used for other stuff as well. However I don't think it's possible to exploit this to have a "conditional" addtemplate. LodSelectors are completely "either or", so you'd have to add some workarounds to it: Either have multiple .sm present that have the individual LOD (however, in this case you could just use the .sm-based LOD system right away, with better perfomance). Or, if you really want the addtemplate stuff: Set up multiple object clones in code, one for each LOD. Each code-object then has to have the required addtemplates. After that you can use a "master object" with the LodSelector to make it switch objects at specific distances.
This approach has the drawback that on every LOD switch the entire object is being reloaded. So if you have two objects "cathedral exterior" + "cathedral exterior&interior", there's no reasonable way to only disable the interior without reloading the exterior.

Again, there's another possible workaround for the last issue: Place the main static that always will be visible as a standard static. Then use the coded multi-object-approach to only LodSelect through the interior. Basicall a LodSelector with "interior" and "nothing/dummy". The dummy could be a single-vertex-object or literally nothing (not sure if LodSelector allows that or throws errors if empty objects are given).


As you see, none of the code solutions is particularly nice. This is mostly because addtemplate never was designed to be a tool for modifying LOD. There are various possibilities to influence and alter LODs ingame, and those should always be preferred over these crude hacks.

E.g. the vanilla interiors of barracks etc. are set up with specific cull and LOD distances. Those two options are the most perfomant way to modify LODs. Culldistance is the distance after which the entire object will be omitted. LODdistances are the distances on which to switch between the different LODs defined in the .sm .

You probably also noticed that there's this infamous "black window effect" when you zoom on windows of an open structure from very far away. This is actually a dirty cheat on behalf of DICE, because they use this "blackness" (which is a simple full black shader that fades in with a specific LOD level) to hide that at the same LOD level the entire interior of that object will no longer be rendered. Ten years ago this was a super efficient way to manage the GPU load, today every computer laughs at BF42' demands, which is why most small-scale mods can easily increase a lot of of the LODdistance and culldistance settings very much. Five years ago when I was modding for my online campaign project one of the most popular changes was that no object at all (tree, bush, tank, barbwire, whatever) would ever be culled out anymore, so no more "popup" objects. Especially the flyboys were delighted by this. Combined with the removal of the black windows this provided a whole new gaming experience.
Diamondback
Posts: 590
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Creating ''infinite LOD'' on a static object

Post by Diamondback »

That is not what I meant, I am sorry for not elaborating enough on what I want precisely, which has nothing to do with the LOD.

What I'm actually looking for is a mother object, or base object (for example the cross-shaped base of a cathedral) on which smaller child objects are addTemplated successively, and with no limits in order to create an almost "infinite" level of detail from a distance, or even up close.

Still using the cathedral example, using the "child/mother object addTemplate" concept, one can build an almost 1:1 replica of the actual model (not in size, but in the level of detail (not LOD!) on the entire object), by always bundling smaller child objects to bigger mother objects, so that from a distance the mother object seems extremely detailed, as mentioned in the above paragraph.

Only issue with that is that it might cause performance problems, such as when a player enters a thick forest with a lot of tree models. A Precache.con designed for each model added to child/mother bundles will be created in that regard.
See my Strasbourg map project here.
User avatar
Senshi
Posts: 697
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany
Contact:

Re: Creating ''infinite LOD'' on a static object

Post by Senshi »

I still do not understand what benefit this might have. If you want statics to show from a far distance in high detail, just place them regularly and assign them a high cullradius and LodDistances. This is even more beneficial, as you can define the cull and detail ranges precisely on a per-object-basis, improving perfomance drastically. There's no point in having a tiny decal (e.g. a poster) be visible from kilometers away where it's reduced to a one-pixel-size.
Post Reply