Download Procedural Modeling: Creating Complex Structures with Automation and Randomness and more Study Guides, Projects, Research Introduction to Sociology in PDF only on Docsity! Procedural Modeling CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005 Models The subject of rendering covers techniques for generating images of complex models, but says little about the creation of those models Within computer graphics, the subject of modeling is as complex as the subject of rendering The demands of modern computer graphics call for the use of extremely complex models containing millions or billions of primitives Examples include scenes in modern special effects movies, or industrial models of buildings and vehicles Create / Delete The most basic operations are: Vertex *CreateVertex(); void DeleteVertex(int v); Triangle *CreateTriangle(); void DeleteTriangle(int t); Just about all higher level modeling functions can be broken down into these basic operations All higher level functions go through these interfaces to create and remove data These functions need to be fast and reliable The ‘delete’ operations can be done in different ways and aren’t as simple as they might first look… Primitive Shapes Many real world objects contain basic shapes like spheres, boxes, cylinders, cones, etc. Sometimes, complex models can be built entirely from these simple shapes Modeling tools should have functions for creating a variety of primitive shapes like these Copy One of the most basic modeling tools is the simple copy operation Models can be built up from multiple copies of simpler shapes A copy operation would probably take a source and destination object as well as a matrix as input It would add new vertices and triangles to the destination object by transforming the verts of the source object by the matrix Path Extrude A powerful variation on extrusion is the path extrude operation With this one, we have one or more lines (or curves) that make up a cross section and a second line (or curve) that makes up the path The path extrusion connects several copies of the cross section along the path that orient to the path as it turns This can be used to make a tree trunk, or a freeway overpass (or tunnel), for example The cross section could also vary along the path to allow for additional control Lofting There are also a variety of lofting tools that can be used to create surfaces out of a set of input lines (or curves) For example, various lofting tools can be used to model shapes like boat hulls, airplane wings, and car bodies Boolean Boolean operations can be used to compute unions, intersections, and subtractions with complex 3D shapes Many industrial models are build from Boolean operations Noise Another form of randomness which is sometimes useful for procedural modeling is noise Noise represents a distribution of randomness over some space (usually 2D or 3D) Noise isn’t entirely random, as two points nearby will have a similar value In this way, noise has a frequency associated with it By combining noise patterns of different frequencies, one can make more complex turbulence patterns Fractals A fractal is a geometric object that is self-similar when viewed at different scales For example, the shape of a coastline may appear as a jagged line when we view a map of California. As we zoom in closer and closer, we see that there is more and more detail at finer scales. We always see a jagged line no matter how close we look at the coastline Fractals Fractals can be regular repeated patterns, or can be irregular and incorporate randomness as well Random fractals are useful for creating a wide variety of natural shapes such as mountain landscapes Even trees can be thought of as a fractal, as the branching patterns are similar when one looks at the main trunk down to the finest branches For procedural modeling, we may borrow some fractal concepts, but we rarely deal with true mathematical fractals with infinite detail We usually think of fractals as techniques for generating randomness in some limited range of scales Height Fields Landscapes are often constructed as height fields In a height field, we assume a regular grid in the ground plane (for us, that’s the xz plane) At each grid point, we store a height (y) value In this way, a large terrain can be stored in memory without explicitly storing the x & z coordinates of the verts or the triangle connection information The terrain can be shaped by operations that modify the y coordinates In a lot of ways, shaping the terrain is like rendering an image, where the heights of the cells in the height fields can be compared to the pixel colors in an image Similar tools can be used to shape the height field to the tools used in rendering, such as the use of triangles or noise patterns Height Fields The height field itself is an efficient data structure for storing the shape of the terrain, but it still must be converted to triangles to render We could simply generate a grid of triangles However, if we use a grid, we will end up with too many triangles in flat regions and too high of a triangle density off in the distance It would be better to perform some sort of adaptive tessellation of the height field, much like the tessellations used in patch rendering and displacement mapping Quadtree Tessellation One way to triangulate height fields adaptively is through the use of a quadtree The quadtree is a 2D data structure that is usually based on rectangles or squares It works in a very similar way as the fractal subdivision we just covered, except it can be used for triangulating height fields (or Bezier patches…) We start with single square around our whole terrain We perform some sort of analysis on the square and determine if it contains more detail than is adequately represented by a square If the detail is insufficient, the square is split into four smaller squares, which are recursively tested Ultimately, squares are then split into two triangles Roads Roads can be placed on height fields by placing the control points of the road curves on the height field This will still require some local flattening for the road and the area to the side of the road This can be achieved by essentially rendering road triangles onto the height field, where a low detail road is extruded and ‘rendered’ into the cells of the height field to set their heights. Sides of roads can be blended using techniques similar to alpha blending These operations can be used to modify the existing shape the height field in a very similar way to how real roads are constructed Roads Ideally, the road surface would be an extrusion and the open terrain would be a height field They can be sewn together into a single triangle mesh in a similar way to how trim curves are used in patch tessellation Trees Trees are a classic example of complex natural objects that can be procedurally modeled There have been numerous research papers published on various aspects of botanical modeling One recent paper focused on creating the detailed sub-millimeter scale vein patterns seen on leaf surfaces By varying a number of key parameters, one can model a wide variety of plants and trees to any level of detail desired Even with about 10 parameters, one can model a wide variety of overall plant shapes, but real plant modeling systems may allow hundreds of parameters as well as the inclusion of custom geometric data to define leaf shapes or branch cross sections… Flowers Flowers will form at the tips of younger stems at certain times of the year, triggered by seasonal properties such as day length or temperature Flower petals and other floral components are modified leaves themselves Plant Shapes The variety of plant shapes is mainly due to variations in stem shapes, branching properties, and leaf shapes, and these can be broken down into specific properties that can be used to control a procedural plant model A simple way to model a plant is to start by thinking of it as a bunch of branches (stems) and leaves Branches We can think of a branch as being a circular extrusion along some path, but it would certainly be possible to use non-circular cross sections as well Overall, the radius of the cross section will either remain constant or may taper from being thicker at the base and thinner at the tip. We can simplify this by just specifying a radius at each end and assume a linear interpolation along the branch The path of the branch can just be a set of points At the simplest, these points could form a straight line, but it wouldn’t be hard to add some curvature and randomness The path could be randomly created just from a starting point, an initial direction, and a desired length Buildings & Cities Buildings and other man-made structures can also be procedurally modeled In addition to the overall shapes of buildings, there have been papers for details such as exact brick placement including a variety of patterns There have also been research papers on automatically generating city road map layouts based on terrain height fields From the road maps, city blocks are then subdivided into lots, which have procedural buildings placed on them Details like street lights, trees, etc. can be placed alongs the roads In this way, entire cities can be build automatically Cities (and other complex models) can either be generated completely randomly, or as a mix of random and non-random processes Additional data exists for cities that describe locations and overall outlines of buildings, placement of power & telephone lines, train tracks, and other data Prop Placement There have been various research papers that have addressed the issue of prop placement as a procedural modeling tool To place plants, for example, we don’t just want to randomly scatter them around Models have been designed that take the shape of the terrain into consideration and determine plant locations based on properties such as wetness, light exposure, and other geographic properties In addition, simulations can be run that model the changes in the ecosystem over time and allow for different plant groups to spread about the terrain Man-made objects can also be automatically placed in terrains. Objects such as street lights, traffic lights, houses, street signs, and more can be placed automatically in a city based on the basic road map and terrain layouts Project 4 For project 4, make a simple ray tracer that renders a Model with shadows It only needs to implement rays from the camera and rays to light sources I suggest making a Ray and Intersection class as in the ray tracing lecture Also, I would write an intersection routine for the triangle class and an additional intersection for the model class that just loops through all of the triangles and calls their intersection routine Once you can compute ray intersections, generate primary rays from the camera and store the results in an image See the web page for more details Also, take a look at the book, as it has a lot of info on this stuff