Game Genres: Ch6 3D Graphics Matrix Calculations and Etc. WTF? Don't Have To Know?
Game Genres: Ch6 3D Graphics Matrix Calculations and Etc. WTF? Don't Have To Know?
Game Genres: Ch6 3D Graphics Matrix Calculations and Etc. WTF? Don't Have To Know?
Traditional - Computerized card games or board games e.g., Tic-tac-toe, Monopoly, Reversi; Adventure - No action involved; Text/Graphical adventure
Action - Involves fast-paced combat and movements; Platformer - Involves a character running and jumping in a playing field. RPG - Characters need to explore the world and have specific
skill sets; MMORPG - Thousands of players simultaneously play in a virtual world; Racing/Sports; Education
Game Development Methods
Code-and-fix - many technical problems, incompatibility issues, crash bugs; Waterfall - Processes are well planned, accurate schedule and concrete milestones are set up Agile plan for short
periods of time. allows things to change and have iterative refinement of goals and schedules.
Understanding Game Experience
Psychology (how people think), Anthropology (understand people holistically), Design (art, music etc.)
Four basic elements of game: Aesthetics (How your game looks, sounds and feels), Mechanics (Procedures and rules of your game), Story (Sequence of events in your game), Technology
(Media, materials and interactions enabling your game) Play-testing get people to play. Check their experience and improve the game. Test developers, friends, expert gamers, tissue testers.
Bartle's Taxonomy of Player Types : Achievers (challenges), Explorers (discovery), Socializers (cooperation), Killers (competition)
Concept of Frame
Double Buffering - A technique for drawing graphics that shows no (or less) flicker, tearing, and other artifacts.
Frame rate > 10 fps (i.e. Timestep < 0.1): Human eyes will interpret as a video. Frame rate > 100 fps (i.e. Timestep < 0.01): Too much processing power required.
Game loop - A collection of frames forms a. Or each iteration of the game loop is a frame; usually 30,60fps
Game object - anything in the game world that needs to be updated, drawn, or both updated and drawn on every frame
Unity Syntax (check end of Ch3)
Audio
2 types: Mono / Stereo; Audio effects fade in, fade out, echo, repeat, reverse, invert, amplify, normalize.
Common Audio file format - PCM: uncompressed raw audio data; MP3: compressed audio data; MIDI: music notes
2 processes to convert an analog signal into a digital signal for computer storage:
Sampling take samples at discrete time; Quantization each sample is mapped to a discrete level
More on Audio File Formats
1.
PCM (Pulse Code Modulation/ .wav extension) - Quantization: 8/16/24 bit per sample; Keeps the raw quality, while other formats dont- as a result, biggest file size.
2.
MP3 - Lossy compression; reduces audio parts not sensitive to human; good for songs.
32 kbit/s speech, 96 low-quality streaming, 128 mid-range quality, 192 commonly used, 320 highest level quality
ID3 tag: Additional information such as artist, album, genre, lyrics, album art
Variable bit rates (VBR): Audio parts in MP3 can be divided into frames, each has its own bit rate according to the complexity of audio.
3.
WMA (windows media audio) - Lossy audio compression. Audio signals that are deemed to be imperceptible to the human ear are encoded with reduced resolution.
4.
MIDI (musical instrument digital interface) - for describing musical events, such as notes, dynamics, volume, and vibrato; no human sound
when to start and stop playing a specific note; volume and modulation of the note; change sounds, modulation devices, etc.
Image
BMP (Bit Map)
Raw data with header, simple and direct operation
Header has these information: XL - # of pixels in x-direction; YL - # of pixels in y-direction; bpp - bit per pixel
Raw data, for width of XL pixels and heigth of YL pixels, N bpp, need XL*YL*N/8 bytes + header size
For 16 color (4 bits to represent), 1 byte may represent 2 pixels, or 4 byte for 8 pixels.
RAW (Digital Camera Raw Images)
Original Image pixel data. Really high quality. Can adjust brightness, contrast, sharpen, white balance and can apply noise reduction, sensor dust removal, etc using proper
software
S-RAW 25% the pixel count. M-RAW 55-60% pixel count. Suitable for wedding, sports/action photographers
GIF (Graphics Interchange Format)
Lampel-Ziv-Welch (LZW) is a way of compressing data that takes advantage of repetition of strings in the data.
Block Graphic Control Extension contains delay time (to allow animation effect) and transparency color
Lossless compression; has encoding/decoding mechanism; Good for graphics such as cartoon, line art
Not good for photos. Max of 8 bit (256) colors so some colors may be missing for pictures.
PNG (Portable Network Graphics)
Lossless data compression using DEFLATE (in zlib); support transparency; not limited to 8 bit (256) colors; no animation support (MNG is another extension for animations)
less space, but most hardware cannot natively draw PNGs, need to be converted when loaded and hence less efficient for game environments.
JPEG (Joint Photographic Experts Group)
Lossy compression. There are lots of color levels and JPEG works by removing some of them that are not easily noticed by human eyes. Good for natural image and photos. Much
smaller size compared to BMP/RAW. But reduced quality compared to them. Does not support transparency, so not good for logos, icons. Supports 24 bit colors.
Anti-aliasing
Fooling the eye into thinking a jagged edge on an image is smooth. Used in font smoothing; bitmap re-sampling and scaling; scalable graphics, e.g. Flash graphics; Disintegrating
textures
Works by surrounding the stairsteps with intermediate shades of gray (for gray-scaling devices) or color.
Although this reduces the jagged appearance of the lines, it also makes them fuzzier.
Sub-pixel Rendering
a way to increase the apparent resolution of a computer's liquid crystal display (LCD) or organic light-emitting diode (OLED) display by rendering pixels to take into account the
screen type's physical properties.
It anti-aliases text with greater detail or increases the resolution of all image types on layouts which are specifically designed to be compatible with subpixel rendering.
Improves display resolution by as much as 300%; usually improve readability of text but for small type sizes anti-aliasing merely blurs the image and reduces readability
Screen Rendering
Vertical Blank (VBLANK): the time needed to shift the aim of the gun from the bottom-right back to the top-left corner
Refresh rate - The number of times a screen can be redrawn in one second (60/80Hz). most LCD is still drawn line by line due to bandwidth problem
Framebuffer - some physical memory (RAM) used to store the entire image to be displayed on a screen. pixel - Each element in a framebuffer
Frame rate (Frame Per Second, FPS) - the rate that your game can output a frame (a complete image in the framebuffer) in one second. Minimum FPS is 25-30 for smooth animation. Game
should not be under 25.
Single-Buffering - "Race the scanline": Always draw behind the scanline. Because the drawing could be too slow, screen tearing might occur where display shows two different frames at the
same time. Screen tearing can be avoided by writing only during VBLANK interval (but this is not enough time to render).
Double-Buffering- two framebuffers: front (monitor shows whats inside the buffer); back (where we are currently drawing to). Computer writes to the back buffer. When the front buffer is
fully displayed, the two buffers will be swapped. Can attain framerate at the rendering speed. But screen tearing will still happen if not written during VBLANK interval. Also another problem
is that framerate will be capped at refresh rate of the monitor.
Triple-Buffering - One front buffer, 2 back buffers. Swapping from the most recently completed back buffers to front buffer during VBLANK and monitor displays from front buffer. No
screen tearing.
Painter's Algorithm - solves the visibility problem of 2D sprites in a scene by sorting all sprites from back to front, and then rendering the sprites in back-to-front order (background to character
order)
Textures
Texture simply an image that is used to modify the appearance of a surface. Texel texture element from texture image.
Mipmaps a popular method for antialiasing textures. The original texture is augmented with a set of smaller versions of the texture. Starting from level 0 (the original texture), a new but
smaller texture is formed by averaging each 2x2 area into a texel for the next level. Mipmaps are pre-computed, it is efficient in terms of time taken for integrating texels for a pixel. It takes up
additional texture memory, but the slight overhead is worth for the significant improvement in texturing quality.
Ch6 3D Graphics Matrix calculations and etc. wtf? Dont have to know?
3D Graphics
Steps for rendering a 3D Scene setting up a virtual scene, positioning a virtual camera, defining light sources, defining the visual properties of surfaces, computing the color and intensity of
the light rays shining on a screen pixel
Model space a local coordinate system for each object; World space coordinate system common to all objects in the game world.
Perspective projection gives a sense of depth, while orthographic projection is better if measurements or comparisons of lengths are needed; 2D. Most 3D games use perspective transformation.
Some games like Diablo use isometric projection (orthographic projection at an angle) to convey 3D information.
Lights
Ambient light - uniform amount of light is applied to every object in the scene; Independent of viewing angle and has no specific direction
Point light - Emits from a specific point and casts light in all direction; Can illuminate only one side of an object; Has attenuation
Spotlight - Has its position and attenuation; can focus the emitted light in a cone
Directional light - Without position but is emitted from a specific direction; Parallel light from infinity; Best for emulating sunlight
Area light - Simulate light coming from a large surface area; Can cast soft shadow that add realism to a scene; computationally intensive, cannot be done in real-time; can be simulated using
several point lights or spotlights.
Shading
Flat shading: carry out light calculation once for each triangle, and the entire triangle will be filled with the same color.
Gourand shading: Lighting calculation is done once for each vertex, which may then have different colors. The rest of the triangle is then filled by bilinearly interpolating the colors at the 3
vertices.
Phong shading: Lighting calculation is carried out for every pixel covered by a triangle. Surface normal at a pixel is estimated using bilinear interpolation.
Lighting Models
Phong reflection model (local illumination): models light reflected from a surface as a sum of three terms: Ambient: An approximation of the overall illumination of the scene Regions in
shadow will not appear totally black Independent of the location of lights and the camera. Diffuse: Accounts for lights that is reflected uniformly in all directions from each direct light source
(directional, point, or spotlights) affecting an object. Depends on N (surface normal) and L (vector from surface to light); independent of view direction. Specular: Represents shiny highlights
on the surface Occurs when viewing angle is closely aligned with the direction of the reflected light R.
Global illumination: achieves true photorealism by accounting for indirect lighting, where light bounces multiple times off many surfaces before reaching the virtual camera. Can model a
wide range of optical phenomena: shadow, reflection, transparency.
Normal Mapping
Image-based lighting algorithms make use of image data to achieve advanced lighting and shading effects by adding surface details without altering the actual geometries.
A normal map specifies a surface normal direction vector at each texel.
Object Properties
Opaque light cannot pass through the volume; Transparent light passes through without scattered; Translucent light passes through, scattered
Surface (end of chapter 6. TODO too many things)
Random Function int r = M + myRandom.nextInt(N M + 1);
Rotation of Image
float ca=cos(A); float sa=sin(A); int ca32=ca*16384; int sa32=sa*16384; int x32=0, y32=0;
for (y=0; y<YL; y++) { x32 = y*sa32+8192; y32 = y*ca32+8192;
for (x=0; x<XL; x++) { xx = x32>>14; x32 += ca32; yy = y32>>14; y32 -= sa32; c=GetPixelColor(xx, yy); SetPixelColor(x, y, c); } }
Bit Shifting
Multiplication: N * 12 = N * (8 + 4) = N * 8 + N * 4 = N << 3 + N << 2; N * 31 = N * (32 1) = N * 32 N = N << 5 N
24 bit color representation (RGB): R << 16 = 10101010 00000000 00000000; R << 16 + G << 8 + B = 10101010 01010101 11110000
Swapping R and B: RGB=((RGB&0xff)<<16) + (RGB&0xff00) + (RGB>>16)
B = RGB & 0x0000ff // get lower 8 bits; G = (RGB & 0x00ff00) >> 8 // get middle 8 bits; if (N & 0x1) // True if N is odd number
if (bit0 ^ bit1) // True if 2 bits are different; if (int & 0x7) // False when int is divisible by 8; a ^= b; b ^= a; a ^= b; // swapping 2 variables
Collision
axis-aligned bounding box (AABB) - a rectangular prism where every side of the prism is parallel to one of the coordinate axis planes in the game world. Need to recompute AABB if object is
rotated.
oriented bounding box (OBB) - also uses a rectangular prism to bound an object, but the sides of the prism are not required to align with the coordinates planes. When an object is rotated, we
just need to rotate the OBB without the need of recomputing the bounding box.
Collision testing bounding spheres: (C1-C2) * (C1-C2) < (r1+r2)2; C1 and C2 are vectors while r1 and r2 are scalars.
When two circles for each object, to find center: x2 = x1 + 2r * cos A; y2 = y1 + 2r * sin A; d = (x2-x1)2 + (y2-y1)2 < 4r2
Capsule - Slightly more accurate than AABBs in terms of bounding tightness. However, collision test on capsules is more complicated.
Convex polyhedron - More accurate as an approximation to an object, but requires more expensive collision tests; represented by a collection of intersection planes.
With instantaneous collision detection, we check if two static objects collide in the current frame; Collision status can be missed if the objects move very quickly. But with Continuous collision
detection (CCD), guarantee that no collision status will be missed by detecting if there is any collision between two moving objects within a time span.
When we have two objects that need to bounce off from each other, we should not negate the velocity as the objects might get stuck, we should find the time of contact and roll back to that
time and update the velocity accordingly.
Camera
field of view - Specifies the amount of the world that is visible using an angle (usually 90~100. High degrees will give fisheye effect).
Fixed camera Many cameras, remains in the same position at all times; first-person perspective of player; follow follows behind a target; cutscene non-interactive scene sequence.
Cutscene cameras need smooth transition to minimize the rotation and this is called camera interpolation.
AI
Artificial Neural Networks (ANNs) - family of models inspired by biological neural networks (brain); Game Tree - a directed graph whose nodes are positions (stages) in a game and whose
edges are moves. Tells the probability of winning (or losing) for each possible next move. Minimax algorithm - For evaluating the probability of winning; A score is assigned to each node,
starting from the leaf nodes. Alpha-Beta Pruning - A search algorithm that seeks to decrease the number of nodes that are evaluated by the minimax algorithm. Stops evaluating a move when at
least one possibility has been found that proves the move to be worse
Techniques :: Pathfinding: NPC from one point on a map to another (terrain, obstacles) :: Greedy Best-First - picks the best choice locally at each step; it is fast but does not guarantee an
optimal solution. A* - combines Best-first and Dijkstra by taking into account both the given cost (actual cost from the start node) and the heuristic cost. More efficient that Dijkstra Dijkstra keeps track of the cost of the path from the start to any given cell. Guarantee a shortest path from the source to the goal. However, it is an exhaustive search and thus is slow.; Cheating AI:
where AI has more advantage over the players, e.g. faster, know more; Emergent AI: learn from interactions, electronic pet
Network
Peer-to-peer - Clients broadcasts messages to each other; Easy to code; need more bandwidth for each client; Limited number of players; High security risk
Client-server - One server serves many clients; More complicated coding; Can support many players; server needs more bandwidth; Improved security
UDP Unreliable, data can be lost, no overhead for checking, faster & efficient; TCP reliable, no packets lost, slower, data cannot be lost; Network Security Anti-hacking, cheat prevention
Position Extrapolation - Use current facing direction to predict next position; Position Chasing - Always being late for one step as the master, Not good for moving fast objects
Fault Tolerance - Any type of server cannot be down at anytime; Every job must be transferred between servers; Load Balancing - distributes workloads across multiple computing resources.
increase reliability and availability through redundancy. Zone - a region of game happening on servers. usually mapped to a scene in the gameplay. software region that the players
communicate directly. Under the concept of Zone Moving, we can move the zones between hardware server to achieve load balancing.
UI
Five senses: Sight, hear, taste, touch, smell; Touch Screen Types multi-touch, resistive (any pointing device), capacitive (only with hands), force touch (pressure sensitive)
Motion sensing simple (pedometers for counting walking steps), MEMS (detection of acceleration), Camera (detecting light pattern), Kinect (Detect voice, face and movement)
Force Feedback - the simulating of physical attributes such as weight. Vibration of pager and phone, steering wheel, joystick/joypad. Time-based effect - force increases in strength over time,
should be >1s for noticeable; Space-based and Invariant Effects - provide forces that are not a function of time but are updated depending on where the joystick handle is pointing or how it is
being moved.
Input device: keyboard, mouse, joystick, joypad, microphone, touch screen Output device: speaker, monitor, force feedback, 3D image, smell synthesis