To see exactly what I mean, look at these examples: https://imgur.com/a/C5PNs
Seeing them side-by-side, Factorio's current appearance is just crazy dark. Even in the middle of the day it's difficult to see because there isn't enough light. It looks like it does when you're outside and it's all dark and cloudy because it's about to start raining. That's as bright as the game ever gets.
I got the brighter images simply by modifying the game's graphics files, something the game itself could easily do as it loads them. The same modifications work for both day and night, so this is very easy to fix.
EDIT: Later in this thread I post a link to a Windows program I wrote that can do what this code does automatically.
Here's the complete source code for the utility I made to modify the graphics. It also needs "stb_image" library which is available on the internet, but of course if this were integrated into Factorio, it would just use whatever Factorio presently uses to load graphics, and it wouldn't need to save the graphics afterwards.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
int main(int argc, char **argv) {
if (argc < 3) {
fprintf(stderr, "Please supply input and output file names.\n");
exit(1);
};
// load the input image
int width, height, channels;
unsigned char *image = stbi_load(argv[1], &width, &height, &channels, 4);
if (image == NULL) {
printf("Failed to load '%s': %s\n", argv[1], stbi_failure_reason());
exit(1);
};
// There're only 256 possible inputs, so to
// speed things up, store the results of
// the brightening calculations in a table.
unsigned char old_to_new[256];
for (int i = 0; i < 256; i++) {
// remove gamma curve
float t = powf((i + 0.5f) / 256.0f, 2.2f);
// apply a brightening formula
t = 0.25f * sqrtf(t) + 3.0f * t;
// Generally it makes it 3x brighter, but it
// also brightens the darks a little more.
// apply gamma curve
int o = 256.0f * powf(t, 1.0f / 2.2f);
// clip the values
if (o < 0) o = 0;
if (o > 255) o = 255;
// save in table
old_to_new[i] = o;
};
// modify all the pixels
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
for (int c = 0; c < 3; c++) {
int t = *(image + (y * width + x) * 4 + c);
t = old_to_new[t];
*(image + (y * width + x) * 4 + c) = t;
};
};
};
// save the output image
stbi_write_png(argv[2], width, height, 4, image, width * 4);
stbi_image_free(image);
};
I (and I assume everyone else) would really appreciate it if the developers could integrate this code into Factorio itself. The game is just crazy dark by default, and even though I have this solution for myself, the darkness still annoys me. I can only update the game with the original files in place. Since there are updates seemingly every day, that means I have to quit the game, put the old graphics files back, run the game, do the update, quit the game, re-run this code to brighten the graphics, then run the game again. What's worse, I now want to help out a friend by making his game brighter too, but the thought of explaining to him how to do this is a bit much. In particular, the script I use in my Linux won't work in his Windows, and I can't write a script for him that does because I don't have Windows and so I can't test it. ...and the thought of trying to do so seems silly when this is something the game ought to be able to fix for itself.
Please, please, make Factorio brighter. Even having my own fix for this problem, it still tortures me. I can't imagine how much it tortures the average player who can't fix it for themselves. I really don't understand how it doesn't torture the developers, unless maybe they all play the game in total darkness to compensate for the game's darkness. If I were a Factorio developer, this would be my #1 priority as it is the most conspicuous defect in the game and incredibly easy to fix.