{"id":304393,"date":"2020-05-28T09:00:44","date_gmt":"2020-05-28T09:00:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304393"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304393","title":{"rendered":"\u041f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 Raymarching-\u0430: \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 Unity"},"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\/503554\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/244\/286\/4a4\/2442864a40f38cd658275532f8841522.png\" alt=\"image\"><\/div>\n<p>  <em>Raymarching<\/em> \u2014 \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u043e\u0432\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u0446\u0435\u043d \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041e\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0440\u0435\u043d\u0434\u0435\u0440\u0435\u0440 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u0435\u0448\u0435\u0439 \u0438 \u0441\u0446\u0435\u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0435, \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u0432\u0441\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u043c\u0435\u0440\u044b. \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0441\u0446\u0435\u043d\u0435 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u043e\u0439 \u0438 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u0446\u0435\u043d\u044b (\u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u043f\u043e\u043b\u044f\u043c\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 Raymarching-\u0430<\/em>). \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0441\u0446\u0435\u043d\u044b. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0448\u0438 (\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f), \u0437\u0434\u0435\u0441\u044c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0435\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043b\u0430\u0432\u043d\u044b\u0435 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e2f\/07d\/4dd\/e2f07d4dd3aaf8e405a67376f828cfb2.png\"><\/div>\n<p>  <i><a href=\"https:\/\/www.shadertoy.com\/view\/ld3Gz2\" rel=\"nofollow\">Snail<\/a> \u0418\u043d\u0438\u0433\u043e \u041a\u0438\u043b\u0435\u0437\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 raymarching. \u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u043d\u0443\u0442\u044b\u0445 raymarching-\u0443 \u0441\u0446\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/www.shadertoy.com\" rel=\"nofollow\">Shadertoy<\/a>.<\/i><\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u0445 \u0438 \u0442\u0435\u043e\u0440\u0438\u0438 raymarching, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 raymarcher \u0432 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0434\u0432\u0438\u0436\u043a\u0435 Unity. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c, \u043a\u0430\u043a \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c raymarching \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0433\u0440\u0443 \u043d\u0430 Unity, \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0441 raymarching-\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 GameObjects.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/Flafla2\/Generic-Raymarch-Unity\" rel=\"nofollow\">\u044d\u0442\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 Github<\/a>.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 Raymarching<\/h2>\n<p>  Raymarching \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u0443\u044e \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u043b\u0443\u0447\u0435\u0439 (raytracing) \u0442\u0435\u043c, \u0447\u0442\u043e \u043b\u0443\u0447 \u0432 \u0441\u0446\u0435\u043d\u0443 \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u0412 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0435 \u043b\u0443\u0447\u0435\u0439 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0430 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u044f\u0449\u0438\u0445\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0435\u0442 \u043b\u0443\u0447 (\u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u0438\u0442 \u043a\u0430\u043c\u0435\u0440\u0430). \u0422\u0430\u043a\u0436\u0435 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u043d\u0435\u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0444\u0435\u0440\u044b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0441\u0444\u0435\u0440\u044b \u0438 \u043b\u0443\u0447\u0430. \u041e\u0434\u043d\u0430\u043a\u043e raytracing \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u0435\u043d, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0446\u0435\u043d\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u043b\u0443\u0447\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u043b\u0430\u043a\u0430 \u0438 \u0432\u043e\u0434\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u043b\u0443\u0447\u0435\u0439 \u0440\u0435\u0434\u043a\u043e \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c21\/8e5\/da6\/c218e5da67dd1204cfc4cf352de53332.png\"><\/div>\n<p>  <i>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 1: \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u043b\u0443\u0447\u0435\u0439. \u0416\u0438\u0440\u043d\u0430\u044f \u0447\u0451\u0440\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0437 \u043a\u0430\u043c\u0435\u0440\u044b \u043b\u0443\u0447\u0430 \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u043f\u0438\u043a\u0441\u0435\u043b\u044f.<\/i><\/p>\n<p>  Raymarching \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0430 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. Raymarching \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u041f\u0440\u0438 \u043d\u0451\u043c <strong>\u043c\u044b \u00ab\u0448\u0430\u0433\u0430\u0435\u043c\u00bb \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0434\u043e\u043b\u044c \u043b\u0443\u0447\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u043c, \u0433\u0434\u0435 \u0442\u043e\u0447\u043a\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442<\/strong>. \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0434\u043e\u043b\u044c \u043b\u0443\u0447\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438 \u043c\u0430\u043b\u043e\u0437\u0430\u0442\u0440\u0430\u0442\u043d\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u043d\u043e\u0439 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 2, \u044d\u0442\u043e\u0442 \u0441\u043f\u043e\u0441\u043e\u0431 \u043c\u0435\u043d\u0435\u0435 \u0442\u043e\u0447\u0435\u043d, \u0447\u0435\u043c raytracing (\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0433\u043b\u044f\u0434\u0435\u0442\u044c\u0441\u044f, \u0442\u043e \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0447\u0442\u043e \u0442\u043e\u0447\u043a\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u043b\u0435\u0433\u043a\u0430 \u0441\u043c\u0435\u0449\u0435\u043d\u0430). \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u0438\u0433\u0440 \u043e\u043d \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u043c \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0438\u0441\u0441\u043e\u043c \u043c\u0435\u0436\u0434\u0443 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0438 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e raytracing.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/9b2\/562\/4f9\/9b25624f940dc7cbd740977ea20d0037.png\"><\/div>\n<p>  <i>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 2: \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 raymarching-\u0430 (\u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u0439 raymarcher) \u0441 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0448\u0430\u0433\u0430. \u041a\u0440\u0430\u0441\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u044b \u0432\u0441\u0435 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0442\u043e\u0447\u043a\u0438.<\/i><\/p>\n<h3>\u041f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439<\/h3>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f raymarching-\u0430 \u0441 <em>\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c<\/em>, \u0442\u0430\u043a\u0430\u044f \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 2, \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0430 \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u044a\u0451\u043c\u043d\u044b\u0445 \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0445 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0435\u0439. \u041e\u0434\u043d\u0430\u043a\u043e \u0434\u043b\u044f \u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u0432\u0435\u0441\u0442\u0438 \u0435\u0449\u0451 \u043e\u0434\u043d\u0443 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e. \u0414\u043b\u044f \u044d\u0442\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <em>\u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c (signed distance fields)<\/em>. <strong><em>\u041f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439<\/em> \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0430\u044f \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0442\u043e\u0447\u043a\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0430\u044f \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0434\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0441\u0446\u0435\u043d\u0435<\/strong>. \u041f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 <em>\u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c<\/em> \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0435\u0441\u043b\u0438 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u2014 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u044d\u043c\u043f\u043b\u043e\u0432 \u043f\u0440\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 raymarching-\u043e\u043c \u0432\u0434\u043e\u043b\u044c \u043b\u0443\u0447\u0430. \u0421\u043c. \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b91\/a1f\/2fd\/b91a1f2fd7a2b0255f955b1690de350e.png\"><\/div>\n<p>  <i>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 3: \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f raymarcher-\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c. \u041a\u0440\u0430\u0441\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0432\u0441\u0435 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0442\u043e\u0447\u043a\u0438. \u0421\u0438\u043d\u0438\u043c\u0438 \u043a\u0440\u0443\u0433\u0430\u043c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u043e\u0431\u043b\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439). \u041f\u0443\u043d\u043a\u0442\u0438\u0440\u043d\u044b\u043c\u0438 \u0437\u0435\u043b\u0451\u043d\u044b\u043c\u0438 \u043b\u0438\u043d\u0438\u044f\u043c\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u044b \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u0435 \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0438\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u043c\u0435\u0436\u0434\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0438 \u0441\u0446\u0435\u043d\u043e\u0439.<\/i><\/p>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0432\u044b\u0448\u0435, \u043f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u0441 \u043a\u0430\u0436\u0434\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043b\u0443\u0447\u0443 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<h2>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e Raymarcher-\u0430<\/h2>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c raymarching-\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, raymarcher \u0432 Unity \u043f\u043e \u0441\u0443\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0418\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u043d\u0430 C#, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c, \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0434\u043b\u044f \u043f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f<\/h3>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u043a\u0440\u0438\u043f\u0442 <a href=\"http:\/\/framebunker.com\/blog\/viewing-image-effects-in-the-scene-view\/\" rel=\"nofollow\">SceneViewFilter<\/a> \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 Scene. \u042d\u0442\u043e \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043e\u0442\u043b\u0430\u0434\u043a\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0430. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u043e <code>MonoBehaviour<\/code> \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c <code>SceneViewFilter<\/code>.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0432\u044b \u043d\u0435 \u043c\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0441 boilerplate-\u043a\u043e\u0434\u043e\u043c, \u043d\u0438\u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d \u0441\u043a\u0440\u0438\u043f\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cs\">using UnityEngine; using System.Collections;  [ExecuteInEditMode] [RequireComponent(typeof(Camera))] [AddComponentMenu(&quot;Effects\/Raymarch (Generic)&quot;)] public class TutorialRaymarch : SceneViewFilter {      [SerializeField]     private Shader _EffectShader;      public Material EffectMaterial     {         get         {             if (!_EffectMaterial &amp;&amp; _EffectShader)             {                 _EffectMaterial = new Material(_EffectShader);                 _EffectMaterial.hideFlags = HideFlags.HideAndDontSave;             }              return _EffectMaterial;         }     }     private Material _EffectMaterial;      public Camera CurrentCamera     {         get         {             if (!_CurrentCamera)                 _CurrentCamera = GetComponent&lt;Camera&gt;();             return _CurrentCamera;         }     }     private Camera _CurrentCamera;      [ImageEffectOpaque]     void OnRenderImage(RenderTexture source, RenderTexture destination)     {         if (!EffectMaterial)         {             Graphics.Blit(source, destination); \/\/ do nothing             return;         }          Graphics.Blit(source, destination, EffectMaterial, 0); \/\/ use given effect shader as image effect     } }<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0435\u0433\u043e \u043a \u043a\u0430\u043c\u0435\u0440\u0435 \u0438 \u043f\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u044c \u0448\u0435\u0439\u0434\u0435\u0440 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 \u043f\u043e\u043b\u0435 \u00abEffect Shader\u00bb. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0435\u0441\u0442\u0430 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (Assets &gt; Create &gt; Shader &gt; Image Effects Shader), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u044d\u043a\u0440\u0430\u043d. \u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432\u0448\u0438\u0441\u044c \u0441 \u044d\u0442\u0438\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0431\u043e\u043b\u0435\u0435 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0430\u0441\u043f\u0435\u043a\u0442\u0430\u043c\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<h3>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043b\u0443\u0447\u0435\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443<\/h3>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u043f\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 raymarcher \u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u0438 \u043b\u0443\u0447\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 Unity (\u0442\u0430\u043a\u0438\u043c\u0438, \u043a\u0430\u043a \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u043a\u0430\u043c\u0435\u0440\u044b, FOV \u0438 \u0442.\u043f.).<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/593\/690\/d1c\/593690d1cfe18437e101bbc9366e90a0.png\"><\/div>\n<p>  <i>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 4: \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u0443\u0447\u0435\u0439, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0445 \u0438\u0437 \u043a\u0430\u043c\u0435\u0440\u044b<\/i><\/p>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438, \u043d\u043e \u044f \u0440\u0435\u0448\u0438\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u0430\u0434\u0440\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443:<\/p>\n<ol>\n<li>\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0447\u0435\u0442\u044b\u0440\u0451\u0445 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0445 <a href=\"https:\/\/docs.unity3d.com\/Manual\/UnderstandingFrustum.html\" rel=\"nofollow\">\u043f\u0438\u0440\u0430\u043c\u0438\u0434\u0443 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u043c\u0435\u0440\u044b (Camera View Frustum)<\/a>. \u042d\u0442\u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u00ab\u0443\u0433\u043b\u044b\u00bb \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u044b \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438:\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/1d6\/b8d\/cd5\/1d6b8dcd537895343bf779edcdc6fb90.png\"><\/div>\n<p>  <i>\u0427\u0435\u0442\u044b\u0440\u0435 \u0443\u0433\u043b\u0430 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u044b \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0437\u0436\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u0443<\/i><\/li>\n<li>\u041f\u0440\u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0435 \u043d\u0430\u0448\u0435\u0433\u043e raymarcher \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430\u0448\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u043c\u0435\u043d\u0443 <a href=\"https:\/\/docs.unity3d.com\/ScriptReference\/Graphics.Blit.html\" rel=\"nofollow\">Graphics.Blit()<\/a>. \u041f\u043e \u0441\u0443\u0442\u0438, Graphics.Blit \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u0438 \u044d\u0442\u043e\u0442 \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u0441\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f. \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0433\u043e, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b <em>\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u0430, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c\u0438 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 1<\/em>. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u043d\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a\u0438\u0435 \u043b\u0443\u0447\u0438 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0443\u0433\u043b\u043e\u0432 \u044d\u043a\u0440\u0430\u043d\u0430!<\/li>\n<li>\u0412 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0438\u0437 \u044d\u0442\u0430\u043f\u0430 2 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440. Cg \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0435\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0430.<\/li>\n<\/ol>\n<p>  \u0418\u0442\u0430\u043a, \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441.<\/p>\n<h4>\u042d\u0442\u0430\u043f 1: \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0443\u0433\u043b\u043e\u0432 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u044b \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438<\/h4>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0435\u0439 \u0443\u0433\u043b\u043e\u0432 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u044b \u043a\u0430\u043c\u0435\u0440\u044b \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u043c\u0435\u0440\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0435\u0451 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0441\u0442\u043e\u0440\u043e\u043d. \u042f \u0441\u0434\u0435\u043b\u0430\u043b \u044d\u0442\u043e \u0432 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u043d\u0438\u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>GetFrustumCorners<\/code>:<\/p>\n<pre><code class=\"cs\">\/\/\/ \\brief Stores the normalized rays representing the camera frustum in a 4x4 matrix.  Each row is a vector. \/\/\/  \/\/\/ The following rays are stored in each row (in eyespace, not worldspace): \/\/\/ Top Left corner:     row=0 \/\/\/ Top Right corner:    row=1 \/\/\/ Bottom Right corner: row=2 \/\/\/ Bottom Left corner:  row=3 private Matrix4x4 GetFrustumCorners(Camera cam) {     float camFov = cam.fieldOfView;     float camAspect = cam.aspect;      Matrix4x4 frustumCorners = Matrix4x4.identity;      float fovWHalf = camFov * 0.5f;      float tan_fov = Mathf.Tan(fovWHalf * Mathf.Deg2Rad);      Vector3 toRight = Vector3.right * tan_fov * camAspect;     Vector3 toTop = Vector3.up * tan_fov;      Vector3 topLeft = (-Vector3.forward - toRight + toTop);     Vector3 topRight = (-Vector3.forward + toRight + toTop);     Vector3 bottomRight = (-Vector3.forward + toRight - toTop);     Vector3 bottomLeft = (-Vector3.forward - toRight - toTop);      frustumCorners.SetRow(0, topLeft);     frustumCorners.SetRow(1, topRight);     frustumCorners.SetRow(2, bottomRight);     frustumCorners.SetRow(3, bottomLeft);      return frustumCorners; }<\/code><\/pre>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0436\u0435 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e\u0431 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Matrix4x4<\/code>, \u0430 \u043d\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 Vector3. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0448\u0435\u0439\u0434\u0435\u0440\u0443 \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 (\u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432). \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043b\u0443\u0447\u0438 \u0443\u0433\u043b\u043e\u0432 \u043f\u0438\u0440\u0430\u043c\u0438\u0434\u044b \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0432 <em>\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0433\u043b\u0430\u0437\u0430 (eye space)<\/em>. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e (0,0,0) \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u043a\u0430\u043c\u0435\u0440\u044b, \u0430 \u0441\u0430\u043c\u0438 \u043b\u0443\u0447\u0438 \u0438\u0441\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043a\u0430\u043c\u0435\u0440\u044b (\u0430 \u043d\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043c\u0438\u0440\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 (worldspace)).<\/p>\n<h4>\u042d\u0442\u0430\u043f 2: \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043b\u0443\u0447\u0438 \u0432 GPU<\/h4>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0432 \u0441\u043a\u0440\u0438\u043f\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cs\">[ImageEffectOpaque] void OnRenderImage(RenderTexture source, RenderTexture destination) {     if (!EffectMaterial)     {         Graphics.Blit(source, destination); \/\/ do nothing         return;     }      \/\/ pass frustum rays to shader     EffectMaterial.SetMatrix(&quot;_FrustumCornersES&quot;, GetFrustumCorners(CurrentCamera));     EffectMaterial.SetMatrix(&quot;_CameraInvViewMatrix&quot;, CurrentCamera.cameraToWorldMatrix);     EffectMaterial.SetVector(&quot;_CameraWS&quot;, CurrentCamera.transform.position);      Graphics.Blit(source, destination, EffectMaterial, 0); \/\/ use given effect shader as image effect }<\/code><\/pre>\n<p>  \u041f\u043e\u0437\u0436\u0435, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0430\u0447\u043d\u0451\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 \u0441\u0430\u043c\u0438\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 uniform <code>_FrustumCornersES<\/code>. \u0422\u0430\u043a\u0436\u0435 \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0439\u0441\u044f \u043a \u043a\u0430\u043c\u0435\u0440\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u043f\u043e\u0437\u0436\u0435 (<code>_CameraInvViewMatrix<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043b\u0443\u0447\u0435\u0439 \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0433\u043b\u0430\u0437\u0430 \u0432 \u043c\u0438\u0440\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e, \u0430 <code>_CameraWS<\/code> \u2014 \u044d\u0442\u043e \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043a\u0430\u043c\u0435\u0440\u044b).<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b. \u041f\u043e\u043c\u043d\u0438\u0442\u0435: \u044d\u0444\u0444\u0435\u043a\u0442 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 <code>_FrustumCornersES<\/code>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0437\u0430\u043c\u0435\u043d\u0443 <code>Graphics.Blit<\/code> (\u0441\u043c. \u0441\u0442\u0440\u043e\u043a\u0443 13 \u0432\u044b\u0448\u0435). \u0412 \u044d\u0442\u043e\u0439 \u0438\u0437\u043c\u0435\u043d\u0451\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b\u0438 \u0445\u0438\u0442\u0440\u044b\u0439 \u0442\u0440\u044e\u043a: \u0442\u0430\u043a \u043a\u0430\u043a \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0432 <code>Graphics.Blit<\/code> \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <a href=\"http:\/\/blender.stackexchange.com\/questions\/648\/what-are-the-differences-between-orthographic-and-perspective-views\" rel=\"nofollow\">\u043e\u0440\u0442\u043e\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0446\u0438\u0438<\/a>, \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043f\u043e <code>z<\/code> \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b <code>_FrustumCornersES<\/code> \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 <code>z<\/code> \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b! \u0417\u0432\u0443\u0447\u0438\u0442 \u0441\u043b\u043e\u0436\u043d\u043e, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e:<\/p>\n<pre><code class=\"cs\">\/\/\/ \\brief Custom version of Graphics.Blit that encodes frustum corner indices into the input vertices. \/\/\/  \/\/\/ In a shader you can expect the following frustum cornder index information to get passed to the z coordinate: \/\/\/ Top Left vertex:     z=0, u=0, v=0 \/\/\/ Top Right vertex:    z=1, u=1, v=0 \/\/\/ Bottom Right vertex: z=2, u=1, v=1 \/\/\/ Bottom Left vertex:  z=3, u=1, v=0 \/\/\/  \/\/\/ \\warning You may need to account for flipped UVs on DirectX machines due to differing UV semantics \/\/\/          between OpenGL and DirectX.  Use the shader define UNITY_UV_STARTS_AT_TOP to account for this. static void CustomGraphicsBlit(RenderTexture source, RenderTexture dest, Material fxMaterial, int passNr) {     RenderTexture.active = dest;      fxMaterial.SetTexture(&quot;_MainTex&quot;, source);      GL.PushMatrix();     GL.LoadOrtho(); \/\/ Note: z value of vertices don't make a difference because we are using ortho projection      fxMaterial.SetPass(passNr);      GL.Begin(GL.QUADS);      \/\/ Here, GL.MultitexCoord2(0, x, y) assigns the value (x, y) to the TEXCOORD0 slot in the shader.     \/\/ GL.Vertex3(x,y,z) queues up a vertex at position (x, y, z) to be drawn.  Note that we are storing     \/\/ our own custom frustum information in the z coordinate.     GL.MultiTexCoord2(0, 0.0f, 0.0f);     GL.Vertex3(0.0f, 0.0f, 3.0f); \/\/ BL      GL.MultiTexCoord2(0, 1.0f, 0.0f);     GL.Vertex3(1.0f, 0.0f, 2.0f); \/\/ BR      GL.MultiTexCoord2(0, 1.0f, 1.0f);     GL.Vertex3(1.0f, 1.0f, 1.0f); \/\/ TR      GL.MultiTexCoord2(0, 0.0f, 1.0f);     GL.Vertex3(0.0f, 1.0f, 0.0f); \/\/ TL          GL.End();     GL.PopMatrix(); }  \/\/ ...  void OnRenderImage(RenderTexture source, RenderTexture destination) {     \/\/ ...     EffectMaterial.SetMatrix(&quot;_FrustumCornersES&quot;, GetFrustumCorners(CurrentCamera));      CustomGraphicsBlit(source, destination, EffectMaterial, 0); \/\/ Replace Graphics.Blit with CustomGraphicsBlit }<\/code><\/pre>\n<p>  \u0412 \u043e\u0431\u044b\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>Graphics.Blit<\/code> \u0432\u0441\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <code>GL.Vertex3<\/code> \u0431\u0443\u0434\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b z, \u0440\u0430\u0432\u043d\u044b\u0435 0. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u044b \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0435 z \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432 <code>_FrustumCornersES<\/code>.<\/p>\n<h4>\u042d\u0442\u0430\u043f 3: \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u043b\u0443\u0447\u0435\u0439 \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0433\u043e\u0442\u043e\u0432\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043f\u0438\u0441\u0430\u0442\u044c \u0448\u0435\u0439\u0434\u0435\u0440 raymarching-\u0430. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u0441\u043d\u043e\u0432\u044b \u044f \u043d\u0430\u0447\u043d\u0443 \u0441\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f (Assets &gt; Create &gt; Shader &gt; Image Effects Shader). \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043b <code>_FrustumCornersES<\/code>:<\/p>\n<pre><code class=\"cs\">\/\/ Provided by our script uniform float4x4 _FrustumCornersES; uniform sampler2D _MainTex; uniform float4 _MainTex_TexelSize; uniform float4x4 _CameraInvViewMatrix;  \/\/ Input to vertex shader struct appdata {     \/\/ Remember, the z value here contains the index of _FrustumCornersES to use     float4 vertex : POSITION;     float2 uv : TEXCOORD0; };  \/\/ Output of vertex shader \/ input to fragment shader struct v2f {     float4 pos : SV_POSITION;     float2 uv : TEXCOORD0;     float3 ray : TEXCOORD1; };  v2f vert (appdata v) {     v2f o;          \/\/ Index passed via custom blit function in RaymarchGeneric.cs     half index = v.vertex.z;     v.vertex.z = 0.1;          o.pos = mul(UNITY_MATRIX_MVP, v.vertex);     o.uv = v.uv.xy;          #if UNITY_UV_STARTS_AT_TOP     if (_MainTex_TexelSize.y &lt; 0)         o.uv.y = 1 - o.uv.y;     #endif      \/\/ Get the eyespace view ray (normalized)     o.ray = _FrustumCornersES[(int)index].xyz;      \/\/ Transform the ray from eyespace to worldspace     \/\/ Note: _CameraInvViewMatrix was provided by the script     o.ray = mul(_CameraInvViewMatrix, o.ray);     return o; }<\/code><\/pre>\n<p>  \u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0437\u043d\u0430\u043a\u043e\u043c\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c \u0433\u0440\u0430\u0444\u0438\u043a\u0438 Unity: \u043a\u0430\u043a \u0438 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u0432\u0435\u0440\u0448\u0438\u043d \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 UV \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443. \u0422\u0430\u043a\u0436\u0435 \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0442\u044c UV \u043f\u043e \u043e\u0441\u0438 Y, \u0447\u0442\u043e\u0431\u044b <a href=\"https:\/\/docs.unity3d.com\/Manual\/SL-PlatformDifferences.html\" rel=\"nofollow\">\u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0451\u0440\u043d\u0443\u0442\u043e\u0433\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445<\/a>. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043d\u0430\u043c \u043b\u0443\u0447 \u0438\u0437 <code>_FrustumCornersES<\/code> \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b Z \u0432\u0445\u043e\u0434\u044f\u0449\u0435\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b (\u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u044b\u043b\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b Z \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 2). \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 GPU \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u0443\u0435\u0442 \u043b\u0443\u0447\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043b\u0443\u0447\u0438 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435!<\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u0435\u0441\u0442\u0430 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0430:<\/p>\n<pre><code class=\"cs\">fixed4 frag (v2f i) : SV_Target {     fixed4 col = fixed4(i.ray, 1);     return col; }<\/code><\/pre>\n<p>  \u0412 Unity \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><video controls style=\"top: 0; left: 0; width: 100%; height: 100%; position: absolute;\">Your browser does not support HTML5 video.<source src=\"https:\/\/adrianb.io\/gfycat_old\/SaltyIckyFiddlercrab.mp4\" type=\"video\/mp4\"><\/source><\/video><\/div>\n<\/div>\n<\/div>\n<p>  <i>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043b\u0443\u0447\u0430 \u0432 \u043c\u0438\u0440\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u0437\u0435\u043b\u0451\u043d\u044b\u043c. \u041e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u043b\u0443\u0447\u0430 (0, 1, 0).<\/i><\/p>\n<h3>\u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439<\/h3>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0447\u0442\u043e <strong>\u043f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439<\/strong> \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0442\u043e, \u0447\u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c (\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 3D-\u043c\u043e\u0434\u0435\u043b\u0435\u0439\/\u043c\u0435\u0448\u0435\u0439 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0435\u0440\u0430). \u041d\u0430\u0448\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0442\u043e\u0447\u043a\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0434\u043e \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0441\u0446\u0435\u043d\u0435. \u0415\u0441\u043b\u0438 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0442\u043e \u043f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e.<\/p>\n<p>  \u041f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u2014 \u044d\u0442\u043e \u043d\u0435\u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0442\u0435\u043c\u0430, \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0432 \u0418\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0435\u0441\u0442\u044c \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043f\u0440\u043e \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 <a href=\"http:\/\/iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm\" rel=\"nofollow\">\u044d\u0442\u043e\u043c \u043f\u043e\u0442\u0440\u044f\u0441\u0430\u044e\u0449\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435 \u0418\u043d\u0438\u0433\u043e \u041a\u0438\u043b\u0435\u0437\u0430 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439<\/a>. \u0414\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u044f \u043f\u043e\u0437\u0430\u0438\u043c\u0441\u0442\u0432\u0443\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0443 \u0418\u043d\u0438\u0433\u043e \u0438 \u043e\u0442\u0440\u0438\u0441\u0443\u044e \u0432 \u0442\u043e\u0447\u043a\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0442\u043e\u0440:<\/p>\n<pre><code class=\"cs\">\/\/ Torus \/\/ t.x: diameter \/\/ t.y: thickness \/\/ Adapted from: http:\/\/iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm float sdTorus(float3 p, float2 t) {     float2 q = float2(length(p.xz) - t.x, p.y);     return length(q) - t.y; }  \/\/ This is the distance field function.  The distance field represents the closest distance to the surface \/\/ of any object we put in the scene.  If the given point (point p) is inside of an object, we return a \/\/ negative answer. float map(float3 p) {     return sdTorus(p, float2(1, 0.2)); }<\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <code>map<\/code> \u0437\u0430\u0434\u0430\u0451\u0442 \u043f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0435\u0435 \u0442\u043e\u0440 \u0434\u0438\u0430\u043c\u0435\u0442\u0440\u043e\u043c 1.0 \u0438 \u0442\u043e\u043b\u0449\u0438\u043d\u043e\u0439 0.2, \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0441\u0446\u0435\u043d\u044b. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>map<\/code> \u2014 \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0430\u0441\u043f\u0435\u043a\u0442 raymarching-\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043d\u0435\u0439! \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b, \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043e\u0432 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u044b! \u041f\u043e\u0432\u0442\u043e\u0440\u044e\u0441\u044c, \u0432\u0430\u043c \u0441\u0442\u043e\u0438\u0442 <a href=\"http:\/\/iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm\" rel=\"nofollow\">\u0438\u0437\u0443\u0447\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0440\u0435\u0441\u0443\u0440\u0441, \u0447\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439<\/a>.<\/p>\n<h3>\u041f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e Raymarch-\u0430<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u0443\u0434\u0435\u043c \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0446\u0438\u043a\u043b raymarch-\u0430. \u042d\u0442\u043e\u0442 \u0446\u0438\u043a\u043b \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0437 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430; \u043a\u0430\u043a \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043e \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0442\u0430, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0437\u0430 \u00ab\u0448\u0430\u0433\u0430\u043d\u0438\u0435\u00bb (marching) \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0434\u043e\u043b\u044c \u043b\u0443\u0447\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f. \u0424\u0443\u043d\u043a\u0446\u0438\u044f raymarch-\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0446\u0432\u0435\u0442 \u0442\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0441\u0442\u043e\u043b\u043a\u043d\u0451\u0442\u0441\u044f \u043b\u0443\u0447 (\u0438\u043b\u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0435\u0441\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d). \u041f\u043e \u0441\u0443\u0442\u0438, \u0444\u0443\u043d\u043a\u0446\u0438\u044f raymarch-\u0430 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u043f\u0440\u043e\u0441\u0442\u043e\u043c\u0443 \u0446\u0438\u043a\u043b\u0443 <code>for<\/code>, \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"cs\">\/\/ Raymarch along given ray \/\/ ro: ray origin \/\/ rd: ray direction fixed4 raymarch(float3 ro, float3 rd) {     fixed4 ret = fixed4(0,0,0,0);      const int maxstep = 64;     float t = 0; \/\/ current distance traveled along ray     for (int i = 0; i &lt; maxstep; ++i) {         float3 p = ro + rd * t; \/\/ World space position of sample         float d = map(p);       \/\/ Sample of distance field (see map())          \/\/ If the sample &lt;= 0, we have hit something (see map()).         if (d &lt; 0.001) {             \/\/ Simply return a gray color if we have hit an object             \/\/ We will deal with lighting later.             ret = fixed4(0.5, 0.5, 0.5, 1);             break;         }          \/\/ If the sample &gt; 0, we haven't hit anything yet so we should march forward         \/\/ We step forward by distance d, because d is the minimum distance possible to intersect         \/\/ an object (see map()).         t += d;     }      return ret; }<\/code><\/pre>\n<p>  \u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0446\u0438\u043a\u043b\u0430 raymarch-\u0430 \u043c\u044b \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u0443\u0435\u043c \u0442\u043e\u0447\u043a\u0443 \u0432\u0434\u043e\u043b\u044c \u043b\u0443\u0447\u0430. \u0415\u0441\u043b\u0438 \u043c\u044b \u0441 \u0447\u0435\u043c-\u0442\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0451\u043c\u0441\u044f, \u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u043c \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0446\u0432\u0435\u0442 (\u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0446\u0432\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430). \u0415\u0441\u043b\u0438 \u043c\u044b \u043d\u0438 \u0441 \u0447\u0435\u043c \u043d\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0451\u043c\u0441\u044f (\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 <code>map<\/code> \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0443\u043b\u044f), \u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u0435\u043c\u0441\u044f \u0432\u043f\u0435\u0440\u0451\u0434 \u043d\u0430 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u043c\u043e\u0435 \u043d\u0430\u043c \u043f\u043e\u043b\u0435\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0442\u0430\u043b\u0438\u0441\u044c, \u0442\u043e \u0432\u0435\u0440\u043d\u0438\u0442\u0435\u0441\u044c \u043a \u0442\u0435\u043e\u0440\u0438\u0438, \u043e\u0431\u044a\u044f\u0441\u043d\u0451\u043d\u043d\u043e\u0439 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0441\u0446\u0435\u043d\u044b \u0441\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e\u043c \u043c\u0435\u043b\u043a\u0438\u0445 \u0434\u0435\u0442\u0430\u043b\u0435\u0439. \u0442\u043e \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 <code>maxstep<\/code> \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 7 (\u043d\u043e \u0440\u0430\u0441\u043f\u043b\u0430\u0447\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0430 \u044d\u0442\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438). \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0442\u0449\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c <code>maxstep<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0441\u044d\u043c\u043f\u043b\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c (\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0442\u043e\u0440\u0430 64 \u0441\u044d\u043c\u043f\u043b\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u043e\u043c, \u043d\u043e \u0440\u0430\u0434\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044e \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435).<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0437\u0432\u0430\u0442\u044c <code>raymarch()<\/code> \u0438\u0437 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043b\u0435\u0433\u043a\u043e:<\/p>\n<pre><code class=\"cs\">\/\/ Provided by our script uniform float3 _CameraWS;  \/\/ ...  fixed4 frag (v2f i) : SV_Target {     \/\/ ray direction     float3 rd = normalize(i.ray.xyz);     \/\/ ray origin (camera position)     float3 ro = _CameraWS;      fixed3 col = tex2D(_MainTex,i.uv); \/\/ Color of the scene before this shader was run     fixed4 add = raymarch(ro, rd);      \/\/ Returns final color using alpha blending     return fixed4(col*(1.0 - add.w) + add.xyz * add.w,1.0); }<\/code><\/pre>\n<p>  \u0412\u0441\u0451, \u0447\u0442\u043e \u043c\u044b \u0437\u0434\u0435\u0441\u044c \u0434\u0435\u043b\u0430\u0435\u043c \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0443\u0447\u0435\u0439 \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>raymarch()<\/code>. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441 <code>_MainTex<\/code> (\u0441\u0446\u0435\u043d\u043e\u0439, \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u043d\u043e\u0439 \u0434\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430) \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Alpha_compositing#Alpha_blending\" rel=\"nofollow\">\u0430\u043b\u044c\u0444\u0430-\u0441\u043c\u0435\u0448\u0438\u0432\u0430\u043d\u0438\u044f<\/a>. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e <code>_CameraWS<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u0437\u0438\u0446\u0438\u044e \u043a\u0430\u043c\u0435\u0440\u044b \u0432 \u043c\u0438\u0440\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438 \u0447\u0442\u043e \u0440\u0430\u043d\u0435\u0435 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435 C# \u043e\u043d\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u043b\u0430\u0441\u044c \u0448\u0435\u0439\u0434\u0435\u0440\u0443 \u043a\u0430\u043a uniform.<\/p>\n<p>  \u0421\u043d\u043e\u0432\u0430 \u043e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 Unity, \u0438 \u0443\u0437\u0440\u0438\u0442\u0435! \u0412\u043e\u0442 \u043e\u043d \u2014 \u0442\u043e\u0440!<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><video controls style=\"top: 0; left: 0; width: 100%; height: 100%; position: absolute;\">Your browser does not support HTML5 video.<source src=\"https:\/\/adrianb.io\/gfycat_old\/WholeWeirdFirefly.mp4\" type=\"video\/mp4\"><\/source><\/video><\/div>\n<\/div>\n<\/div>\n<p>  <i>\u0418 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u043e\u0432!<\/i><\/p>\n<h2>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041c\u044b \u0443\u0436\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u043b\u0438 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441: \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 raymarching-\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u044b \u0441 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c. \u041e\u0434\u043d\u0430\u043a\u043e, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0440\u0435\u043d\u0434\u0435\u0440\u0435\u043d\u043d\u044b\u0435 raymarching-\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0438\u0433\u0440\u0435 \u0431\u0435\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u043d\u0438\u0445 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f (\u0435\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u043d\u0435 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u0430\u044f \u0438\u0433\u0440\u0430).<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043d\u0430\u043c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0421\u0432\u0435\u0442 \u043e\u0442\u0440\u0430\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0445 \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439. \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0435\u0435, \u0442\u043e \u043b\u044e\u0431\u0430\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bidirectional_reflectance_distribution_function\" rel=\"nofollow\">BDRF<\/a> \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u043e\u0440\u043c\u0430\u043b\u044c \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438. \u0423 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e 3D-\u043c\u0435\u0448\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u043e\u0438\u0441\u043a \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430 \u2014 \u044d\u0442\u043e <a href=\"https:\/\/en.wikipedia.org\/wiki\/Cross_product\" rel=\"nofollow\">\u043b\u0435\u0433\u043a\u043e \u0440\u0435\u0448\u0430\u0435\u043c\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u0438 \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043d\u0435 \u0442\u0430\u043a \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e.<\/p>\n<p>  \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0432 \u043b\u044e\u0431\u043e\u0439 \u0442\u043e\u0447\u043a\u0435 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0432 \u043f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439, <em>\u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442<\/em> \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435, \u043a\u0430\u043a \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0435. \u0413\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c), \u043f\u043e \u0441\u0443\u0442\u0438, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u043b\u044f \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445 x, y \u0438 z. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f <em>d<\/em> \u043c\u044b \u0444\u0438\u043a\u0441\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438 \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u043d\u0443\u044e \u043f\u043e\u043b\u044f \u0432\u0434\u043e\u043b\u044c <em>d<\/em>. \u0418\u043d\u0442\u0443\u0438\u0442\u0438\u0432\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0440\u0430\u0441\u0442\u0451\u0442 \u043f\u0440\u0438 \u043f\u0440\u044f\u043c\u043e\u043c \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u0432\u0434\u0430\u043b\u044c \u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 (\u0442\u043e \u0435\u0441\u0442\u044c \u0432\u0434\u043e\u043b\u044c \u0435\u0433\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u0438). \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0432 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u043e\u0447\u043a\u0435, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u043d\u043e\u0440\u043c\u0430\u043b\u044c \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0435.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0430\u043f\u043f\u0440\u043e\u043a\u0441\u0438\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442 \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"cs\">float3 calcNormal(in float3 pos) {     \/\/ epsilon - used to approximate dx when taking the derivative     const float2 eps = float2(0.001, 0.0);      \/\/ The idea here is to find the &quot;gradient&quot; of the distance field at pos     \/\/ Remember, the distance field is not boolean - even if you are inside an object     \/\/ the number is negative, so this calculation still works.     \/\/ Essentially you are approximating the derivative of the distance field at this point.     float3 nor = float3(         map(pos + eps.xyy).x - map(pos - eps.xyy).x,         map(pos + eps.yxy).x - map(pos - eps.yxy).x,         map(pos + eps.yyx).x - map(pos - eps.yyx).x);     return normalize(nor); }<\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u0431\u0443\u0434\u044c\u0442\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b, \u0432\u0435\u0434\u044c \u044d\u0442\u0430 \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u0437\u0430\u0442\u0440\u0430\u0442\u043d\u0430! \u0414\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0435\u0449\u0451 \u0448\u0435\u0441\u0442\u044c \u0440\u0430\u0437 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u043e\u0441\u0432\u0435\u0449\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u043c\u0435\u0442\u044b! \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443, \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0441\u043a\u0440\u0438\u043f\u0442\u044b:<\/p>\n<pre><code class=\"cs\">\/\/ ...  public class TutorialRaymarch : SceneViewFilter {      \/\/ ...      public Transform SunLight;      \/\/ ...      void OnRenderImage(RenderTexture source, RenderTexture destination)     {         \/\/ ...          EffectMaterial.SetVector(&quot;_LightDir&quot;, SunLight ? SunLight.forward : Vector3.down);          \/\/ ...          CustomGraphicsBlit(source, destination, EffectMaterial, 0);     }      \/\/ ... }<\/code><\/pre>\n<p>  \u042d\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u043d\u0430\u0448\u0435\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443 \u0432\u0435\u043a\u0442\u043e\u0440, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u043b\u043d\u0446\u0430. \u0415\u0441\u043b\u0438 \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435, \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f\u0440\u043a\u043e\u0441\u0442\u044c \u0441\u0432\u0435\u0442\u0430, \u0446\u0432\u0435\u0442 \u0438 \u0442.\u0434.), \u043d\u043e \u043c\u044b \u043f\u043e\u043a\u0430 \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0438 \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435 \u0441 \u044f\u0440\u043a\u043e\u0441\u0442\u044c\u044e 1.0. \u042d\u0442\u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430\u0448\u0438\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c \u0447\u0435\u0440\u0435\u0437 uniform <code>_LightDir<\/code> \u0448\u0435\u0439\u0434\u0435\u0440\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>_LightDir<\/code> \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 <code>calcNormal()<\/code> \u0434\u043b\u044f \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cs\">\/\/ ...  uniform float3 _LightDir;  \/\/ ...  fixed4 raymarch(float3 ro, float3 rd) {     fixed4 ret = fixed4(0,0,0,0);      const int maxstep = 64;     float t = 0; \/\/ current distance traveled along ray     for (int i = 0; i &lt; maxstep; ++i) {         float3 p = ro + rd * t; \/\/ World space position of sample         float d = map(p);       \/\/ Sample of distance field (see map())          \/\/ If the sample &lt;= 0, we have hit something (see map()).         if (d &lt; 0.001) {             \/\/ Lambertian Lighting             float3 n = calcNormal(p);             ret = fixed4(dot(-_LightDir.xyz, n).rrr, 1);             break;         }          \/\/ If the sample &gt; 0, we haven't hit anything yet so we should march forward         \/\/ We step forward by distance d, because d is the minimum distance possible to intersect         \/\/ an object (see map()).         t += d;     }     return ret; }  \/\/ ...<\/code><\/pre>\n<p>  \u0412 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 18-20 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lambert%27s_cosine_law\" rel=\"nofollow\">\u043c\u043e\u0434\u0435\u043b\u044c \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u043f\u043e \u041b\u0430\u043c\u0431\u0435\u0440\u0442\u0443<\/a>, \u043d\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u0443\u044e \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u0432\u0448\u0443\u044e\u0441\u044f <a href=\"https:\/\/en.wikipedia.org\/wiki\/Bidirectional_reflectance_distribution_function\" rel=\"nofollow\">BDRF<\/a> (\u043f\u0440\u044f\u043c\u043e \u043a\u0430\u043a \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 3D-\u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438!). \u0412\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u0432 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 Unity \u0438 \u043d\u0430\u0437\u043d\u0430\u0447\u0438\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u00abSun Light\u00bb \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0443 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432 \u0441\u0446\u0435\u043d\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u043e\u0441\u0432\u0435\u0449\u0451\u043d\u043d\u044b\u0439 \u0442\u043e\u0440:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f72\/f0f\/0ad\/f72f0f0ad608dc2778a14f2449af591e.png\"><\/div>\n<p>  <i>\u041d\u0430\u0448 \u0442\u043e\u0440 \u0441 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u041b\u0430\u043c\u0431\u0435\u0440\u0442\u0443<\/i><\/p>\n<h2>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438\u0437 \u043c\u0435\u0448\u0435\u0439<\/h2>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u044b \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u0445 \u0432 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 Unity. \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0451\u0442\u0435\u0441\u044c \u0441 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439: \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u0437 \u043c\u0435\u0448\u0435\u0439 \u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 raymarching-\u043e\u043c, \u043d\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u0441\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0430! \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 raymarching-\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b <em>\u0432\u0441\u0435\u0433\u0434\u0430<\/em> \u043f\u043b\u0430\u0432\u0430\u044e\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e raymarcher \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0433\u043b\u0443\u0431\u0438\u043d\u0443. \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0440\u043e\u043b\u0438\u043a\u0435:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><video controls style=\"top: 0; left: 0; width: 100%; height: 100%; position: absolute;\">Your browser does not support HTML5 video.<source src=\"https:\/\/adrianb.io\/gfycat_old\/GrossThoroughEasternnewt.mp4\" type=\"video\/mp4\"><\/source><\/video><\/div>\n<\/div>\n<\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432\u0434\u043e\u043b\u044c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043b\u0443\u0447\u0430, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0437 \u043c\u0435\u0448\u0435\u0439. \u0415\u0441\u043b\u0438 \u043d\u0430\u0448 \u0446\u0438\u043a\u043b raymarch-\u0430 \u043f\u0440\u043e\u0448\u0430\u0433\u0430\u0435\u0442 \u0434\u0430\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438, \u0442\u043e \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u044b\u0445\u043e\u0434 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442 (\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u043b\u044e\u0431\u044b\u043c\u0438 \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c\u0438 raymarching-\u043e\u043c).<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u044d\u0442\u043e \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0443\u0444\u0435\u0440\u043e\u043c \u0433\u043b\u0443\u0431\u0438\u043d. \u0411\u0443\u0444\u0435\u0440 \u0433\u043b\u0443\u0431\u0438\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0439 \u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0441\u0446\u0435\u043d\u0435 \u0432 <em>\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0433\u043b\u0430\u0437\u0430<\/em>. \u0421\u043c. \u0440\u0438\u0441\u0443\u043d\u043e\u043a 5 \u043d\u0438\u0436\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f46\/df8\/75d\/f46df875db1d31609f19aeeaac39fff8.png\"><\/div>\n<p>  <i>\u0420\u0438\u0441\u0443\u043d\u043e\u043a 5: \u0441\u0445\u0435\u043c\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b \u043f\u0440\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0438 \u0433\u043b\u0443\u0431\u0438\u043d\u044b. \u041a\u0440\u0430\u0441\u043d\u0430\u044f \u043b\u0438\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u043b\u0443\u0447 \u0434\u043b\u044f \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f.<\/i><\/p>\n<p>  \u0412\u0435\u043b\u0438\u0447\u0438\u043d\u0430 <em>r<\/em> \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 5 \u2014 \u044d\u0442\u043e \u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 (\u0433\u043b\u0443\u0431\u0438\u043d\u0430, \u0434\u0430\u043b\u044c\u0448\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0432\u044b\u0439\u0442\u0438 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 raymarch). \u0412\u0435\u043b\u0438\u0447\u0438\u043d\u0430 <em>d<\/em> \u2014 \u044d\u0442\u043e \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0433\u043b\u0430\u0437\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0435\u0440\u0451\u043c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f \u0432 \u0431\u0443\u0444\u0435\u0440\u0435 \u0433\u043b\u0443\u0431\u0438\u043d (\u0437\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e <em>d<\/em> \u043a\u043e\u0440\u043e\u0447\u0435, \u0447\u0435\u043c <em>r<\/em>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <em>d<\/em> \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0443).<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 <em>r<\/em>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u043e\u0434\u043e\u0431\u0438\u044f \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u043e\u0432. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c <em>r<sub>n<\/sub><\/em>, \u0432\u0435\u043a\u0442\u043e\u0440 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0438 \u0443 <em>r<\/em>, \u043d\u043e \u0438\u043c\u0435\u044e\u0449\u0438\u0439 \u0434\u043b\u0438\u043d\u0443 1.0 \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 z. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c <em>r<sub>n<\/sub><\/em> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <i>r<sub>n<\/sub> = r<sub>d<\/sub><\/i> \u00f7 (<i>r<sub>d<\/sub><\/i>)<i>.z<\/i><\/p>\n<p>  \u0412 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 <em>r<sub>d<\/sub><\/em> \u2014 \u044d\u0442\u043e \u0432\u0435\u043a\u0442\u043e\u0440 \u0441 \u0442\u0435\u043c \u0436\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c, \u0447\u0442\u043e \u0438 <em>r<\/em>, \u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u044b (\u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0432\u0435\u043a\u0442\u043e\u0440 \u043b\u0443\u0447\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442\u0441\u044f \u043d\u0430\u0448\u0435\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443). \u0418\u0437 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 5 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e <em>r<\/em> \u0438 <em>r<sub>n<\/sub><\/em> \u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442 \u0434\u0432\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430. \u0423\u043c\u043d\u043e\u0436\u0438\u0432 <em>r<sub>n<\/sub><\/em> \u043d\u0430 <em>d<\/em> (\u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430 \u0433\u043b\u0443\u0431\u0438\u043d), \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c <em>r<\/em> \u0438 \u0435\u0433\u043e \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  | <i>r<\/i> | \/ <i>d<\/i> = <i>r<sub>d<\/sub><\/i> \/ 1.0<br \/>  | <i>r<\/i> | = <i>r<sub>d<\/sub><\/i> \u00d7 <i>d<\/i><\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0431\u0443\u0444\u0435\u0440 \u0433\u043b\u0443\u0431\u0438\u043d \u0432 \u043d\u0430\u0448\u0435\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0435<\/h3>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u043a\u043e\u0435-\u043a\u0430\u043a\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0439 \u0432\u044b\u0448\u0435 \u0442\u0435\u043e\u0440\u0438\u0438. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b <em>r<sub>n<\/sub><\/em> \u0432\u043c\u0435\u0441\u0442\u043e <em>r<sub>d<\/sub><\/em>:<\/p>\n<pre><code class=\"cs\">v2f vert (appdata v) {     \/\/ ...      \/\/ Dividing by z &quot;normalizes&quot; it in the z axis     \/\/ Therefore multiplying the ray by some number i gives the viewspace position     \/\/ of the point on the ray with [viewspace z]=i     o.ray \/= abs(o.ray.z);      \/\/ Transform the ray from eyespace to worldspace     o.ray = mul(_CameraInvViewMatrix, o.ray);      return o; }<\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u043b\u0438\u043c \u043d\u0430 <code>abs(o.ray.z)<\/code>, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430 <code>o.ray.z<\/code>. \u042d\u0442\u043e \u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0433\u043b\u0430\u0437\u0430 <code>z &lt; 0<\/code> \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044e \u0432\u043f\u0435\u0440\u0451\u0434. \u0415\u0441\u043b\u0438 \u043c\u044b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u043d\u0430 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u043e \u043f\u0440\u0438 \u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0430 \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f (\u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u0451\u0440\u043d\u0443\u0442\u043e\u0439 \u0438 \u0441\u0430\u043c\u0430 \u0441\u0446\u0435\u043d\u0430, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f raymarching-\u043e\u043c).<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u043d\u0438\u0435 \u0433\u043b\u0443\u0431\u0438\u043d\u044b \u0432 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0438 \u0446\u0438\u043a\u043b raymarch:<\/p>\n<pre><code class=\"cs\">\/\/ Raymarch along given ray \/\/ ro: ray origin \/\/ rd: ray direction \/\/ s: unity depth buffer fixed4 raymarch(float3 ro, float3 rd, float s) {     fixed4 ret = fixed4(0,0,0,0);      const int maxstep = 64;     float t = 0; \/\/ current distance traveled along ray     for (int i = 0; i &lt; maxstep; ++i) {         \/\/ If we run past the depth buffer, stop and return nothing (transparent pixel)         \/\/ this way raymarched objects and traditional meshes can coexist.         if (t &gt;= s) {             ret = fixed4(0, 0, 0, 0);             break;         }          \/\/ ...     }      return ret; }  \/\/ ... uniform sampler2D _CameraDepthTexture; \/\/ ...  fixed4 frag (v2f i) : SV_Target {     \/\/ ray direction     float3 rd = normalize(i.ray.xyz);     \/\/ ray origin (camera position)     float3 ro = _CameraWS;      float2 duv = i.uv;     #if UNITY_UV_STARTS_AT_TOP     if (_MainTex_TexelSize.y &lt; 0)         duv.y = 1 - duv.y;     #endif      \/\/ Convert from depth buffer (eye space) to true distance from camera     \/\/ This is done by multiplying the eyespace depth by the length of the &quot;z-normalized&quot;     \/\/ ray (see vert()).  Think of similar triangles: the view-space z-distance between a point     \/\/ and the camera is proportional to the absolute distance.     float depth = LinearEyeDepth(tex2D(_CameraDepthTexture, duv).r);     depth *= length(i.ray.xyz);      fixed3 col = tex2D(_MainTex,i.uv);     fixed4 add = raymarch(ro, rd, depth);      \/\/ Returns final color using alpha blending     return fixed4(col*(1.0 - add.w) + add.xyz * add.w,1.0); }<\/code><\/pre>\n<p>  \u0412 \u0441\u0442\u0440\u043e\u043a\u0435 45 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0435 \u0433\u043b\u0443\u0431\u0438\u043d Unity \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e uniform <code>_CameraDepthTexture<\/code> \u0448\u0435\u0439\u0434\u0435\u0440\u0430 Unity \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0435\u0451 \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0433\u043b\u0430\u0437\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>LinearEyeDepth()<\/code>. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0430\u0445 \u0433\u043b\u0443\u0431\u0438\u043d \u0438 Unity \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 <a href=\"https:\/\/docs.unity3d.com\/Manual\/SL-CameraDepthTexture.html\" rel=\"nofollow\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u0438\u0437 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0430 Unity<\/a>. \u0414\u0430\u043b\u0435\u0435, \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 46 \u043c\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043d\u0430 \u0434\u043b\u0438\u043d\u0443 <em>r<sub>n<\/sub><\/em>, \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043d\u0430\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u043d\u044b\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u043c, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u0432\u0441\u0451 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u043a\u0430\u043a \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>raymarch()<\/code>. \u0412 \u0446\u0438\u043a\u043b\u0435 raymarch \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432\u044b\u0445\u043e\u0434 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u044b\u0439 \u0446\u0432\u0435\u0442, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0448\u0430\u0433\u0430\u043b\u0438 \u0437\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0431\u0443\u0444\u0435\u0440\u043e\u043c \u0433\u043b\u0443\u0431\u0438\u043d (\u0441\u043c. \u0441\u0442\u0440\u043e\u043a\u0438 13-16). \u0415\u0441\u043b\u0438 \u043c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u0432 Unity, \u0442\u043e \u043d\u0430\u0448\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 raymarching-\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0441 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 \u0438\u0437 \u043c\u0435\u0448\u0435\u0439:<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><video controls style=\"top: 0; left: 0; width: 100%; height: 100%; position: absolute;\">Your browser does not support HTML5 video.<source src=\"https:\/\/adrianb.io\/gfycat_old\/SimpleInfiniteBlackandtancoonhound.mp4\" type=\"video\/mp4\"><\/source><\/video><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u0420\u0430\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439<\/h2>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0448 raymarcher \u0433\u043e\u0442\u043e\u0432 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u0441\u0446\u0435\u043d! \u041a\u0430\u043a \u044f \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0432\u044b\u0448\u0435, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0433\u043b\u0443\u0431\u043e\u043a\u0430\u044f \u043a\u0440\u043e\u043b\u0438\u0447\u044c\u044f \u043d\u043e\u0440\u0430, \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0437\u0430 \u0440\u0430\u043c\u043a\u0430\u043c\u0438 \u0441\u0442\u0430\u0442\u044c\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u044f \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043b. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0434\u043b\u044f \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0430 <a href=\"https:\/\/www.shadertoy.com\" rel=\"nofollow\">Shadertoy<\/a>. \u041a\u0430\u043a \u0431\u044b \u0442\u043e \u043d\u0438 \u0431\u044b\u043b\u043e, \u043d\u0438\u0436\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c:<\/p>\n<h3>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>  \u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 3D-\u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438 \u0438\u0437 \u043c\u0435\u0448\u0435\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/solarianprogrammer.com\/2013\/05\/22\/opengl-101-matrices-projection-view-model\/\" rel=\"nofollow\">\u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043c\u043e\u0434\u0435\u043b\u0438<\/a>. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c <em>\u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u043e\u0434\u0435\u043b\u0438<\/em>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u043d\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u043c \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0442\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u044d\u043c\u043f\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439.<\/p>\n<p>  \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u0438\u0445 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443:<\/p>\n<pre><code class=\"cs\">[ImageEffectOpaque] void OnRenderImage(RenderTexture source, RenderTexture destination) {     \/\/ ...          \/\/ Construct a Model Matrix for the Torus     Matrix4x4 MatTorus = Matrix4x4.TRS(         Vector3.right * Mathf.Sin(Time.time) * 5,          Quaternion.identity,         Vector3.one);     MatTorus *= Matrix4x4.TRS(         Vector3.zero,          Quaternion.Euler(new Vector3(0, 0, (Time.time * 200) % 360)),          Vector3.one);     \/\/ Send the torus matrix to our shader     EffectMaterial.SetMatrix(&quot;_MatTorus_InvModel&quot;, MatTorus.inverse);      \/\/ ... }<\/code><\/pre>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u0443\u0447\u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>Time.time<\/code> \u0434\u043b\u044f \u0430\u043d\u0438\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u043d\u0430\u0448\u0435\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439 Unity) \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u044d\u0442\u0438\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0451 \u043a \u0442\u043e\u0440\u0443:<\/p>\n<pre><code class=\"cs\">uniform float4x4 _MatTorus_InvModel;  float map(float3 p) {     float4 q = mul(_MatTorus_InvModel, float4(p,1));          return sdTorus(q.xyz, float2(1, 0.2)); }<\/code><\/pre>\n<p>  \u0412\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u0442\u043e\u0440 \u0432 Unity \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0434\u0432\u0438\u0436\u0435\u0442\u0441\u044f \u0432\u043f\u0435\u0440\u0451\u0434-\u043d\u0430\u0437\u0430\u0434 (\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0440\u0435\u0436\u0438\u043c Play, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e):<\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><video controls style=\"top: 0; left: 0; width: 100%; height: 100%; position: absolute;\">Your browser does not support HTML5 video.<source src=\"https:\/\/adrianb.io\/gfycat_old\/TalkativeHopefulHowlermonkey.mp4\" type=\"video\/mp4\"><\/source><\/video><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u041a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b<\/h3>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u0430\u043a\u0436\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0444\u043e\u0440\u043c\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 \u043a\u043e\u043c\u0431\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439: <code>opU()<\/code> (Union, \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435), <code>opI()<\/code> (Intersection, \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435) \u0438 <code>opS()<\/code> (Subtraction, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435). \u041d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439, \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u044d\u0442\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439:<\/p>\n<pre><code class=\"cs\">\/\/ Box \/\/ b: size of box in x\/y\/z \/\/ Adapted from: http:\/\/iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm float sdBox(float3 p, float3 b) {     float3 d = abs(p) - b;     return min(max(d.x, max(d.y, d.z)), 0.0) +         length(max(d, 0.0)); }  \/\/ Union \/\/ Adapted from: http:\/\/iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm float opU( float d1, float d2 ) {     return min(d1,d2); }  \/\/ Subtraction \/\/ Adapted from: http:\/\/iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm float opS( float d1, float d2 ) {     return max(-d1,d2); }  \/\/ Intersection \/\/ Adapted from: http:\/\/iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm float opI( float d1, float d2 ) {     return max(d1,d2); }  float map(float3 p) {     float union_box = opU(         sdBox(p - float3(-4.5, 0.5, 0), float3(1,1,1)),          sdBox(p - float3(-3.5, -0.5, 0), float3(1,1,1))     );     float subtr_box = opS(         sdBox(p - float3(-0.5, 0.5, 0), float3(1,1,1.01)),          sdBox(p - float3(0.5, -0.5, 0), float3(1,1,1))     );     float insec_box = opI(         sdBox(p - float3(3.5, 0.5, 0), float3(1,1,1)),          sdBox(p - float3(4.5, -0.5, 0), float3(1,1,1))     );      float ret = opU(union_box, subtr_box);     ret = opU(ret, insec_box);          return ret; }<\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432 Unity:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/a61\/a7c\/710\/a61a7c710901cf728a45bca00f5854e2.png\"><\/div>\n<p>  <i>\u0421\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e: \u0441\u043e\u043f\u0440\u044f\u0436\u0435\u043d\u0438\u0435, \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435 \u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435<\/i><\/p>\n<h3>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432<\/h3>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u043b\u0430 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432. \u041f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>map()<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u2014 \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435 \u043c\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0446\u0432\u0435\u0442 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b <em>\u043b\u0438\u043d\u0435\u0439\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430<\/em>. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0448\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>opU()<\/code>.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/86c\/81b\/02d\/86c81b02dab7e1059395d0fd4aafe579.png\"><\/div>\n<p>  <i>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043c\u043d\u043e\u0439 \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d (Color Ramp).<\/i><\/p>\n<p>  \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c color ramp \u043d\u0430\u0448\u0435\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u043a\u0440\u0438\u043f\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cs\">[SerializeField] private Texture2D _ColorRamp;  \/\/ ...  [ImageEffectOpaque] void OnRenderImage(RenderTexture source, RenderTexture destination) {     \/\/ ...      EffectMaterial.SetTexture(&quot;_ColorRamp&quot;, _ColorRamp);      \/\/ ... }<\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 uniform <code>_ColorRamp<\/code> \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432, \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c <code>map()<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f \u0432 <code>raymarch()<\/code>.<\/p>\n<pre><code class=\"cs\">uniform sampler2D _ColorRamp;  \/\/ ...  \/\/ Union (with material data) float2 opU( float2 d1, float2 d2 ) {     return (d1.x &lt; d2.x) ? d1 : d2; }  \/\/ Notice how map() now returns a float2 \/\/ \\return.x: Distance field value \/\/ \\return.y: Color of closest object (0 - 1) float2 map(float3 p) {     float2 d_torus = float2(sdTorus(p, float2(1, 0.2)), 0.5);     float2 d_box = float2(sdBox(p - float3(-3,0,0), float3(0.75,0.5,0.5)), 0.25);     float2 d_sphere = float2(sdSphere(p - float3(3,0,0), 1), 0.75);      float2 ret = opU(d_torus, d_box);     ret = opU(ret, d_sphere);          return ret; }  fixed4 raymarch(float3 ro, float3 rd, float s) {     fixed4 ret = fixed4(0,0,0,0);      const int maxstep = 64;     float t = 0; \/\/ current distance traveled along ray     for (int i = 0; i &lt; maxstep; ++i) {         \/\/ ...          float3 p = ro + rd * t; \/\/ World space position of sample         float2 d = map(p);      \/\/ Sample of distance field (see map())                                 \/\/ d.x: distance field output                                 \/\/ d.y: material data          \/\/ If the sample &lt;= 0, we have hit something (see map()).         if (d.x &lt; 0.001) {             float3 n = calcNormal(p);             float light = dot(-_LightDir.xyz, n);             \/\/ Use y value given by map() to choose a color from our Color Ramp             ret = fixed4(tex2D(_ColorRamp, float2(d.y,0)).xyz * light, 1);             break;         }          \/\/ ...     }      return ret; }<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0446\u0432\u0435\u0442\u0430\u043c\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/528\/62a\/b6c\/52862ab6c26622abf1ea4847d01093c2.png\"><\/div>\n<p>  <i>Raymarching \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u043c\u0438<\/i><\/p>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p>  \u0427\u0430\u0441\u0442\u044c \u043d\u0430\u043c \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c raymarch-\u0448\u0435\u0439\u0434\u0435\u0440\u0430. \u041b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432, \u043a\u0430\u043a \u0447\u0430\u0441\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u0430\u0434\u0440\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>map()<\/code>. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u0443\u044e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u044d\u0442\u043e\u0433\u043e, \u0438\u0437\u043c\u0435\u043d\u0438\u0432 <code>raymarch()<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u043b\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u044d\u043c\u043f\u043b\u043e\u0432 \u043d\u0430 \u043a\u0430\u0434\u0440. \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u044f\u0436\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u044d\u043c\u043f\u043b\u043e\u0432 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u043f\u0438\u043a\u0441\u0435\u043b\u0435 \u043a Color Ramp, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435.<\/p>\n<pre><code class=\"cs\">fixed4 raymarch(float3 ro, float3 rd, float s) {     const int maxstep = 64;     float t = 0; \/\/ current distance traveled along ray      for (int i = 0; i &lt; maxstep; ++i) {         float3 p = ro + rd * t; \/\/ World space position of sample         float2 d = map(p);      \/\/ Sample of distance field (see map())          \/\/ If the sample &lt;= 0, we have hit something (see map()).         if (d.x &lt; 0.001) {             \/\/ Simply return the number of steps taken, mapped to a color ramp.             float perf = (float)i \/ maxstep;             return fixed4(tex2D(_ColorRamp, float2(perf, 0)).xyz, 1);         }          t += d;     }      \/\/ By this point the loop guard (i &lt; maxstep) is false.  Therefore     \/\/ we have reached maxstep steps.     return fixed4(tex2D(_ColorRamp, float2(1, 0)).xyz, 1); }<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Unity:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/b4e\/1a8\/5dd\/b4e1a85dd4bb7ae9bf212ba53fafb4e0.png\"><\/div>\n<p>  <i>\u0412\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0421\u0438\u043d\u0438\u0439 = \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432, \u043a\u0440\u0430\u0441\u043d\u044b\u0439 = \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0448\u0430\u0433\u043e\u0432.<\/i><\/p>\n<p>  \u041f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u0430\u044f \u0432\u044b\u0448\u0435 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u0442 \u0441\u0435\u0440\u044c\u0451\u0437\u043d\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u041f\u0438\u043a\u0441\u0435\u043b\u0438, \u043d\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 raymarching-\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (\u0430 \u0442\u0430\u043a\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e) \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0448\u0430\u0433\u043e\u0432! \u042d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e: \u0438\u0441\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u0435 \u0438\u0437 \u044d\u0442\u0438\u0445 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u043b\u0443\u0447\u0438 \u043d\u0438 \u0441 \u0447\u0435\u043c \u043d\u0435 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0448\u0430\u0433\u0430\u044e\u0442 \u0432\u043f\u0435\u0440\u0451\u0434. \u0427\u0442\u043e\u0431\u044b \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438:<\/p>\n<pre><code class=\"cs\">fixed4 raymarch(float3 ro, float3 rd, float s) {     const int maxstep = 64;     const float drawdist = 40; \/\/ draw distance in unity units      float t = 0; \/\/ current distance traveled along ray      for (int i = 0; i &lt; maxstep; ++i) {         float3 p = ro + rd * t; \/\/ World space position of sample         float2 d = map(p);      \/\/ Sample of distance field (see map())          \/\/ If the sample &lt;= 0, we have hit something (see map()).         \/\/ If t &gt; drawdist, we can safely bail because we have reached the max draw distance         if (d.x &lt; 0.001 || t &gt; drawdist) {             \/\/ Simply return the number of steps taken, mapped to a color ramp.             float perf = (float)i \/ maxstep;             return fixed4(tex2D(_ColorRamp, float2(perf, 0)).xyz, 1);         }          t += d;     }      \/\/ By this point the loop guard (i &lt; maxstep) is false.  Therefore     \/\/ we have reached maxstep steps.     return fixed4(tex2D(_ColorRamp, float2(1, 0)).xyz, 1); }<\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u0448\u0430 \u0442\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0430 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/244\/286\/4a4\/2442864a40f38cd658275532f8841522.png\"><\/div>\n<p>  <i>\u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438.<\/i><\/p>\n<p>  \u0413\u043e\u0440\u0430\u0437\u0434\u043e \u043b\u0443\u0447\u0448\u0435! \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043d\u0435\u0441\u0442\u0438 \u044d\u0442\u0443 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b raymarch, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0443\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0444\u0435\u0440\u0430 \u0433\u043b\u0443\u0431\u0438\u043d:<\/p>\n<pre><code class=\"cs\">fixed4 raymarch(float3 ro, float3 rd, float s) {     fixed4 ret = fixed4(0,0,0,0);      const int maxstep = 64;     const float drawdist = 40; \/\/ draw distance in unity units      float t = 0; \/\/ current distance traveled along ray     for (int i = 0; i &lt; maxstep; ++i) {         if (t &gt;= s || t &gt; drawdist) { \/\/ check draw distance in additon to depth             ret = fixed4(0, 0, 0, 0);             break;         }          \/\/ ...     }      return ret; }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0441\u0442\u0430\u043b\u0430 \u0434\u043b\u044f \u0432\u0430\u0441 \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u0432 \u043f\u043e\u043b\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 Raymarching-\u0430. \u041f\u043e\u043b\u043d\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/Flafla2\/Generic-Raymarch-Unity\" rel=\"nofollow\">\u044d\u0442\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 Github<\/a>. \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0430 <a href=\"https:\/\/www.shadertoy.com\" rel=\"nofollow\">Shadertoy<\/a> \u0438 \u043d\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u043d\u0438\u0436\u0435. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0442\u0435\u0445\u043d\u0438\u043a, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0432 Distance Field Raymarching \u043d\u0435 \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0438\u0441\u043a\u0430\u0442\u044c \u0438\u0445 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0421 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f, \u044f \u043d\u0435 \u043a\u0430\u0441\u0430\u043b\u0441\u044f \u0446\u0435\u043b\u043e\u0439 \u0441\u0444\u0435\u0440\u044b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0445 \u0442\u0435\u043c, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 raymarching-\u043e\u043c, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 <a href=\"http:\/\/www.iquilezles.org\/www\/articles\/rmshadows\/rmshadows.htm\" rel=\"nofollow\">\u0442\u0435\u043d\u0435\u0439<\/a>, ambient occlusion, <a href=\"http:\/\/www.iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm\" rel=\"nofollow\">\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u043c\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u044f\u043c\u0438<\/a>, \u0442\u0435\u0445\u043d\u0438\u043a \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u043d\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0438 \u0442.\u0434. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0432\u0430\u0441 \u0441\u0430\u043c\u0438\u043c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0442\u0440\u044e\u043a\u0438!<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e-\u043c\u043e\u0435\u043c\u0443, <a href=\"http:\/\/www.iquilezles.org\/www\/index.htm\" rel=\"nofollow\">\u0431\u043b\u043e\u0433 \u0418\u043d\u0438\u0433\u043e \u041a\u0438\u043b\u0435\u0441\u0430<\/a> \u2014 \u0432\u0430\u0436\u043d\u0435\u0439\u0448\u0438\u0439 \u0440\u0435\u0441\u0443\u0440\u0441 \u043f\u043e \u043f\u043e\u043b\u044f\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 Raymarching-\u0430. \u0412 \u0435\u0433\u043e \u0441\u0442\u0430\u0442\u044c\u044f\u0445 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u0438\u043a\u0430\u0445 raymarching-\u0430.<br \/> \n<ul>\n<li><a href=\"http:\/\/www.iquilezles.org\/www\/articles\/distfunctions\/distfunctions.htm\" rel=\"nofollow\">\u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438, \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f<\/a> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u044b\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u043c \u043f\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439.<\/li>\n<\/ul>\n<\/li>\n<li><a href=\"http:\/\/9bitscience.blogspot.com\/2013\/07\/raymarching-distance-fields_14.html\" rel=\"nofollow\">\u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f 9bit Science<\/a> \u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0435 \u0447\u0442\u0435\u043d\u0438\u0435 \u043f\u043e \u0442\u0435\u043e\u0440\u0438\u0438, \u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 raymarching-\u0430.<\/li>\n<li><a href=\"https:\/\/www.shadertoy.com\" rel=\"nofollow\">Shadertoy<\/a> \u2014 \u044d\u0442\u043e \u0441\u0430\u0439\u0442 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043f\u043e\u043b\u0435\u0439 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 raymarching-\u0430 (\u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f raymarching-\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0431\u044a\u0451\u043c\u043d\u043e\u0433\u043e \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u044f). \u041d\u0430 \u0441\u0430\u0439\u0442\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u0438\u043a.<\/li>\n<li><a href=\"http:\/\/gamedev.stackexchange.com\/questions\/67719\/how-do-raymarch-shaders-work\" rel=\"nofollow\">\u042d\u0442\u043e \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u043d\u0430 Gamedev Stackexchange<\/a> \u0434\u0430\u0451\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0441\u043d\u043e\u0432\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u044b \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 raymarching-\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f raymarching-\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043e\u0431\u044a\u0451\u043c\u043d\u043e\u043c \u043e\u0441\u0432\u0435\u0449\u0435\u043d\u0438\u0438.<\/li>\n<\/ul>\n<\/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\/503554\/\"> https:\/\/habr.com\/ru\/post\/503554\/<\/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\/503554\/\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/244\/286\/4a4\/2442864a40f38cd658275532f8841522.png\" alt=\"image\"><\/div>\n<p>  <em>Raymarching<\/em> \u2014 \u044d\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u043e\u0432\u0430\u044f \u0442\u0435\u0445\u043d\u0438\u043a\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0434\u043b\u044f \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0441\u0446\u0435\u043d \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041e\u043d\u0430 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u044d\u043a\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0440\u0435\u043d\u0434\u0435\u0440\u0435\u0440 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u0435\u0448\u0435\u0439 \u0438 \u0441\u0446\u0435\u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0447\u0435\u0442\u044b\u0440\u0451\u0445\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0435, \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u0432\u0441\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043a\u0430\u043c\u0435\u0440\u044b. \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u0441\u0446\u0435\u043d\u0435 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u043e\u0447\u043a\u043e\u0439 \u0438 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441\u0446\u0435\u043d\u044b (\u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0442\u0435\u0445\u043d\u0438\u043a\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u043f\u043e\u043b\u044f\u043c\u0438 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0439 Raymarching-\u0430<\/em>). \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0440\u0430\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0441\u0446\u0435\u043d\u044b. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u043e\u043b\u0438\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0448\u0438 (\u0438 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f), \u0437\u0434\u0435\u0441\u044c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0440\u0435\u043d\u0434\u0435\u0440\u0435\u0440\u0430, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043b\u0430\u0432\u043d\u044b\u0435 \u043f\u043e\u0432\u0435\u0440\u0445\u043d\u043e\u0441\u0442\u0438.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e2f\/07d\/4dd\/e2f07d4dd3aaf8e405a67376f828cfb2.png\"><\/div>\n<p>  <i><a href=\"https:\/\/www.shadertoy.com\/view\/ld3Gz2\" rel=\"nofollow\">Snail<\/a> \u0418\u043d\u0438\u0433\u043e \u041a\u0438\u043b\u0435\u0437\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0437\u0434\u0430\u043d\u0430 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 raymarching. \u0414\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u043d\u0443\u0442\u044b\u0445 raymarching-\u0443 \u0441\u0446\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/www.shadertoy.com\" rel=\"nofollow\">Shadertoy<\/a>.<\/i><\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e \u0444\u0443\u043d\u0434\u0430\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u044f\u0445 \u0438 \u0442\u0435\u043e\u0440\u0438\u0438 raymarching, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 raymarcher \u0432 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u0434\u0432\u0438\u0436\u043a\u0435 Unity. \u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c, \u043a\u0430\u043a \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0432\u0441\u0442\u0440\u043e\u0438\u0442\u044c raymarching \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0433\u0440\u0443 \u043d\u0430 Unity, \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c \u0441 raymarching-\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 GameObjects.<\/p>\n<p>  \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 <a href=\"https:\/\/github.com\/Flafla2\/Generic-Raymarch-Unity\" rel=\"nofollow\">\u044d\u0442\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 Github<\/a>.  <\/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-304393","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304393","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=304393"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304393\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}