[font=tahoma, geneva, sans-serif]In this thread, I'd like experienced 3D programmers to brainstorm to attempt to identify the set of techniques that will most speed rendering of high-quality general scenes on current and next-generation high-end CPUs, GPUs and OpenGL/GLSL APIs (let's assume a 5 year timeframe). Complexity of implementation should also be considered important.[/font]
[font=tahoma, geneva, sans-serif]The goal is to come up with a set of techniques, and their order of execution (including parallel execution) that best suits high-quality, general purpose scenes with large numbers of objects. In other words, imagine you're writing a 3D engine that needs to execute a variety of common game and simulation scenarios efficiently (not just one specific game). The nominal scenarios should range between:[/font]
[font=tahoma, geneva, sans-serif]#1: A very large outdoor [or indoor] environment in which most objects do not move on a typical frame, but dozens of objects are moving each frame.[/font]
[font=tahoma, geneva, sans-serif]#2: A game in outer space in which most or all objects move every frame.[/font]
[font=tahoma, geneva, sans-serif]Let's assume the engine supports 1 ambient, and several point light-sources and some form of soft shadows are required.[/font]
[font=tahoma, geneva, sans-serif]The following lower efficiency and should be considered:[/font]
[font=tahoma, geneva, sans-serif]- small batches[/font]
[font=tahoma, geneva, sans-serif]- switching shaders[/font]
[font=tahoma, geneva, sans-serif]- rendering objects outside frustum[/font]
[font=tahoma, geneva, sans-serif]- rendering objects entirely obscured by closer opaque objects[/font]
[font=tahoma, geneva, sans-serif]- rendering objects behind semi-transparent objects[/font]
[font=tahoma, geneva, sans-serif]- some form of parallax mapping vs detailed geometry[/font]
[font=tahoma, geneva, sans-serif]- add more here[/font]
[font=tahoma, geneva, sans-serif]There are many possible "dynamics" that people consider.[/font]
[font=tahoma, geneva, sans-serif]For example, if we write one or more "uber-shaders" that tests bit-fields and/or texture-IDs and/or matrix-IDs in each vertex structure to control how the pixel shader renders each triangle, it is possible to render huge quantities of objects with a single call to glDrawElements() or equivalent. On the other hand, every triangle takes a little bit longer to execute, due to the multiple paths in the pixel shader.[/font]
[font=tahoma, geneva, sans-serif]Another dynamic is the complexity of culling objects outside the frustum when they do or might cast shadows, and when the environment contains mirrors or [semi]-reflective surfaces, and when the environment contains virtual cameras that point in random directions and their view is rendered on video displays at various places [possibly] within the scene. Furthermore, should not collision detection and response be computed for all objects, even those outside the frustum?[/font]
[font=tahoma, geneva, sans-serif]At one end of the spectrum of possibilities is an approach in which every possible efficiency is tested-for and potentially executed every frame. Considering how various possible efficiencies and possible aspects of a scene interact, this approach could be extremely complex, tricky and prone to discovering cases that are not handled correctly due to that complexity.[/font]
[font=tahoma, geneva, sans-serif]At the other end of the spectrum of possibilities is an approach in which every object that has moved is transformed every frame, without testing for being visible in the frustum, casting a shadow onto any object in the frustum, etc. Instead, this approach would attempt to find a way to most efficiently perform every applicable computation on every object, and possibly even render every object. Perhaps this approach could support one type of culling without risking unwanted interactions - by grouping objects near to each other into individual batches, then not rendering into the backbuffer those batches that fall entirely outside the frustum. But this culling would only be on the final rendering phase, not the collision-phase or shadow computing phase, etc.[/font]
[font=tahoma, geneva, sans-serif]I consider this a difficult problem! I've brainstormed this issue with myself for years, and have never felt confident I have the best answer... or even close to the best answer. I won't bias this brainstorming session by stating my nominal working opinion before others have voice their observations and opinions.[/font]
[font=tahoma, geneva, sans-serif]Please omit discussions that apply to CPUs older than current high-end CPUs, GPUs older than GTX-680 class, and OpenGL/GLSL older than v4.20, because the entire point of this thread is to design something that's efficient 2~4 years from now, and likely for years beyond that. Also omit discussions that apply to non-general environments or non-general rendering.[/font]
[font=tahoma, geneva, sans-serif]OTOH, if you know of new features of next-generation CPUs/GPUs/OpenGL/GLSL that are important to this topic, please DO discuss these.[/font]
[font=tahoma, geneva, sans-serif]Assume the computer contains:[/font]
[font=tahoma, geneva, sans-serif]- one 4GHz 8-core AMD/Intel CPU[/font]
[font=tahoma, geneva, sans-serif]- 8GB to 32GB fastish system RAM[/font]
[font=tahoma, geneva, sans-serif]- one GTX-680 class GPU with 2GB~4GB RAM[/font]
[font=tahoma, geneva, sans-serif]- one 1920x1200 LCD display (or higher-resolution)[/font]
[font=tahoma, geneva, sans-serif]- computer is not running other applications simultaneously[/font]
[font=tahoma, geneva, sans-serif][font=tahoma, geneva, sans-serif]- up to 8~16 simultaneously active engine threads on CPU[/font][/font]
[font=tahoma, geneva, sans-serif]Assume the 3D engine supports the following conventional features:[/font]
[font=tahoma, geneva, sans-serif]- some kind of background (mountains, ocean, sky)[/font]
[font=tahoma, geneva, sans-serif]- many thousand objects[/font]
[font=tahoma, geneva, sans-serif]- millions of triangles[/font]
[font=tahoma, geneva, sans-serif]- several point lights (or many point lights but only closest*brightest applied to each triangle)[/font]
[font=tahoma, geneva, sans-serif]- ambient lighting[/font]
[font=tahoma, geneva, sans-serif]- diffuse shading[/font]
[font=tahoma, geneva, sans-serif]- reflective shading[/font]
[font=tahoma, geneva, sans-serif]- soft shadows (variance shadow mapping or alternative)[/font]
[font=tahoma, geneva, sans-serif]- texture mapping[/font]
[font=tahoma, geneva, sans-serif]- bump mapping[/font]
[font=tahoma, geneva, sans-serif]- parallax mapping (maybe, vs real geometry)[/font]
[font=tahoma, geneva, sans-serif]- collision detection (broad & narrow phase, convex/concave, fairly accurate)[/font]
[font=tahoma, geneva, sans-serif]- collision response (basic physics)[/font]
[font=tahoma, geneva, sans-serif]- objects support hierarchies (rotate/translate against each other)[/font]
[font=tahoma, geneva, sans-serif]- semi-transparent objects == optional[/font]