Jump to content
The Dark Mod Forums

Benefits from LOD AI?


Springheel
 Share

Recommended Posts

I'm looking into whether LOD AI would be a good idea. Just to log my first test:

 

10 AI, 2 lights.

 

3100 poly version -- 51 fps

1550 poly version -- 61 fps

 

(better check to make sure the shadow meshes match up though)

  • Like 2
Link to comment
Share on other sites

It would certainly allow for more Ai in a map,

 

Well, my tests should answer that question. I'm not sure poly count is the main bottleneck though.

Link to comment
Share on other sites

I guess the first thing I should have done is test whether LOD actually WORKS with AI. I was under the impression it did, as people had asked me to make LOD AI versions in the past. But if it does work, I'm not able to see how. No combination of spawnargs I've used has had any effect.

Link to comment
Share on other sites

It would certainly allow for more Ai in a map, somthing player's always complain about not having enough off.

 

Pretty sure the limit was because AI runs on one thread along with the rest of the game and the CPU can only calculate so much.

You got the slow down even when not looking at the 32 AI in the test map.

But that was 6 years ago or so.

I always assumed I'd taste like boot leather.

 

Link to comment
Share on other sites

My tests suggest that there are definitely savings to be had...just reducing the quality of the shadowmesh can save some FPS. LOD would also allow me to make AI look better at close range...we could swap in fully modelled hands at close range, for example.

 

It's a shame it doesn't work...I could have sworn Tels asked me to make LOD AI at one point.

Link to comment
Share on other sites

Steve, I don't suppose in exploring LOD you found anything to suggest that md5mesh support might be easy to do?

Link to comment
Share on other sites

I don't know... I didn't spot any clues, but I wasn't looking for them and I don't know off hand how the model or md5mesh is set up for an ai. Lod works by manipulating the values normally set by the "model", "skin", and "noshadows" spawnargs on an entity. I don't know whether md5meshes are specified through the model spawnarg, but even if they're not, adding that functionality might turn out to be as easy as it was to add support for blendlights to entity lights. I'll be back within reach of my pc Friday afternoon. I might need to tap you for a bit of info, but let's try it out then and see.

Link to comment
Share on other sites

Animated entities have a "model" spawnarg (which points to a modelDef).

 

ModelDef entities have a "mesh" spawnarg that points to a specific md5mesh file.

 

From a maintenance standpoint, it would be easiest if the lod spawnargs could be added to the modelDef, like below:

 

 

model tdm_ai_scientist {

inherit tdm_ai_proguard

mesh models/md5/chars/inventors/scientist/tdm_inventor_scientist.md5mesh

 

"lod_1_distance" "600"

"mesh_lod_1" "models/md5/chars/inventors/scientist/tdm_inventor_scientist.md5mesh"

 

channel torso ( *Spine_Dummy)

channel legs ( origin Pelvis Pelvis2 *Hips)

 

//replacing animations that don't fit character

anim idle_nose_wipe models/md5/chars/guards/proguard/idle_armwipe.md5anim

anim idle_nosewipe_short models/md5/chars/guards/proguard/idle_ponder02.md5anim

anim idle_spit models/md5/chars/guards/proguard/idle_armwipe.md5anim

anim idle_eat models/md5/chars/guards/proguard/idle_ponder02.md5anim

 

 

 

}

Link to comment
Share on other sites

I agree, otherwise we'd end up duplicating the model defs and have to support changing the anim override and channel settings too.

 

I'll need to find where and when the lod models get loaded. It doesn't seem to be while the entity is spawning. Perhaps it happens during runtime, or perhaps once for all entities at the end of spawn time, in some code I haven't found yet. I'll shelve that question until I'm back. Given that Tels talked to you about it, I assume he thought it could be done.

 

Can you recommend a pair of existing model defs that'll be compatible? So I can try it out. I assume I'll need to find two ai meshes that have the same joints, but I don't know how common that is or whether anything else will need to match.

Link to comment
Share on other sites

Try this one:

 

model tdm_ai_citywatch {

inherit tdm_ai_proguard

mesh models/md5/chars/guards/citywatch/tdm_ai_citywatch.md5mesh

channel torso ( *Spine_Dummy)

channel legs ( origin Pelvis Pelvis2 *Hips)

 

"lod_1_distance" "600"

"mesh_lod_1" "models/md5/chars/undead/skeleton/skeleton.md5mesh"

 

}

 

That should cause the citywatch to turn into a skeleton at 600 units. Should be fun. :)

Link to comment
Share on other sites

Tracker created #3770. Simply plugging the existing LOD code into AI (i.e. just swapping the model) changes the guard's body to a skeleton but leaves him with his original head and no animations. That's not what we were planning to do, but I wanted to know what'd happen. Now looking for a way to switch him smoothly, which'll need to continue the current animation somehow to support your model hands etc. I suppose that'd be less important for making distant AI low-poly.

Edited by SteveL
Link to comment
Share on other sites

The heads are a separate, attached entity, so it makes sense they wouldn't switch the way things are currently set up. If heads can't use LOD that's not a big deal, though it would be a bonus if they could.

 

 

Now looking for a way to switch him smoothly, which'll need to continue the current animation somehow to support your model hands etc

 

Not sure what you mean about the hands...?

Link to comment
Share on other sites

I'll be aiming for heads too, once I work out why model-switched AIs can no longer walk. They play further idle animations ok.

Not sure what you mean about the hands...?

You mentioned modelled hands as a possible benefit. For any close-up work like that, we'll need to preserve and continue the AI's current animations though the mesh switch. Currently, the SetModel method for AIs resets all the anim channels.

Link to comment
Share on other sites

Oh, right. Yes, if the animations can't be preserved then the benefits would be a lot less, even at a distance.

Link to comment
Share on other sites

Did that run on idTech too? having a bit of trouble figuring it out just from googling.

 

I'm still only a couple of hours into this investigation. My computer has been out of action all weekend. Plenty to find out yet before I'll have any idea what is and isn't possible.

Link to comment
Share on other sites

Ok I got a proof of concept working, by using an new SwapModel() procedure for animated entities that changes the render model and the animated model but without resetting ongoing animations.

 

The heads can be dealt with the same way as the AI bodies -- they are animated entities too -- so I reckon they'll be able to have optional LOD spawnargs added to their model defs just like the AI bodies will (once I've set that bit up -- I did this demo by using spawnargs on the AI themselves).

 

I assume that doing this would be crashy or unpredictable if the animations and/or skeletons of the two models were not compatible. I've put in a couple of compatibility checks, but it won't be a problem for genuine LOD switches, which'll use identical animations and skeletons. In my tests, if the ai starts off as a skeleton (because he's too far away at map load), then when he turns into a human he carries on shuffling like a skeleton until he hits his first path corner. After that, he walks like a human. That's intentional (no resetting of ongoing animations), and again, that won't be an issue for real LOD ai.

 

I've not worked out how best to implement it yet, this is to just show that it's possible. I'll finish doing my homework and then consult the team about what else we might need to test or cover off.

 

http://youtu.be/6sjFt_eUO54

  • Like 1
Link to comment
Share on other sites

Very exciting!! Thanks for taking this on Steve. :)

 

Did anyone else start thinking about interesting ways to use this for creative creatures? You could have AI that 'turn into' skeletons or ghosts or something when they get close enough to attack you, but look like regular AI at a distance. Or something like Sotha's creatures, that are completely invisible until they get close to you, and then they suddenly become visible.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


  • Recent Status Updates

    • Nort

      Spent most of the day learning and writing about AI navigation. It's stuff I already know, but the magic about writing something down as clearly formulated as possible, is that you then see things that much more clearly. You also find what's unclear to you, and then you figure out exactly how things work. I was hoping to get through it all within just a day, but it looks like this will take tomorrow as well, at this rate. There's also plenty of other nonsense I have to get through as well. Everything's a chore.
      · 0 replies
    • Nort

      I want to be a fish, but I'm not a fish. My mom wants to be a fish too, and so she's killing herself eating plankton and sh***ng blood, and tells me to stop nagging her about taking her medication. I spent several hours today, just lying in bed, having anxiety over just existing, and not being a fish. You fish, you don't know how lucky you are. You can eat all the plankton you want. I tried eating plankton again yesterday, and I just got sick. I hate being a shark.
      · 0 replies
    • Nort

      I just gave myself vertigo. A pleasant kind of vertigo, like the world has been lifted off my shoulders. I'll explain:
      Yesterday I saw to my dismay, that I had made my entire map two - two - units too short on every level - that every set01 piece was sticking 2 units into the ceiling. That's basically 402 brushes that needs to be realigned (minus the ground floor brushes).
      I knew enough about selections to do all of that in a very tense five minutes, and it compiled without leaks. (Thank you so much, Dark Radiant devs, for making an editor with such care for precision that you can align hundreds of brushes perfectly at once (which is not something I can say for Valve's Hammer editor, which has some serious issues on that front, which actually made me just quit it in disgust).) However, the result is that the entire level has now been stretched a barely noticable 2 units, and it will take some getting used to psychologically.
      · 0 replies
    • Nort

      My workflow is basically running from a chain of disasters, eventually trying to seek shelter in former disasters. It's not ideal - it's just my life.
      When I abandoned my first map, it was out of a typical mental breakdown, and so I returned to find a skybox void where the kitchen door should have been (due to a misplaced visportal) and two overlapping brushes Z-fighting on the kitchen floor.
      I've now cleaned up the last bit of mess, by cleanly separating every floor into its own layer. Now I can finally work on each floor in peace.
      ...not that I really needed to. Once you get skilled enough, the orthographic messes, well, I'll let this video speak for itself:
       
      · 1 reply
    • Nort

      Beams, beams, beams...
      Support beams, and cross beams, and then beams to fixate the support beams to the cross beams. The more beams you have in a map, the better. There's walls, floors and ceilings, but the rest of the map is pretty much just beams. Beams makes a thief happy.
      · 0 replies
×
×
  • Create New...