Aller au contenu

Photo

City Hak optimisation


  • Veuillez vous connecter pour répondre
31 réponses à ce sujet

#1
Tchos

Tchos
  • Members
  • 5 042 messages

I was beta-testing Andy's campaign, and one of the areas makes heavy use of Tupoun's City Hak, which, at least on my system, slows the frame rate to a crawl (perhaps 2 frames per second on average, 1 or 0.5 at worst).  I've heard people say that it's because the models lack LODs, so I looked into them to see if anything could be done to remedy that.

 

First I checked to make sure the textures had mipmaps.  That alone could improve the speed, as I found in other areas.  They do have mipmaps.

 

Next I looked at the models themselves -- mainly the houses, which seemed like the main culprits.  I found that they were not only rather heavy on polygons (7200 for one building in one that I checked), but that they're made of multiple separate objects, each using its own texture.  This is because the Oblivion textures (which is where these textures come from) are generally single elements, such as stone, wood, cloth, or single pieces of objects, like a window.  This is in contrast to the other, possibly more common, method that NWN2 generally uses, which is a single image file containing numerous textures to be applied to different areas on a single mesh.  So these houses are not only a bit on the high end polygon-wise, but also pull 3-5 textures each.

 

Now, the problem here is that I have no idea if it's even possible to add LOD models that will work properly with a multi-mesh model.  I tried adding some LODs to a few of the houses, but when I moved them out to a distance to see the effect, only the first-named mesh was swapped out, leaving all of the subsequently-named meshes still there.  If this were a single-mesh file, it wouldn't be an issue.  I checked one of the known multi-mesh stock objects, the alarm gong, to see how it handled it, and found that it had no LODs either.

 

Attaching the separate pieces to each other doesn't work, because of how the textures are set up.  Unless there's some way that I'm not aware of, the only way I know to optimise these things is to create a new image file containing the common textures, and remap the UV coordinates on the merged model.



#2
rjshae

rjshae
  • Members
  • 4 485 messages

I've added LoD 1 to a few (~10) of the models thus far, but it's a lot of work and not very interesting.



#3
Nagual_NWN

Nagual_NWN
  • Members
  • 70 messages

It disturb me cause i use a lot multitexturing..and i m too bored to restart all i ve made.

Seems obsidian used mostly multi mesh when there was some part needing animation.In the 2da they use then attached model,but i haven t seen any lod on one of this model.

 

Btw could a prefab do the work?

 

Edit: you were able to ad LOD to multi sub object Rjshae?



#4
rjshae

rjshae
  • Members
  • 4 485 messages

It disturb me cause i use a lot multitexturing..and i m too bored to restart all i ve made.

Seems obsidian used mostly multi mesh when there was some part needing animation.In the 2da they use then attached model,but i haven t seen any lod on one of this model.

 

Btw could a prefab do the work?

 

Edit: you were able to ad LOD to multi sub object Rjshae?

 

Yes, adding LoD to a subset of a model's meshes seems to work.



#5
Nagual_NWN

Nagual_NWN
  • Members
  • 70 messages

Well i retested and it works now...don t know what i have miss at my early attempts :/

(only idea is it need to reload editor to take effects atm...)

 

Btw 7 k poly on simple house seems really a lot for nwn2.



#6
rjshae

rjshae
  • Members
  • 4 485 messages

Well i retested and it works now...don t know what i have miss at my early attempts :/

(only idea is it need to reload editor to take effects atm...)

 

Btw 7 k poly on simple house seems really a lot for nwn2.

 

Yes. For the models I looked at, he added a lot of bevels to the model edges. Much of my LoD efforts consisted of removing said bevels then correcting the UV map; typically that reduces the poly count by a half or more, with little appreciable visual difference (from a distance of course).



#7
Tchos

Tchos
  • Members
  • 5 042 messages

Can you find which ones you did, Bob?  Perhaps I can add to them, since you've mentioned that each sub-mesh can have its own LOD.  That hadn't occurred to me.  That means I can make a single "real" LOD object for each of the two resolutions, and make a "dummy" LOD consisting of a single polygon buried within the main one for the rest of them, which will at least speed up the process.

 

Nagual: These need LODs primarily because of their high polygon count.  If yours are sufficiently low, then the lack of LODs shouldn't cause much trouble.  It's just that these placeables tend to be used in high concentration in addition to being heavy.



#8
MokahTGS

MokahTGS
  • Members
  • 946 messages

I would greatly appreciate any work done on this project as I use it extensively as well.  I did at one point take all the textures from this hak and shrink them a bit to see if I could improve performance but I'm really just a noob with this stuff.

 

Actual optimization would be very nice.



#9
rjshae

rjshae
  • Members
  • 4 485 messages

Can you find which ones you did, Bob?

 

Thus far I've modified these: plc_bc_castlebuildingpart01, plc_bc_castleedges01, plc_bc_castleedges02, plc_bc_castleedges03, plc_bc_castlejail01, plc_bc_castlestairs01, plc_bc_castlestairs02, plc_bc_castlestairs03, plc_bc_castlestairs04, and plc_bc_castlestairs05. Here's a copy in case you want to test them and see if the LoD makes any difference.

 

The castleedges transition doesn't look great. Oh well. I will probably have to revisit that one.



#10
Tchos

Tchos
  • Members
  • 5 042 messages

Thanks!  I'll drop them in.  As long as the area in question uses some castle pieces, it should help.  At the moment, I'm testing out what I suggested in the previous post, on one of the houses in the "houselower" series.



#11
andysks

andysks
  • Members
  • 1 645 messages

The area uses castle pieces around the edges. I an't remember if they are there as placeables or if I converted them to environmental objects. Does it matter if they are converted?



#12
Tchos

Tchos
  • Members
  • 5 042 messages

Environmental objects do have a somewhat lower impact, but for different reasons.  I don't think using environmentals does much proportionally to LOD generation.

 

The good news is that using single polygons for all of the sub-parts works!  I haven't done enough of them yet to test it out in-game and see the difference, but I can see the swapping in the toolset.


  • rjshae aime ceci

#13
kamal_

kamal_
  • Members
  • 5 240 messages

If you want an area to test out optimizations in, Allyndyn's City (http://neverwinterva...a/allyndns-city) is a complete 16x16 or so city area built almost entirely with City Hak. I used it for the city of Pros in Path of Evil. The prefab uses camb's vines, but works fine without them.



#14
Tchos

Tchos
  • Members
  • 5 042 messages

Thanks, but I'm actually doing this because I already have a particular area in the module I'm beta testing, which is primarily built from the City Hak, and that's what I want to make run more smoothly.



#15
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

I'd be very interested in seeing where this goes, I have a lot of areas suffering framerate issues due to the city hak, the models are just too pretty not to use.



#16
Tchos

Tchos
  • Members
  • 5 042 messages

Oh, this is bliss.  It's a rough and sort of placeholder solution so far, but the frame rate has jumped up dramatically when I did this to the 9 houses used most often in this area.  I've identified 8 more in the area that I need to modify, and after that, the area should run very nicely.

 

Issues: The LOD swap is ignoring the textures I assign to the LOD models, instead using the textures (diffuse, normal, and tint) that are on the original model that it's swapping out.  Therefore, from far away, the buildings are built of only one of the single tiling images that one of the sub-objects uses, and moreover, the LODs in some cases are tinted black, which I believe is because some of the objects previously didn't have areas where the tint channels had any effect and were set to black as the stock blueprints are.

 

Since the area I'm doing this for is a very dense city where there are few places where you can see buildings at the sort of distance where the LOD swap occurs, this matters little.  As a quick and dirty solution, it's more than worth it.


  • BartjeD, PJ156 et andysks aiment ceci

#17
rjshae

rjshae
  • Members
  • 4 485 messages

The problem is that doing a proper job of LoD for that set will take darn near forever. I had to spend up to a couple of hours per model, just because many of them typically have multiple thousands of faces.

 

Something I need to experiment with is whether just deleting the beveled edges would be sufficient for LoD. If I can't see much of a difference at the distance that _L01 kicks in, then that would greatly simplify the task.



#18
MokahTGS

MokahTGS
  • Members
  • 946 messages

So how will this work?  Will I be able to just replace models in my HAKs and the areas will have the new versions or am I going to have to go through the areas and swap out the models manually?



#19
FaerzressSparkles

FaerzressSparkles
  • Members
  • 219 messages

The areas will work fine as long as the 2da references are the same. You could replace a house model with a rubber ducky model and it would work. You would just see a rubber ducky in place of the house model you replaced.



#20
rjshae

rjshae
  • Members
  • 4 485 messages

Right. Ideally it will just be a drop-in hak file swap. The only difference is that the hak file will be bigger.



#21
Tchos

Tchos
  • Members
  • 5 042 messages

Ideally, it needn't involve a hak at all.  I don't use haks for things like this.  I just put them in the campaign folder.  No way would I even consider editing these things if I had to put them in a hak every time I changed something!  But if you want to deal with sticking them in a hak, yes, they'll work fine that way, too.  In neither case would you have to change anything in your areas.  As mentioned, I'm doing this for a module I'm playing, and it's one of those where the area is so big and intensive that we can't even open it in the toolset anymore.

 

If you're happy with the quick fix I've done so far, which is as much as I plan to do for the time being, I'll package them up.



#22
Nagual_NWN

Nagual_NWN
  • Members
  • 70 messages

I think an old pw where i mapped the city with this hack would be more than happy to get this optimisation.

 

Btw i was wondering if it was possible to have a lod 1 or 2 with no model/poly.I may have to do another city after some mapping and ending dwarf thing and i was thinking to have all the little things just disappearing once you can t see them.(barrel,crate and others.)And i don t want to have a close far clip so you still can have some nice view of the city building at the horizon.

Worst case i could have only one triangle deep down under ground as LoD.



#23
rjshae

rjshae
  • Members
  • 4 485 messages

I haven't tested LoD with meshes that have zero faces. Worse case, you can set the face normal pointing downward so it can't be seen from above.



#24
Tchos

Tchos
  • Members
  • 5 042 messages

I haven't either.  I'm using single triangles, but I suppose I could have tried it with only a single vertex instead.  There has to be something there, in any case, but with a vertex there shouldn't be any texture calls, and you wouldn't see it.



#25
MokahTGS

MokahTGS
  • Members
  • 946 messages

Well out of curiosity, what 2DA ranges are these using?  I want to see if they match mine.