I think the problem on the F7 screen is that the new planet image is being super-imposed over the old planet image.
Still looks stunning in real space though!
F7 Screen :

Same Planet in real space:

Moderators: winston, another_commander
That might have been funny... I could get the mangled names using objdump. Luckily I don't have to go there now :)Ahruman wrote:The only alternative I can think of to wrapping like this is to use the mangled symbols directly, which is possible but horrible (and I really don’t feel like going into it). Building the wrapper into a DLL sounds feasible. The fact that the GNUstep compiler flavour doesn’t support C++ sounds perverse and dogmatic, but maybe that’s just me; building gcc with both ObjC and C++ support shouldn’t be much harder than building it with just one of the two (and is different from supporting ObjC++).
Code: Select all
float lerp5( float v0, float v1, float v2, float v3, float v4, float q)
{
if (q < 0.25)
return v0 * (1.0 - q * 4.0) + v1 * q * 4.0;
q -= 0.25;
if (q < 0.25)
return v1 * (1.0 - q * 4.0) + v2 * q * 4.0;
q -= 0.25;
if (q < 0.25)
return v2 * (1.0 - q * 4.0) + v3 * q * 4.0;
q -= 0.25;
if (q < 0.25)
return v3 * (1.0 - q * 4.0) + v4 * q * 4.0;
return v4; // values of q over 1.0
}
float my_lerp( float v0, float v1, float q)
{
float q1 = 0.5 * (1.0 + cosf((q + 1.0) * PI));
return v0 * (1.0 - q1) + v1 * q1;
}
void addNoise(float * buffer, int p, int n, float scale)
{
int x, y;
float R[n*n];
for (y = 0; y < n; y++) for (x = 0; x < n; x++) R[y * n + x] = randf(); // random array
float r = (float)p / (float)n;
for (y = 0; y < p; y++) for (x = 0; x < p; x++)
{
int ix = floor( (float)x / r);
int jx = (ix + 1) % n;
int iy = floor( (float)y / r);
int jy = (iy + 1) % n;
float qx = x / r - ix;
float qy = y / r - iy;
float rix = my_lerp( R[iy * n + ix], R[iy * n + jx], qx);
float rjx = my_lerp( R[jy * n + ix], R[jy * n + jx], qx);
float rfinal = scale * my_lerp( rix, rjx, qy);
buffer[ y * p + x ] += rfinal;
}
}
void fillSquareImageDataWithSmoothNoise(unsigned char * imageBuffer, int width, int nplanes)
{
float accbuffer[width * width];
int x, y;
for (y = 0; y < width; y++) for (x = 0; x < width; x++) accbuffer[ y * width + x] = 0.0f;
// generate 6 octaves of noise
int octave = 4;
float scale = 0.5;
int n;
for (n = 0; n < 6; n++)
{
addNoise( accbuffer, width, octave, scale);
octave *= 2;
scale *= 0.5;
}
for (y = 0; y < width; y++) for (x = 0; x < width; x++)
{
int p;
float q = accbuffer[ y * width + x];
q = 2.0f * ( q - 0.5f);
if (q < 0.0f)
q = 0.0f;
for (p = 0; p < nplanes - 1; p++)
imageBuffer[ p + nplanes * (y * width + x) ] = 255 * q;
imageBuffer[ p + nplanes * (y * width + x) ] = 255;
}
}
void fillSquareImageWithGenTex(unsigned char * imageBuffer, int width, int nplanes, float impress, float bias,
OOColor* c0, OOColor* c1, OOColor* c2, OOColor* c3, OOColor* c4)
{
float accbuffer[width * width];
int x, y;
for (y = 0; y < width; y++) for (x = 0; x < width; x++) accbuffer[ y * width + x] = 0.0f;
// generate 4 octaves of noise
int octave = 4;
float scale = 0.5;
int n;
for (n = 0; n < 6; n++)
{
addNoise( accbuffer, width, octave, scale);
octave *= 2;
scale *= 0.5;
}
for (y = 0; y < width; y++) for (x = 0; x < width; x++)
{
float q = accbuffer[ y * width + x];
q = impress * q + bias;
if (q < 0.0) q = 0.0;
if (q > 1.0) q = 1.0;
float red = lerp5( [c0 redComponent], [c1 redComponent], [c2 redComponent], [c3 redComponent], [c4 redComponent], q);
float blue = lerp5( [c0 blueComponent], [c1 blueComponent], [c2 blueComponent], [c3 blueComponent], [c4 blueComponent], q);
float green = lerp5( [c0 greenComponent], [c1 greenComponent], [c2 greenComponent], [c3 greenComponent], [c4 greenComponent], q);
if (nplanes == 1)
imageBuffer[ y * width + x ] = 255 * q;
if (nplanes == 3)
{
imageBuffer[ 0 + 3 * (y * width + x) ] = 255 * red;
imageBuffer[ 1 + 3 * (y * width + x) ] = 255 * green;
imageBuffer[ 2 + 3 * (y * width + x) ] = 255 * blue;
}
if (nplanes == 4)
{
imageBuffer[ 0 + 4 * (y * width + x) ] = 255 * red;
imageBuffer[ 1 + 4 * (y * width + x) ] = 255 * green;
imageBuffer[ 2 + 4 * (y * width + x) ] = 255 * blue;
imageBuffer[ 3 + 4 * (y * width + x) ] = 255;
}
}
}
I'm impressed at how quickly you pulled that together... weren't you busy with other things? ;)aegidian wrote:Not developing on the PC I couldn't compile your experiments, so I picked up my graphics textbooks and rolled my own.
libnoise has a lot of good stuff in it. There are multiple noise generators, probably all based on perlin noise, but with usefully different results.aegidian wrote:libnoise has built in routines for generating neato planet textures (their webpage seems to imply this)? Are these what you're using?
To turn perlin noise (with each value clamped between 0.0and 1.0) into colour I presume you're either sampling a 1d texture at the given value, or using some other gradient method? Or is this another function of libnoise?
Ah, I tried the planets out and they are fabulous! Now I cannot wait to see how the better quality textures and libnoise atmosphere&clouds will look like!dajt wrote:What you're seeing on the planetary info page is the original atmosphere and clouds being rendered, which I'd disabled in the space view while debugging the textures. I'll put the originals back for now until the libnoise ones are going.