{"id":304693,"date":"2020-06-02T09:01:13","date_gmt":"2020-06-02T09:01:13","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304693"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304693","title":{"rendered":"\u0420\u0435\u0432\u0435\u0440\u0441-\u0438\u043d\u0436\u0438\u043d\u0438\u0440\u0438\u043d\u0433 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0430 3\u00bb: \u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c, \u043f\u043e\u0440\u0442\u0430\u043b\u044b \u0438 \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u044f"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504336\/\">[\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430: <a href=\"https:\/\/habr.com\/ru\/post\/422573\/\">\u043f\u0435\u0440\u0432\u0430\u044f<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/437100\/\">\u0432\u0442\u043e\u0440\u0430\u044f<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/450332\/\">\u0442\u0440\u0435\u0442\u044c\u044f<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/489118\/\">\u0447\u0435\u0442\u0432\u0451\u0440\u0442\u0430\u044f<\/a>.]<\/p>\n<h2>\u0427\u0430\u0441\u0442\u044c 1: \u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c<\/h2>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b, \u043a\u0430\u043a \u0432 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0435 3\u00bb \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u0437\u0432\u0451\u0437\u0434\u044b. \u042d\u0442\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043d\u0435\u0442 \u0432 \u00ab\u041a\u0440\u043e\u0432\u0438 \u0438 \u0432\u0438\u043d\u0435\u00bb. \u0412 \u043f\u043e\u0441\u0442\u0435 \u044f \u043e\u043f\u0438\u0448\u0443 \u044d\u0444\u0444\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u043c DLC: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Milky_Way\" rel=\"nofollow\">\u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c<\/a>.<\/p>\n<p>  \u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/c8iURjd03vE?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0418 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432: (1) \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430, (2) \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0446\u0432\u0435\u0442\u043e\u043c \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438, (3) \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/842\/903\/ccd\/842903ccd1787d3a1c5ea8280162cc7a.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/206\/cd8\/8cf\/206cd88cfed00e5934a531a5c496abc5.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/26d\/31a\/317\/26d31a3176c9e696c7f09d67ca428b3a.png\"><\/div>\n<\/div><\/div>\n<p>  \u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u0430\u0434\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u043d\u0438\u043c \u041c\u043b\u0435\u0447\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c (\u0431\u0435\u0437 \u0446\u0432\u0435\u0442\u0430 \u043d\u0435\u0431\u0430 \u0438 \u0437\u0432\u0451\u0437\u0434) \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/eb7\/7ea\/807\/eb77ea807cadc8affeb5c475bcf51f36.jpg\"><\/div>\n<p>  \u042d\u0444\u0444\u0435\u043a\u0442 \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438, \u0441\u0442\u0430\u0432\u0448\u0438\u0439 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0433\u0440\u044b 2015 \u0433\u043e\u0434\u0430, \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/450332\/\">\u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00ab\u0413\u043b\u0443\u043f\u044b\u0435 \u0442\u0440\u044e\u043a\u0438 \u0441 \u043d\u0435\u0431\u043e\u043c\u00bb<\/a>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d!<\/p>\n<p>  \u041f\u043b\u0430\u043d \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c \u0432\u0441\u0451, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0435\u0441\u044f \u043a \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043f\u0440\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3>1. \u0413\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044f<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043c\u0435\u0448\u0430 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430. \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u0443\u043f\u043e\u043b\u043e\u043c 2015 \u0433\u043e\u0434\u0430 (\u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0433\u0440\u0430 + DLC \u00ab\u041a\u0430\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0434\u0446\u0430\u00bb, \u044f \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u0438\u0445 \u043e\u0431\u0435 \u00ab\u0438\u0433\u0440\u043e\u0439 2015 \u0433\u043e\u0434\u0430\u00bb) \u0438 \u043a\u0443\u043f\u043e\u043b\u043e\u043c \u0432 DLC \u00ab\u041a\u0440\u043e\u0432\u044c \u0438 \u0432\u0438\u043d\u043e\u00bb (2016 \u0433\u043e\u0434):<\/p>\n<p>  \u0430) \u0412 \u00ab\u041a\u0440\u043e\u0432\u0438 \u0438 \u0432\u0438\u043d\u0435\u00bb \u043c\u0435\u0448 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043b\u043e\u0442\u043d\u044b\u0439,<\/p>\n<p>  \u0431) \u0412 \u043c\u0435\u0448\u0435 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430 \u00ab\u041a\u0438\u0412\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439.<\/p>\n<p>  \u0412\u043e\u0442 \u043c\u0435\u0448 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430 2015 \u0433\u043e\u0434\u0430 \u2014 DrawIndexed(720)<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/844\/600\/53e\/84460053ed9f2d004e069dba60356360.png\"><\/div>\n<p>  <i>\u041c\u0435\u0448 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430 \u0432 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0435 3\u00bb 2015 \u0433\u043e\u0434\u0430 \u2014 720 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/i><\/p>\n<p>  \u0410 \u0432\u043e\u0442 \u043c\u0435\u0448 \u0438\u0437 \u00ab\u041a\u0438\u0412\u00bb \u2014 DrawIndexed(2640):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a83\/196\/697\/a83196697ccf581e35aa507c9b5706f6.png\"><\/div>\n<p>  <i>\u041c\u0435\u0448 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430 DLC \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a 3: \u041a\u0440\u043e\u0432\u044c \u0438 \u0432\u0438\u043d\u043e\u00bb \u2014 2640 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432<\/i><\/p>\n<p>  \u0412\u043e\u0442 \u0435\u0449\u0451 \u0440\u0430\u0437 \u043c\u0435\u0448 \u0438\u0437 \u00ab\u041a\u0438\u0412\u00bb: \u044f \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b, \u043a\u0430\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u2014 \u043e\u043d\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u00ab\u0446\u0435\u043d\u0442\u0440\u00bb \u043c\u0435\u0448\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e28\/db1\/186\/e28db11861d59198636fc7d80093cc81.png\"><\/div>\n<p>  <i>\u041c\u0435\u0448 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430 DLC \u00ab\u041a\u0440\u043e\u0432\u044c \u0438 \u0432\u0438\u043d\u043e\u00bb \u0441 \u043d\u043e\u0440\u043c\u0430\u043b\u044f\u043c\u0438<\/i><\/p>\n<h3>2. \u0412\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440<\/h3>\n<p>  \u0412\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442. \u0412\u043e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434. \u0420\u0430\u0434\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 SV_Position:<\/p>\n<pre><code class=\"cpp\"> vs_5_0       dcl_globalFlags refactoringAllowed       dcl_constantbuffer cb1[4], immediateIndexed       dcl_constantbuffer cb2[6], immediateIndexed       dcl_input v0.xyz       dcl_input v1.xy       dcl_input v2.xyz       dcl_output o0.xyzw       dcl_output o1.xyzw       dcl_output_siv o2.xyzw, position       dcl_temps 3      0: mov o0.xy, v1.xyxx      1: mad r0.xyz, v0.xyzx, cb2[4].xyzx, cb2[5].xyzx      2: mov r0.w, l(1.000000)      3: dp4 o0.z, r0.xyzw, cb2[0].xyzw      4: dp4 o0.w, r0.xyzw, cb2[1].xyzw      5: mad r1.xyz, v2.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)      6: dp3 r2.x, r1.xyzx, cb2[0].xyzx      7: dp3 r2.y, r1.xyzx, cb2[1].xyzx      8: dp3 r2.z, r1.xyzx, cb2[2].xyzx      9: dp3 r1.x, r2.xyzx, r2.xyzx     10: rsq r1.x, r1.x     11: mul o1.xyz, r1.xxxx, r2.xyzx     12: dp4 o1.w, r0.xyzw, cb2[2].xyzw  <\/code><\/pre>\n<p>  \u0412\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u0432\u0435\u0440\u0448\u0438\u043d \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f:<\/p>\n<p>  1) \u041f\u043e\u0437\u0438\u0446\u0438\u044f \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 [0-1] \u2014 v0.xyz,<\/p>\n<p>  2) Texcoords \u2014 v1.xy,<\/p>\n<p>  3) \u0412\u0435\u043a\u0442\u043e\u0440 \u043d\u043e\u0440\u043c\u0430\u043b\u0438 [0-1] \u2014 v2.xyz<\/p>\n<p>  \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 cbuffer:<\/p>\n<p>  1) \u041c\u0430\u0442\u0440\u0438\u0446\u0430 \u043c\u0438\u0440\u0430 (0-3) \u2014 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434: \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u043e\u0435 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043a\u0430\u043c\u0435\u0440\u044b,<\/p>\n<p>  2) \u041c\u0430\u0441\u0448\u0442\u0430\u0431 \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u044b (4-5) \u2014 \u0442\u0440\u044e\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0438\u0433\u0440\u044b \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 [0-1] \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e [-1;1], \u0438 \u0434\u043b\u044f \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u00ab\u0441\u043f\u043b\u044e\u0449\u0438\u0432\u0430\u043d\u0438\u044f\u00bb \u043c\u0435\u0448\u0435\u0439.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/356\/b61\/5d3\/356b615d3f35e29bb22a7de3df88114e.png\"><\/div>\n<p>  \u0410 \u0432\u043e\u0442 \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435:<\/p>\n<p>  \u0428\u0435\u0439\u0434\u0435\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 texcoords (\u0441\u0442\u0440\u043e\u043a\u0430 0). \u041a \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u043c\u0438\u0440\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0448\u0442\u0430\u0431 \u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 (\u0441\u0442\u0440\u043e\u043a\u0430 1), \u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u0438\u0440\u0430 (\u0441\u0442\u0440\u043e\u043a\u0438 3-4, 12). \u0412\u0435\u043a\u0442\u043e\u0440 \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0451\u043d \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 [0-1] \u0432 [-1;1] (\u0441\u0442\u0440\u043e\u043a\u0430 5), \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u043d \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u0438\u0440\u0430 (\u0441\u0442\u0440\u043e\u043a\u0438 6-8) \u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f (\u0441\u0442\u0440\u043e\u043a\u0438 9-11).<\/p>\n<p>  \u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/670\/219\/ded\/670219ded77f24df4185ca70360ca6a4.png\"><\/div>\n<p>  <\/p>\n<h3>3. \u041f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440<\/h3>\n<p>  \u0412\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0434\u043d\u0430 \u0447\u0430\u0441\u0442\u044c \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043d\u0435\u0431\u0430. \u0412 \u00ab\u041a\u0438\u0412\u00bb \u043e\u043d \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0434\u043b\u0438\u043d\u043d\u0435\u0435, \u0447\u0435\u043c \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 2015 \u0433\u043e\u0434\u0430. \u041e\u043d \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 385 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435, \u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 2015 \u0433\u043e\u0434\u0430 \u2014 \u0438\u0437 267 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c:<\/p>\n<pre><code class=\"cpp\">  175: sample_indexable(texturecube)(float,float,float,float) r4.xyz, r2.xyzx, t0.xyzw, s0     176: mul r4.xyz, r4.xyzx, r4.xyzx     177: sample_indexable(texturecube)(float,float,float,float) r0.w, r2.xyzx, t1.yzwx, s0     178: dp3 r1.w, v1.xyzx, v1.xyzx     179: rsq r1.w, r1.w     180: mul r2.xyz, r1.wwww, v1.xyzx     181: dp3 r1.w, cb12[204].yzwy, cb12[204].yzwy     182: rsq r1.w, r1.w     183: mul r5.xyz, r1.wwww, cb12[204].yzwy     184: dp3 r1.w, r2.xyzx, r5.xyzx     185: mad_sat r0.w, r0.w, l(0.200000), r1.w     186: ge r1.w, l(0.497925), r0.w     187: if_nz r1.w     188:  ge r1.w, l(0.184939), r0.w     189:  mul r2.y, r0.w, l(5.407188)     190:  min r2.z, r2.y, l(1.000000)     191:  mad r2.w, r2.z, l(-2.000000), l(3.000000)     192:  mul r2.z, r2.z, r2.z     193:  mul r2.z, r2.z, r2.w     194:  mul r5.xyz, r2.zzzz, l(0.949254, 0.949254, 0.949254, 0.000000)     195:  mov r2.x, l(0.949254)     196:  movc r2.xw, r1.wwww, r2.xxxy, l(0.000000, 0.000000, 0.000000, 0.500000)     197:  not r4.w, r1.w     198:  if_z r1.w     199:   ge r1.w, l(0.239752), r0.w     200:   add r5.w, r0.w, l(-0.184939)     201:   mul r6.y, r5.w, l(18.243849)     202:   mov_sat r5.w, r6.y     203:   mad r6.z, r5.w, l(-2.000000), l(3.000000)     204:   mul r5.w, r5.w, r5.w     205:   mul r5.w, r5.w, r6.z     206:   mad r5.w, r5.w, l(-0.113726), l(0.949254)     207:   movc r5.xyz, r1.wwww, r5.wwww, r5.zzzz     208:   and r7.xyz, r1.wwww, l(0.949254, 0.949254, 0.949254, 0.000000)     209:   mov r6.x, l(0.835528)     210:   movc r2.xw, r1.wwww, r6.xxxy, r2.xxxw     211:   mov r2.xyzw, r2.xxxw     212:  else     213:   mov r7.xyz, l(0, 0, 0, 0)     214:   mov r2.xyzw, r2.xxxw     215:   mov r1.w, l(-1)     216:  endif     217:  not r5.w, r1.w     218:  and r4.w, r4.w, r5.w     219:  if_nz r4.w     220:   ge r5.w, r0.w, l(0.239752)     221:   ge r6.x, l(0.294564), r0.w     222:   and r1.w, r5.w, r6.x     223:   add r5.w, r0.w, l(-0.239752)     224:   mul r6.w, r5.w, l(18.244175)     225:   mov_sat r5.w, r6.w     226:   mad r7.w, r5.w, l(-2.000000), l(3.000000)     227:   mul r5.w, r5.w, r5.w     228:   mul r5.w, r5.w, r7.w     229:   mad r5.w, r5.w, l(0.015873), l(0.835528)     230:   movc r5.xyz, r1.wwww, r5.wwww, r5.xyzx     231:   movc r7.xyz, r1.wwww, l(0.835528, 0.835528, 0.835528, 0.000000), r7.xyzx     232:   mov r6.xyz, l(0.851401, 0.851401, 0.851401, 0.000000)     233:   movc r2.xyzw, r1.wwww, r6.xyzw, r2.xyzw     234:  endif     235:  not r5.w, r1.w     236:  and r4.w, r4.w, r5.w     237:  if_nz r4.w     238:   ge r1.w, r0.w, l(0.294564)     239:   add r0.w, r0.w, l(-0.294564)     240:   mul r6.w, r0.w, l(4.917364)     241:   mov_sat r0.w, r6.w     242:   mad r4.w, r0.w, l(-2.000000), l(3.000000)     243:   mul r0.w, r0.w, r0.w     244:   mul r0.w, r0.w, r4.w     245:   mad r0.w, r0.w, l(-0.851401), l(0.851401)     246:   movc r5.xyz, r1.wwww, r0.wwww, r5.xyzx     247:   movc r7.xyz, r1.wwww, l(0.851401, 0.851401, 0.851401, 0.000000), r7.xyzx     248:   mov r6.xyz, l(0, 0, 0, 0)     249:   movc r2.xyzw, r1.wwww, r6.xyzw, r2.xyzw     250:  endif     251: else     252:  mov r7.xyz, l(0, 0, 0, 0)     253:  mov r2.xyzw, l(0.000000, 0.000000, 0.000000, 0.500000)     254:  mov r1.w, l(0)     255: endif     256: mov_sat r2.w, r2.w     257: mad r0.w, r2.w, l(-2.000000), l(3.000000)     258: mul r2.w, r2.w, r2.w     259: mul r0.w, r0.w, r2.w     260: add r2.xyz, -r7.xyzx, r2.xyzx     261: mad r2.xyz, r0.wwww, r2.xyzx, r7.xyzx     262: movc r2.xyz, r1.wwww, r5.xyzx, r2.xyzx     263: mul r2.xyz, r2.xyzx, l(0.150000, 0.200000, 0.250000, 0.000000)<\/code><\/pre>\n<p>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0443\u0433\u0430\u044e\u0449\u0435, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u041a\u043e\u0433\u0434\u0430 \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u0435\u0433\u043e \u0432\u043f\u0435\u0440\u0432\u044b\u0435 (\u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044f \u0443\u0432\u0438\u0434\u0435\u043b \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0437\u0432\u0451\u0437\u0434), \u0442\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u043b: \u00ab\u0427\u0442\u043e \u044d\u0442\u043e \u0437\u0430 \u0430\u0434? \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0432\u0435\u0440\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c!\u00bb<\/p>\n<p>  \u041d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u0430\u0441\u043f\u0435\u043a\u0442 \u2014 \u0435\u0441\u043b\u0438 \u0432\u044b \u0447\u0438\u0442\u0430\u043b\u0438 \u043f\u043e\u0441\u0442 \u043f\u0440\u043e \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u0437\u0432\u0451\u0437\u0434\u044b, \u0442\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u0430\u0442\u0442\u0435\u0440\u043d. \u041a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 \u043c\u0435\u0442\u0435\u043e\u0440\u0438\u0442\u043e\u0432! \u0421\u043a\u043e\u0440\u043e \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u0438 \u043e \u043a\u0440\u0438\u0432\u043e\u0439.<\/p>\n<p>  \u0424\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0443\u0431\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0430\u0440\u0442\u044b \u0437\u0432\u0451\u0437\u0434 (\u0441\u0442\u0440\u043e\u043a\u0430 175), \u0433\u0434\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 r2.xyz. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 line 177 \u0435\u0441\u0442\u044c \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u043f\u043d\u0438\u044f \u0435\u0449\u0451 \u043e\u0434\u043d\u043e\u0439 \u043a\u0443\u0431\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043a\u0430\u0440\u0442\u044b. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 2015 \u0433\u043e\u0434\u0430, \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u00ab\u041a\u0438\u0412\u00bb \u0435\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u00ab\u043a\u0443\u0431\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043a\u0430\u0440\u0442\u0430 \u0448\u0443\u043c\u0430\u00bb, \u0433\u0440\u0430\u043d\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/50e\/fe8\/3a4\/50efe83a4cb977aa1497c9a6addf7931.jpg\"><\/div>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0434\u043e\u0431\u0435\u0440\u0451\u043c\u0441\u044f \u0434\u043e \u043a\u0440\u0438\u0432\u043e\u0439, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0439\u0434\u0451\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0435\u0451. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 (\u0441\u0442\u0440\u043e\u043a\u0430 184) \u043c\u0435\u0436\u0434\u0443 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430 (\u0441\u0442\u0440\u043e\u043a\u0438 178-180) \u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u0441\u0432\u0435\u0442\u0430 \u041b\u0443\u043d\u044b (\u0441\u0442\u0440\u043e\u043a\u0438 181-183) \u2014 \u043f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e N*L.<\/p>\n<p>  \u0412\u043e\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f (\u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/3c6\/597\/f45\/3c6597f453f7c751ab60c985fcc6f937.jpg\"><\/div>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u00ab\u043a\u0440\u0438\u0432\u043e\u0439 \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438\u00bb, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 185:<\/p>\n<p>  <i>x = saturate( noise * 0.2 + Ndot );<\/i><\/p>\n<p>  \u0410 \u0432\u043e\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0438\u0441\u043a\u0430\u0436\u0451\u043d\u043d\u043e\u0433\u043e N*L, \u0442\u043e\u0436\u0435 \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5fb\/570\/61c\/5fb57061c7387ed9853c855351b1ba8a.jpg\"><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438! \u041e\u043d\u0430 \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0437\u0432\u0451\u0437\u0434. \u041a\u0430\u043a \u044f \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435, \u043c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043f\u043e \u043e\u0441\u0438 x. \u0412\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434, \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0438\u0445 \u0443\u0432\u0438\u0434\u0438\u043c:<\/p>\n<pre><code class=\"cpp\">   \/\/ Control points (x-axis)      float controlPoint0 = 0.0;      float controlPoint1 = 0.184939;      float controlPoint2 = 0.239752;      float controlPoint3 = 0.294564;      float controlPoint4 = 0.497925;  <\/code><\/pre>\n<p>  \u041e\u0442\u043a\u0443\u0434\u0430 \u043c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u0440\u0430\u0432\u043d\u044b \u043d\u0443\u043b\u044e? \u042d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 189 \u043d\u0435\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 \u00abadd\u00bb.<\/p>\n<p>  \u0421\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043f\u043e\u0441\u0442\u0443 \u043e \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0437\u0432\u0451\u0437\u0434\u0430\u0445, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 \u0434\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0434\u043b\u044f \u043d\u0438\u0445 \u0432\u0435\u0441\u0430.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u0412\u0435\u0441 \u0440\u0430\u0432\u0435\u043d 0.949254:<\/p>\n<pre><code class=\"cpp\">  194: mul r5.xyz, r2.zzzz, l(0.949254, 0.949254, 0.949254, 0.000000)      195: mov r2.x, l(0.949254)   <\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043d\u0430\u0439\u0442\u0438 \u0438\u0445 \u0434\u043b\u044f \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0438 \u0442\u0440\u0435\u0442\u044c\u0435\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">  206:  mad r5.w, r5.w, l(-0.113726), l(0.949254)      207:  movc r5.xyz, r1.wwww, r5.wwww, r5.zzzz      208:  and r7.xyz, r1.wwww, l(0.949254, 0.949254, 0.949254, 0.000000)      209:  mov r6.x, l(0.835528)      ...     229:  mad r5.w, r5.w, l(0.015873), l(0.835528)      230:  movc r5.xyz, r1.wwww, r5.wwww, r5.xyzx      231:  movc r7.xyz, r1.wwww, l(0.835528, 0.835528, 0.835528, 0.000000), r7.xyzx      232:  mov r6.xyz, l(0.851401, 0.851401, 0.851401, 0.000000)   <\/code><\/pre>\n<p>  \u0418\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u043c\u043e\u043c\u0435\u043d\u0442\u0435 \u044f \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u044e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u0447\u0442\u043e-\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0435 \u0442\u0430\u043a (\u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u0442\u044b \u0434\u0443\u043c\u0430\u0435\u0448\u044c \u00ab\u0445\u043c\u043c\u00bb). \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u043b\u0435\u0433\u043a\u043e, \u043a\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043e\u0434\u0438\u043d \u0432\u0435\u0441. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u0442\u043a\u0443\u0434\u0430 \u0432\u0437\u044f\u043b\u0438\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 -0.113726 \u0438 0.015873?<\/p>\n<p>  \u041f\u043e\u0442\u043e\u043c \u044f \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043c\u0435\u0436\u0434\u0443 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0435 ( 0.835528 \u2014 0.949254 = -0.113726 \u0438 0.851401 \u2014 0.835528 = 0.015873)! \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e (\u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u0442\u044b \u0434\u0443\u043c\u0430\u0435\u0448\u044c \u00ab\u044d\u0432\u0440\u0438\u043a\u0430!\u00bb). \u041a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0435 \u0432\u0435\u0441\u0430\u043c\u0438, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 y \u0442\u043e\u0447\u0435\u043a, \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0445 \u043a\u0440\u0438\u0432\u0443\u044e!<\/p>\n<p>  \u042d\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0438 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u0435\u0441\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435<\/p>\n<pre><code class=\"cpp\"> float getSmoothTransition(float cpLeft, float cpRight, float x)    {      return smoothstep( 0, 1, linstep(cpLeft, cpRight, x) );    }  <\/code><\/pre>\n<p>  \u0418 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\"> float milkyway_curve( float x )    {      \/\/ Define a set of 2D points which form the curve    \/\/ Of course, you can use a Point2D-like struct here      \/\/ Control points (x-axis)    float controlPoint0 = 0.0;      float controlPoint1 = 0.184939;      float controlPoint2 = 0.239752;      float controlPoint3 = 0.294564;      float controlPoint4 = 0.497925;            \/\/ Values at points (y-axis)      float value0 = 0.0;      float value1 = 0.949254;      float value2 = 0.835528;      float value3 = 0.851401;      float value4 = 0.0;            float function_value = 0.0;            [branch] if (x &lt;= controlPoint4)      {        [branch] if (x &lt;= controlPoint1)        {          float t = getSmoothTransition(controlPoint0, controlPoint1, x);          function_value = lerp(value0, value1, t);        }                [branch] if (x &gt;= controlPoint1 &amp;&amp; x &lt;= controlPoint2)        {          float t = getSmoothTransition(controlPoint1, controlPoint2, x);          function_value = lerp(value1, value2, t);        }                [branch] if (x &gt;= controlPoint2 &amp;&amp; x &lt;= controlPoint3)        {          float t = getSmoothTransition(controlPoint2, controlPoint3, x);          function_value = lerp(value2, value3, t);        }                [branch] if (x &gt;= controlPoint3)        {          float t = getSmoothTransition(controlPoint3, controlPoint4, x);          function_value = lerp(value3, value4, t);             }          }            return function_value;    }  <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043e\u0431\u043e\u0431\u0449\u0451\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0442\u043e\u0447\u0435\u043a, \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0449\u0438\u0445 \u043f\u043b\u0430\u0432\u043d\u0443\u044e \u043a\u0440\u0438\u0432\u0443\u044e. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u00ab\u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0445\u00bb \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u2014 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0442\u043e\u0447\u0435\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440.<\/p>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u043a\u043e\u0434\u0443 \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0437\u0432\u0451\u0437\u0434.<\/p>\n<p>  \u0412\u043e\u0442 \u0433\u0440\u0430\u0444\u0438\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e7d\/1b7\/6fe\/e7d1b76fe163d6dca4341619cba73e28.jpg\"><\/div>\n<p>  <i>\u0413\u0440\u0430\u0444\u0438\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438.<\/i><\/p>\n<p>  \u041a\u0440\u0430\u0441\u043d\u043e\u0435 \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438,<\/p>\n<p>  \u0417\u0435\u043b\u0451\u043d\u043e\u0435 \u2014 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u043e x<\/p>\n<p>  \u0421\u0438\u043d\u0435\u0435 \u2014 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043f\u043e y<\/p>\n<p>  \u0416\u0451\u043b\u0442\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u2014 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u0435<\/p>\n<p>  \u0425\u043e\u0440\u043e\u0448\u043e, \u043d\u043e \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435? \u0412 \u0441\u0442\u0440\u043e\u043a\u0435 263 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430 \u0441\u0438\u043d\u0435\u0432\u0430\u0442\u044b\u0439 \u0446\u0432\u0435\u0442:<\/p>\n<pre><code class=\"cpp\"> 263: mul r2.xyz, r2.xyzx, l(0.150000, 0.200000, 0.250000, 0.000000) <\/code><\/pre>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u043a\u043e\u043d\u0435\u0446! \u041d\u0430\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0433\u0430\u043c\u043c\u0430-\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u044e:<\/p>\n<pre><code class=\"cpp\">  263: mul r2.xyz, r2.xyzx, l(0.150000, 0.200000, 0.250000, 0.000000)     264: mad r2.xyz, r4.xyzx, l(3.000000, 3.000000, 3.000000, 0.000000), r2.xyzx     ...     269: log r2.xyz, r2.xyzx     270: mul r2.xyz, r2.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     271: exp r2.xyz, r2.xyzx <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430: \u044f \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u043b \u0440\u0430\u0437\u043d\u044b\u0435 \u0446\u0432\u0435\u0442\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c \u043f\u043e \u043e\u0441\u0438 x:<\/p>\n<pre><code class=\"cpp\">   float3 gradient0 = float3(1, 0, 0);      float3 gradient1 = float3(0, 1, 0);      float3 gradient2 = float3(0, 0, 1);      float3 gradient3 = float3(1, 1, 0);      float3 gradient4 = float3(0, 1, 1);  <\/code><\/pre>\n<p>  \u0418 \u0432\u043e\u0442 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f60\/62b\/ac8\/f6062bac8e1920787172e0653e9075c5.jpg\"><\/div>\n<p>  \u0418 \u043d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0451 \u0434\u043b\u044f \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0441\u0434\u0435\u043b\u0430\u043d\u043e.<\/p>\n<p>  \u0412 \u0441\u0442\u0440\u043e\u043a\u0435 264 \u0435\u0441\u0442\u044c r4.xyz \u0438\u2026<\/p>\n<h3>4. \u0417\u0432\u0451\u0437\u0434\u044b \u0422\u0443\u0441\u0441\u0435\u043d\u0442\u0430 (\u0431\u043e\u043d\u0443\u0441)<\/h3>\n<p>  \u042f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u044d\u0442\u0430 \u0447\u0430\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u044c\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u00ab\u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c\u00bb, \u043d\u043e \u043d\u0435 \u0441\u043c\u043e\u0433 \u0443\u0434\u0435\u0440\u0436\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043a\u0440\u0430\u0442\u0446\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0437\u0432\u0451\u0437\u0434\u044b \u0422\u0443\u0441\u0441\u0435\u043d\u0442\u0430. \u041e\u043d\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u044f\u0440\u0447\u0435, \u0447\u0435\u043c \u0432 \u041d\u043e\u0432\u0438\u0433\u0440\u0430\u0434\u0435, \u043d\u0430 \u0421\u043a\u0435\u043b\u043b\u0438\u0433\u0435 \u0438\u043b\u0438 \u0432 \u0412\u0435\u043b\u0435\u043d\u0435.<\/p>\n<p>  \u0412 <a href=\"https:\/\/habr.com\/ru\/post\/450332\/\">\u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u0441\u0442\u043e\u0432<\/a> \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043e \u0437\u0432\u0451\u0437\u0434\u0430\u0445 2015 \u0433\u043e\u0434\u0430; \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043e \u0437\u0432\u0451\u0437\u0434\u0430\u0445 2016 \u0433\u043e\u0434\u0430!<\/p>\n<p>  \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">  175: sample_indexable(texturecube)(float,float,float,float) r4.xyz, r2.xyzx, t0.xyzw, s0      176: mul r4.xyz, r4.xyzx, r4.xyzx      ...     264: mad r2.xyz, r4.xyzx, l(3.000000, 3.000000, 3.000000, 0.000000), r2.xyzx      ...      269: log r2.xyz, r2.xyzx      270: mul r2.xyz, r2.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)      271: exp r2.xyz, r2.xyzx      ...     302: add r0.z, -cb0[9].w, l(1.000000)     303: mul r2.xyz, r0.zzzz, r2.xyzx     304: add r2.xyz, r2.xyzx, r2.xyzx<\/code><\/pre>\n<p>  \u041d\u0430 HLSL \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\"> float3 stars = texStars.Sample(sampler, starsDir).rgb;    stars *= stars;        float3 milkyway = milkyway_func(noisePerturbed) * float3(0.15, 0.20, 0.25);    float3 skyContribution = milkyway + 3.0 * stars;        \/\/ gamma correction    skyContribution = pow(skyContribution, 2.2);        \/\/ starsOpacity - 0.0 during the day (so stars and the Milky Way are not visible then), 1.0 during the night    float starsOpacity = 1.0 - cb0_v9.w;    skyContribution *= starsOpacity;     skyContribution *= 2;<\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u0441\u0430\u043c\u0438 \u0437\u0432\u0451\u0437\u0434\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 3 (\u0441\u0442\u0440\u043e\u043a\u0430 264), \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0432\u043b\u0438\u044f\u043d\u0438\u0435\u043c \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u043d\u0430 2 (\u0441\u0442\u0440\u043e\u043a\u0430 304) \u2014 \u043e\u043b\u0434\u0441\u043a\u0443\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u043d\u043e!<\/p>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043f\u043e\u0437\u0436\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438 \u043a\u043e\u0435-\u0447\u0442\u043e \u0435\u0449\u0451 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u0435\u0440\u0446\u0430\u043d\u0438\u0435 \u0437\u0432\u0451\u0437\u0434 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0448\u0443\u043c\u0430, \u0438 \u0442.\u0434.), \u043d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0442\u0435\u043c\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0441\u044f, \u043a\u0430\u043a \u0432 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0435 3: \u041a\u0440\u043e\u0432\u044c \u0438 \u0432\u0438\u043d\u043e\u00bb \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0438 \u0437\u0432\u0451\u0437\u0434\u044b.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043a\u043e\u0434\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438. \u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u0430\u0434\u0440 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/121\/db2\/b0c\/121db2b0c6dc42db8671e920246123ab.jpg\"><\/div>\n<p>  \u0430 \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c \u043a\u0430\u0434\u0440 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/09b\/a5b\/ca8\/09ba5bca883343c1c198d095310b9016.jpg\"><\/div>\n<p>  \u041d\u0435\u043f\u043b\u043e\u0445\u043e.<\/p>\n<h2>\u0427\u0430\u0441\u0442\u044c 2: \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u044f<\/h2>\n<p>  \u041e\u0434\u0438\u043d \u0438\u0437 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u0432 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0435 3\u00bb \u043f\u043e\u0447\u0442\u0438 \u0432\u0435\u0437\u0434\u0435 \u2014 \u044d\u0442\u043e \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u044f. \u0415\u0451 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u043e\u0438\u0441\u043a\u0430 (LUT) \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>  \u041e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a: \u0435\u0441\u0442\u044c \u043d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f (\u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0446\u0432\u0435\u0442 = \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u043c\u0443 \u0446\u0432\u0435\u0442\u0443) \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u043f\u043e\u0438\u0441\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0445 \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 Adobe Photoshop \u2014 \u0443\u0441\u0438\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0435\u0451 \u043a\u043e\u043d\u0442\u0440\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u044c\/\u044f\u0440\u043a\u043e\u0441\u0442\u044c\/\u043d\u0430\u0441\u044b\u0449\u0435\u043d\u043d\u043e\u0441\u0442\u044c\/\u043e\u0442\u0442\u0435\u043d\u043e\u043a \u0438 \u0442.\u0434., \u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f LUT-\u0430\u043c \u044d\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043c\u0435\u043d\u0435\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0435.<\/p>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0442\u0440\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043c\u043d\u0435 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 LUT: \u0442\u0440\u0451\u0445\u043c\u0435\u0440\u043d\u044b\u0435, \u00ab\u0434\u043b\u0438\u043d\u043d\u044b\u0435\u00bb \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0435 \u0438 \u00ab\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u044b\u0435\u00bb \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c42\/22f\/103\/c4222f1037010c3662fd73c94e7c8a36.jpg\"><\/div>\n<p>  <i>\u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u00ab\u0434\u043b\u0438\u043d\u043d\u0430\u044f\u00bb \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u0430\u044f LUT<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/497\/c99\/85c\/497c9985c332d18cdea9023c3b33a5c4.png\"><\/div>\n<p>  <i>\u041d\u0435\u0439\u0442\u0440\u0430\u043b\u044c\u043d\u0430\u044f \u00ab\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u0430\u044f\u00bb \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u0430\u044f LUT<\/i><\/p>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438 \u0432 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0435 3\u00bb, \u0432\u043e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0435\u0445\u043d\u0438\u043a\u0435:<\/p>\n<p>  <a href=\"https:\/\/github.com\/mattdesl\/glsl-lut\/blob\/master\/index.glsl\" rel=\"nofollow\">\u0425\u043e\u0440\u043e\u0448\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 OpenGL \u0441 \u043e\u043d\u043b\u0430\u0439\u043d-\u0434\u0435\u043c\u043e<\/a><\/p>\n<p>  <a href=\"https:\/\/kosmonautblog.wordpress.com\/2017\/04\/26\/color-grading-correction\/\" rel=\"nofollow\">\u0426\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u044f<\/a><\/p>\n<p>  <a href=\"http:\/\/www.adriancourreges.com\/blog\/2017\/12\/15\/mgs-v-graphics-study\/\" rel=\"nofollow\">\u0418\u0441\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 Metal Gear Solid V<\/a> (\u0445\u043e\u0440\u043e\u0448\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0432 \u0446\u0435\u043b\u043e\u043c, \u0435\u0441\u0442\u044c \u0440\u0430\u0437\u0434\u0435\u043b \u043e \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438) <a href=\"https:\/\/habr.com\/ru\/post\/344916\/\">[\u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043d\u0430 \u0425\u0430\u0431\u0440\u0435]<\/a><\/p>\n<p>  <a href=\"https:\/\/halisavakis.com\/my-take-on-shaders-color-grading-with-look-up-textures-lut\/\" rel=\"nofollow\">\u0426\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u043f\u043e\u0438\u0441\u043a\u0430 (LUT)<\/a><\/p>\n<p>  <a href=\"https:\/\/www.gamedev.net\/forums\/topic\/657511-color-grading-shader\/\" rel=\"nofollow\">\u0422\u0435\u043c\u0430 \u0441 \u0444\u043e\u0440\u0443\u043c\u0430 gamedev.net<\/a><\/p>\n<p>  <a href=\"https:\/\/developer.nvidia.com\/gpugems\/gpugems2\/part-iii-high-quality-rendering\/chapter-24-using-lookup-tables-accelerate-color\" rel=\"nofollow\">\u0421\u0442\u0430\u0442\u044c\u044f \u0438\u0437 \u043a\u043d\u0438\u0433\u0438 \u00abGPU Gems 2\u00bb \u2014 \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0442\u0440\u0451\u0445\u043c\u0435\u0440\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u0443\u0440<\/a><\/p>\n<p>  <a href=\"https:\/\/docs.unrealengine.com\/en-US\/Engine\/Rendering\/PostProcessEffects\/UsingLUTs\/index.html\" rel=\"nofollow\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f UE4 \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0446\u0432\u0435\u0442\u043e\u0432\u044b\u0445 LUT<\/a><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440 LUT, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0433\u0440\u044b White Orchard \u2014 \u0431\u041e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0437\u0435\u043b\u0451\u043d\u044b\u0445 \u0446\u0432\u0435\u0442\u043e\u0432 \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u0430 \u043d\u0430 \u0436\u0451\u043b\u0442\u044b\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/840\/f54\/814\/840f54814faa5f6ae11cfa9890fcc42d.jpg\"><\/div>\n<p>  \u0412 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0435 3\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0435 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 512&#215;512.<\/p>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 LDR. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 256<sup>3<\/sup> \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u2014 \u0431\u043e\u043b\u044c\u0448\u0435 16 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c\u044b\u0445 \u0432\u0441\u0435\u0433\u043e \u0432 512<sup>2<\/sup>=262 144 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0440\u044b\u0442\u044c \u0432\u0435\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0438\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.<\/p>\n<p>  \u0410 \u0432\u043e\u0442 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f: \u0434\u043e \u0438 \u043f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/318\/e4b\/20d\/318e4b20d4828bdba7f58759ba399bf0.jpg\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/df6\/77c\/268\/df677c268bbf640a0561048116b679be.jpg\"><\/div>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0435\u0432\u0435\u043b\u0438\u043a\u0430, \u043d\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u0430 \u2014 \u043d\u0435\u0431\u043e \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043e\u0440\u0430\u043d\u0436\u0435\u0432\u044b\u0439 \u043e\u0442\u0442\u0435\u043d\u043e\u043a.<\/p>\n<p>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0435 3\u00bb, \u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439, \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 render targets \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430\u043c\u0438 \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u044f\u0442\u043e\u0439 (R11G11B10). \u041b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u043e, \u0447\u0442\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0432 \u044d\u0442\u043e\u0439 \u0441\u0446\u0435\u043d\u0435 \u043a\u0430\u043d\u0430\u043b\u044b \u0441\u0430\u043c\u044b\u0445 \u044f\u0440\u043a\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 (\u0440\u044f\u0434\u043e\u043c \u0441 \u0421\u043e\u043b\u043d\u0446\u0435\u043c) \u0438\u043c\u0435\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0438\u0435 1.0f \u2014 \u0434\u0430\u0436\u0435 \u043f\u043e\u0447\u0442\u0438 \u0434\u043e 2.0f!<\/p>\n<p>  \u0412\u043e\u0442 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\"> ps_5_0       dcl_globalFlags refactoringAllowed       dcl_constantbuffer cb3[2], immediateIndexed       dcl_sampler s0, mode_default       dcl_sampler s1, mode_default       dcl_resource_texture2d (float,float,float,float) t0       dcl_resource_texture2d (float,float,float,float) t1       dcl_input_ps linear v1.xy       dcl_output o0.xyzw       dcl_temps 5      0: max r0.xy, v1.xyxx, cb3[0].xyxx      1: min r0.xy, r0.xyxx, cb3[0].zwzz      2: sample_indexable(texture2d)(float,float,float,float) r0.xyzw, r0.xyxx, t0.xyzw, s0      3: log r1.xyz, abs(r0.xyzx)      4: mul r1.xyz, r1.xyzx, l(0.454545, 0.454545, 0.454545, 0.000000)      5: exp r1.xyz, r1.xyzx      6: mad r2.xyz, r1.xyzx, l(1.000000, 1.000000, 0.996094, 0.000000), l(0.000000, 0.000000, 0.015625, 0.000000)      7: min r2.xyz, r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)      8: min r2.z, r2.z, l(0.999990)      9: add r2.xy, r2.xyxx, l(0.007813, 0.007813, 0.000000, 0.000000)     10: mul r2.xyzw, r2.xyzz, l(0.996094, 0.996094, 64.000000, 8.000000)     11: max r2.xy, r2.xyxx, l(0.015625, 0.015625, 0.000000, 0.000000)     12: min r2.xy, r2.xyxx, l(0.984375, 0.984375, 0.000000, 0.000000)     13: round_ni r3.xz, r2.wwww     14: mad r2.z, -r3.x, l(8.000000), r2.z     15: round_ni r3.y, r2.z     16: mul r2.zw, r3.yyyz, l(0.000000, 0.000000, 0.125000, 0.125000)     17: mad r2.xy, r2.xyxx, l(0.125000, 0.125000, 0.000000, 0.000000), r2.zwzz     18: sample_l(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t1.xyzw, s1, l(0)     19: mul r2.w, r1.z, l(63.750000)     20: round_ni r2.w, r2.w     21: mul r1.w, r2.w, l(0.015625)     22: mad r1.z, r1.z, l(63.750000), -r2.w     23: min r1.xyw, r1.xyxw, l(1.000000, 1.000000, 0.000000, 1.000000)     24: min r1.w, r1.w, l(0.999990)     25: add r1.xy, r1.xyxx, l(0.007813, 0.007813, 0.000000, 0.000000)     26: mul r1.xy, r1.xyxx, l(0.996094, 0.996094, 0.000000, 0.000000)     27: max r1.xy, r1.xyxx, l(0.015625, 0.015625, 0.000000, 0.000000)     28: min r1.xy, r1.xyxx, l(0.984375, 0.984375, 0.000000, 0.000000)     29: mul r3.xy, r1.wwww, l(64.000000, 8.000000, 0.000000, 0.000000)     30: round_ni r4.xz, r3.yyyy     31: mad r1.w, -r4.x, l(8.000000), r3.x     32: round_ni r4.y, r1.w     33: mul r3.xy, r4.yzyy, l(0.125000, 0.125000, 0.000000, 0.000000)     34: mad r1.xy, r1.xyxx, l(0.125000, 0.125000, 0.000000, 0.000000), r3.xyxx     35: sample_l(texture2d)(float,float,float,float) r1.xyw, r1.xyxx, t1.xywz, s1, l(0)     36: add r2.xyz, -r1.xywx, r2.xyzx     37: mad r1.xyz, r1.zzzz, r2.xyzx, r1.xywx     38: log r1.xyz, abs(r1.xyzx)     39: mul r1.xyz, r1.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     40: exp r1.xyz, r1.xyzx     41: mad r1.xyz, cb3[1].zzzz, r1.xyzx, -r0.xyzx     42: mad o0.xyz, cb3[1].yyyy, r1.xyzx, r0.xyzx     43: mov o0.w, r0.w     44: ret  <\/code><\/pre>\n<p>  \u0412 \u0446\u0435\u043b\u043e\u043c, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0430 3\u00bb \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0430\u0442\u044c \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043c\u043d\u043e\u0433\u043e \u00ab\u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0433\u043e\u00bb \u043a\u043e\u0434\u0430. \u042d\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0432\u0435\u0434\u044c \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b\u043c \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440.<\/p>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a LUT, \u044d\u0442\u043e \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f 2D-\u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u2014 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0438\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0438\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u043d\u0430\u043b\u0430 \u0441\u0438\u043d\u0435\u0433\u043e. \u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432\u044b\u0448\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 OpenGL \u0441\u043b\u0438\u044f\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u0430\u043d\u0430\u043b\u0430 \u0441\u0438\u043d\u0435\u0433\u043e.<\/p>\n<p>  \u0427\u0442\u043e \u043c\u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c, \u0442\u0430\u043a \u044d\u0442\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/direct3dhlsl\/dx-graphics-hlsl-ceil\" rel=\"nofollow\">ceil<\/a> (<i>round_pi<\/i>) \u0438 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/direct3dhlsl\/dx-graphics-hlsl-frac\" rel=\"nofollow\">frac<\/a> (<i>frc<\/i>). \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u0451\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/direct3dhlsl\/dx-graphics-hlsl-floor\" rel=\"nofollow\">floor<\/a>&nbsp;(<i>round_ni<\/i>).<\/p>\n<p>  \u0428\u0435\u0439\u0434\u0435\u0440 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0446\u0432\u0435\u0442\u0430 \u0438 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u043d\u0435\u0451 \u0446\u0432\u0435\u0442\u0430 \u0432 \u0433\u0430\u043c\u043c\u0430-\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435:<\/p>\n<pre><code class=\"cpp\">   float3 LinearToGamma(float3 c) { return pow(c, 1.0\/2.2); }    float3 GammaToLinear(float3 c) { return pow(c, 2.2); }     ...        \/\/ Set range of allowed texcoords      float2 minAllowedUV = cb3_v0.xy;      float2 maxAllowedUV = cb3_v0.zw;      float2 samplingUV = clamp( Input.Texcoords, minAllowedUV, maxAllowedUV );          \/\/ Get color in *linear* space      float4 inputColorLinear = texture0.Sample( samplerPointClamp, samplingUV );     \/\/ Calculate color in *gamma* space for RGB    float3 inputColorGamma = LinearToGamma( inputColorLinear.rgb ); <\/code><\/pre>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f min \u0438 max \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0438\u0437 cbuffer:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/223\/7b7\/829\/2237b7829985f28e80d5acab4969cc3f.png\"><\/div>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u0430\u0434\u0440 \u0431\u044b\u043b \u0437\u0430\u0445\u0432\u0430\u0447\u0435\u043d \u0432 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0438 1920&#215;1080 \u2014 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f max \u0440\u0430\u0432\u043d\u044b: (1919\/1920, 1079\/1080)<\/p>\n<p>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u0431\u043b\u043e\u043a\u0430, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 LUT. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0441\u043e\u0437\u0434\u0430\u043b \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 uv \u0434\u043b\u044f LUT. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">   7: min r2.xyz, r2.xyzx, l(1.000000, 1.000000, 1.000000, 0.000000)      8: min r2.z, r2.z, l(0.999990)      9: add r2.xy, r2.xyxx, l(0.007813, 0.007813, 0.000000, 0.000000)     10: mul r2.xyzw, r2.xyzz, l(0.996094, 0.996094, 64.000000, 8.000000)     11: max r2.xy, r2.xyxx, l(0.015625, 0.015625, 0.000000, 0.000000)     12: min r2.xy, r2.xyxx, l(0.984375, 0.984375, 0.000000, 0.000000)     13: round_ni r3.xz, r2.wwww     14: mad r2.z, -r3.x, l(8.000000), r2.z     15: round_ni r3.y, r2.z     16: mul r2.zw, r3.yyyz, l(0.000000, 0.000000, 0.125000, 0.125000)     17: mad r2.xy, r2.xyxx, l(0.125000, 0.125000, 0.000000, 0.000000), r2.zwzz     18: sample_l(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t1.xyzw, s1, l(0)  <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c r2.xyz \u2014 \u044d\u0442\u043e \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0446\u0432\u0435\u0442.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u043e\u0433\u043e, \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043b\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 [0-1]. (\u0441\u0442\u0440\u043e\u043a\u0430 7). \u042d\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 &gt; 1.0, \u043a\u0430\u043a \u0443 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0421\u043e\u043b\u043d\u0446\u0430.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043a\u0430\u043d\u0430\u043b \u0441\u0438\u043d\u0435\u0433\u043e \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 0.99999 (\u0441\u0442\u0440\u043e\u043a\u0430 8), \u0447\u0442\u043e\u0431\u044b <i>floor(color.b)<\/i> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 [0-7].<\/p>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 LUT \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u043a\u0430\u043d\u0430\u043b\u044b \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0438 \u0437\u0435\u043b\u0451\u043d\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u00ab\u0432\u0442\u0438\u0441\u043d\u0443\u0442\u044c\u00bb \u0438\u0437 \u0432 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442. \u041a\u0430\u043d\u0430\u043b \u0441\u0438\u043d\u0435\u0433\u043e [0-1] \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0435\u0442\u0441\u044f \u043d\u0430 64 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432\u0441\u0435\u043c 64 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u043c \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0435 \u043f\u043e\u0438\u0441\u043a\u0430. \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0441\u0438\u043d\u0435\u0433\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043d\u0435\u0433\u043e.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b\u0431\u0435\u0440\u0435\u043c (0.75, 0.5, 1.0). \u041a\u0430\u043d\u0430\u043b\u044b \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0438 \u0437\u0435\u043b\u0451\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043b\u0435\u0432\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c:<\/p>\n<p>  <i>float2 rgOffset = (0.75, 0.5) \/ 8 = (0.09375, 0.0625)<\/i><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432 \u043a\u0430\u043a\u043e\u043c \u0438\u0437 64 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u0438\u043d\u0435\u0433\u043e (1.0). \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 \u2014 64.<\/p>\n<p>  \u0421\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432\u044b\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0445 (rowOffset, columnOffset):<\/p>\n<p>  <i>float blue_rowOffset = 7.0;<\/i><\/p>\n<p>  <i>float blue_columnOffset = 7.0;<\/i><\/p>\n<p>  <i>float2 blueOffset =float2(blue_rowOffset, blue_columnOffset) \/ 8.0 = (0.875, 0.875)<\/i><\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f:<\/p>\n<p>  <i>float2 finalUV = rgOffset + blueOffset;<\/i><\/p>\n<p>  <i>finalUV =&nbsp;<\/i><i>(<\/i><i>0.09375<\/i><i>, 0.0625) +&nbsp;<\/i><i>(0.875, 0.875) = (0.96875, 0.9375)<\/i><\/p>\n<p>  \u042d\u0442\u043e \u0431\u044b\u043b \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0438 \u0437\u0435\u043b\u0451\u043d\u043e\u0433\u043e (r2.xy) \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 9 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0432 \u043f\u043e\u043b\u043f\u0438\u043a\u0441\u0435\u043b\u044f (0.5 \/ 64). \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0438\u0445 \u043d\u0430 0.996094 (\u0441\u0442\u0440\u043e\u043a\u0430 10) \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0438\u0445 (clamp) \u043e\u0441\u043e\u0431\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c (\u0441\u0442\u0440\u043e\u043a\u0438 11-12).<\/p>\n<p>  \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u043b\u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430 \u2014 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u0446\u0435\u043d\u0442\u0440\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u044b\u043c \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 10 \u2014 \u043e\u043d \u0440\u0430\u0432\u0435\u043d 63,75\/64.0. \u0421\u043a\u043e\u0440\u043e \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e \u043d\u0451\u043c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c [1\/64 \u2014 63\/64].<\/p>\n<p>  \u0417\u0430\u0447\u0435\u043c \u043d\u0430\u043c \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e? \u042f \u043d\u0435 \u0437\u043d\u0430\u044e \u0442\u043e\u0447\u043d\u043e, \u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0435, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/direct3d9\/bilinear-texture-filtering\" rel=\"nofollow\">\u0431\u0438\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0440\u0430\u043b\u043e \u0441\u044d\u043c\u043f\u043b\u044b \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u043c\u0438 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>  \u0412\u043e\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u0432 \u0432\u0438\u0434\u0435 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 6&#215;6, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0435\u0435, \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u044d\u0442\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f (clamp):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d92\/6d8\/4b7\/d926d84b74f64e3d9e72df7d9be882e1.png\"><\/div>\n<p>  \u0412\u043e\u0442 \u0441\u0446\u0435\u043d\u0430 \u0431\u0435\u0437 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f clamp \u2014 \u0437\u0430\u043c\u0435\u0442\u044c\u0442\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0435 \u043e\u0431\u0435\u0441\u0446\u0432\u0435\u0447\u0438\u0432\u0430\u043d\u0438\u0435 \u0432\u043e\u043a\u0440\u0443\u0433 \u0421\u043e\u043b\u043d\u0446\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/38c\/533\/ee6\/38c533ee6220117ab9bba3d37c622998.jpg\"><\/div>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0435\u0449\u0451 \u0440\u0430\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u0437 \u0438\u0433\u0440\u044b:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/df6\/77c\/268\/df677c268bbf640a0561048116b679be.jpg\"><\/div>\n<p>  \u0412\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<pre><code class=\"cpp\">   \/\/ * Calculate red\/green offset               \/\/ half-pixel offset to always sample within centre of a pixel      const float halfOffset = 0.5 \/ 64.0;      const float scale = 63.75\/64.0;             float2 rgOffset;      rgOffset = halfOffset + color.rg;      rgOffset *= scale;          rgOffset.xy = clamp(rgOffset.xy, float2(1.0\/64.0, 1.0\/64.0), float2(63.0\/64.0, 63.0\/64.0) );          \/\/ place within the top left slice      rgOffset.xy \/= 8.0;  <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u0440\u0430 \u043d\u0430\u0439\u0442\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0441\u0438\u043d\u0435\u0433\u043e.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u043a\u0430\u043d\u0430\u043b \u0441\u0438\u043d\u0435\u0433\u043e \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 8 \u0447\u0430\u0441\u0442\u0435\u0439, \u043a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0435 \u043f\u043e\u0438\u0441\u043a\u0430.<\/p>\n<pre><code class=\"cpp\">   \/\/ rows      bOffset.y = floor(color.b * 8);  <\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0435\u0449\u0451 \u0440\u0430\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430 8 \u043c\u0435\u043d\u044c\u0448\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u0447\u0442\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0441\u0435\u043c 8 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u043c \u0441\u0442\u0440\u043e\u043a\u0438. \u0423\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438\u0437 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u043e\u0435:<\/p>\n<pre><code class=\"cpp\">   \/\/ columns      bOffset.x = floor(color.b * 64 - 8*bOffset.y );      <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e:<\/p>\n<p>  <i>frac(x) = x \u2014 floor(x)<\/i><br \/>  \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\"> bOffset.x = floor(8 * frac(color.b * 8) );  <\/code><\/pre>\n<p>  \u0410 \u0432\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e:<\/p>\n<pre><code class=\"cpp\">   \/\/ * Calculate blue offset      float2 bOffset;            \/\/ rows      bOffset.y = floor(color.b * 8);            \/\/ columns      bOffset.x = floor(color.b * 64 - 8*bOffset.y );          \/\/ or:     \/\/ bOffset.x = floor(8 * frac(color.b * 8) );            \/\/ at this moment bOffset stores values in [0-7] range, we have to divide it by 8.0.      bOffset \/= 8.0;            float2 lutPos = rgOffset + bOffset;      return lutPos;  <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0434\u043b\u044f \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b LUT. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u044d\u0442\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u00abgetUV\u00bb.<\/p>\n<pre><code class=\"cpp\"> float2 getUV(in float3 color)    {     ...    }  <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u0430. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u0438\u0437-\u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u043e\u0439 LUT \u0434\u043b\u044f \u0441\u0438\u043c\u0443\u043b\u044f\u0446\u0438\u0438 \u0431\u0438\u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0433\u043e \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0430\u043d\u0430\u043b\u0430 \u0441\u0438\u043d\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u044b \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a LUT (\u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0445 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432).<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043d\u0430 HLSL:<\/p>\n<pre><code class=\"cpp\">   \/\/ Part 1      float scale_1 = 63.75\/64.0;      float offset_1 = 1.0\/64.0;   \/\/ 0.015625      float3 inputColor1 = inputColorGamma;        inputColor1.b = inputColor1.b * scale_1 + offset_1;            float2 uv1 = getUV(inputColor1);      float3 color1 = texLUT.SampleLevel( sampler1, uv1, 0 ).rgb;            \/\/ Part 2      float3 inputColor2 = inputColorGamma;      inputColor2.b = floor(inputColorGamma.b * 63.75) \/ 64;            float2 uv2 = getUV(inputColor2);      float3 color2 = texLUT.SampleLevel( sampler1, uv2, 0 ).rgb;       \/\/ frac(x) = x - floor(x);    \/\/float blueInterp = inputColorGamma.b*63.75 - floor(inputColorGamma.b * 63.75);    float blueInterp = frac(inputColorGamma.b * 63.75);         \/\/ Final LUT-corrected color    const float lutCorrectedMult = cb3_v1.z;         float3 finalLUT = lerp(color2, color1, blueInterp);    finalLUT = lutCorrectedMult * GammaToLinear(finalLUT);<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0446\u0432\u0435\u0442\u0430 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043f\u043e \u0441\u043e\u0441\u0435\u0434\u0441\u0442\u0432\u0443 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044e \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u2014 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0441\u0438\u043d\u0435\u0433\u043e \u0446\u0432\u0435\u0442\u0430.<\/p>\n<p>  Part 1 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0446\u0432\u0435\u0442 \u0438\u0437 \u00ab\u0434\u0430\u043b\u044c\u043d\u0435\u0433\u043e\u00bb \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u0438\u0437-\u0437\u0430 \u044f\u0432\u043d\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u0438\u043d\u0435\u0433\u043e ( + 1.0 \/ 64 );<\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u00abfinalLUT\u00bb. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u043d\u043e\u0432\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u043b\u0438\u043d\u0435\u0439\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438 \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <i>lutCorrectedMult<\/i>. \u0412 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043a\u0430\u0434\u0440\u0435 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u043e 1.00916. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u0446\u0432\u0435\u0442\u0430 LUT.<\/p>\n<p>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0441\u0430\u043c\u043e\u0439 \u0438\u043d\u0442\u0440\u0438\u0433\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ab63.75\u00bb \u0438 \u00ab63.75 \/ 64\u00bb. \u042f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u044e, \u043e\u0442\u043a\u0443\u0434\u0430 \u043e\u043d\u0438 \u0431\u0435\u0440\u0443\u0442\u0441\u044f. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u043d\u0430\u0448\u0451\u043b: 63.75 \/ 64.0 = 510.0 \/ 512.0. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 (clamp) \u0434\u043b\u044f \u043a\u0430\u043d\u0430\u043b\u043e\u0432 .rg, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0441\u0438\u043d\u0435\u0433\u043e \u044d\u0442\u043e \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u0435 \u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u044b LUT \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0446\u0432\u0435\u0442\u0430 \u044f\u0432\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u00ab\u0432\u0442\u0438\u0441\u043d\u0443\u0442\u044b\u00bb \u0432 \u0446\u0435\u043d\u0442\u0440 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043f\u043e\u0438\u0441\u043a\u0430 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 510&#215;510.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0447\u0442\u043e <i>inputColorGamma.b<\/i>&nbsp;= 0.75 \/ 64.0.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/437\/1be\/637\/4371be6372754803fb505b7ee8d6985e.png\"><\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 (1-4), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u043a\u0430\u043d\u0430\u043b \u0441\u0438\u043d\u0435\u0433\u043e \u0441 [0 \u2014 4\/64].<\/p>\n<p>  \u0421\u0443\u0434\u044f \u043f\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u043f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u043a\u0430\u043d\u0430\u043b\u044b \u043a\u0440\u0430\u0441\u043d\u043e\u0433\u043e \u0438 \u0437\u0435\u043b\u0451\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u044b 0.75 \u0438 0.5.<\/p>\n<p>  \u041c\u044b \u0434\u0432\u0430\u0436\u0434\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a LUT \u2014 \u00abPart 1\u00bb \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0441\u0435\u0433\u043c\u0435\u043d\u0442 2, \u0430 \u00abPart 2\u00bb \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0435\u0433\u043c\u0435\u043d\u0442.<\/p>\n<p>  \u0410 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0446\u0432\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0432\u043d\u0430 0.75.<\/p>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u043c\u0435\u0435\u0442 75% \u0446\u0432\u0435\u0442\u0430 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430 \u0438 25% \u0446\u0432\u0435\u0442\u0430 \u0438\u0437 \u0432\u0442\u043e\u0440\u043e\u0433\u043e.<\/p>\n<p>  \u041c\u044b \u043f\u043e\u0447\u0442\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">   \/\/ Calculate the final color      const float lutCorrectedInfluence = cb3_v1.y; \/\/ 0.20 in this frame      float3 finalColor = lerp(inputColorLinear.rgb, finalLUT, lutCorrectedInfluence);            return float4( finalColor, inputColorLinear.a );  <\/code><\/pre>\n<p>  \u0425\u0430! \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0446\u0432\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 80% \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u0438 20% \u0446\u0432\u0435\u0442\u0430 LUT!<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0451\u043c \u043a\u0440\u0430\u0442\u043a\u043e\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439: \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0446\u0432\u0435\u0442 (\u0442\u043e \u0435\u0441\u0442\u044c, \u043f\u043e \u0441\u0443\u0442\u0438, \u0441 0% \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438), \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u0430\u0434\u0440 (20%) \u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (100% \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/318\/e4b\/20d\/318e4b20d4828bdba7f58759ba399bf0.jpg\"><\/div>\n<p>  <i>0% \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/df6\/77c\/268\/df677c268bbf640a0561048116b679be.jpg\"><\/div>\n<p>  <i>20% \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438 (\u0438\u0441\u0442\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440)<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/117\/2cd\/be6\/1172cdbe64c841af91b529ae5a02ea05.jpg\"><\/div>\n<p>  <i>100% \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438<\/i><\/p>\n<h3>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e LUT<\/h3>\n<p>  \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a 3\u00bb \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e LUT.<\/p>\n<p>  \u0412\u043e\u0442 \u0441\u0446\u0435\u043d\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u0432\u0430 LUT:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/10c\/98f\/b01\/10c98fb01ded1426075b104454034f13.jpg\"><\/div>\n<p>  <i>\u0414\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/79a\/a81\/99f\/79aa8199f82eba7378cc4c774e0b227c.jpg\"><\/div>\n<p>  <i>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438<\/i><\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 LUT:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2d6\/02e\/f89\/2d602ef89d4ff07635c684d6321456e7.jpg\"><\/div>\n<p>  <i>LUT 1 (texture1)<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fc\/a62\/1fd\/6fca621fd829c6137ebd35636fe1920d.jpg\"><\/div>\n<p>  <i>LUT 2 (texture2)<\/i><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0438\u0437 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">  18: sample_l(texture2d)(float,float,float,float) r3.xyz, r2.xyxx, t2.xyzw, s2, l(0)     19: sample_l(texture2d)(float,float,float,float) r2.xyz, r2.xyxx, t1.xyzw, s1, l(0)      ...     36: sample_l(texture2d)(float,float,float,float) r4.xyz, r1.xyxx, t2.xyzw, s2, l(0)     37: sample_l(texture2d)(float,float,float,float) r1.xyw, r1.xyxx, t1.xywz, s1, l(0)     38: add r3.xyz, r3.xyzx, -r4.xyzx     39: mad r3.xyz, r1.zzzz, r3.xyzx, r4.xyzx     40: log r3.xyz, abs(r3.xyzx)     41: mul r3.xyz, r3.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     42: exp r3.xyz, r3.xyzx     43: add r2.xyz, -r1.xywx, r2.xyzx     44: mad r1.xyz, r1.zzzz, r2.xyzx, r1.xywx     45: log r1.xyz, abs(r1.xyzx)     46: mul r1.xyz, r1.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     47: exp r1.xyz, r1.xyzx     48: add r2.xyz, -r1.xyzx, r3.xyzx     49: mad r1.xyz, cb3[1].xxxx, r2.xyzx, r1.xyzx     50: mad r1.xyz, cb3[1].zzzz, r1.xyzx, -r0.xyzx     51: mad o0.xyz, cb3[1].yyyy, r1.xyzx, r0.xyzx     52: mov o0.w, r0.w     53: ret  <\/code><\/pre>\n<p>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0442\u0443\u0442 \u0432\u0441\u0451 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u0412 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c:<\/p>\n<pre><code class=\"cpp\">   \/\/ Part 1      \/\/ ...      float2 uv1 = getUV(inputColor1);      float3 lut2_color1 = texture2.SampleLevel( sampler2, uv1, 0 ).rgb;      float3 lut1_color1 = texture1.SampleLevel( sampler1, uv1, 0 ).rgb;            \/\/ Part 2      \/\/ ...      float2 uv2 = getUV(inputColor2);      float3 lut2_color2 = texture2.SampleLevel( sampler2, uv2, 0 ).rgb;      float3 lut1_color2 = texture1.SampleLevel( sampler1, uv2, 0 ).rgb;            float blueInterp = frac(inputColorGamma.b * 63.75);           float3 lut2_finalLUT = lerp(lut2_color2, lut2_color1, blueInterp);      lut2_finalLUT = GammaToLinear(lut2_finalLUT);               float3 lut1_finalLUT = lerp(lut1_color2, lut1_color1, blueInterp);      lut1_finalLUT = GammaToLinear(lut1_finalLUT);               const float lut_Interp = cb3_v1.x;      float3 finalLUT = lerp(lut1_finalLUT, lut2_finalLUT, lut_Interp);               const float lutCorrectedMult = cb3_v1.z;      finalLUT *= lutCorrectedMult;            \/\/ Calculate the final color      const float lutCorrectedInfluence = cb3_v1.y;      float3 finalColor = lerp(inputColorLinear.rgb, finalLUT, lutCorrectedInfluence);            return float4( finalColor, inputColorLinear.a );    }  <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0446\u0432\u0435\u0442\u043e\u0432 \u0438\u0437 LUT \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u044f\u0446\u0438\u044f \u0432 <i>lut_Interp<\/i>. \u0412\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0442\u0430\u043a\u043e\u0435 \u0436\u0435, \u043a\u0430\u043a \u0432 \u0432\u0435\u0440\u0441\u0438\u0438 \u0441 \u043e\u0434\u043d\u043e\u0439 LUT.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <i>lut_interp<\/i>, \u0441\u043e\u043e\u0431\u0449\u0430\u044e\u0449\u0430\u044f, \u043a\u0430\u043a \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0435 LUT.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/339\/052\/77a\/33905277a643b710c3b0c93a1727d553.png\"><\/div>\n<p>  \u0415\u0451 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u043a\u0430\u0434\u0440\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0432\u043d\u043e 0.96, \u0442\u043e \u0435\u0441\u0442\u044c <i>finalLUT<\/i> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 96% \u0446\u0432\u0435\u0442\u0430 \u0438\u0437 LUT2 \u0438 4% \u0446\u0432\u0435\u0442\u0430 \u0438\u0437 LUT1.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u043a\u043e\u043d\u0435\u0446! \u0421\u0446\u0435\u043d\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0438\u0437\u0443\u0447\u0430\u043b \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/489118\/\">\u0447\u0430\u0441\u0442\u0438 \u00ab\u0422\u0443\u043c\u0430\u043d\u00bb<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <u>\u0442\u0440\u0438<\/u> LUT!<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c!<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/409\/bf8\/180\/409bf818084dbe05f0dee341f88ff16d.jpg\"><\/div>\n<p>  <i>\u0414\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/64f\/a83\/4fc\/64fa834fc2a5866d3f9e4be584dd2186.jpg\"><\/div>\n<p>  <i>\u041f\u043e\u0441\u043b\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u0430 \u0446\u0432\u0435\u0442\u043e\u043a\u043e\u0440\u0440\u0435\u043a\u0446\u0438\u0438<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/2d6\/02e\/f89\/2d602ef89d4ff07635c684d6321456e7.jpg\"><\/div>\n<p>  <i>LUT1 (texture1)<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/6fc\/a62\/1fd\/6fca621fd829c6137ebd35636fe1920d.jpg\"><\/div>\n<p>  <i>LUT2 (texture2)<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/50f\/b99\/806\/50fb99806ff70451f2870632244f4991.jpg\"><\/div>\n<p>  <i>LUT3 (texture3)<\/i><\/p>\n<p>  \u0418 \u0441\u043d\u043e\u0432\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"cpp\">  23: mad r2.yz, r2.yyzy, l(0.000000, 0.125000, 0.125000, 0.000000), r3.xxyx     24: sample_l(texture2d)(float,float,float,float) r3.xyz, r2.yzyy, t2.xyzw, s2, l(0)     ...     34: mad r1.xy, r1.xyxx, l(0.125000, 0.125000, 0.000000, 0.000000), r1.zwzz     35: sample_l(texture2d)(float,float,float,float) r4.xyz, r1.xyxx, t2.xyzw, s2, l(0)     36: add r4.xyz, -r3.xyzx, r4.xyzx     37: mad r3.xyz, r2.xxxx, r4.xyzx, r3.xyzx     38: log r3.xyz, abs(r3.xyzx)     39: mul r3.xyz, r3.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     40: exp r3.xyz, r3.xyzx     41: sample_l(texture2d)(float,float,float,float) r4.xyz, r1.xyxx, t1.xyzw, s1, l(0)     42: sample_l(texture2d)(float,float,float,float) r1.xyz, r1.xyxx, t3.xyzw, s3, l(0)     43: sample_l(texture2d)(float,float,float,float) r5.xyz, r2.yzyy, t1.xyzw, s1, l(0)     44: sample_l(texture2d)(float,float,float,float) r2.yzw, r2.yzyy, t3.wxyz, s3, l(0)     45: add r4.xyz, r4.xyzx, -r5.xyzx     46: mad r4.xyz, r2.xxxx, r4.xyzx, r5.xyzx     47: log r4.xyz, abs(r4.xyzx)     48: mul r4.xyz, r4.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     49: exp r4.xyz, r4.xyzx     50: add r3.xyz, r3.xyzx, -r4.xyzx     51: mad r3.xyz, cb3[1].xxxx, r3.xyzx, r4.xyzx     52: mad r3.xyz, cb3[1].zzzz, r3.xyzx, -r0.xyzx     53: mad r3.xyz, cb3[1].yyyy, r3.xyzx, r0.xyzx     54: add r1.xyz, r1.xyzx, -r2.yzwy     55: mad r1.xyz, r2.xxxx, r1.xyzx, r2.yzwy     56: log r1.xyz, abs(r1.xyzx)     57: mul r1.xyz, r1.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     58: exp r1.xyz, r1.xyzx     59: mad r1.xyz, cb3[2].zzzz, r1.xyzx, -r0.xyzx     60: mad r0.xyz, cb3[2].yyyy, r1.xyzx, r0.xyzx     61: mov o0.w, r0.w     62: add r0.xyz, -r3.xyzx, r0.xyzx     63: mad o0.xyz, cb3[2].wwww, r0.xyzx, r3.xyzx     64: ret  <\/code><\/pre>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0437\u0430\u043f\u0443\u0442\u0430\u043d\u043d\u0430\u044f, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0434\u0432\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, UV \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u00abuv1\u00bb \u0440\u0430\u043d\u044c\u0448\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438\u0441\u044c \u0432 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u043f\u0435\u0440\u0435\u0434 \u00abuv2\u00bb (\u0441\u0440\u0430\u0432\u043d\u0438\u0442\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0432\u0441\u0435\u0433\u043e \u0441 \u043e\u0434\u043d\u043e\u0439 LUT). \u041d\u043e \u0437\u0434\u0435\u0441\u044c \u0432\u0441\u0451 \u043d\u0435 \u0442\u0430\u043a \u2014 UV \u0434\u043b\u044f \u00abPart 1\u00bb \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 34, UV \u0434\u043b\u044f \u00abPart 2\u00bb \u2014 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 23.<\/p>\n<p>  \u041f\u043e\u0442\u0440\u0430\u0442\u0438\u0432 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438 \u043d\u0435\u0434\u043e\u0443\u043c\u0435\u0432\u0430\u044f, \u043f\u043e\u0447\u0435\u043c\u0443 Part2, \u043f\u043e\u0445\u043e\u0436\u0435, \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0430\u0441\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u0441 Part1, \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u043d\u0430 HLSL \u0434\u043b\u044f \u0442\u0440\u0451\u0445 LUT:<\/p>\n<pre><code class=\"cpp\">   \/\/ Part 1       \/\/ ...       float2 uv1 = getUV(inputColor1);       float3 lut3_color1 = texture3.SampleLevel( sampler3, uv1, 0 ).rgb;      float3 lut2_color1 = texture2.SampleLevel( sampler2, uv1, 0 ).rgb;       float3 lut1_color1 = texture1.SampleLevel( sampler1, uv1, 0 ).rgb;              \/\/ Part 2       \/\/ ...       float2 uv2 = getUV(inputColor2);       float3 lut3_color2 = texture3.SampleLevel( sampler3, uv2, 0 ).rgb;      float3 lut2_color2 = texture2.SampleLevel( sampler2, uv2, 0 ).rgb;       float3 lut1_color2 = texture1.SampleLevel( sampler1, uv2, 0 ).rgb;              float blueInterp = frac(inputColorGamma.b * 63.75);             \/\/ At first compute linear color for LUT 2 [assembly lines 36-40]      float3 lut2_finalLUT = lerp(lut2_color2, lut2_color1, blueInterp);       lut2_finalLUT = GammaToLinear(lut2_finalLUT);           \/\/ Compute linear color for LUT 1 [assembly: 45-49]          float3 lut1_finalLUT = lerp(lut1_color2, lut1_color1, blueInterp);       lut1_finalLUT = GammaToLinear(lut1_finalLUT);             \/\/ Interpolate between LUT 1 and LUT 2 [assembly: 50-51]      const float lut12_Interp = cb3_v1.x;       float3 lut12_finalLUT = lerp(lut1_finalLUT, lut2_finalLUT, lut12_Interp);            \/\/ Multiply the LUT1-2 intermediate result with scale factor [assembly: 52]      const float lutCorrectedMult_LUT1_2 = cb3_v1.z;       lut12_finalLUT *= lutCorrectedMult;              \/\/ Mix LUT1-2 intermediate result with the scene color [assembly: 52-53]      const float lutCorrectedInfluence_12 = cb3_v1.y;       lut12_finalLUT = lerp(inputColorLinear.rgb, lut12_finalLUT, lutCorrectedInfluence_12);           \/\/ Compute linear color for LUT3 [assembly: 54-58]      float3 lut3_finalLUT = lerp(lut3_color2, lut3_color1, blueInterp);      lut3_finalLUT = GammaToLinear(lut3_finalLUT);          \/\/ Multiply the LUT3 intermediate result with the scale factor [assembly: 59]      const float lutCorrectedMult_LUT3 = cb3_v2.z;      lut3_finalLUT *= lutCorrectedMult_LUT3;          \/\/ Mix LUT3 intermediate result with the scene color [assembly: 59-60]      const float lutCorrectedInfluence3 = cb3_v2.y;      lut3_finalLUT = lerp(inputColorLinear.rgb, lut3_finalLUT, lutCorrectedInfluence3);          \/\/ The final mix between LUT1+2 and LUT3 influence [assembly: 62-63]      const float finalInfluence = cb3_v2.w;      float3 finalColor = lerp(lut12_finalLUT, lut3_finalLUT, finalInfluence);          return float4( finalColor, inputColorLinear.a );    }   <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b LUT1 \u0438 LUT2, \u0437\u0430\u0442\u0435\u043c \u043e\u043d\u0438 \u0443\u043c\u043d\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0430 \u0434\u0430\u043b\u0435\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0441 \u043b\u0438\u043d\u0435\u0439\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0446\u0435\u043d\u044b. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0437\u043e\u0432\u0451\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <i>lut12_finalLUT<\/i>.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f LUT3 \u2014 \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u043d\u0430 \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u043c \u0441 \u0446\u0432\u0435\u0442\u043e\u043c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0446\u0435\u043d\u044b, \u0447\u0442\u043e \u0434\u0430\u0451\u0442 \u043d\u0430\u043c <i>lut3_finalLUT<\/i>.<\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435 \u043e\u0431\u0430 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0441\u043d\u043e\u0432\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f.<\/p>\n<p>  \u0412\u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u0437 cbuffer:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b9a\/694\/355\/b9a694355db98f0141524e4e7e27012c.png\"><\/div>\n<h2>\u0427\u0430\u0441\u0442\u044c 3: \u043f\u043e\u0440\u0442\u0430\u043b\u044b<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/878\/eca\/7c8\/878eca7c897abff8139c6d04f5a1a960.png\"><\/div>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043e\u043b\u0433\u043e \u0438\u0433\u0440\u0430\u043b\u0438 \u0432 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0430 3\u00bb, \u0442\u043e \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0413\u0435\u0440\u0430\u043b\u044c\u0442 \u2014 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u044c \u043f\u043e\u0440\u0442\u0430\u043b\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043b\u0438 \u043e\u043d\u0438 \u0442\u0430\u043a \u0441\u0442\u0440\u0430\u0448\u043d\u044b.<\/p>\n<p>  \u0412 \u0438\u0433\u0440\u0435 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u043f\u043e\u0440\u0442\u0430\u043b\u043e\u0432:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/18f\/f0c\/282\/18ff0c282e1999b5e938797d298ed7b6.jpg\"><\/div>\n<p>  <i>\u0421\u0438\u043d\u0438\u0439 \u043f\u043e\u0440\u0442\u0430\u043b<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/afb\/50e\/8f5\/afb50e8f5f52f0f94ca89c5f684b9e48.jpg\"><\/div>\n<p>  <i>\u041e\u0433\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0440\u0442\u0430\u043b<\/i><\/p>\n<p>  \u042f \u043e\u0431\u044a\u044f\u0441\u043d\u044e, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0433\u043d\u0435\u043d\u043d\u044b\u0439. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0435\u0433\u043e \u043a\u043e\u0434 \u043f\u0440\u043e\u0449\u0435, \u0447\u0435\u043c \u0443 \u0441\u0438\u043d\u0435\u0433\u043e \ud83d\ude42<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u043e\u0433\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0440\u0442\u0430\u043b \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u0438\u0433\u0440\u0435:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/ol0rxFPBQgc?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0421\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u2014 \u044d\u0442\u043e, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043e\u0433\u043e\u043d\u044c, \u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043a \u0446\u0435\u043d\u0442\u0440\u0443, \u043d\u043e \u0441\u0430\u043c \u044d\u0444\u0444\u0435\u043a\u0442 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0432\u0438\u0434\u0438\u043c\u043e\u0439 \u0447\u0430\u0441\u0442\u0438. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u043e\u0437\u0436\u0435.<\/p>\n<p>  \u041f\u043b\u0430\u043d \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435\u043d: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044f, \u043f\u043e\u0442\u043e\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0435 \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b. \u0411\u0443\u0434\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432 \u0438 \u0432\u0438\u0434\u0435\u043e.<\/p>\n<p>  \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u043f\u043e\u0440\u0442\u0430\u043b\u044b \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u044f\u043c\u043e\u043c \u043f\u0440\u043e\u0445\u043e\u0434\u0435 \u0441\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u0435\u043c \u2014 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0439 \u0432 \u0438\u0433\u0440\u0435 \u043f\u0440\u0438\u0451\u043c; \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0441\u043c. \u0432 \u0447\u0430\u0441\u0442\u0438 \u043e <a href=\"https:\/\/habr.com\/ru\/post\/489118\/\">\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0445 \u0437\u0432\u0451\u0437\u0434\u0430\u0445<\/a>.<\/p>\n<p>  \u041d\u0443 \u0447\u0442\u043e, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c.<\/p>\n<h2>1. \u0413\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u044f<\/h2>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u0435\u0448 \u043f\u043e\u0440\u0442\u0430\u043b\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4e8\/fd5\/7e4\/4e8fd57e430a06f4c5d25ee397dfed09.jpg\"><\/div>\n<p>  <i>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u2014 \u0432\u0438\u0434 \u0441\u043f\u0435\u0440\u0435\u0434\u0438<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/707\/a3e\/299\/707a3e299d75286e74eb556fcc22ca05.jpg\"><\/div>\n<p>  <i>\u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u2014 \u0432\u0438\u0434 \u0441\u0431\u043e\u043a\u0443<\/i><\/p>\n<p>  \u041c\u0435\u0448 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Gabriel%27s_Horn\" rel=\"nofollow\">\u0440\u043e\u0433 \u0413\u0430\u0432\u0440\u0438\u0438\u043b\u0430<\/a>. \u0412\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0441\u0436\u0438\u043c\u0430\u0435\u0442 \u0435\u0433\u043e \u043f\u043e \u043e\u0434\u043d\u043e\u0439 \u043e\u0441\u0438, \u0432\u043e\u0442 \u0442\u043e\u0442 \u0436\u0435 \u043c\u0435\u0448 \u043f\u043e\u0441\u043b\u0435 \u0441\u0436\u0430\u0442\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0431\u043e\u043a\u0443 (\u0432 \u043c\u0438\u0440\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9dc\/a37\/be6\/9dca37be6f7255173e179f7a5c77d4e5.jpg\"><\/div>\n<p>  <i>\u041c\u0435\u0448 \u043f\u043e\u0440\u0442\u0430\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 (\u0432\u0438\u0434 \u0441\u0431\u043e\u043a\u0443)<\/i><\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0435\u0441\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: \u0432\u0430\u0436\u043d\u044b \u0434\u043b\u044f \u043d\u0430\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 (\u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u044f \u0431\u0443\u0434\u0443 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 RenderDoc, \u0430 \u043f\u043e\u0437\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u043d\u0438\u0445 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435):<\/p>\n<p>  Texcoords (float2):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/90c\/df6\/71b\/90cdf671b220eafe85c66a70ebcc04b6.jpg\"><\/div>\n<p>  Tangent (float3):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8dd\/d86\/7bc\/8ddd867bcf25841227db1282edf3bf90.jpg\"><\/div>\n<p>  Color (float3):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/40d\/d37\/72b\/40dd3772bbfdf2dde2ea508614f7697f.jpg\"><\/div>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u043f\u043e\u0437\u0434\u043d\u0435\u0435, \u043d\u043e \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u0430 .obj, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u043a\u0441\u043f\u043e\u0440\u0442 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0448\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u042f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b .csv, \u0430 \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b .csv \u0432 \u043c\u043e\u0451 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 C++ \u0438 \u0441\u0431\u043e\u0440\u043a\u0430 \u043c\u0435\u0448\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u044d\u0442\u0438\u0445 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<\/p>\n<h2>2. \u0412\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440<\/h2>\n<p>  \u0412\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0432\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"cpp\"> vs_5_0       dcl_globalFlags refactoringAllowed       dcl_constantbuffer cb1[7], immediateIndexed       dcl_constantbuffer cb2[6], immediateIndexed       dcl_input v0.xyz       dcl_input v1.xy       dcl_input v3.xyz       dcl_input v4.xyzw       dcl_input v6.xyzw       dcl_input v7.xyzw       dcl_input v8.xyzw       dcl_output o0.xyz       dcl_output o1.xyzw       dcl_output o2.xyz       dcl_output o3.xyz       dcl_output_siv o4.xyzw, position       dcl_temps 3      0: mov o0.xy, v1.xyxx      1: mul r0.xyzw, v7.xyzw, cb1[6].yyyy      2: mad r0.xyzw, v6.xyzw, cb1[6].xxxx, r0.xyzw      3: mad r0.xyzw, v8.xyzw, cb1[6].zzzz, r0.xyzw      4: mad r0.xyzw, cb1[6].wwww, l(0.000000, 0.000000, 0.000000, 1.000000), r0.xyzw      5: mad r1.xyz, v0.xyzx, cb2[4].xyzx, cb2[5].xyzx      6: mov r1.w, l(1.000000)      7: dp4 o0.z, r1.xyzw, r0.xyzw      8: mov o1.xyzw, v4.xyzw      9: dp4 o2.x, r1.xyzw, v6.xyzw     10: dp4 o2.y, r1.xyzw, v7.xyzw     11: dp4 o2.z, r1.xyzw, v8.xyzw     12: mad r0.xyz, v3.xyzx, l(2.000000, 2.000000, 2.000000, 0.000000), l(-1.000000, -1.000000, -1.000000, 0.000000)     13: dp3 r2.x, r0.xyzx, v6.xyzx     14: dp3 r2.y, r0.xyzx, v7.xyzx     15: dp3 r2.z, r0.xyzx, v8.xyzx     16: dp3 r0.x, r2.xyzx, r2.xyzx     17: rsq r0.x, r0.x     18: mul o3.xyz, r0.xxxx, r2.xyzx  <\/code><\/pre>\n<p>  \u0412\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043f\u0440\u043e\u0447\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043a\u0440\u0430\u0442\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u044f \u0432\u044b\u044f\u0441\u043d\u0438\u043b, \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u043d\u0443\u044e struct \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\"> struct VS_OUTPUT    {         float3 TexcoordAndViewSpaceDepth : TEXCOORD0;         float3 Color : TEXCOORD1;         float3 WorldSpacePosition : TEXCOORD2;         float3 Tangent : TEXCOORD3;         float4 PositionH : SV_Position;    };  <\/code><\/pre>\n<p>  \u042f \u0445\u043e\u0442\u0435\u043b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0430\u0441\u043f\u0435\u043a\u0442 \u2014 \u043a\u0430\u043a \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043e\u0431\u0437\u043e\u0440\u0430 (o0.z): \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 .w \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 SV_Position.<\/p>\n<p>  \u041d\u0430 gamedev.net \u0435\u0441\u0442\u044c <a href=\"https:\/\/www.gamedev.net\/forums\/topic\/698741-w-component-of-sv_positiongl_fragcoord\/\" rel=\"nofollow\">\u0442\u0435\u043c\u0430<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044d\u0442\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435.<\/p>\n<h2>3. \u041f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440<\/h2>\n<p>  \u0412\u043e\u0442 \u0441\u0446\u0435\u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u043e\u0439 \u043f\u043e\u0440\u0442\u0430\u043b\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/970\/541\/c18\/970541c1809af189d1196949d68b282d.png\"><\/div>\n<p>  \u2026 \u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9fe\/95c\/995\/9fe95c9956d4552e575a4aa0a7700330.png\"><\/div>\n<p>  \u043a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 \u0443\u0442\u0438\u043b\u0438\u0442\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 RenderDoc \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043e\u043f\u0446\u0438\u044f \u043e\u0432\u0435\u0440\u043b\u0435\u044f \u00abClear Before Draw\u00bb, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0441\u043e \u0432\u0441\u0435\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0440\u0442\u0430\u043b:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/391\/5f4\/753\/3915f4753bdab1c35ea205f852fe8918.png\"><\/div>\n<p>  \u041f\u0435\u0440\u0432\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0430\u0441\u043f\u0435\u043a\u0442 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0430\u043c \u0441\u043b\u043e\u0439 \u043f\u043b\u0430\u043c\u0435\u043d\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043c\u0435\u0448\u0430.<\/p>\n<p>  \u041f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 186 \u0441\u0442\u0440\u043e\u043a, \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u044f \u0432\u044b\u043b\u043e\u0436\u0438\u043b \u0435\u0433\u043e <a href=\"https:\/\/pastebin.com\/BFABZsBy\" rel=\"nofollow\">\u0441\u044e\u0434\u0430<\/a>. \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u044f \u044f \u0431\u0443\u0434\u0443 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e 100 \u0438\u0437 186 \u0441\u0442\u0440\u043e\u043a \u043e\u0442\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u043a \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044e <a href=\"https:\/\/habr.com\/ru\/post\/489118\/\">\u0442\u0443\u043c\u0430\u043d\u0430<\/a>.<\/p>\n<p>  \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u044e\u0442\u0441\u044f 4 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b: \u043e\u0433\u043e\u043d\u044c (t0), \u0448\u0443\u043c\/\u0434\u044b\u043c (t1), \u0446\u0432\u0435\u0442 \u0441\u0446\u0435\u043d\u044b (t6) \u0438 \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0441\u0446\u0435\u043d\u044b (t15):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/bbf\/f96\/898\/bbff96898cfca0776613f7ac044d1e88.jpg\"><\/div>\n<p>  <i>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u043e\u0433\u043d\u044f<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/18f\/a01\/732\/18fa01732e339615225c970ea0affb40.jpg\"><\/div>\n<p>  <i>\u0422\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0448\u0443\u043c\u0430\/\u0434\u044b\u043c\u0430<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/970\/541\/c18\/970541c1809af189d1196949d68b282d.png\"><\/div>\n<p>  <i>\u0426\u0432\u0435\u0442 \u0441\u0446\u0435\u043d\u044b<\/i><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/462\/8a5\/28f\/4628a528f96d8c2324b348bf65ca6282.png\"><\/div>\n<p>  <i>\u0413\u043b\u0443\u0431\u0438\u043d\u0430 \u0441\u0446\u0435\u043d\u044b<\/i><\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u0441 14 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u043c:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/98d\/c00\/682\/98dc006828372c155b88c06f26613497.jpg\"><\/div>\n<p>  \u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435: \u043f\u043e\u0437\u0438\u0446\u0438\u044f, tangent \u0438 texcoords \u2014 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u043d\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u043f\u0440\u0438\u0433\u043b\u044f\u0434\u0438\u043c\u0441\u044f \u043a \u043a\u0430\u043d\u0430\u043b\u0443 \u00abColor\u00bb. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0446\u0432\u0435\u0442 \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435, \u0430 \u0442\u0440\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043c\u0430\u0441\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043b\u043e\u0438 \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0433\u0434\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u044b:<\/p>\n<p>  Color.r \u2014 \u043c\u0430\u0441\u043a\u0430 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0433\u043e \u043c\u0430\u0440\u0435\u0432\u0430. \u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0433\u043e \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0434\u0443\u0445\u0430 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043d\u0451\u043c \u043f\u043e\u0437\u0436\u0435):<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/5a2\/050\/61e\/5a205061e0ee45e3e90d1590e8e93fe9.jpg\"><\/div>\n<p>  Color.g \u2014 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u043c\u0430\u0441\u043a\u0430. \u0412 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043e\u0433\u043d\u044f.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cc2\/8b7\/c37\/cc28b7c37631d0ee957ecb65cede07b5.jpg\"><\/div>\n<p>  Color.b \u2014 \u0437\u0430\u0434\u043d\u044f\u044f \u043c\u0430\u0441\u043a\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u00ab\u0437\u0430\u0434\u043d\u044f\u044f\u00bb \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u0440\u0442\u0430\u043b\u0430.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/610\/258\/e25\/610258e2504bd9f6011437c339fbb76c.jpg\"><\/div>\n<p>  \u042f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u043b\u0443\u0447\u0448\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043b\u043e\u0438, \u0430 \u043d\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e \u043a\u043e\u043d\u0446\u0430, \u043a\u0430\u043a \u044f \u0434\u0435\u043b\u0430\u043b \u0440\u0430\u043d\u044c\u0448\u0435.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u043e\u0435\u0445\u0430\u043b\u0438:<\/p>\n<h3>3.1. \u0421\u043b\u043e\u0439 \u043e\u0433\u043d\u044f<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0441\u0430\u043c\u0443\u044e \u0432\u0430\u0436\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c: \u0441\u043b\u043e\u0439 \u043e\u0433\u043d\u044f. \u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e \u0441 \u043d\u0438\u043c:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/vG7LLh857OQ?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u043d\u044b\u0445 texcoords \u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0438 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u0441\u0442\u0435\u043a\u0448\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u0430\u043a\u0438\u043c \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c texcoords \u043c\u044b \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 (\u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0433\u043d\u044f) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u044d\u043c\u043f\u043b\u0435\u0440\u0430 \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f\/\u043f\u043e\u0432\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u0447\u0442\u043e \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0435 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u043d\u0430\u043b .r \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u043e\u0433\u043d\u044f. \u0427\u0442\u043e\u0431\u044b \u044d\u0444\u0444\u0435\u043a\u0442 \u0431\u044b\u043b \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u0432\u0434\u043e\u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0432\u044b\u0448\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u0441\u043b\u043e\u044f \u043e\u0433\u043d\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0442\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c.<\/p>\n<p>  \u041d\u0443, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043a\u043e\u0434!<\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u043c\u044b \u0441 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u043c texcoords \u0431\u043e\u043b\u0435\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u043d\u044b\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u044e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043c\u0435\u0448\u0430:<\/p>\n<pre><code class=\"cpp\">   const float2 texcoords = Input.TextureUV;      const float uvSquash = cb4_v4.x; \/\/ 2.50      ...            const float y_cutoff = 0.2;      const float y_offset = pow(texcoords.y - y_cutoff, uvSquash);  <\/code><\/pre>\n<p>  \u0410 \u0432\u043e\u0442 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435:<\/p>\n<pre><code class=\"cpp\">  21: add r1.z, v0.y, l(-0.200000)     22: log r1.z, r1.z     23: mul r1.z, r1.z, cb4[4].x     24: exp r1.z, r1.z  <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 texcoords \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u044f \u043e\u0433\u043d\u044f \u0438 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0443 \u043e\u0433\u043d\u044f:<\/p>\n<pre><code class=\"cpp\">   const float elapsedTimeSeconds = cb0_v0.x;      const float uvScaleGlobal1 = cb4_v2.x; \/\/ 1.00      const float uvScale1 = cb4_v3.x;    \/\/ 0.15      ...       \/\/ Sample fire1 - the first fire layer      float fire1; \/\/ r1.w      {      float2 fire1Uv;        fire1Uv.x = texcoords.x;        fire1Uv.y = uvScale1 * elapsedTimeSeconds + y_offset;                 const float scaleGlobal = floor(uvScaleGlobal1); \/\/ 1.0      fire1Uv *= scaleGlobal;                fire1 = texFire.Sample(samplerLinearWrap, fire1Uv).x;      }  <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043d\u0430 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u0435:<\/p>\n<pre><code class=\"cpp\">  25: round_ni r1.w, cb4[2].x     26: mad r2.y, cb4[3].x, cb0[0].x, r1.z     27: mov r2.x, v0.x     28: mul r2.xy, r1.wwww, r2.xyxx     29: sample_indexable(texture2d)(float,float,float,float) r1.w, r2.xyxx, t0.yzwx, s0  <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043b\u043e\u0439 \u043f\u0440\u0438 <i>elapsedTimeSeconds<\/i>&nbsp;= 50.0:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/dd5\/654\/da3\/dd5654da3ed894e65008972da8ab057b.jpg\"><\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0436\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 <i>y_cutoff<\/i>, \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0442\u0443 \u0436\u0435 \u0441\u0446\u0435\u043d\u0443, \u043d\u043e \u0441 <i>y_cutoff<\/i>&nbsp;= 0.5:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4de\/71e\/3e6\/4de71e3e66f4cbb5e5a3ff671df0033a.jpg\"><\/div>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043b\u043e\u0439. \u0414\u0430\u043b\u0435\u0435 \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432\u0442\u043e\u0440\u043e\u0439:<\/p>\n<pre><code class=\"cpp\">   const float uvScale2 = cb4_v6.x;       \/\/ 0.06      const float uvScaleGlobal2 = cb4_v7.x; \/\/ 1.00      ...          \/\/ Sample fire2 - the second fire layer      float fire2; \/\/ r1.z      {                  float2 fire2Uv;        fire2Uv.x = texcoords.x - uvScale2 * elapsedTimeSeconds;        fire2Uv.y = uvScale2 * elapsedTimeSeconds + y_offset;              const float fire2_scale = floor(uvScaleGlobal2);        fire2Uv *= fire2_scale;              fire2 = texFire.Sample(samplerLinearWrap, fire2Uv).x;      }  <\/code><\/pre>\n<p>  \u0410 \u0432\u043e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442:<\/p>\n<pre><code class=\"cpp\">  144: mad r2.x, -cb0[0].x, cb4[6].x, v0.x     145: mad r2.y, cb0[0].x, cb4[6].x, r1.z     146: round_ni r1.z, cb4[7].x     147: mul r2.xy, r1.zzzz, r2.xyxx     148: sample_indexable(texture2d)(float,float,float,float) r1.z, r2.xyxx, t0.yzxw, s0  <\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c, \u043a\u0430\u043a \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 UV: \u0442\u0435\u043f\u0435\u0440\u044c X \u0442\u043e\u0436\u0435 \u0430\u043d\u0438\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u043e\u0439 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/3bb\/151\/bf2\/3bb151bf2c7cbbcef904cca60903d3fc.jpg\"><\/div>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432 \u0434\u0432\u0430 \u0441\u043b\u043e\u044f <b>\u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043e\u0433\u043d\u044f<\/b>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0445 \u0441\u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u043d\u0451\u043c \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044f\u044f \u043c\u0430\u0441\u043a\u0430:<\/p>\n<pre><code class=\"cpp\">   const float innerMask = Input.Color.y;      const float portalInnerColorSqueeze = cb4_v8.x; \/\/ 3.00      const float portalInnerColorBoost = cb4_v9.x; \/\/ 188.00      ...               \/\/ Calculate inner fire influence      float inner_influence;  \/\/ r1.z    {        \/\/ innerMask and &quot;-1.0&quot; are used here to control where the inner part of a portal is.        inner_influence = fire1 * fire2 + innerMask;        inner_influence = saturate(inner_influence - 1.0);                \/\/ Exponentation to hide less luminous elements of inner portal        inner_influence = pow(inner_influence, portalInnerColorSqueeze);                \/\/ Boost the intensity        inner_influence *= portalInnerColorBoost;      }  <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">  149: mad r1.z, r1.w, r1.z, v1.y     150: add_sat r1.z, r1.z, l(-1.000000)     151: log r1.z, r1.z     152: mul r1.z, r1.z, cb4[8].x     153: exp r1.z, r1.z     154: mul r1.z, r1.z, cb4[9].x  <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0432 <i>inner_influence<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0438 \u0447\u0435\u043c \u0438\u043d\u044b\u043c, \u043a\u0430\u043a \u043c\u0430\u0441\u043a\u043e\u0439 \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043e\u0433\u043d\u044f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043c\u0430\u0441\u043a\u0443 \u043d\u0430 \u0446\u0432\u0435\u0442 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043e\u0433\u043d\u044f:<\/p>\n<pre><code class=\"cpp\">   \/\/ Calculate portal color      const float3 colorPortalInner = cb4_v5.rgb; \/\/ (1.00, 0.60, 0.21961)      ...          const float3 portal_inner_final = pow(colorPortalInner, 2.2) * inner_influence;  <\/code><\/pre>\n<p>  \u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">  155: log r2.xyz, cb4[5].xyzx     156: mul r2.xyz, r2.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     157: exp r2.xyz, r2.xyzx     ...     170: mad r2.xyz, r2.xyzx, r1.zzzz, r3.xyzx  <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043b\u043e\u0438 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043e\u0433\u043d\u044f. \u041f\u043e\u0440\u044f\u0434\u043e\u043a: \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043b\u043e\u0439, \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u043b\u043e\u0439, \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u044f \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u0446\u0432\u0435\u0442:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/NtuMFD-Vyeo?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3>3.2. \u0421\u0432\u0435\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0432 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043e\u0433\u043e\u043d\u044c, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u043b\u043e\u044e: \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u044e. \u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 \u043e\u0433\u043e\u043d\u044c, \u043f\u043e\u0442\u043e\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0445 \u0441\u0443\u043c\u043c\u0443 \u2014 \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u043e\u0433\u043d\u044f:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/bVVqQR911zI?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0448\u0435\u0439\u0434\u0435\u0440 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u0435. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043e\u0433\u043d\u044f, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u0442\u0435\u043c \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0446\u0432\u0435\u0442 \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u044f \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442.<\/p>\n<pre><code class=\"cpp\">   const float portalOuterGlowAttenuation = cb4_v10.x; \/\/ 0.30      const float portalOuterColorBoost = cb4_v11.x; \/\/ 1.50    const float3 colorPortalOuterGlow = cb4_v12.rgb; \/\/ (1.00, 0.61961, 0.30196)      ...         \/\/ Calculate outer portal glow      float outer_glow_influence;      {          float outer_mask = (1.0 - backMask) * innerMask;                const float perturbParam = fire1*fire1;        float outer_mask_perturb = lerp( 1.0 - portalOuterGlowAttenuation, 1.0, perturbParam );                outer_mask *= outer_mask_perturb;        outer_glow_influence = outer_mask * portalOuterColorBoost;      }            \/\/ the final glow color      const float3 portal_outer_final = pow(colorPortalOuterGlow, 2.2) * outer_glow_influence;       \/\/ and the portal color, the sum of fire and glow    float3 portal_final = portal_inner_final + portal_outer_final;<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 outer_mask:<\/p>\n<p>  (1.0 \u2014 backMask) * innerMask<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e6b\/8c5\/934\/e6b8c5934ffb97d3ca461fb6b434333d.jpg\"><\/div>\n<p>  \u0421\u0432\u0435\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u0427\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u043b\u043e\u0439 \u043e\u0433\u043d\u044f (\u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0435), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043c\u0435\u0442\u043d\u044b \u0438\u0434\u0443\u0449\u0438\u0435 \u043a \u0446\u0435\u043d\u0442\u0440\u0443 \u043a\u043e\u043b\u0435\u0431\u0430\u043d\u0438\u044f:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b35\/44c\/5b5\/b3544c5b5390fd33ad96bc1fdda7fe6b.jpg\"><\/div>\n<p>  \u0412\u043e\u0442 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">  158: add r2.w, -v1.z, l(1.000000)     159: mul r2.w, r2.w, v1.y     160: mul r1.w, r1.w, r1.w     161: add r3.x, l(1.000000), -cb4[10].x     162: add r3.y, -r3.x, l(1.000000)     163: mad r1.w, r1.w, r3.y, r3.x     164: mul r1.w, r1.w, r2.w     165: mul r1.w, r1.w, cb4[11].x     166: log r3.xyz, cb4[12].xyzx     167: mul r3.xyz, r3.xyzx, l(2.200000, 2.200000, 2.200000, 0.000000)     168: exp r3.xyz, r3.xyzx     169: mul r3.xyz, r1.wwww, r3.xyzx     170: mad r2.xyz, r2.xyzx, r1.zzzz, r3.xyzx  <\/code><\/pre>\n<p>  <\/p>\n<h3>3.3. \u041c\u0430\u0440\u0435\u0432\u043e<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u044f \u043d\u0430\u0447\u0430\u043b \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043f\u043e\u0440\u0442\u0430\u043b\u0430, \u043c\u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0446\u0432\u0435\u0442 \u0441\u0446\u0435\u043d\u044b \u0431\u0435\u0437 \u043f\u043e\u0440\u0442\u0430\u043b\u0430. \u042f \u0440\u0430\u0441\u0441\u0443\u0436\u0434\u0430\u043b \u0442\u0430\u043a \u2014 \u00ab\u0437\u0434\u0435\u0441\u044c \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u043c\u0435\u0448\u0435\u043d\u0438\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0441 \u043d\u0443\u043b\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0430\u043b\u044c\u0444\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430\u00bb.<\/p>\n<p>  \u0428\u0435\u0439\u0434\u0435\u0440 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043d\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u043c\u0430\u0440\u0435\u0432\u0430 (\u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0433\u043e \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043e\u0437\u0434\u0443\u0445\u0430) \u2014 \u043e\u0442 \u043f\u043e\u0440\u0442\u0430\u043b\u0430 \u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0442\u0435\u043f\u043b\u043e \u0438 \u044d\u043d\u0435\u0440\u0433\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0444\u043e\u043d \u0438\u0441\u043a\u0430\u0436\u0451\u043d.<\/p>\n<p>  \u041f\u0440\u0438\u043d\u0446\u0438\u043f \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0438 texcoords \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0438 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b \u0446\u0432\u0435\u0442\u0430 \u0444\u043e\u043d\u0430 \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 \u2014 \u0442\u0430\u043a\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043c\u0435\u0448\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>  \u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e \u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041f\u043e\u0440\u044f\u0434\u043e\u043a: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442, \u043f\u043e\u0442\u043e\u043c \u043c\u0430\u0440\u0435\u0432\u043e \u0438\u0437 \u0448\u0435\u0439\u0434\u0435\u0440\u0430, \u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u044f \u0443\u043c\u043d\u043e\u0436\u0430\u044e \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 10, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0438\u043b\u0438\u0442\u044c \u044d\u0444\u0444\u0435\u043a\u0442.<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/oywjEYe-msI?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"cpp\">   const float ViewSpaceDepth = Input.ViewSpaceDepth;      const float3 Tangent = Input.Tangent;      const float backgroundDistortionStrength = cb4_v1.x; \/\/ 0.40       \/\/ Fades smoothly from the outer edges to the back of a portal    const float heatHazeMask = Input.Color.x;    ...            \/\/ The heat haze effect is view dependent thanks to tangent vectors in view space.      float2 heatHazeOffset = mul( normalize(Tangent), (float3x4)g_mtxView);      heatHazeOffset *= float2(-1, 1);            \/\/ Fade the effect as camera is further from a portal      const float heatHazeDistanceFade = backgroundDistortionStrength \/ ViewSpaceDepth;      heatHazeOffset *= heatHazeDistanceFade;               heatHazeOffset *= heatHazeMask;          \/\/ this is what animates the heat haze effect      heatHazeOffset *= pow(fire1, 0.2);               \/\/ Actually I don't know what's this :)      \/\/ It was 1.0 usually so I won't bother discussing this.      heatHazeOffset *= vsDepth2;  <\/code><\/pre>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440 \u0440\u0430\u0437\u0431\u0440\u043e\u0441\u0430\u043d \u043f\u043e \u043a\u043e\u0434\u0443:<\/p>\n<pre><code class=\"cpp\">  11: dp3 r1.x, v3.xyzx, v3.xyzx     12: rsq r1.x, r1.x     13: mul r1.xyz, r1.xxxx, v3.xyzx     14: mul r1.yw, r1.yyyy, cb12[2].xxxy     15: mad r1.xy, cb12[1].xyxx, r1.xxxx, r1.ywyy     16: mad r1.xy, cb12[3].xyxx, r1.zzzz, r1.xyxx     17: mul r1.xy, r1.xyxx, l(-1.000000, 1.000000, 0.000000, 0.000000)     18: div r1.z, cb4[1].x, v0.z     19: mul r1.xy, r1.zzzz, r1.xyxx     20: mul r1.xy, r1.xyxx, v1.xxxx     ...     33: mul r1.xy, r1.xyxx, r2.xxxx     34: mul r1.xy, r0.zzzz, r1.xyxx<\/code><\/pre>\n<p>  \u041c\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043b\u0438 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435, \u0442\u0430\u043a \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c!<\/p>\n<pre><code class=\"cpp\">   const float2 backgroundSceneMaxUv = cb0_v2.zw; \/\/ (1.0, 1.0)      const float2 invViewportSize = cb0_v1.zw; \/\/ (1.0 \/ 1920.0, 1.0 \/ 1080.0 )             \/\/ Obtain background scene color - we need to obtain it from texture      \/\/ for distortion effect      float3 sceneColor;      {        const float2 sceneUv_0 = pixelUv + backgroundSceneMaxUv*heatHazeOffset;        const float2 sceneUv_1 = backgroundSceneMaxUv - 0.5*invViewportSize;                      const float2 sceneUv = min(sceneUv_0, sceneUv_1);                sceneColor = texScene.SampleLevel(sampler6, sceneUv, 0).rgb;      }  <\/code><\/pre>\n<pre><code class=\"cpp\">  175: mad r0.xy, cb0[2].zwzz, r1.xyxx, r0.xyxx     176: mad r1.xy, -cb0[1].zwzz, l(0.500000, 0.500000, 0.000000, 0.000000), cb0[2].zwzz     177: min r0.xy, r0.xyxx, r1.xyxx     178: sample_l(texture2d)(float,float,float,float) r1.xyz, r0.xyxx, t6.xyzw, s6, l(0)  <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 <i>sceneColor<\/i>.<\/p>\n<h3>3.4. \u0426\u0432\u0435\u0442 \u00ab\u0446\u0435\u043b\u0438\u00bb \u043f\u043e\u0440\u0442\u0430\u043b\u0430<\/h3>\n<p>  \u041f\u043e\u0434 \u0446\u0432\u0435\u0442\u043e\u043c \u00ab\u0446\u0435\u043b\u0438\u00bb \u044f \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u044e \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043f\u043e\u0440\u0442\u0430\u043b\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/547\/3fc\/99a\/5473fc99a829899381bbf459e71a9830.jpg\"><\/div>\n<p>  \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u043e\u043d \u0432\u0435\u0441\u044c \u0447\u0451\u0440\u043d\u044b\u0439. \u0418 \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044d\u0442\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0443\u043c\u0430\u043d.<\/p>\n<p>  \u042f \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0442\u0443\u043c\u0430\u043d \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/489118\/\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u0412 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u043f\u043e\u0440\u0442\u0430\u043b\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0442\u0443\u043c\u0430\u043d\u0430 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 [35-135] \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>  HLSL:<\/p>\n<pre><code class=\"cpp\"> struct FogResult    {      float4 paramsFog;      float4 paramsAerial;    };        ...        FogResult fog;    {      const float3 CameraPosition = cb12_v0.xyz;      const float fogStart = cb12_v22.z; \/\/ near plane            fog = CalculateFog( WSPosition, CameraPosition, fogStart, false );     }        ...        const float3 destination_color = fog.paramsFog.a * fog.paramsFog.rgb;  <\/code><\/pre>\n<p>  \u0418 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0441\u0446\u0435\u043d\u0443:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9fe\/95c\/995\/9fe95c9956d4552e575a4aa0a7700330.png\"><\/div>\n<p>  \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043a\u0430\u043c\u0435\u0440\u0430 \u0432 \u043a\u0430\u0434\u0440\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0430\u043a \u0431\u043b\u0438\u0437\u043a\u043e \u043a \u043f\u043e\u0440\u0442\u0430\u043b\u0443, \u0447\u0442\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0439 <i>destination_color<\/i> \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0442\u043e \u0435\u0441\u0442\u044c \u0447\u0451\u0440\u043d\u044b\u0439 \u0446\u0435\u043d\u0442\u0440 \u043f\u043e\u0440\u0442\u0430\u043b\u0430 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0443\u043c\u0430\u043d\u043e\u043c (\u0438\u043b\u0438, \u0441\u0442\u0440\u043e\u0433\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0435\u0433\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435\u043c).<\/p>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 RenderDoc \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u043d\u044a\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0438\u0433\u0440\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u044b, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043a\u0430\u043c\u0435\u0440\u0443 \u0432\u0440\u0443\u0447\u043d\u0443\u044e:<\/p>\n<pre><code class=\"cpp\">  const float3 CameraPosition = cb12_v0.xyz + float3(100, 100, 0);  <\/code><\/pre>\n<p>  \u0418 \u0432\u043e\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c1c\/831\/ab3\/c1c831ab3b3e9c3a4fb04a642af9219c.jpg\"><\/div>\n<p>  \u0425\u0430!<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0445\u043e\u0442\u044f \u0432 \u044d\u0442\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0442\u0443\u043c\u0430\u043d\u0430, \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438\u0447\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043d\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 <i>destination_color <\/i>. \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043b\u0430\u043d\u0434\u0448\u0430\u0444\u0442 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043c\u0438\u0440\u0430 (\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0430\u0440\u0430 texcoords, \u043d\u043e, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u044d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c\u043e).<\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0443\u043c\u0430\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u0442\u0430\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0433\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<h3>3.5. \u0421\u043c\u0435\u0448\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u0430 \u0441\u0446\u0435\u043d\u044b (\u0441 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u043c\u0430\u0440\u0435\u0432\u043e\u043c) \u0441 \u00ab\u0446\u0435\u043b\u044c\u044e\u00bb<\/h3>\n<p>  \u042f \u0440\u0430\u0437\u0434\u0443\u043c\u044b\u0432\u0430\u043b, \u043a\u0443\u0434\u0430 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b \u2014 \u0432 \u00ab\u0426\u0432\u0435\u0442 \u201e\u0446\u0435\u043b\u0438\u201c\u00bb \u0438\u043b\u0438 \u00ab\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435\u00bb, \u043d\u043e \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043d\u0430 \u044d\u0442\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432 3.3 <i>sceneColor<\/i>, \u0443\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u043c\u0430\u0440\u0435\u0432\u0430 (\u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0433\u043e \u0438\u0441\u043a\u0430\u0436\u0435\u043d\u0438\u044f), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c <i>destination_color<\/i> \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u0430 3.4.<\/p>\n<p>  \u041e\u043d\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438:<\/p>\n<pre><code class=\"cpp\">  178: sample_l(texture2d)(float,float,float,float) r1.xyz, r0.xyxx, t6.xyzw, s6, l(0)     179: mad r3.xyz, r4.wwww, r4.xyzx, -r1.xyzx     180: mad r0.xyw, r0.wwww, r3.xyxz, r1.xyxz  <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0437\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u0435\u0442 (r0.w)?<\/p>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430 \u0448\u0443\u043c\u0430\/\u0434\u044b\u043c\u0430.<\/p>\n<p>  \u041e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u044f \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u00ab\u043c\u0430\u0441\u043a\u043e\u0439 \u0446\u0435\u043b\u0438 \u043f\u043e\u0440\u0442\u0430\u043b\u0430\u00bb.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/fb0\/c6d\/b2c\/fb0c6db2c0df02caf68e95046393a0e1.jpg\"><\/div>\n<p>  \u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e (\u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u043d\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442, \u0437\u0430\u0442\u0435\u043c \u043c\u0430\u0441\u043a\u0430 \u0446\u0435\u043b\u0438, \u0437\u0430\u0442\u0435\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u043d\u0443\u0442\u044b\u0439 \u043c\u0430\u0440\u0435\u0432\u0443 \u0446\u0432\u0435\u0442 \u0441\u0446\u0435\u043d\u044b \u0438 \u0446\u0432\u0435\u0442 \u0446\u0435\u043b\u0438):<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/WnIk4nHVPKw?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043d\u0430 HLSL:<\/p>\n<pre><code class=\"cpp\">   \/\/ Determines the back part of a portal      const float backMask = Input.Color.z;          const float ViewSpaceDepth = Input.TexcoordAndViewSpaceDepth.z;      const float viewSpaceDepthScale = cb4_v0.x; \/\/ 0.50        ...          \/\/ Load depth from texture      float hardwareDepth = texDepth.SampleLevel(sampler15, pixelUv, 0).x;      float linearDepth = getDepth(hardwareDepth);            \/\/ cb4_v0.x = 0.5      float vsDepthScale = saturate( (linearDepth - ViewSpaceDepth) * viewSpaceDepthScale );            float vsDepth1 = 2*vsDepthScale;        ....          \/\/ Calculate 'portal destination' mask - maybe we would like see a glimpse of where a portal leads      \/\/ like landscape from another planet - the shader allows for it.      float portal_destination_mask;      {          const float region_mask = dot(backMask.xx, vsDepth1.xx);              const float2 _UVScale = float2(4.0, 1.0);        const float2 _TimeScale = float2(0.0, 0.2);        const float2 _UV = texcoords * _UVScale + elapsedTime * _TimeScale;                portal_destination_mask = texNoise.Sample(sampler0, _UV).x;        portal_destination_mask = saturate(portal_destination_mask + region_mask - 1.0);        portal_destination_mask *= portal_destination_mask; \/\/ line 143, r0.w      }  <\/code><\/pre>\n<p>  \u041c\u0430\u0441\u043a\u0430 \u0446\u0435\u043b\u0438 \u043f\u043e\u0440\u0442\u0430\u043b\u0430 \u0432 \u0446\u0435\u043b\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u043e\u0433\u043e\u043d\u044c \u2014 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b. \u0414\u043b\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f &quot;<i>region_mask<\/i>&quot;.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <i>region_mask<\/i> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u0434 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c <i>vsDepth1<\/i>. \u0427\u0443\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u044f \u043e\u043f\u0438\u0448\u0443 \u0435\u0451 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u043b\u0438\u044f\u043d\u0438\u0435 \u043d\u0430 \u043c\u0430\u0441\u043a\u0443 \u0446\u0435\u043b\u0438.<\/p>\n<p>  \u0410\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u0430\u0441\u043a\u0438 \u0446\u0435\u043b\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">  137: dp2 r0.w, v1.zzzz, r0.zzzz     138: mul r2.xy, cb0[0].xxxx, l(0.000000, 0.200000, 0.000000, 0.000000)     139: mad r2.xy, v0.xyxx, l(4.000000, 1.000000, 0.000000, 0.000000), r2.xyxx     140: sample_indexable(texture2d)(float,float,float,float) r2.x, r2.xyxx, t1.xyzw, s0     141: add r0.w, r0.w, r2.x     142: add_sat r0.w, r0.w, l(-1.000000)     143: mul r0.w, r0.w, r0.w  <\/code><\/pre>\n<p>  <\/p>\n<h3>3.6. \u0421\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c \u0432\u0441\u0451 \u0432\u043c\u0435\u0441\u0442\u0435<\/h3>\n<p>  \u0424\u0443\u0445, \u043f\u043e\u0447\u0442\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0446\u0432\u0435\u0442 \u043f\u043e\u0440\u0442\u0430\u043b\u0430:<\/p>\n<pre><code class=\"cpp\"> \/\/ Calculate portal color    float3 portal_final;    {      const float3 portal_inner_color = pow(colorPortalInner, 2.2) * inner_influence;      const float3 portal_outer_color = pow(colorPortalOuterGlow, 2.2) * outer_glow_influence;            portal_final = portal_inner_color + portal_outer_color;      portal_final *= vsDepth1; \/\/ fade the effect to avoid harsh artifacts due to depth test      portal_final *= portalFinalColorFilter; \/\/ this was (1,1,1) - so not relevant    }  <\/code><\/pre>\n<p>  \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0430\u0441\u043f\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0445\u043e\u0447\u0443 \u0437\u0434\u0435\u0441\u044c \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c \u2014 \u044d\u0442\u043e <i>vsDepth1<\/i>.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u0430 \u043c\u0430\u0441\u043a\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/50d\/32b\/2a9\/50d32b2a91308b9e356bf5cda0353d39.jpg\"><\/div>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0434\u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u043e\u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f; \u043f\u043e \u0441\u0443\u0442\u0438, \u044d\u0442\u043e \u00ab\u043b\u0438\u043d\u0435\u0439\u043d\u044b\u0439 \u0431\u0443\u0444\u0435\u0440 \u0433\u043b\u0443\u0431\u0438\u043d\u00bb, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u0430 \u043f\u043e\u0440\u0442\u0430\u043b\u0430 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u0440\u0435\u0437\u043a\u043e\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0438\u0437-\u0437\u0430 \u0442\u0435\u0441\u0442\u0430 \u0433\u043b\u0443\u0431\u0438\u043d.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0435\u0449\u0451 \u0440\u0430\u0437 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0441\u0446\u0435\u043d\u0443, \u0441 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0431\u0435\u0437 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 <i>vsDepth1<\/i>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9fe\/95c\/995\/9fe95c9956d4552e575a4aa0a7700330.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/ff3\/8d5\/7d7\/ff38d57d70ee357d6a43c5ccd45deb6b.jpg\"><\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f <i>portal_final<\/i> \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<pre><code class=\"cpp\">   const float finalPortalAmount = cb2_v0.x; \/\/ 0.99443      const float3 finalColorFilter = cb2_v2.rgb; \/\/ (1.0, 1.0, 1.0)      const float finalOpacityFilter = cb2_v2.a; \/\/ 1.0      ...          \/\/ Alpha component for blending      float opacity = saturate( lerp(cb2_v0.x, 1, cb4_v13.x) );          \/\/ Calculate the final color      float3 finalColor;      {        \/\/ Mix the scene color (with heat haze effect) with the 'destination color'.        \/\/ In this particular example fog is used as destination (which is black where camera is nearby)        \/\/ but in theory there is nothing which stops us from putting here a landscape from another world.        const float3 destination_color = fog.paramsFog.a * fog.paramsFog.rgb;            finalColor = lerp( sceneColor, destination_color, portal_destination_mask );                \/\/ Add the portal color        finalColor += portal_final * finalPortalAmount;                \/\/ Final filter        finalColor *= finalColorFilter;      }               opacity *= finalOpacityFilter;            return float4(finalColor * opacity, opacity);  <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451. \u0415\u0441\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <i>finalPortalAmount<\/i>, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0430\u044f, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043b\u0430\u043c\u0435\u043d\u0438 \u0432\u0438\u0434\u0438\u0442 \u0438\u0433\u0440\u043e\u043a. \u042f \u043d\u0435 \u0441\u0442\u0430\u043b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0451 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e, \u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0440\u0442\u0430\u043b \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442 \u2014 \u043d\u0430 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0433\u0440\u043e\u043a \u043d\u0435 \u0432\u0438\u0434\u0438\u0442 \u043e\u0433\u043d\u044f, \u0437\u0430\u0442\u043e \u0432\u0438\u0434\u0438\u0442 \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u0441\u0432\u0435\u0447\u0435\u043d\u0438\u0435, \u0446\u0432\u0435\u0442 \u0446\u0435\u043b\u0438 \u0438 \u0442.\u043f.<\/p>\n<h2>4. \u041f\u043e\u0434\u0432\u0435\u0434\u0451\u043c \u0438\u0442\u043e\u0433<\/h2>\n<p>  \u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u043d\u0430 HLSL \u0432\u044b\u043b\u043e\u0436\u0435\u043d <a href=\"https:\/\/pastebin.com\/d2EYTfaW\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0441\u0442\u0430\u043c\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0430\u0441\u0441\u0435\u043c\u0431\u043b\u0435\u0440\u043d\u044b\u0439 \u043a\u043e\u0434, \u0447\u0442\u043e \u0438 \u0443 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u0435\u0442 \u043e\u0431\u0449\u0435\u043c\u0443 \u043f\u043e\u0442\u043e\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u0428\u0435\u0439\u0434\u0435\u0440 \u0433\u043e\u0442\u043e\u0432 \u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u0441 RenderDoc, \u0432\u0441\u0435 cbuffers \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0442.\u0434, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0435\u0433\u043e \u0438\u043d\u044a\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c, \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/504336\/\"> https:\/\/habr.com\/ru\/post\/504336\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/504336\/\">[\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430: <a href=\"https:\/\/habr.com\/ru\/post\/422573\/\">\u043f\u0435\u0440\u0432\u0430\u044f<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/437100\/\">\u0432\u0442\u043e\u0440\u0430\u044f<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/450332\/\">\u0442\u0440\u0435\u0442\u044c\u044f<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/489118\/\">\u0447\u0435\u0442\u0432\u0451\u0440\u0442\u0430\u044f<\/a>.]<\/p>\n<h2>\u0427\u0430\u0441\u0442\u044c 1: \u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c<\/h2>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b, \u043a\u0430\u043a \u0432 \u00ab\u0412\u0435\u0434\u044c\u043c\u0430\u043a\u0435 3\u00bb \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u0437\u0432\u0451\u0437\u0434\u044b. \u042d\u0442\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u043d\u0435\u0442 \u0432 \u00ab\u041a\u0440\u043e\u0432\u0438 \u0438 \u0432\u0438\u043d\u0435\u00bb. \u0412 \u043f\u043e\u0441\u0442\u0435 \u044f \u043e\u043f\u0438\u0448\u0443 \u044d\u0444\u0444\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u044d\u0442\u043e\u043c DLC: <a href=\"https:\/\/en.wikipedia.org\/wiki\/Milky_Way\" rel=\"nofollow\">\u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c<\/a>.<\/p>\n<p>  \u0412\u043e\u0442 \u0432\u0438\u0434\u0435\u043e, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u041c\u043b\u0435\u0447\u043d\u044b\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/c8iURjd03vE?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  \u0418 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u043e\u0432: (1) \u0434\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043a\u0443\u043f\u043e\u043b\u0430 \u043d\u0435\u0431\u0430, (2) \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0446\u0432\u0435\u0442\u043e\u043c \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438, (3) \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430:<\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0421\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u044b<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/842\/903\/ccd\/842903ccd1787d3a1c5ea8280162cc7a.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/206\/cd8\/8cf\/206cd88cfed00e5934a531a5c496abc5.png\"><\/div>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/26d\/31a\/317\/26d31a3176c9e696c7f09d67ca428b3a.png\"><\/div>\n<\/div><\/div>\n<p>  \u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043a\u0430\u0434\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043e\u0434\u043d\u0438\u043c \u041c\u043b\u0435\u0447\u043d\u044b\u043c \u043f\u0443\u0442\u0451\u043c (\u0431\u0435\u0437 \u0446\u0432\u0435\u0442\u0430 \u043d\u0435\u0431\u0430 \u0438 \u0437\u0432\u0451\u0437\u0434) \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/eb7\/7ea\/807\/eb77ea807cadc8affeb5c475bcf51f36.jpg\"><\/div>\n<p>  \u042d\u0444\u0444\u0435\u043a\u0442 \u041c\u043b\u0435\u0447\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438, \u0441\u0442\u0430\u0432\u0448\u0438\u0439 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0441\u0438\u043b\u044c\u043d\u044b\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u0439 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u0438\u0433\u0440\u044b 2015 \u0433\u043e\u0434\u0430, \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442 <a href=\"https:\/\/habr.com\/ru\/post\/450332\/\">\u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00ab\u0413\u043b\u0443\u043f\u044b\u0435 \u0442\u0440\u044e\u043a\u0438 \u0441 \u043d\u0435\u0431\u043e\u043c\u00bb<\/a>. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c\u0441\u044f, \u043a\u0430\u043a \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d!<\/p>\n<p>  \u041f\u043b\u0430\u043d \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0432\u043a\u0440\u0430\u0442\u0446\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u043c \u0432\u0441\u0451, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0435\u0441\u044f \u043a \u0433\u0435\u043e\u043c\u0435\u0442\u0440\u0438\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043f\u0440\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-304693","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304693","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=304693"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304693\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}