-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a utility function that generates reasonable planetary terrain.
- Loading branch information
Philip Rideout
committed
Aug 16, 2015
1 parent
d46fc32
commit b42794a
Showing
11 changed files
with
137 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <heman.h> | ||
#include "hut.h" | ||
|
||
#define COUNT(a) (sizeof(a) / sizeof(a[0])) | ||
#define OUTFOLDER "build/" | ||
#define SEED 7000 | ||
#define HEIGHT 512 | ||
|
||
static int CP_LOCATIONS[] = { | ||
000, // Dark Blue | ||
126, // Light Blue | ||
127, // Yellow | ||
150, // Dark Green | ||
170, // Brown | ||
200, // Brown | ||
240, // White | ||
255, // White | ||
}; | ||
|
||
static heman_color CP_COLORS[] = { | ||
0x001070, // Dark Blue | ||
0x2C5A7C, // Light Blue | ||
0xE0F0A0, // Yellow | ||
0x5D943C, // Dark Green | ||
0x606011, // Brown | ||
0x606011, // Brown | ||
0xFFFFFF, // White | ||
0xFFFFFF, // White | ||
}; | ||
|
||
static float LIGHTPOS[] = {-0.5f, 0.5f, 1.0f}; | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
heman_image* grad = heman_color_create_gradient( | ||
256, COUNT(CP_COLORS), CP_LOCATIONS, CP_COLORS); | ||
heman_image* hmap = heman_generate_planet_heightmap(HEIGHT * 2, HEIGHT, SEED); | ||
heman_image* albedo = heman_color_apply_gradient(hmap, -0.5, 0.5, grad); | ||
heman_image_destroy(grad); | ||
heman_image* planet = | ||
heman_lighting_apply(hmap, albedo, 1, 1, 0.75, LIGHTPOS); | ||
heman_image_destroy(hmap); | ||
heman_image_destroy(albedo); | ||
hut_write_image(OUTFOLDER "planet.png", planet, 0, 1); | ||
heman_image_destroy(planet); | ||
} |