I was just wondering if anyone found a way of correcting this so I don't have to reinvent the wheel.
I found that if one uses a lighter color for the spec color that the problem is not as noticeable. Like this
Code: Select all
SpecularColor [ 0.180 0.170 0.155 ]
Here is the program that does this. It looks and works a lot like nm16 because I used it as a template. I only built it with linux. It builds on Windows but doesn't work. I also recolored my oceans slightly so you may not get the same affect when combined with a unaltered texture. Build it with
Code: Select all
g++ -O3 bmng-spec5.cpp -o bmng-spec
Code: Select all
bmng-spec5 4096 4096 < testa.rgb > spec-testa.ppm
Again this DOES NOT work with Windows.
Code: Select all
#include <iostream>
#include <cstdio>
#include <stdio.h>
using namespace std;
int start = 2;
int change = 1;
unsigned char readRGB(FILE *in)
{
unsigned char c[1];
fread(c, 1, 1, in);
//fscanf(stdin, %s, &c );
return c[0];
}
unsigned char* readRowRGB(FILE* in, int width)
{
unsigned char* row = new unsigned char[width * 3];
for (int i = 0; i < width * 3; i++)
row[i] = readRGB(in);
return row;
}
int main(int argc, char* argv[])
{
if (argc < 3)
{
cerr << "Usage: bmng-fix <width> <height> \n";
return 1;
}
int width = 0;
int height = 0;
if (sscanf(argv[1], " %d", &width) != 1 ||
sscanf(argv[2], " %d", &height) != 1)
{
cerr << "Bad image dimensions.\n";
return 1;
}
fprintf(stdout, "P6\n");
fprintf(stdout, "%d %d\n255\n", width, height);
unsigned char** samples = new unsigned char*[height];
unsigned char* rgb = new unsigned char[width * 3];
for (int i = 0; i < start - 1; i++)
samples[i] = readRowRGB(stdin, width);
for (int y = 0; y < height; y++)
{
if (y % 100 == 0)
cerr << '[' << y << ']';
if (y > change)
delete[] samples[y - change - 1];
if (y < height - change)
samples[y + change] = readRowRGB(stdin, width);
for (int x = 0; x < width; x++)
{
unsigned char r;
unsigned char g;
unsigned char b;
r = samples[y][x * 3 + 0];
g = samples[y][x * 3 + 1];
b = samples[y][x * 3 + 2];
if ( r <= 0x08 )
r = 0xff,
g = 0xff,
b = 0xff;
else
r = 0x00,
g = 0x00,
b = 0x00;
rgb[x * 3 + 0] = (unsigned char) (r);
rgb[x * 3 + 1] = (unsigned char) (g);
rgb[x * 3 + 2] = (unsigned char) (b);
}
fwrite(rgb, width, 3, stdout);
}
return 0;
}
I'm also trying some other things because this does not include rivers and a lot of the small lakes.
Good Luck,
cartrite