国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

1.1.3 | 前向渲染

2023-08-05 16:44 作者:GeometryGlacier  | 我要投稿

目錄索引

本系列與知乎同名翻譯同步更新,原文鏈接:https://zhuanlan.zhihu.com/p/646141370

如有任何翻譯錯(cuò)誤,歡迎在評(píng)論區(qū)踹我:)!

原文對照

Forward is the default rendering path and supports all typical features of a material (e.g. normal maps, pixel lighting, shadows, etc.). This rendering path has two different code written passes that we can use in our shader, the first,?base pass?and the second?additional pass.

In the base pass, we can define the?ForwardBase?light mode and in the additional pass, we can define the?ForwardAdd?light mode. Both are characteristic functions of a shader with lighting calculation. The base pass can process directional light per-pixel and will use the brightest light if there are multiple directional lights in the scene. In addition, the base pass can process light probes, global illumination, and ambient illumination (skylight).

As its name says, the additional pass can process "additional lights" per-pixel or also shadows that affect the object, what does this mean? If we have two lights in the scene, our object will be influenced only by one of them, however, if we have defined an additional pass for this configuration, then it will be influenced by both.

One point that we must take into consideration is that each illuminated pass will generate a separate draw call. A?draw call?is a call graphic that is made in the GPU every time we want to draw an element on the screen of our computer. These calls are processes that require a large amount of computation, so they need to be kept to a minimum possible, even more so if we are working on projects for mobile devices.

To understand this concept, we are going to suppose that we have four Spheres and one directional light in our scene. Each Sphere, by its nature, generates a call to the GPU, this means that each of them will generate an independent?draw call?by default.

Likewise, the directional light influences all the Spheres that are found in the scene, therefore, it will generate an additional?draw call?for each Sphere, this is mainly because a second pass has been included in the shader to calculate the shadow projection, therefore, four Spheres, plus one-directional light will generate eight draw calls in total.

Fig. 1.1.3a. In the image above, we can see the increase in draw calls when there are light sources. The calculation includes the ambient color and the light source as the object.

Having determined the base pass, if we add another pass in our shader, then we are going to add a new draw call for each object, and consequently, the graphic load will increase significantly.

There are some ways to optimize this process, which we will talk about later in the book. For now, we will continue the rendering path concept.

譯文

前向渲染是默認(rèn)的渲染路徑,支持諸如法線貼圖、逐像素光照、陰影等多種材質(zhì)功能。前向渲染包含了兩種可以在著色器內(nèi)編程的pass,分別是?base pass?和?additional pass。(譯者注:pass一般不翻譯成中文。base指基礎(chǔ),additional指附加)

在base pass中,我們可以定義?ForwardBase?光照模型;而在additional pass中,我們可以定義?ForwardAdd?光照模型。這兩種模型都具有在著色器中計(jì)算光照的功能。Bass pass 可以逐像素地處理平行光,當(dāng)場景中有多個(gè)平行光源時(shí),則會(huì)處理最亮的光源。除此之外,bass pass 還可以處理光照探針、全局照明和環(huán)境光(天空盒光照)。

顧名思義, Additional pass 可以逐像素地處理額外的光源,也可以處理影響模型的陰影。如果場景中有兩束光,我們的模型將只受其中一束光的影響。但如果我們?yōu)樗渲昧薬dditional pass,那么該模型將同時(shí)受兩束光的影響。

我們必須考慮的一點(diǎn)是每一個(gè)計(jì)算照明的pass都會(huì)單獨(dú)生成一個(gè)繪制調(diào)用(draw call)。繪制調(diào)用指的是每次我們想要在電腦屏幕上繪制一個(gè)元素時(shí),在 GPU 中進(jìn)行的圖形調(diào)用。這些調(diào)用需要大量的計(jì)算,因此需要盡可能地減少調(diào)用次數(shù),特別是運(yùn)行在移動(dòng)設(shè)備上的項(xiàng)目。

為了更好的理解這個(gè)概念,現(xiàn)在假設(shè)我們的場景中有四個(gè)球體和一束平行方向光。對每個(gè)球體來說,它將生成一次發(fā)送到GPU的繪制調(diào)用。這意味著默認(rèn)情況下每一個(gè)球體都會(huì)生成一次獨(dú)立的繪制調(diào)用。

同樣,平行光會(huì)影響場景中的所有球體,每個(gè)球體都會(huì)產(chǎn)生一次額外的繪制調(diào)用,這主要是因?yàn)橹髦械牡诙€(gè)pass計(jì)算了陰影投影。因此,四個(gè)球體加上一個(gè)平行光總共會(huì)產(chǎn)生八次繪制調(diào)用。

Fig. 1.1.3a. 上圖顯示了當(dāng)場景中存在光源時(shí),繪制調(diào)用的次數(shù)增加了。這些計(jì)算包括了環(huán)境光與作用在模型上的光源

在了解完base pass后,如果我們往shader中加入別的pass,那么我們將為每個(gè)模型增加一次新的繪制調(diào)用,圖形負(fù)載將大幅增加。

有一些方法可以優(yōu)化這一過程,我們將在本書的后半部分討論。現(xiàn)在,我們將繼續(xù)學(xué)習(xí)渲染路徑的概念。

1.1.3 | 前向渲染的評(píng)論 (共 條)

分享到微博請遵守國家法律
兴隆县| 衡阳市| 集贤县| 马龙县| 石家庄市| 横峰县| 焦作市| 巴楚县| 原阳县| 田林县| 侯马市| 克拉玛依市| 梓潼县| 栾城县| 全州县| 萨迦县| 抚宁县| 镇赉县| 崇仁县| 长沙县| 禹州市| 壶关县| 磐石市| 西乌珠穆沁旗| 台南县| 巴林右旗| 肥城市| 三门峡市| 济源市| 汽车| 靖远县| 杂多县| 华亭县| 舒城县| 本溪| 墨玉县| 自贡市| 南康市| 嘉义市| 鄂尔多斯市| 攀枝花市|