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

basic_unlit sky dome materials sometimes don't work properly #89

Closed DoctorAnsem closed 4 years ago

DoctorAnsem commented 5 years ago

I've had this happen on a couple of maps now. While the materials and their textures do load up properly, they render not so much. It seems that only at a certain angle the actual sky material is visible, but when I turn the camera it randomly flickers between normal maps from other materials.

PrismaticFlower commented 5 years ago

Hmm, would I be able to bother you for the relevant model (with it's accompany textures and material) and the skydome entry for it?

DoctorAnsem commented 5 years ago

Yeah, I guess. I'll include both of the skies that had this problem, although there isn't really anything special about them, I don't think. I've actually had these kind of issues happen before, but with particles and such. It usually corrected itself after a clean munge, but these skies got mangled up right after a clean munge either way so it probably won't do much here.

skies.zip

PrismaticFlower commented 4 years ago

I'm unable to reproduce this sorry. I copied your files into my test world and both skies seemed to render normally. What does the ingame material editor display as the textures for them for you?

image

DoctorAnsem commented 4 years ago

It displays the textures as they should be, nothing to go on from there.

Though I'm curious, might your test world contain water? It so far seems to be the only thing these two maps I'm having this problem in have in common. It's a stretch, I know, but there is something causing unrelated normal, height and AO maps to leak into the sky and this is as good a guess as any I can throw at this point.

DoctorAnsem commented 4 years ago

Damn, that was actually it. I turned off ingame water in zero editor and it resolved all the mayhem in the sky, and sure enough, turning it back on reverted the effect.

PrismaticFlower commented 4 years ago

Frustratingly even once I add water to my test world I can't replicate it this at all. Maybe it's possible some change I've already made has fixed it, but I find that unlikely. You'll have to let me know once the next version drops, shouldn't be long now.

PrismaticFlower commented 4 years ago

I just encountered and fixed a bug that could be related or the same thing. In this case the material would randomly flicker between displaying properly and just being black. The cause it turns out was that there are points where SP clears the game's device context state in order to do something itself, afterwards it restores the game's state. Mistakenly custom materials resource bindings were not being restored. Which meant that if you had the right series of draw calls and actions from the game the custom material would end up getting drawn without any of it's resources bound, causing it to turn up black.

I can't be certain without having replicated your bug myself but it seems possible it's just a different manifestation of the same (now fixed) bug. Again you'll have to let me know once the next version is out.

DoctorAnsem commented 4 years ago

Yep, it's been fixed in all the cases where I had the bug. Skies are looking good.