1d midpoint displacement 2d diamond square particle
play

1D: Midpoint Displacement 2D: Diamond-Square Particle Systems - PowerPoint PPT Presentation

University of British Columbia Procedural Textures Procedural Modeling CPSC 314 Computer Graphics textures, geometry generate image on the fly, instead of Jan-Apr 2016 loading from disk nonprocedural: explicitly stored in


  1. University of British Columbia Procedural Textures Procedural Modeling CPSC 314 Computer Graphics • textures, geometry • generate “ image ” on the fly, instead of Jan-Apr 2016 loading from disk • nonprocedural: explicitly stored in memory Tamara Munzner • often saves space • procedural approach • allows arbitrary level of detail Procedural Approaches • compute something on the fly • often less memory cost Procedural, Collision • visual richness • fractals, particle systems, noise http://www.ugrad.cs.ubc.ca/~cs314/Vjan2016 2 3 4 Fractal Landscapes Self-Similarity Fractal Dimension Language-Based Generation • D = log(N)/log(r) • fractals: not just for “ showing math ” • infinite nesting of structure on all scales • L-Systems: after Lindenmayer N = measure, r = subdivision scale • triangle subdivision • Koch snowflake: F :- FLFRRFLF • Hausdorff dimension: noninteger • vertex displacement • F: forward, R: right, L: left Koch snowflake • recursive until termination condition coastline of Britain • Mariano’s Bush: F=FF-[-F+F+F]+[+F-F-F] } • angle 16 D = log(N)/log(r) D = log(4)/log(3) = 1.26 http://www.fractal-landscapes.co.uk/images.html http://spanky.triumf.ca/www/fractint/lsys/plants.html http://www.vanderbilt.edu/AnS/psychology/cogsci/chaos/workshop/Fractals.html 5 6 7 8 1D: Midpoint Displacement 2D: Diamond-Square Particle Systems Particle System Examples • loosely defined • divide in half • fractal terrain with diamond-square approach • objects changing fluidly over time • fire, steam, smoke, water • modeling, or rendering, or animation • generate a new value at midpoint • randomly displace • objects fluid in form • average corner values + random displacement • key criteria • scale variance by half • grass, hair, dust • scale variance by half each time • collection of particles • physical processes • random element controls attributes • waterfalls, fireworks, explosions • position, velocity (speed and direction), color, • group dynamics: behavioral lifetime, age, shape, size, transparency • birds/bats flock, fish school, human crowd, dinosaur/elephant stampede • predefined stochastic limits: bounds, variance, type of distribution http://www.gameprogrammer.com/fractal.html 9 10 11 12 Particle Systems Demos Particle Life Cycle Particle System Rendering Procedural Approaches Summary • expensive to render thousands of particles • general particle systems • generation • Perlin noise • randomly within “fuzzy” location • simplify: avoid hidden surface calculations • http://www.wondertouch.com • covered in previous texturing lectures • initial attribute values: random or fixed • each particle has small graphical primitive • fractals • dynamics (blob) • attributes of each particle may vary over time • boids: bird-like objects • L-systems • pixel color: sum of all particles mapping to it • color darker as particle cools off after explosion • http://www.red3d.com/cwr/boids/ • particle systems • can also depend on other attributes • some effects easy • position: previous particle position + velocity + time • temporal anti-aliasing (motion blur) • death • many shaders • normally expensive: supersampling over time • not at all a complete list! • age and lifetime for each particle (in frames) • http://www.shadertoy.com • position, velocity known for each particle • or if out of bounds, too dark to see, etc • big subject: entire classes on this alone • just render as streak 13 14 15 16

  2. Collision Detection Collision Detection Applications From Simple to Complex • boundary check • do objects collide/intersect? • determining if player hit wall/floor/obstacle • perimeter of world vs. viewpoint or objects • terrain following (floor), maze games (walls) • static, dynamic • stop them walking through it • 2D/3D absolute coordinates for bounds • picking is simple special case of general • determining if projectile has hit target • simple point in space for viewpoint/objects collision detection problem (covered next) • determining if player has hit target • set of fixed barriers • punch/kick (desired), car crash (not desired) • walls in maze game Collision/Acceleration • check if ray cast from cursor position collides • detecting points at which behavior should change • 2D/3D absolute coordinate system with any object in scene • car in the air returning to the ground • set of moveable objects • simple shooting • cleaning up animation • one object against set of items • projectile arrives instantly, zero travel time • making sure a motion-captured character’s feet do not pass • missile vs. several tanks through the floor • better: projectile and target move over time • multiple objects against each other • simulating motion • punching game: arms and legs of players • see if collides with object during trajectory • physics, or cloth, or something else • room of bouncing balls 17 18 19 20 Naive General Collision Detection Fundamental Design Principles Example: Player-Wall Collisions Stupid Algorithm • for each object i containing polygons p • first person games must prevent the player • fast simple tests first , eliminate many potential collisions • on each step, do a general mesh-to-mesh • test bounding volumes before testing individual triangles from walking through walls and other • test for intersection with object j containing intersection test to find out if the player • exploit locality , eliminate many potential collisions obstacles polygons q intersects the wall • use cell structures to avoid considering distant objects • for polyhedral objects, test if object i • most general case: player and walls are • if they do, refuse to allow the player to move • use as much information as possible about geometry polygonal meshes penetrates surface of j • spheres have special properties that speed collision testing • problems with this approach? how can we • test if vertices of i straddle polygon q of j • each frame, player moves along path not • exploit coherence between successive tests improve: known in advance • if straddle, then test intersection of polygon q • things don’t typically change much between two frames • in response? with polygon p of object i • assume piecewise linear: straight steps on • very expensive! O(n 2 ) each frame • in speed? • assume player’s motion could be fast 21 22 23 24 Collision Response Accelerating Collision Detection Collision Proxies Trade-off in Choosing Proxies • frustrating to just stop • two kinds of approaches (many others also) • proxy: something that takes place of real object • for player motions, often best thing to do is move • cheaper than general mesh-mesh intersections • collision proxies / bounding volumes player tangentially to obstacle • collision proxy (bounding volume) is piece of geometry used • spatial data structures to localize to represent complex object for purposes of finding collision • do recursively to ensure all collisions caught • if proxy collides, object is said to collide • find time and place of collision • used for both 2D and 3D Sphere AABB OBB 6-dop Convex Hull • collision points mapped back onto original object • adjust velocity of player • used to accelerate many things, not just increasing complexity & tightness of fit • good proxy: cheap to compute collisions for, tight fit to the real • repeat with new velocity, start time, start position collision detection geometry (reduced time interval) decreasing cost of (overlap tests + proxy update) • common proxies: sphere, cylinder, box, ellipsoid • handling multiple contacts at same time • raytracing • consider: fat player, thin player, rocket, car … • find a direction that is tangential to all contacts • AABB: axis aligned bounding box • culling geometry before using standard • OBB: oriented bounding box, arbitrary alignment rendering pipeline • k-dops – shapes bounded by planes at fixed orientations 25 26 27 • discrete orientation polytope 28 Pair Reduction Spatial Data Structures Uniform Grids Quadtrees/Octrees • want proxy for any moving object requiring collision • can only hit something that is close • axis-aligned • axis-aligned detection • spatial data structures tell you what is close • divide space uniformly • subdivide until no points in cell • before pair of objects tested in any detail, quickly test if to object proxies intersect • when lots of moving objects, even this quick bounding • uniform grid, octrees, kd-trees, BSP trees sphere test can take too long: N 2 times if there are N objects • bounding volume hierarchies • reducing this N 2 problem is called pair reduction • OBB trees • pair testing isn ’ t a big issue until N>50 or so … • for player-wall problem, typically use same spatial data structure as for rendering • BSP trees most common 29 30 31 32

  3. KD Trees BSP Trees Bounding Volume Hierarchies OBB Trees • axis-aligned • planes at arbitrary orientation • covered in previous raytracing lecture • oriented bounding boxes • subdivide in alternating dimensions • covered in upcoming hidden surfaces lectures 33 34 35 36 Related Reading Acknowledgement • Real-Time Rendering • slides borrow heavily from • Tomas Moller and Eric Haines • Stephen Chenney, (UWisc CS679) • http://www.cs.wisc.edu/~schenney/courses/cs679-f2003/lectures/cs679-22.ppt • on reserve in CICSR reading room • slides borrow lightly from • Steve Rotenberg, (UCSD CSE169) http://graphics.ucsd.edu/courses/cse169_w05/CSE169_17.ppt • 37 38

Recommend


More recommend