If I understand correctly, there’s several different methods for handling reflections in video games. What are they, and which ones are most processor intensive (Bonus Q: which ones are utilized most in video games today)?
Also, what exactly are particle effects? I’ve always understood them to be those sparks that spring forth, from say, a sword smacking a wall. Though I still don’t know what’s so special about them? Couldn’t they just be little polygonal figures?
Please enlighten me, thanks!
With regard to particle effects, yes, sparks are typically particle effects, but you can do more with them.
Particle systems basically work like this: you define an emitter which puts out points at a defined rate. You can then assign behaviours to them-- velocity, original direction, etc. – environmental behaviours like directional wind, or gravity, etc. – or they can have randomized movements, or collision behaviours, etc.
So you’re shooting out this little points, right? And they can have all sorts of behaviours assigned. Now you can decide how you want to render them. You can make them complex polygonal models (or simple ones) if you want. You can make them simple points, or whatever. Say you’re making sparks, you’ll want them to be rendered bright orange at the emitter, and then change colours to red and finally transparent over a certain number of frames, so it appears to be cooling and fading.
You can do fancier things with particle effects, too – things that don’t necessarily look like particles. Smoke is usually done with particle effects. A cheap way to do it is to make lots of little floaty spheres that have negative “gravity” (so they rise up,) and a certain amount of random motion, and are effected by horizontal “wind.” Then you render each sphere according to its distance from another sphere-- the closer any one sphere is to another sphere, the more opaque and dark it is. (They may also scale over time.) This gives the effect of dense “smoke” dissipating into the atmosphere, if you do it right.
As for reflections, “ray tracing” is the most processor-intensive. It’s basically plotting the way photons bounce around and simulating reflections, colour-shifts, etc. (ie; you define light sources and surface material and then let an insane amount of calculations are done.) I doubt that anyone uses this for real-time rendering, though, and I don’t know what short-cuts are commonly used for video games.
3-D scenes are rendered by having a “camera” and determining the visible polygon list, then rendering the scene. BSP trees and such are often used to make the polygon list easy to determine, although there are other rendering methods like using portals. Reflections are usually done by setting up another “camera” and rendering what it would see (using the same algorithm as is used for normal scenes) then mapping its image onto the polygon that is the reflective surface.
Quake was one of the first games to use particle effects. If something explodes, the little bits all become particles which can then bounce off of walls, etc. which is more realistic than just using a bitmap explosion.
To expand a little on what engineer_comp_geek said, a common speedup is to render an environment map of the static geometry in the scene, and to then dynamically calculate the texture coordinates of a polygon’s vertices based upon the viewer’s position in the scene. Then you do a blending operation between the calculated reflection on the surface and the surface’s base colors.
This is a gross estimate of the reflection, since the environment map is calculated based upon a particular origin, but for scenery that’s far enough away it’s a good enough approximation. For closer scenery or for dynamic objects, you either render those into a copy of the environment map, or you render them on top of the calculated reflection on the surface, depending upon the surface’s properties and the properties of the graphics hardware you’re using.
Dammit, I love particle effects. I wanted to answer that one
I’ll add one point though. A particle emitter itself doesn’t do much more than provide the particles. You can achive the desired effects by adding say, a gravity source, that will attract the particles. You can also define deflection or wind forces to blow the particles around. Want to make a burning wick on a stick of dynamite? Stick a sphereical particle emitter on a track along the wick’s path. Put a deflector in to blow the particles back a little to simulate wind, and render with the appropriate materials (quite possibly the most difficult part).