301
Projects, demos, and games Information / Re: STICKY: 2020 King's Field II port progress report
« on: June 18, 2020, 07:07:33 AM »
Random update
I told myself I would add the pirate skeletons, mosquitoes, and sigils today, rounding out the demo's monsters and NPCs, but instead I found myself (again) obsessing over the color function to see if I could make it better, just by luck I guess, since I've never had the good sense to set up a proper UI for dialing parameters up and down. And in this case it wouldn't work anyway since the function is hardwired into the shader.
Usually this just gets me on a roll whiling away hours possibly, playing with the numbers, but I decided to consider if my old formula was wrong to scale the texture colors when mapping them into the power function, mainly because I'd reached the limits of what I could do to try to improve the color because I always ran into the problem with the bright marbled ceilings becoming to garish to go on.
To my surprise I found out I could make almost anything look acceptable by scaling and shifting the outputs a little bit. I think this is a problem I often run into where either I assume that if a bug can exist that it will appear instantly, since it's hard to imagine most would not, or in this case, if something works, then I assume that there aren't other solutions that would work too. And so don't go further.
So I decided the old solution to the color was too baroque and so started looking for a simper solution, and I eventually convinced myself the power for the formula was 1.25 instead of 1.5. Even though a little surprised I was pleased that less power meant the ceiling situation could be less going forward, and I kind of knew the power had to be less because I thought probably the color in the textures just mapped far enough to cover the unused space in the palette.
Oh, and something important I forgot is my first experiment was to situate the middle of the color on 1 for the power function, whereas the old formula set the brightest color at 1 and shifted the darkest colors up, so instead of making a hump it was just a ramp. What surprised me is that both approaches can appear so similar even though they're radically different. (And as a reminder I sat down and compared individual pixel values with the old formula, so it was accurate over a large swath of the game's surfaces to the pixel value. But there were a few cases it couldn't cover. I checked all of those cases with the new formula and everything seems to match. But I haven't sat down to test pixel values and the new working formula is just an approximation. I actually don't like the standard color so much, so I'm not super concerned with perfecting it since the lighting is pretty much hammered out.)
Maybe this is more critical than figuring out that the power is 1.25. My motivation for shifting the center was the ceiling again. I thought if I could position it in the center then the power function would affect it least.
The black fog's power is 1.25 too. Speaking of which, yesterday I worked on the little fireflies around the lighthouse. I think these are called Fire Elementals in one version of the game or both?
The first problem was finding out if SOM could do them since something like them had never been demonstrated. Although I think I remember someone finding the necessary data in the SFX.dat file. I think KFII just copies the sprites directly onto the screen. SOM doesn't do that that I know of, at least not for its little "flame" sprites. I had to use a flame for the fireflies and was able to make it face the screen in both directions, however I think it needs some work because it doesn't take into account the direction you're looking, so it isn't as convincing up close as in KFII. I assume it's possible to refine it, but I don't know with certainty.
Finally, I knew that I would have to add something to make them blend into the fog. I think ever since I added the "shader" system to SOM I purposefully made sprites to not disappear into the fog. I also found out yesterday that the sprite system always treats sprites as transparent elements, so you can't even make one that isn't part of the transparency layer.
Originally SOM didn't apply fog to any transparent elements, so technically speaking sprites were never in the fog, although they were as some point, and still may be if you bypassed the shader system.
My reason for excluding them is I thought that they just looked better if you could see the flames even when everything around them were still in fog. It makes sense since the flame should stand out from the fog. Some of the monsters with flames are more ominous since you can see the flames peeking through the darkness before you can see the source.
But the sprites appear out of nowhere since they aren't blended into the fog. I never really noticed until now. I guess it needs certain conditions to be noticeable, like for one, a short draw distance, otherwise the flames might first be so small in the distance as to go unnoticed.
Nevertheless what's called for is a smooth transition, as always. In fact I don't put a lot of stock into "graphics" for SOM but I do take seriously smooth transitions, no sharp edges in other words. So what I've done is to change the fog factors just for sprites, and add some new extensions to cover this, that are fov_sky_and_fog_powers3 and fov_sky_and_fog_powers4. The default behavior is to use 70% of the sky power and 35% of the fog power. This may not always be acceptable.
The idea is for the sprites to just appear almost like a lamp turning on. Not out of the blue but pretty quickly so they're at their full brightness almost as fast as snapping your fingers.
I told myself I would add the pirate skeletons, mosquitoes, and sigils today, rounding out the demo's monsters and NPCs, but instead I found myself (again) obsessing over the color function to see if I could make it better, just by luck I guess, since I've never had the good sense to set up a proper UI for dialing parameters up and down. And in this case it wouldn't work anyway since the function is hardwired into the shader.
Usually this just gets me on a roll whiling away hours possibly, playing with the numbers, but I decided to consider if my old formula was wrong to scale the texture colors when mapping them into the power function, mainly because I'd reached the limits of what I could do to try to improve the color because I always ran into the problem with the bright marbled ceilings becoming to garish to go on.
To my surprise I found out I could make almost anything look acceptable by scaling and shifting the outputs a little bit. I think this is a problem I often run into where either I assume that if a bug can exist that it will appear instantly, since it's hard to imagine most would not, or in this case, if something works, then I assume that there aren't other solutions that would work too. And so don't go further.
So I decided the old solution to the color was too baroque and so started looking for a simper solution, and I eventually convinced myself the power for the formula was 1.25 instead of 1.5. Even though a little surprised I was pleased that less power meant the ceiling situation could be less going forward, and I kind of knew the power had to be less because I thought probably the color in the textures just mapped far enough to cover the unused space in the palette.
Oh, and something important I forgot is my first experiment was to situate the middle of the color on 1 for the power function, whereas the old formula set the brightest color at 1 and shifted the darkest colors up, so instead of making a hump it was just a ramp. What surprised me is that both approaches can appear so similar even though they're radically different. (And as a reminder I sat down and compared individual pixel values with the old formula, so it was accurate over a large swath of the game's surfaces to the pixel value. But there were a few cases it couldn't cover. I checked all of those cases with the new formula and everything seems to match. But I haven't sat down to test pixel values and the new working formula is just an approximation. I actually don't like the standard color so much, so I'm not super concerned with perfecting it since the lighting is pretty much hammered out.)
Maybe this is more critical than figuring out that the power is 1.25. My motivation for shifting the center was the ceiling again. I thought if I could position it in the center then the power function would affect it least.
The black fog's power is 1.25 too. Speaking of which, yesterday I worked on the little fireflies around the lighthouse. I think these are called Fire Elementals in one version of the game or both?
The first problem was finding out if SOM could do them since something like them had never been demonstrated. Although I think I remember someone finding the necessary data in the SFX.dat file. I think KFII just copies the sprites directly onto the screen. SOM doesn't do that that I know of, at least not for its little "flame" sprites. I had to use a flame for the fireflies and was able to make it face the screen in both directions, however I think it needs some work because it doesn't take into account the direction you're looking, so it isn't as convincing up close as in KFII. I assume it's possible to refine it, but I don't know with certainty.
Finally, I knew that I would have to add something to make them blend into the fog. I think ever since I added the "shader" system to SOM I purposefully made sprites to not disappear into the fog. I also found out yesterday that the sprite system always treats sprites as transparent elements, so you can't even make one that isn't part of the transparency layer.
Originally SOM didn't apply fog to any transparent elements, so technically speaking sprites were never in the fog, although they were as some point, and still may be if you bypassed the shader system.
My reason for excluding them is I thought that they just looked better if you could see the flames even when everything around them were still in fog. It makes sense since the flame should stand out from the fog. Some of the monsters with flames are more ominous since you can see the flames peeking through the darkness before you can see the source.
But the sprites appear out of nowhere since they aren't blended into the fog. I never really noticed until now. I guess it needs certain conditions to be noticeable, like for one, a short draw distance, otherwise the flames might first be so small in the distance as to go unnoticed.
Nevertheless what's called for is a smooth transition, as always. In fact I don't put a lot of stock into "graphics" for SOM but I do take seriously smooth transitions, no sharp edges in other words. So what I've done is to change the fog factors just for sprites, and add some new extensions to cover this, that are fov_sky_and_fog_powers3 and fov_sky_and_fog_powers4. The default behavior is to use 70% of the sky power and 35% of the fog power. This may not always be acceptable.
The idea is for the sprites to just appear almost like a lamp turning on. Not out of the blue but pretty quickly so they're at their full brightness almost as fast as snapping your fingers.