The Components of a Schoolwide Title I Program Presented by Ryan Saunders, Ed.D. August 14, 2014.
Terrainosaurus Terrain Generation Using Genetic Algorithms Ryan Saunders Texas A&M Student Research...
-
Upload
heather-newman -
Category
Documents
-
view
212 -
download
0
Transcript of Terrainosaurus Terrain Generation Using Genetic Algorithms Ryan Saunders Texas A&M Student Research...
TerrainosaurusTerrainosaurusTerrain Generation Terrain Generation Using Genetic AlgorithmsUsing Genetic Algorithms
Ryan SaundersRyan Saunders
Texas A&M Student Research WeekTexas A&M Student Research Week
03/29/200503/29/2005
22
OverviewOverview
IntroductionIntroductionMotivationMotivation
Applications of terrain generationApplications of terrain generationCharacteristics of an idealized t-gen methodologyCharacteristics of an idealized t-gen methodology
BackgroundBackgroundCurrent methodsCurrent methodsTerrain model representationTerrain model representationGenetic algorithmsGenetic algorithms
The algorithmThe algorithmPhase I:Phase I: Construct a terrain type databaseConstruct a terrain type databasePhase II:Phase II: Design the terrain layoutDesign the terrain layoutPhase III:Phase III: Generate the heightfieldGenerate the heightfield
Discussion & future workDiscussion & future work
33
TerrainosaurusTerrainosaurusTerrain generation for dummiesTerrain generation for dummies
A novel approach to terrain generationA novel approach to terrain generationUser-orientedUser-oriented
Physically-basedPhysically-based
ExtensibleExtensible
44
Potential ApplicationsPotential ApplicationsWhy would you want to do this?Why would you want to do this?
ArtArt
Architectural Architectural renderingrendering
Military training Military training exercisesexercises
CG moviesCG movies
GamesGames
55
Idealized Terrain GenerationIdealized Terrain GenerationIn a perfect world…In a perfect world…
Allowing a high degree of control, but requiring Allowing a high degree of control, but requiring only a low baseline amount of inputonly a low baseline amount of input
Easy to use, with only intuitive user inputsEasy to use, with only intuitive user inputs
Able to produce a wide variety of recognizable Able to produce a wide variety of recognizable types of terrain, in believable relation to each othertypes of terrain, in believable relation to each other
Realistic, providing a plausible simulation of the Realistic, providing a plausible simulation of the real worldreal world
Extensible, to support new types of terrainExtensible, to support new types of terrain
Useful at arbitrary levels-of-detail (LOD)Useful at arbitrary levels-of-detail (LOD)
Fast enough to run in real-timeFast enough to run in real-time
66
Current Terrain Generation Current Terrain Generation MethodsMethodsStrengths & WeaknessesStrengths & Weaknesses
GIS Data Sculpting (e.g., Terragen)
Procedural (e.g., fractals) Simulation (e.g., erosion)
77
Terrain Model RepresentationTerrain Model RepresentationHeightfields & other thingsHeightfields & other things
Heightfield – the most commonHeightfield – the most common2D grid of elevations2D grid of elevations h=f(x,y)h=f(x,y)
Precludes representation of caves & overhangsPrecludes representation of caves & overhangs
Real-world surveying data availableReal-world surveying data available
Ideal for optimized rendering and collision Ideal for optimized rendering and collision detectiondetection
Other possible representationsOther possible representationsPolygonal meshPolygonal mesh
Implicit functionImplicit function
88
Genetic AlgorithmsGenetic AlgorithmsHow to solve really hard problemsHow to solve really hard problems
Genetic algorithm (GA):Genetic algorithm (GA): any of a family of techniques for any of a family of techniques for solving difficult optimization problems by analogy to solving difficult optimization problems by analogy to Darwinian natural selectionDarwinian natural selection
GAs are useful for finding GAs are useful for finding approximateapproximate solutions when the solutions when the optimaloptimal solution is unknown or infeasible to calculate solution is unknown or infeasible to calculateA candidate solution (a A candidate solution (a chromosomechromosome, in GA parlance) is , in GA parlance) is decomposed into interchangeable subunits called decomposed into interchangeable subunits called genesgenesA A population population of such chromosomes is evolved for some of such chromosomes is evolved for some number of generations, allowing multiple potential solutions to number of generations, allowing multiple potential solutions to be explored simultaneouslybe explored simultaneouslyThe “goodness” of a solution is measured by an objective The “goodness” of a solution is measured by an objective function (the function (the fitnessfitness function), and the more promising function), and the more promising solutions are “cross-bred” and “mutated” to explore nearby solutions are “cross-bred” and “mutated” to explore nearby solutions which might be even bettersolutions which might be even better
99
Phase IPhase IConstructing a terrain libraryConstructing a terrain library
The user creates a database of heightfield data The user creates a database of heightfield data (normally from a GIS data provider), classified (normally from a GIS data provider), classified into logical into logical terrain typesterrain types (e.g., “Sierra Nevada (e.g., “Sierra Nevada mountains”, “midwest prairie”, “sand dunes”)mountains”, “midwest prairie”, “sand dunes”)
1010
Phase IIPhase IILaying out the terrainLaying out the terrain
The user expresses his The user expresses his design for the terrain design for the terrain by sketching a 2D by sketching a 2D map of polygonal map of polygonal terrain regions, terrain regions, providing the size, providing the size, shape and relative shape and relative placement of the placement of the different terrain typesdifferent terrain types
1111
Phase IIPhase IIRefining region boundariesRefining region boundaries
In order to prevent the appearance of noticeable artifacts in the In order to prevent the appearance of noticeable artifacts in the generated heightfield (caused by the unnaturally straight generated heightfield (caused by the unnaturally straight boundaries drawn by the user), the user’s boundaries are replaced boundaries drawn by the user), the user’s boundaries are replaced with irregular, GA-generated boundaries. The shape of the with irregular, GA-generated boundaries. The shape of the generated boundary can be controlled by a generated boundary can be controlled by a smoothnesssmoothness parameter to the GA.parameter to the GA.
High smoothness value Low smoothness value
1212
Phase IIIPhase IIIThe general ideaThe general idea
Construct progressively higher-resolution versions of the heightfield, with Construct progressively higher-resolution versions of the heightfield, with each successive version based on the previouseach successive version based on the previous
By using the previous LOD as a rough “pattern” to approximate, we ensure that By using the previous LOD as a rough “pattern” to approximate, we ensure that macro-level details of the heightfield are fixed before we worry about the micro-macro-level details of the heightfield are fixed before we worry about the micro-level detailslevel details
We do this using a genetic algorithm that searches for an arrangement of We do this using a genetic algorithm that searches for an arrangement of high-resolution chunks of elevation data that:high-resolution chunks of elevation data that:
““fit” the shape of the lower-resolution heightfieldfit” the shape of the lower-resolution heightfielddisplay the appropriate terrain type characteristics in each regiondisplay the appropriate terrain type characteristics in each region
Resample Replace
1313
Phase IIIPhase IIIThe heightfield refinement GAThe heightfield refinement GA
A heightfield can be A heightfield can be represented as a represented as a chromosomechromosome containing a containing a 2D, rectangular grid of 2D, rectangular grid of overlapping, circular overlapping, circular genesgenes of of a certain radius, in which each a certain radius, in which each gene holds a chunk of gene holds a chunk of elevation data from one of the elevation data from one of the input samplesinput samples
The genes may be mutated The genes may be mutated independently and traded independently and traded between chromosomesbetween chromosomesWhen we’re done, we can turn When we’re done, we can turn a chromosome back into a a chromosome back into a heightfield with standard heightfield with standard image compositing operationsimage compositing operations
1414
Phase IIIPhase IIIMutation & crossover operatorsMutation & crossover operators
Just as a heightfield can be interpreted as a grayscale Just as a heightfield can be interpreted as a grayscale image (and vice versa), the mutation and crossover gene image (and vice versa), the mutation and crossover gene operations correspond to image manipulation operationsoperations correspond to image manipulation operations
The effect of these operations diminishes towards the The effect of these operations diminishes towards the boundary of the gene due to blending between adjacent genesboundary of the gene due to blending between adjacent genes
Original heightfield Vertical offset mutation Rotate mutation
1515
Phase IIIPhase IIIThe fitness functionThe fitness function
The The fitness functionfitness function is a scalar function is a scalar function returning [0,1], giving an evaluation of how returning [0,1], giving an evaluation of how “good” a particular chromosome is. Our fitness “good” a particular chromosome is. Our fitness function is:function is:
G
N
c
RA
AR
G
T
Rff 1
fR the fitness of region R
cG the compatibility of gene G with the pattern heightfield
α relative weighting factor
AR area of region R
AT total area of heightfield
N number of genes
1616
Phase IIIPhase IIIFitness evaluation: the fitness of an individual Fitness evaluation: the fitness of an individual regionregion
To measure the characteristics of a region To measure the characteristics of a region of terrain, we use a number of different of terrain, we use a number of different techniquestechniques
Simple statistics (min, max, mean, variance) of Simple statistics (min, max, mean, variance) of physical quantities such as elevation and slopephysical quantities such as elevation and slopePhysical features (edges, peaks, etc.) extracted Physical features (edges, peaks, etc.) extracted with conventional computer vision techniqueswith conventional computer vision techniquesFrequency spectrum coefficients of the FFTFrequency spectrum coefficients of the FFT
1717
Phase IIIPhase IIIFitness evaluation: gene compatibilityFitness evaluation: gene compatibility
The compatibility of a gene with its local The compatibility of a gene with its local environment is a measure of its environment is a measure of its divergence from the mean elevation and divergence from the mean elevation and gradient of the pattern heightfield it is gradient of the pattern heightfield it is trying to matchtrying to match
Compatibility is measured with a 1D Gaussian Compatibility is measured with a 1D Gaussian function centered over the target function centered over the target elevation/gradientelevation/gradient
1818
EvaluationEvaluationHow well we met our goalsHow well we met our goals
Low amount of user input requiredLow amount of user input required(+) Single terrain-type case is trivial(+) Single terrain-type case is trivial
Moderate degree of user control affordedModerate degree of user control afforded(+) User can create arbitrarily complex terrain regions(+) User can create arbitrarily complex terrain regions
(-) User has little control over location and orientation of (-) User has little control over location and orientation of features (e.g., cliffs, individual mountain peaks)features (e.g., cliffs, individual mountain peaks)
Easy to use, with intuitive inputsEasy to use, with intuitive inputs(+) User design is done visually (2D map) and by (+) User design is done visually (2D map) and by example (terrain library)example (terrain library)
(+) Most free parameters are quality-related (GA (+) Most free parameters are quality-related (GA population size, number of cycles, level-of-detail)population size, number of cycles, level-of-detail)
1919
EvaluationEvaluationHow well we met our goalsHow well we met our goals
Extensible, able to produce diverse terrain typesExtensible, able to produce diverse terrain types(+) New terrain types can be added simply by finding (+) New terrain types can be added simply by finding new sample heightfieldsnew sample heightfields
(-) Terrain type analysis is too sensitive to oddities in the (-) Terrain type analysis is too sensitive to oddities in the input samples (e.g., lakes)input samples (e.g., lakes)
Computer-aided terrain-type classification and Computer-aided terrain-type classification and segmentation could reduce or eliminate this problemsegmentation could reduce or eliminate this problem
(-) Terrain types characterized by large variations in (-) Terrain types characterized by large variations in feature content (e.g, Monument Valley) are not likely to feature content (e.g, Monument Valley) are not likely to be well reproduced with the current fitness functionbe well reproduced with the current fitness function
A more detailed analysis of the terrain feature model might A more detailed analysis of the terrain feature model might yield a more complete fitness functionyield a more complete fitness function
2020
EvaluationEvaluationHow well we met our goalsHow well we met our goals
RealisticRealistic(+) Real-world data is used as the raw material for (+) Real-world data is used as the raw material for generating the terrain, resulting in plausible detail at generating the terrain, resulting in plausible detail at both low and high frequenciesboth low and high frequencies(-) Semantic constraints (e.g., rivers must flow downhill) (-) Semantic constraints (e.g., rivers must flow downhill) are not enforced are not enforced
Arbitrary level-of-detail (LOD)Arbitrary level-of-detail (LOD)(+) Can generate at any LOD for which data can be (+) Can generate at any LOD for which data can be providedprovided
Fast enough to run in real-timeFast enough to run in real-time(-) Not exactly…in fact, it’s rather slow(-) Not exactly…in fact, it’s rather slow(+) Many of the operations are inherently parallelizable, (+) Many of the operations are inherently parallelizable, suggesting that a GPU-centric implementation might suggesting that a GPU-centric implementation might offer a significant speed boostoffer a significant speed boost