Game Engine Architecture 10

Game Engine Architecture 10

1、Full-Screen Antialiasing (FSAA)

also known as super-sampled antialiasing (SSAA)。

the scene is rendered into a frame buffer that is larger than the actual screen. Once rendering of the frame is complete, the resulting oversized image is downsampled to the desired resolution. In 4x supersampling, the rendered image is twice as wide and twice as tall as the screen, resulting in a frame buffer that occupies four times the memory. It also requires four times the GPU processing powerbecause the pixel shader must be run four times for each screen pixel.

As you can see, FSAA is an incredibly expensive technique both in terms of memory consumption and GPU cycles. As such, it is rarely usedin practice.

2、Multisampled Antialiasing (MSAA)

visual quality comparable to that of FSAA, while consuming a great deal less GPU bandwidth (and the same amount of video RAM).

效果和 FSAA 同样好,只消耗很少的GPU,但消耗同样多的 vRAM。

To understand how MSAA works, recall that the process of rasterizing a triangle really boils down to three distinct operations:

1)coverage

2)depth testing

3)pixel shading

In MSAA, the coverage and _depth tests are run for N points known as subsamples within each screen pixel._N is typically chosen to be 2, 4, 5, 8 or 16. However, the pixel shader is only _ run once per screen pixel, no matter how many subsamples we use._shading is typically a great deal more expensive than coverage and depth testing.

Nx MSAA,需要N个 depth、stencil、color buffer。

When rasterizing a triangle, _the coverage and depth tests are run N times for the N subsamples ._If at least oneof the N tests indicates that the fragment should be drawn, the pixel shader is run once. The color obtained from the pixel shader is then stored only into those slots that correspond to the subsamples that fell inside the triangle.

Nx MSAA 需要进行N次 coverage、N次 depth testing。

Once the entire scene has been rendered, the oversized color buffer is downsampledto yield the final screen resolution image. This process involves averaging the color values found in the N subsample slots for each screen pixel. The net result is an antialiased image with a shading cost equal to that of a non-antialiased image.

MSAA 的 shading cost 与 非抗锯齿渲染一样。

Game Engine Architecture 10

Game Engine Architecture 10

3、Coverage Sample Antialiasing (CSAA)

将 pixel 拆分成 4×4 subpixel,用一个 16位的 short 来标记当前 triangle 占据了哪些 subpixel。

4、Morphological Antialiasing (MLAA)

focuses its efforts on correcting only those regions of a scene that suffer the most from the effects of aliasing. In MLAA, the scene is rendered at normal size, and then scanned in order to identify stair-stepped patterns. When these patterns are found, they are blurred to reduce the effects of aliasing. Fast approximate antialiasing (FXAA) is an optimized technique developed by Nvidia that is similar to MLAA in its approach.

5、Subpixel Morphological Antialiasing (SMAA)

combines morphological antialiasing (MLAA and FXAA) techniques with multisampling/supersampling strategies (MSAA, SSAA) to produce more accurate subpixel features.

Like FXAA, it’s an inexpensive technique, but it blurs the final image less than FXAA. For these reasons, it’s arguably the best AA solution available today.

SMAA 是目前最先进的搞锯齿技术。它的消耗和 FXAA一样,但效果比 FXAA好。

6、Occlusion and Potentially Visible Sets

Even when objects lie entirely within the frustum, they may occlude one another. Removing objects from the visible list that are entirely occluded by other objects is called occlusion culling.

Because automated PVS tools are imperfect, they typically provide the user with a mechanism for tweaking the results, either by manually placing vantage points for testing, or by manually specifying a list of regions that should be explicitly included or excluded from a particular region’s PVS.

7、Portals

To render a scene with portals, we start by rendering the region that contains the camera. Then, for each portal in the region, we extend a frustum-like volume consisting of planes extending from the camera’s focal point through each edge of the portal’s bounding polygon. The contents of the neighboring region can be culled to this portal volume in exactly the same way geometry is culled against the camera frustum. This ensures that only the visible geometry in the adjacent regions will be rendered. Figure 11.48 provides an illustration of this technique.

Game Engine Architecture 10

8、Occlusion Volumes (Antiportals)

If we flip the portal concept on its head, pyramidal volumes can also be used to describe regions of the scene that cannot be seen because they are being occluded by an object. These volumes are known as occlusion volumes or antiportals.

9、Render State

The set of all configurable parameterswithin the GPU pipeline is known as the hardware state or render state.

10、Geometry Sorting

Clearly we’d like to change render settings as infrequently as possible. The best way to accomplish this is to sort our geometry by material.

Unfortunately, sorting geometry by materialcan have a detrimental effect on rendering performance because it increases overdraw—a situation in which the same pixel is filled multiple times by multiple overlapping triangles.

合批会导致 overdraw 增大。

11、z-Prepass to the Rescue

How can we reconcile the need to sort geometry by materialwith the conflicting need to render opaque geometry in a front-to-back order? The answer lies in a GPU feature known as z-prepass.

The idea behind z-prepass is to render the scene twice: the first time to generate the contents of the z-buffer as efficiently as possible and the second time to populate the frame buffer with full color information (but this time

with no overdraw, thanks to the contents of the z-buffer). The GPU provides a special double-speed rendering mode in which the pixel shaders are disabled, and only the z-buffer is updated.

z-prepass 技术可以解决 batching 导致的 overdraw 问题。渲染2遍,第一遍生成 depth buffer,第二遍才真正渲染。

Order-independent transparency (OIT) is a technique that permits transparent geometry to be rendered in an arbitrary order. It works by storing multiple fragments per pixel, sorting each pixel’s fragments and blending them only after the entire scene has been rendered. This technique produces correct results without the need for pre-sorting the geometry, but it comes at a high memory cost because the frame buffer must be large enough to store all of the translucent fragments for each pixel.

12、Quadtrees and Octrees

quadtrees are often used to store renderable primitives such as 1) mesh instances, 2) subregions of terrain geometry or 3) individual triangles of a large static mesh, for the purposes of efficient frustum culling.

The renderable primitives are stored at the leaves of the tree, and we usually aim to achieve a roughly uniform number of primitives within each leaf region.

Game Engine Architecture 10

Game Engine Architecture 10

13、Bounding Sphere Trees

14、BSP Trees

A kd-tree is a generalization of the BSP tree concept to k dimensions.

BSP tree can also be used to sort triangles into a strictly back-to-front or front-to-back order.

15、Image-Based Lighting

16、Heightmaps: Bump, Parallax and Displacement Mapping

In bump mapping, a heightmap is used as a cheap way to generate surface normals. This technique was primarily used in the early days of 3D graphics—nowadays, most game engines store surface normal information explicitly in a normal map, rather than calculating the normals from a heightmap.

Parallax occlusionmapping uses the information in a heightmap to artificially adjust the texture coordinates used when rendering a flat surface, in such a way as to make the surface appear to contain surface details that move semi-correctlyas the camera moves.

Displacement mapping(also known as relief mapping) produces real surface details by actually tessellating and then extruding surface polygons, again _using a heightmap to determine how much to displace each vertex._This produces

the most convincing effect

17、Specular/Gloss Maps

the specular intensity takes the form Ks(R.V)^a.

Game Engine Architecture 10

将 Ks 保存为纹理的技术,叫做 specular map、gloss map、specular mask。

将 a 保存为纹理的技术,叫做 specular power map。

Game Engine Architecture 10

Game Engine Architecture 10

18、Environment Mapping

It is generally used to inexpensively render reflections.

The two most common formats are spherical environmentmaps and cubic environment maps.

cubic environment maps 优于 spherical environment map.

19、Shadow Volumes

Game Engine Architecture 10

the GPU can be configured so that rendered geometry updates the values in the stencil buffer in various useful ways.

geometry 更新 stencil buffer。

1)the scene is first drawn to generate an unshadowed image in the frame buffer, along with an accurate z-buffer. The stencil buffer is cleared so that it contains zeros at every pixel.

2)Each shadow volume is then rendered from the point of view of the camera in such a way that front-facing triangles increase the values in the stencil buffer by one, while back-facing triangles decrease them by one. In areas of the screen where the shadow volume does not appear at all, of course the stencil buffer’s pixels will be left containing zero.

Game Engine Architecture 10

3)render shadows in a third pass, by simply darkening those regions of the screen that contain a nonzero stencil buffer value.

20、Shadow Maps

First, a shadow map texture is generated by rendering the scene from the point of view of the light source and saving off the contents of the depth buffer.

Second, the scene is rendered as usual, and the shadow map is used to determine whether or not each fragment is in shadow.

Game Engine Architecture 10

21、Ambient Occlusion

22、Reflections

Environment maps are used to produce general reflections of the surrounding environment on the surfaces of shiny objects.

Direct reflections in flat surfaces like mirrors can be produced by reflecting the camera’s position about the plane of the reflective surface and then rendering the scene from that reflected point of view into a texture. The texture is then applied to the reflective surface in a second pass.

Game Engine Architecture 10

23、Caustics

Caustic effects can be produced by projecting a (possibly animated) texturecontaining semi-random bright highlights onto the affected surfaces.

24、Subsurface Scattering

When light enters a surface at one point, is scattered beneath the surface, and then reemerges at a different point on the surface, we call this subsurface scattering.

This phenomenon is responsible for the “warm glow” of human skin, waxand marble statues.

Game Engine Architecture 10

25、Precomputed Radiance Transfer (PRT)

26、Deferred Rendering

In deferred rendering, the majority of the lighting calculations are done in screen space, not view space. We efficiently render the scene without worrying about lighting. During this phase, we store all the information we’re going to need to light the pixels in a “deep” frame buffer known as the G-buffer. Once the scene has been fully rendered, we use the information in the G-buffer to perform our lighting and shading calculations.

27、Physically Based Shading

28、Decals

A decal is a relatively small piece of geometry that is overlaid on top of the regular geometry in the scene, allowing the visual appearance of the surface to be modified dynamically. Examples include bullet holes, foot prints, scratches, cracks.

29、Sky

On modern game platforms, where pixel shading costs can be high, sky rendering is often done afterthe rest of the scene has been rendered.

30、Terrain

31、Water

There are lots of different kinds of water, including oceans, pools, rivers, waterfalls, fountains, jets, puddles(水坑) and damp(潮湿) solid surfaces. Each type of water generally requires some specialized rendering technology.

32、Text and Fonts

a text rendering system needs to be capable of displaying a sequence of character glyphs corresponding to a text string.

_A font is often implemented via a texture map known as a glyph atlas._A font description file provides information such as the bounding boxes of each glyph within the texture, and font layout information such as kerning, baseline offsets and so on.

The FreeType library enables a game or other application to read fonts in a wide variety of formats, including TrueType (TTF) and OpenType (OTF), and to render glyphs into in-memory pixmaps at any desired point size. FreeType renders each glyph using its Bezier curve outlines, so it produces very accurate results.

FreeType library 将 glyphs 渲染进 pixmaps中。

Typically a real-time application like a game will use FreeType to prerender the necessary glyphs into an atlas, which is in turn used as a texture map to render glyphs as simple quads every frame. However, by embedding FreeType or a similar library in your engine, it’s possible to render some glyphs into the atlas on the fly, on an as-needed basis. This can be useful when rendering text in a language with a very large number of possible glyphs, like Chinese or Korean.

FreeType 离线、实时将 glyphs 渲染成 texture map,供 text rendering engine 使用。

signed distance fields,each pixel contains a signed distance from that pixel center to the nearest edge of the glyph. Inside the glyph, the distances are negative; outside the glyph’s outlines, they are positive.

33、Gamma Correction

CRT monitors tend to have a nonlinear response to luminance values. Visually, the dark regions of the image would look darker than they should.

Game Engine Architecture 10

gCRT > 1. To correct for this effect, the colors sent to the CRT display are usually passed through an inverse transformation (i.e., using a gamma value gcorr < 1). The value of gCRT for a typical CRT monitor is 2.2, so the correction value is usually gcorr = 1/2.2 = 0.455.

One problem that is encountered, however, is that the bitmap images used to represent texture maps are often gamma-corrected themselves.

34、Full-Screen Post Effects

35、

36、

37、

Original: https://www.cnblogs.com/tekkaman/p/10685982.html
Author: Tekkaman
Title: Game Engine Architecture 10

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/548994/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

  • PgSQL-||-连字符

    (PgSQL)连字符 || — 22.22& select 22.22||’%’ as 值; Original: https://www.cnblogs.com/a999…

    技术杂谈 2023年6月21日
    083
  • SpringBoot-Mybatis

    SpringBoot 整合 Mybatis SpringBoot-Mybatis 10.1 导入 MyBatis 所需要的依赖 org.mybatis.spring.boot my…

    技术杂谈 2023年6月21日
    071
  • Flink DataStream API

    DataStream API主要可为分为三个部分,DataSource模块、Transformation模块以及DataSink模块。 DataSource模块 内置DataSou…

    技术杂谈 2023年7月10日
    075
  • CentOS7添加一个systemd服务教程

    一、说明 1.1 背景说明 刚工作时D运营商多用CentOS6,在很长的一段时间内搞不清这两个问题:为什么yum安装的mysql服务用service命令就能启动了、如果自己rpm安…

    技术杂谈 2023年5月31日
    097
  • lightdb实例初始化

    `[lightdb@hs-10-20-30-199 ~]$ lt_initdb -p9876 -D lightdb22.1-dataThe files belonging to t…

    技术杂谈 2023年6月1日
    079
  • Linux 7安装Mysql5.7版本

    Mysql 5.7的安装搭建 首先去到官方网站的下载链接中找到对应你Linux服务器版本的mysql软件包 https://dev.mysql.com/downloads/repo…

    技术杂谈 2023年6月21日
    0105
  • 查找文本文件中重复的汉字

    查找文本文件中重复的汉字,找到在所在行号 文本文件格式 大 小 多 少 前 后 左 …… text.py import os import re list = [] sam…

    技术杂谈 2023年5月31日
    0134
  • Go Programming Language 3

    【 Go Programming Language 3】 1、These two statements declare a struct type called and a var…

    技术杂谈 2023年5月31日
    073
  • 定制化知识图谱 项目介绍

    宣传网站 http://dingzhitupu.com/ 定制化知识图谱 根据您的业务特性,通过图分析、建模,创建专门适合与您业务逻辑的专有知识图谱 特性介绍 用户不必懂相关技术 …

    技术杂谈 2023年5月31日
    099
  • FineUIPro/Mvc/Core v8.0.0 发布了!

    FineUIPro/Mvc/Core v8.0.0 正式发布了,这个版本推出高性能延迟渲染表格和期待已久的卡片渲染模式,并对主题配色进行优化调整! 相关文章: 《致广大 FineU…

    技术杂谈 2023年6月1日
    081
  • Map–部分方法

    1.Map.values()方法:获取Map集合中的所有键值对象 获取 Map 集合中的所有键值对象,这些键值对象将存放在另一个集合对象中 2.getOrDefault() 方法 …

    技术杂谈 2023年7月24日
    078
  • SpringBoot 多环境配置文件切换

    背景 很多时候,我们项目在开发环境和生成环境的环境配置是不一样的,例如,数据库配置,在开发的时候,我们一般用测试数据库,而在生产环境的时候,我们是用正式的数据,这时候,我们可以利用…

    技术杂谈 2023年7月11日
    089
  • 学习链表复盘中

    链表基础知识 链表的分类 链表是一种通过指针串联在一起的线性结构,主要分为单链表、双向链表和循环链表。 单链表 单链表中每一个节点是由两部分组成,一个是数据域、一个是指针域(存放指…

    技术杂谈 2023年7月25日
    0100
  • 怎样记住Integer的最大值(有趣的思维和搞笑的回答)

    今天一个同事问我,数据库里面的某表如果用int做PK,那该表最多可以放多少记录,我说简单啊,就是2^31(正数),跟.NET的Int32.MaxValue一样,约等于20亿(正数)…

    技术杂谈 2023年5月31日
    078
  • oc dealloc 内存管理

    404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 contact@cnblogs.com 园子的商业化努力-困…

    技术杂谈 2023年5月30日
    086
  • 安卓逆向从0到1学习总结

    PS:该文已经首发于公众号信安之路!!! 初识安卓逆向是在2019年的暑假,到现在也快一年了,这一年来有刚从web渗透转来的迷茫,有成功破解了第一个app的喜悦,也有通宵熬夜逆向的…

    技术杂谈 2023年7月11日
    079
亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球