{"id":278449,"date":"2016-04-17T14:40:08","date_gmt":"2016-04-17T10:40:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=278449"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=278449","title":{"rendered":"\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 GLSL, HLSL, Metal"},"content":{"rendered":"<p>       \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0434\u043d\u044f \u0445\u0430\u0431\u0440. \u042d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0442\u0435\u043b-\u0431\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0435\u043c\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0421 \u043a\u0430\u0436\u0434\u044b\u043c \u0433\u043e\u0434\u043e\u043c \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u043c\u043e\u0449\u043d\u0435\u0435, \u0438 \u0431\u043e\u043b\u0435\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0435\u0435. \u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0438 \u043a\u043e\u0433\u043e \u043d\u0435 \u0443\u0434\u0438\u0432\u0438\u0448\u044c 3d \u0438\u0433\u0440\u043e\u0439 \u043d\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u043e\u043c, \u0440\u044b\u043d\u043e\u043a \u0440\u0430\u0441\u0442\u0435\u0442, \u0430 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0438\u043c \u0438 \u0440\u0430\u0441\u0442\u0435\u0442 \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c \u0432\u0438\u0434\u0435\u0442\u044c \u044d\u043a\u0441\u043a\u043b\u044e\u0437\u0438\u0432\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u0432\u043e\u0435\u043c \u043c\u0430\u0440\u043a\u0435\u0442\u0435. \u0415\u0449\u0435 3-5 \u043b\u0435\u0442 \u043d\u0430\u0437\u0430\u0434 \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0433\u0440 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u043e\u0441\u044c 2 \u0430\u043f\u0438, OpenGLES \u0438 DirectX, \u0442\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0438\u0445 \u043a\u043e\u043b-\u0432\u043e \u0440\u0430\u0441\u0442\u0435\u0442. Apple \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u0435\u0442 Metal, \u0430 \u043d\u0430 \u044d\u0442\u043e\u0439 \u043d\u0435\u0434\u0435\u043b\u0435 \u0443\u0436\u0435 \u0432\u044b\u0448\u043b\u0438 development \u0432\u0435\u0440\u0441\u0438\u0438 android \u043f\u0440\u043e\u0448\u0438\u0432\u043e\u043a \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 Vulkan. \u0421 \u0440\u043e\u0441\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u0438\u0441\u0442\u0435\u043c \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433\u0430 \u0440\u0430\u0441\u0442\u0435\u0442 \u0438 \u043a\u043e\u043b-\u0432\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u043e-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<p>  \u0417\u0430\u0434\u0430\u0432\u0430\u044f\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c \u00ab\u041a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b-\u0432\u043e \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u043e-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430?\u00bb \u044f \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0432\u044b\u0432\u043e\u0434\u0443 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u0443 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0439 (HLSL, GLSL, Metal) \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u043e\u043d\u0438 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0437\u0430\u0434\u0430\u0447\u0438. \u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u2014 \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0435 \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435. \u0418\u0434\u0435\u044f \u043d\u0435 \u043d\u043e\u0432\u0430, \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 Unity, Unreal Engine. \u0412 Unity \u0434\u043b\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f NVidia CG \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, CG Toolkit \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 <a href=\"http:\/\/http.developer.nvidia.com\/Cg\/index_profiles.html\">\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c<\/a>. \u041d\u043e \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e NVidia \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u043b\u0430 \u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443. \u0418 \u043a\u0430\u043a \u043d\u0435 \u0442\u0440\u0443\u0434\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0432 \u043f\u0440\u043e\u0444\u0438\u043b\u044f\u0445 \u043d\u0435\u0442 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 api \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 Metal, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c Unity \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0438\u0441\u043a\u043e\u0432 \u044f \u043d\u0430\u0448\u0435\u043b <a href=\"http:\/\/aras-p.info\/blog\/2010\/09\/29\/glsl-optimizer\/\">\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a<\/a> \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e\u0449\u0438\u0439 glsl es \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u0441 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 Metal, \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0435\u043d\u0438\u044f\u043c \u0430\u0432\u0442\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 Unity.<\/p>\n<p>  \u0418\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u043d\u0430 GLSL \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 Metal. \u041d\u043e \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u2014 HLSL, \u043d\u0430\u0439\u0442\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0438\u0437 GLSL \u0432 HLSL \u0443 \u043c\u0435\u043d\u044f \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c, \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0432 HLSL \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u0438\u0435 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0432 GLSL 1.0. \u041d\u043e \u0437\u0430\u0442\u043e \u043d\u0430\u0448\u0435\u043b\u0441\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 <a href=\"http:\/\/aras-p.info\/blog\/2010\/05\/21\/compiling-hlsl-into-glsl-in-2010\/\">\u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440<\/a> \u0432\u0441\u0435 \u0443 \u0442\u043e\u0433\u043e \u0436\u0435 \u0430\u0432\u0442\u043e\u0440\u0430. \u0417\u0430 \u043e\u0441\u043d\u043e\u0432\u0443 \u0432 \u0438\u0442\u043e\u0433\u0435 \u0431\u044b\u043b \u0432\u0437\u044f\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 HLSL. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0432\u0441\u0435 \u0443 \u0442\u043e\u0433\u043e \u0436\u0435 CG Toolkit \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c fx \u0444\u0430\u0439\u043b\u044b, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 (\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 pipeline, \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432). \u0414\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 fx \u0444\u0430\u0439\u043b\u043e\u0432 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/github.com\/pperehozhih\/hlslparser\">hlslparser<\/a>, \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043c\u0435\u0442\u0430\u0434\u0430\u043d\u043d\u044b\u0435. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0441\u043e\u0431\u0440\u0430\u0432 \u0432\u0441\u0435 \u044d\u0442\u043e \u0432\u043e \u0435\u0434\u0438\u043d\u043e, \u0431\u044b\u043b\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0430\u044f <a href=\"https:\/\/github.com\/pperehozhih\/shgen\">\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c GLSL, HLSL, Metal \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u0438\u0437 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 fx \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c HLSL.<\/p>\n<p>  \u041d\u0438\u0436\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e fx \u0444\u0430\u0439\u043b\u0430, \u0438 \u0447\u0442\u043e \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c<\/p>\n<p>  fx.fx  <\/p>\n<pre><code class=\"cpp\">float4x4 u_MVPMatrix;  struct VS_DEFAULT_OUTPUT  {    float4 position: POSITION;    float2 texture_coord: TEXCOORD0;    float4 color: COLOR0; };  VS_DEFAULT_OUTPUT vs_default_texture(float4 u_position: POSITION, float2 u_texture_coord: TEXCOORD0, float4 u_color: COLOR0)  { \tVS_DEFAULT_OUTPUT Out; \tOut.position = mul(u_MVPMatrix, u_position); \tOut.texture_coord = u_texture_coord; \tOut.color = u_color; \treturn Out; }  float4 ps_default_texture(VS_DEFAULT_OUTPUT Out, uniform sampler2D u_texture) : COLOR { \tfloat4 clr = tex2D(u_texture, Out.texture_coord) * Out.color; \treturn clr; }  technique default_texture { \tpass P0 \t{ \t\tvertexShader = vs_default_texture(); \t\tpixelShader = ps_default_texture(); \t\tdepthtest = false; \t\tdepthwrite = false; \t} } <\/code><\/pre>\n<p>  \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u0434\u043b\u044f GLES \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c  <\/p>\n<pre><code class=\"cpp\">uniform highp mat4 u_MVPMatrix; attribute highp vec4 u_position; attribute highp vec2 u_texture_coord; attribute highp vec4 u_color; varying highp vec2 xlv_TEXCOORD0; varying highp vec4 xlv_COLOR0; void main () {   gl_Position = (u_MVPMatrix * u_position);   xlv_TEXCOORD0 = u_texture_coord;   xlv_COLOR0 = u_color; } <\/code><\/pre>\n<p>  \u0418 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440  <\/p>\n<pre><code class=\"cpp\">uniform sampler2D xlu_u_texture; varying highp vec2 xlv_TEXCOORD0; varying highp vec4 xlv_COLOR0; void main () {   lowp vec4 tmpvar_1;   tmpvar_1 = texture2D (xlu_u_texture, xlv_TEXCOORD0);   highp vec4 tmpvar_2;   tmpvar_2 = (tmpvar_1 * xlv_COLOR0);   gl_FragColor = tmpvar_2; } <\/code><\/pre>\n<p>  \u041d\u0438\u0436\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u0434\u043b\u044f Metal  <\/p>\n<pre><code class=\"cpp\">#include &lt;metal_stdlib&gt; #pragma clang diagnostic ignored &quot;-Wparentheses-equality&quot; using namespace metal; struct xlatMtlShaderInput {   float4 u_position [[attribute(0)]];   float2 u_texture_coord [[attribute(1)]];   float4 u_color [[attribute(2)]]; }; struct xlatMtlShaderOutput {   float4 gl_Position [[position]];   float2 xlv_TEXCOORD0;   float4 xlv_COLOR0; }; struct xlatMtlShaderUniform {   float4x4 u_MVPMatrix; }; vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]) {   xlatMtlShaderOutput _mtl_o;   _mtl_o.gl_Position = (_mtl_u.u_MVPMatrix * _mtl_i.u_position);   _mtl_o.xlv_TEXCOORD0 = _mtl_i.u_texture_coord;   _mtl_o.xlv_COLOR0 = _mtl_i.u_color;   return _mtl_o; } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"cpp\">#include &lt;metal_stdlib&gt; #pragma clang diagnostic ignored &quot;-Wparentheses-equality&quot; using namespace metal; struct xlatMtlShaderInput {   float2 xlv_TEXCOORD0;   float4 xlv_COLOR0; }; struct xlatMtlShaderOutput {   half4 gl_FragColor; }; struct xlatMtlShaderUniform { }; fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]   ,   texture2d&lt;float&gt; xlu_u_texture [[texture(0)]], sampler _mtlsmp_xlu_u_texture [[sampler(0)]]) {   xlatMtlShaderOutput _mtl_o;   half4 tmpvar_1;   tmpvar_1 = half4(xlu_u_texture.sample(_mtlsmp_xlu_u_texture, (float2)(_mtl_i.xlv_TEXCOORD0)));   _mtl_o.gl_FragColor = ((half4)((float4)tmpvar_1 * _mtl_i.xlv_COLOR0));   return _mtl_o; } <\/code><\/pre>\n<p>  \u0418\u0437 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u0441\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435<br \/>   \u2014 Metal \u0448\u0435\u0439\u0434\u0435\u0440\u044b \u0438\u043c\u0435\u044e\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0438\u043c\u0435\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0447\u0442\u043e \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u0445 \u043d\u0435\u0441\u0442\u0438 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u0435\u0441\u0442\u0438 \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u0438\u043f\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u044f \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u044e\u0441\u044c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c<br \/>   \u2014 \u0412 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u0445 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u043c\u0438 \u0444\u0438\u0447\u0430\u043c\u0438 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c (geometry shader, instancing)<\/p>\n<p>  \u0418\u0437 \u043f\u043b\u044e\u0441\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c<br \/>   \u2014 \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 GLES \u0448\u0435\u0439\u0434\u0435\u0440\u044b, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 \u043b\u0435\u0433\u043b\u0430 \u043d\u0430 \u043f\u043b\u0435\u0447\u0438 \u0432\u0435\u043d\u0434\u043e\u0440\u043e\u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0435\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u043d\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u044f\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0440\u0430\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c               <\/p>\n<div class=\"clear\"><\/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:\/\/habrahabr.ru\/post\/281767\/\"> https:\/\/habrahabr.ru\/post\/281767\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0434\u043d\u044f \u0445\u0430\u0431\u0440. \u042d\u0442\u043e \u043c\u043e\u044f \u043f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u0445\u0430\u0431\u0440\u0435, \u043d\u0435 \u0441\u0443\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u0433\u043e.<\/p>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0442\u0435\u043b-\u0431\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0435\u043c\u0443 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u0434\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e.  <\/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-278449","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/278449","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=278449"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/278449\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=278449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=278449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=278449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}