PrismaticFlower / shaderpatch

Improved shaders (and fun stuff for modders) for Star Wars Battlefront II (2005) - Incompatible with Classic Collection
MIT License
39 stars 2 forks source link

Materials on ordnance geometry crash the game #62

Closed DoctorAnsem closed 4 years ago

DoctorAnsem commented 5 years ago

I have a very strong hunch this is related to #34 as the stock version works fine, but yeah this is a thing nonetheless. A thermal detonator with SP materials always crashes the game just as it's going to explode, which makes me think lvl_pack (assuming it's the one in charge of wrapping it all up) is not packing the explosion classes in. As I believe #34 was caused by the animation banks not being included, it would stand to reason this is the same kind of problem but of course I'll let you be the judge of that.

PrismaticFlower commented 5 years ago

Interesting. Do BFront2.log or shader patch.log hold any clues?

DoctorAnsem commented 5 years ago

I didn't catch any at the time it happened, but now I think I've been trolled. I can't replicate the crash anymore, which is stupid because all I did was clean the munged files and take out the material from the sides folder, then munge without it - now I wanted to double check the logs so I re-munged the material, and apparently now there's nothing wrong with the weapon. It's not like I changed anything in the material since the beginning so I haven't the slightest clue why it didn't work the first time. Maybe BF2 just hates me.

Thing is though, I'm not sure I'm seeing the PBR material on the grenade now. I wonder if it failed to munge properly after all.

DoctorAnsem commented 5 years ago

Update. While this crash never resurfaced again, there's a little bit of an interesting thing that popped up in the log just now. As it seems, the material of the ordnance model was loaded, but after that there's a "Destroying material" message regarding it. Is this supposed to happen? If it means the material is released because there was nothing using it, I guess it makes sense... but of course an ordnance model can't be there to use it all the time so this could be a logic issue, I suppose?

PrismaticFlower commented 5 years ago

Material lifetime should be controlled by the game. Is it possible an .lvl or child lvl being loaded after that one is also loading "cool_ordnance_material" not as a material but as a texture? That could cause it to get seemingly mysteriously destroyed and replaced like this.

DoctorAnsem commented 5 years ago

Oh. Well, yeah, that's definitely happening but I thought it was fine since the game's standard order of operations is load first instance of an asset -> discard the subsequent ones. I suppose there's one more test I can do to find out.

PrismaticFlower commented 5 years ago

Usually that is what happens but textures (which is what materials are loaded as from the game's perspective) are different. For whatever reason they decided to do it the other way for them, discard the previously loaded texture and load the new one.

DoctorAnsem commented 5 years ago

After a little bit of sorting, I've now successfully gotten the ordnance material working in game. I don't think this crash is going to happen anymore.