1 KIPA Game Engine Seminars Jonathan Blow Seoul, Korea November 30, 2002 Day 5.
-
Upload
alvin-manning -
Category
Documents
-
view
223 -
download
0
Transcript of 1 KIPA Game Engine Seminars Jonathan Blow Seoul, Korea November 30, 2002 Day 5.
1
KIPA Game Engine Seminars
Jonathan Blow
Seoul, Korea
November 30, 2002
Day 5
2
Stencil Shadow Visibility Culling
• (clarification from yesterday…)
• There are two rendering passes, “shadow” and “normal”, and visibility detection is separate for each, but there are dependencies
3
GameCube rendering source code example
• (Wanted to show one yesterday but didn’t have it available)
4
Explanation ofdouble-sort algorithm
for networking
• Use a global sorted list for the server, along with one list for each client
• (on whiteboard: show how to use combined information to speed up object search)
• These lists only change incrementally, so keeping them sorted should be cheap
5
Further Work onFiltered Variance for Networking
• (quick summary of yesterday’s subjects)
• Presentation of solution that I said I hadn’t figured out yet, yesterday– Easy to rotate variance matrix into the frame of
the viewpoint– No loner need approximation for z
6
Raycasting against The World
• First navigate a BSP tree or something.
• Then you need to collide against meshes in the world, probably.
• Mesh representation can make for some interesting issues…
7
Triangle Strip Meshes
• Want to iterate over the whole mesh, ignoring degenerate faces
• Since you want to do this frequently, it’s good to abstract that into an iterator class
• (looking at code)
8
PC vs. UMA Console
• On a PC, vertex buffers may be stored in video RAM (if application is high-performance)
• On a UMA console (e.g. Xbox), vertex buffers exist in common memory
9
PC Version is Less Efficient
• Maybe you have two copies of all vertex data– Expensive in terms of RAM
• Maybe you lock the vertex/index buffers to traverse them.– Expensive in terms of CPU
10
Cross-Platform Issues
• Looking at mesh geometry is very common– Raycasting, decals, dynamic bounding volumes…
• So it needs to be done from many places in the engine
• So we need to be able to inspect mesh geometry in a cross-platform way – Because we don’t want to write all that code several
times… too much complication!
11
This makes me sad
• It means we need to introduce abstractions that are forced by the PC…
• All applications get access to vertex memory by calling a lock / unlock function.– But on consoles this usually is not necessary!– So console games are a little bit more
complicated than they would be otherwise
12
Looking at the code…
• In the engine, the class “Fast_Rendering_Vertex_Data” provides this abstraction.
• Systems deep in the engine like skeletal animation, lock this buffer in order to save the deformed vertices
• On some platforms, the lock is a “no-op”
13
But it gets worse…
• Because locking the buffers may be expensive on a platform like the PC
• You want to try to optimize the core engine to minimize locks, even though locks are “no-ops” on some platforms– Example: Animating vertices, then updating
vertex normals … sometimes we don’t need normals!
14
Difference in Philosophy:Xbox vs. GameCube
• Xbox wants you to lock vertex buffers– So that it can invalidate cache on the graphics processor
– But software is more complicated due to lock/unlock calls
• GameCube lets you modify vertex and index buffers freely– But you must remember to invalidate the cache
memory yourself• Though it is easy to get this wrong as well
• I am not sure which is better
15
Visibility
16
Three main categoriesof visibility algorithms
• “Blind”– PVS
• View Space– Portals, occluders, horizon computation
• Screen Space– Span buffer, coverage mask, hierarchical
z-buffer
17
Indoor vs Outdoor Rendering
• Different techniques applicable to each
• Indoor engine: Half-Life– Counter-Strike screenshot examples of “fake
outdoors”
• Outdoor engine: Starsiege TRIBES– Screenshots
18
Indoor vs Outdoor Rendering
• But of course we want to make worlds that have both indoors and outdoors
• Some games have engines that switch between them (like Tribes)
• This is not a good thing; we want a unified rendering method.
19
High Average Frame Ratevs. Consistent Frame Rate
• Consistent frame rate is more important!• If I am standing in some place and looking
in some direction and I get 60fps, that is not very good if my frame rate drops to 15fps when I turn left– Example: a room in a first person shooter with
a lot of objects in one corner• (quick demo)
20
Some Outdoor RenderersTry to Use Visibility Culling
• Occluders
• Horizon detection-based culling
(examples)
21
But, Occlusion Cullingdoes not make much sense
for outdoors• Outdoor scenes are relatively uncontrolled;• Definition of an outdoor engine is that you
can go up on top of a big mountain and look around
• If frame rate must be fast in that situation, what is the point of trying to make it faster?
• Trying to make things faster in occluded cases will make the mountain case slower
22
But, Occlusion Cullingis critical for indoors
• It’s the only way modern games like Doom 3 are fast
• What this means is…
23
Unification won’t really happenfor a while.
• Until we come up with an occlusion culling method that is simple, and fast in the case where nothing is occluded;
• Or we come up with a way to render indoor areas without occlusion culling, and without suffering any speed losses.
24
Screenspace Method:Span Buffer
• Something we used a lot in software rendering
• Unreal used this (newer Unreal-engine games do not)– It did not scale well with hardware rendering– I think Unreal actually used span portal
visibility (explained after we talk about portals)
25
Screenspace Method:Triage Coverage Masks
• Proposed by Ned Greene, paper: “Hierarchical Polygon Tiling with Coverage Masks”
26
Screenspace Method:Hierarchical Z-Buffer
• Also proposed by Ned Greene, paper: “Hierarchical Z-Buffer Visibility”
• Uses frame coherence for increased speed
• I do not like frame coherence
27
Why I Dislike Frame Coherence
• Games want a stable frame rate (not just a fast frame rate!)
• If the frame rate becomes slightly slower, the viewpoint moves further = less coherence
• Because there’s less coherence, the next frame will draw even slower
• This causes a feedback loop (the frame rate plummets)
28
Frame Coherence
• Frame Coherence is relied upon heavily by many of the algorithms I like to pick on
– (like the ROAM terrain rendering algorithm)
29
Academic Research
• Frame coherence is thought of as a standard way to speed up algorithms in the academic world
• This is one of several ways in which the academic community is “out to lunch”
Frame coherence is good for batch rendering; it is not suitable for most interactive rendering!
30
My Recommendations
• For runtime visibility in games, use an algorithm like PVS or portals. Don’t use a screenspace method.
• Screenspace methods are better for software rendering.
• These days we are making some tools that effectively do software rendering, so screenspace methods may apply– The normal map generation algorithm
• Actually doesn’t need occlusion culling, but it’s an example of software rendering “coming back” in preprocessing tools