Hi all,
So I use the Evolved Advanced Lighting system in my game, and I have a strange thing going on...
During the course of a user playing the game, the advanced lighting system is loaded and cleared multiple times. The game is broken into 3 different area "types"; dungeons, towns and countryside.
When setting up Post Processing in dungeons and countryside areas, the whole process is done in about 4 seconds, but when setting it up in towns for some reason that blows out to about 35 seconds, and I'm not entirely sure why. The code used to set up the advanced lighting and post-processing is the same for each of the three areas - the only difference being the shaders loaded (which happens AFTER the post processing setup anyway).
I thought perhaps it was due to the game assets not being purged correctly beforehand, but that's not the case - I checked... Every memblock, object, image, sprite, effect, etc is being fully cleared before setting up the advanced lighting in each of the three scenarios, meaning the environment should be clear for it to be set up.
=== LONG STORY SHORT ===
Thinking this was odd, I went deeper into the Evolved code and stepped it out to see where it was slowing down, and I found out where the slow-down is happening... There's a part of the code where it opens up the shader files and edits the values in there based on the settings which are being passed in. It does this with a simple "OPEN TO WRITE" process. However, despite the shader file being only about 80 lines of text long, it is taking up to 6 seconds per file to open up and process. And yet, when I run the exact same code in other parts of my program, it doesn't take that long - in fact it takes a 10th of that time or less.
What could cause a file open/write to slow down so much? I'd post code examples, but there's about 94,000 lines lol so basically I'm looking for suggestions on where I should be looking to find the cause of this issue...
I'm aware that this is a bizarre problem, so if I have missed out some vital piece of info please tell me and I'll do my best to answer it. This issue has been driving me mental!