From 17db004ba1e49a7cd64075448f12ef1f6b736635 Mon Sep 17 00:00:00 2001 From: Allanis Date: Fri, 19 Jul 2013 19:18:04 +0100 Subject: [PATCH] [Fix] Tweaked a little bit, and the transitions is perfectly smooth now. --- src/nebulae.c | 9 +++++---- src/perlin.c | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/nebulae.c b/src/nebulae.c index 643627b..c0f0018 100644 --- a/src/nebulae.c +++ b/src/nebulae.c @@ -10,7 +10,7 @@ #include "rng.h" #include "perlin.h" -#define NEBU_DT_MAX 1. +#define NEBU_DT_MAX 5. #define NEBULAE_Z 16 /* Z plane. */ #define NEBULAE_PATH "gen/nebu_%02d.png" @@ -132,12 +132,12 @@ void nebu_render(void) { /* Texture 0. */ glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, nebu_textures[cur_nebu[0]]); + glBindTexture(GL_TEXTURE_2D, nebu_textures[cur_nebu[1]]); /* Texture 1. */ glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, nebu_textures[cur_nebu[1]]); + glBindTexture(GL_TEXTURE_2D, nebu_textures[cur_nebu[0]]); /* Prepare it. */ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); @@ -147,8 +147,9 @@ void nebu_render(void) { glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, col); /* Arguments. */ + /* Arg0 */ glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_CONSTANT); - glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE1); + glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); /* Arg 1. */ diff --git a/src/perlin.c b/src/perlin.c index 58cfcf2..c20bf36 100644 --- a/src/perlin.c +++ b/src/perlin.c @@ -199,8 +199,10 @@ float* noise_genNebulaeMap(const int w, const int h, const int n, float rug) { /* Start to create the nebulae. */ max = 0.; - f[2] = 0.; for(z = 0; z < n; z++) { + + f[2] = zoom * (float)z / (float)n; + for(y = 0; y < h; y++) { f[1] = zoom * (float)y / (float)h; @@ -215,7 +217,6 @@ float* noise_genNebulaeMap(const int w, const int h, const int n, float rug) { nebulae[z*w*h + y*w+x] = value; } } - f[2] += 0.01; /* More time magic debug. */ t[z] = SDL_GetTicks();