[Change] Puffs of nebulae now look more visually pleasing.
This commit is contained in:
parent
497081b3ed
commit
cc37706fb1
@ -43,7 +43,6 @@ static glTexture* nebu_pufftexs[NEBULAE_PUFFS];
|
||||
/* Puff handling. */
|
||||
typedef struct NebulaePuff_ {
|
||||
double x, y; /* Position. */
|
||||
double a, va; /* Alpha, alpha velocity. */
|
||||
double height; /* Height vs player. */
|
||||
int tex; /* Texture. */
|
||||
} NebulaePuff;
|
||||
@ -256,13 +255,15 @@ void nebu_renderOverlay(const double dt) {
|
||||
#define ANG45 0.70710678118654757
|
||||
#define COS225 0.92387953251128674
|
||||
#define SIN225 0.38268343236508978
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glTranslated(gui_xoff+shake_pos.x, gui_yoff+shake_pos.y, 0.);
|
||||
|
||||
/* Render the puffs. */
|
||||
nebu_renderPuffs(dt, 0);
|
||||
|
||||
/* Prepare the matrix. */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glTranslated(gui_xoff+shake_pos.x, gui_yoff+shake_pos.y, 0.);
|
||||
|
||||
/* Mask for area player can still see (partially). */
|
||||
glShadeModel(GL_SMOOTH);
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
@ -345,11 +346,6 @@ void nebu_renderOverlay(const double dt) {
|
||||
/* Render the puffs. */
|
||||
void nebu_renderPuffs(const double dt, int below_player) {
|
||||
int i;
|
||||
glColour cPuff;
|
||||
|
||||
cPuff.r = cPurple.r;
|
||||
cPuff.g = cPurple.g;
|
||||
cPuff.b = cPurple.b;
|
||||
|
||||
for(i = 0; i < nebu_npuffs; i++) {
|
||||
if((below_player && (nebu_puffs[i].height < 1.)) ||
|
||||
@ -357,14 +353,11 @@ void nebu_renderPuffs(const double dt, int below_player) {
|
||||
|
||||
/* Calculate new position. */
|
||||
if(!paused) {
|
||||
nebu_puffs[i].x -= player->solid->vel.x * nebu_puffs[i].height * dt;
|
||||
nebu_puffs[i].y -= player->solid->vel.y * nebu_puffs[i].height * dt;
|
||||
/* TODO: WTF?!? */
|
||||
/*nebu_puffs[i].x -= player->solid->vel.x * nebu_puffs[i].height * dt;*/
|
||||
/*nebu_puffs[i].y -= player->solid->vel.y * nebu_puffs[i].height * dt;*/
|
||||
}
|
||||
|
||||
/* Calculate new alpha. */
|
||||
/*nebu_puffs[i].a += nebu_puffs[i].va * dt;*/
|
||||
cPuff.a = nebu_puffs[i].a;
|
||||
|
||||
/* Check boundaries. */
|
||||
if(nebu_puffs[i].x > SCREEN_W + NEBULAE_PUFF_BUFFER)
|
||||
nebu_puffs[i].x = -NEBULAE_PUFF_BUFFER;
|
||||
@ -377,7 +370,7 @@ void nebu_renderPuffs(const double dt, int below_player) {
|
||||
|
||||
/* Render. */
|
||||
gl_blitStatic(nebu_pufftexs[nebu_puffs[i].tex],
|
||||
nebu_puffs[i].x, nebu_puffs[i].y, &cPuff);
|
||||
nebu_puffs[i].x, nebu_puffs[i].y, &cPurple);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -398,8 +391,7 @@ void nebu_prep(double density, double volatility) {
|
||||
SCREEN_W + NEBULAE_PUFF_BUFFER);
|
||||
nebu_puffs[i].y = (double)RNG(-NEBULAE_PUFF_BUFFER,
|
||||
SCREEN_H + NEBULAE_PUFF_BUFFER);
|
||||
nebu_puffs[i].a = (double)RNG(20,100)/100.;
|
||||
nebu_puffs[i].height = RNGF()*2.;
|
||||
nebu_puffs[i].height = RNGF() + 0.2;
|
||||
}
|
||||
}
|
||||
|
||||
|
16
src/perlin.c
16
src/perlin.c
@ -243,7 +243,8 @@ float* noise_genNebulaeMap(const int w, const int h, const int n, float rug) {
|
||||
|
||||
/* Generate tiny nebuale puffs */
|
||||
float* noise_genNebulaePuffMap(const int w, const int h, float rug) {
|
||||
int x, y;
|
||||
int x, y, hw, hh;
|
||||
float d;
|
||||
float f[3];
|
||||
int octaves;
|
||||
float hurst;
|
||||
@ -271,12 +272,20 @@ float* noise_genNebulaePuffMap(const int w, const int h, float rug) {
|
||||
/* Start to create the nebulae. */
|
||||
max = 0.;
|
||||
f[2] = 0.;
|
||||
hw = w/2;
|
||||
hh = h/2;
|
||||
d = (float)MIN(hw, hh);
|
||||
for(y = 0; y < h; y++) {
|
||||
f[1] = zoom * (float)y / (float)h;
|
||||
for(x = 0; x < w; x++) {
|
||||
f[0] = zoom * (float)x / (float)w;
|
||||
|
||||
value = noise_turbulence(noise, f, octaves);
|
||||
|
||||
/* Make value also depend on distance from center. */
|
||||
value *= (d - 1. - sqrtf((float)((x-hw)*(x-hw)+(y-hh)*(y-hh))))/d;
|
||||
if(value < 0.) value = 0.;
|
||||
|
||||
if(max < value) max = value;
|
||||
|
||||
nebulae[y*w + x] = value;
|
||||
@ -284,10 +293,11 @@ float* noise_genNebulaePuffMap(const int w, const int h, float rug) {
|
||||
}
|
||||
|
||||
/* Post filtering. */
|
||||
value = 1. - max;
|
||||
/*value = 1. - max;
|
||||
for(y = 0; y < h; y++)
|
||||
for(x = 0; x < w; x++)
|
||||
nebulae[y*w + x] += value;
|
||||
if(nebulae[y*w+x] > 0.)
|
||||
nebulae[y*w + x] += value;*/
|
||||
|
||||
/* Clean up. */
|
||||
noise_delete(noise);
|
||||
|
Loading…
Reference in New Issue
Block a user