Skip to content

Commit

Permalink
gaseous-giganticus: Fix discontinuities in the velocity field.
Browse files Browse the repository at this point in the history
The problem was in fij_to_xyz().  I had converted i and j
correctly to the correct pair of x, y and z, scaled between 0
and 1, but the remaining coordinate, I scaled between 0 and 500
or so.  So the noise field that was being represented was 6
tiny very separate regions on the face of a sphere (imagine
the central mechanism of a dismantled rubik's cube -- the
six separated square faces on this mechanism were somewhat
like the noise I was sampling.)  This also explained why I
had to pick seemingly excessively large noise scale values.
  • Loading branch information
smcameron committed May 3, 2014
1 parent bf7abfa commit 8896774
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions gaseous-giganticus.c
Expand Up @@ -41,8 +41,8 @@
#define YDIM DIM

static const int niterations = 1000;
static const float noise_scale = 1000.0;
static const float velocity_factor = 1.0;
static const float noise_scale = 2.0;
static const float velocity_factor = 80.0;

static char *start_image;
static int start_image_width, start_image_height, start_image_has_alpha;
Expand Down Expand Up @@ -154,31 +154,31 @@ static union vec3 fij_to_xyz(int f, int i, int j)
case 0:
answer.v.x = (float) (i - XDIM / 2) / (float) XDIM;
answer.v.y = -(float) (j - YDIM / 2) / (float) YDIM;
answer.v.z = (float) DIM / 2.0f;
answer.v.z = 0.5;
break;
case 1:
answer.v.x = (float) DIM / 2.0f;
answer.v.x = 0.5;
answer.v.y = -(float) (j - YDIM / 2) / (float) YDIM;
answer.v.z = -(float) (i - XDIM / 2) / (float) XDIM;
break;
case 2:
answer.v.x = -(float) (i - XDIM / 2) / (float) XDIM;
answer.v.y = -(float) (j - YDIM / 2) / (float) YDIM;
answer.v.z = -(float) DIM / 2.0f;
answer.v.z = -0.5;
break;
case 3:
answer.v.x = -(float) DIM / 2.0f;
answer.v.x = -0.5;
answer.v.y = -(float) (j - YDIM / 2) / (float) YDIM;
answer.v.z = (float) (i - XDIM / 2) / (float) XDIM;
break;
case 4:
answer.v.x = (float) (i - XDIM / 2) / (float) XDIM;
answer.v.y = (float) (float) YDIM / 2.0f;
answer.v.y = 0.5;
answer.v.z = (float) (j - YDIM / 2) / (float) YDIM;
break;
case 5:
answer.v.x = (float) (i - XDIM / 2) / (float) XDIM;
answer.v.y = -(float) (float) YDIM / 2.0f;
answer.v.y = -0.5;
answer.v.z = -(float) (j - YDIM / 2) / (float) YDIM;
break;
}
Expand Down

0 comments on commit 8896774

Please sign in to comment.