{"id":326062,"date":"2021-07-06T21:00:16","date_gmt":"2021-07-06T21:00:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=326062"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=326062","title":{"rendered":"\u0414\u0435\u043b\u0430\u0435\u043c \u0441\u043f\u0440\u0430\u0439\u0442 \u0440\u0430\u0437\u043d\u044b\u0445 \u0446\u0432\u0435\u0442\u043e\u0432"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042f \u043f\u0440\u043e\u0431\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0433\u0440\u044b. \u041f\u0438\u0448\u0443 \u043a\u043e\u0434, \u043f\u0440\u043e\u0431\u0443\u044e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0438 \u0445\u043e\u0447\u0443 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0443\u0437\u044b\u043a\u0443. \u042f \u043f\u0440\u043e\u0440\u0438\u0441\u043e\u0432\u0430\u043b \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430 \u0438 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0446\u0432\u0435\u0442 \u043e\u0434\u0435\u0436\u0434\u044b. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0448\u043b\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0434\u043d\u043e, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c6b\/06d\/23a\/c6b06d23a84ef9cd3a39050e7638a275.png\" width=\"1920\" height=\"1080\"><figcaption><\/figcaption><\/figure>\n<p>\u043f\u0435\u0440\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e \u0447\u0435\u0433\u043e \u044f \u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0441\u044f, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443 \u0441\u0442\u0435\u043d \u0440\u0430\u0437\u043d\u0443\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c. \u0412 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0446\u0432\u0435\u0442. \u041c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043d\u043e \u044f \u0432\u0441\u0451 \u0442\u0430\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u0430. \u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u044b\u0439 \u0446\u0432\u0435\u0442 \u0438 \u044f \u043a\u0430\u043a \u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u0435\u0433\u043e \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u0445 \u0440\u0438\u0441\u0443\u044e \u0447\u0442\u043e-\u0442\u043e. \u0412\u043e\u0442 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u043a\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/daa\/2b7\/e8f\/daa2b7e8f382a188d79a7a1bb9c6132c.png\" width=\"1920\" height=\"1080\"><figcaption><\/figcaption><\/figure>\n<p>\u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0432\u0441\u044f \u043e\u0434\u0435\u0436\u043a\u0430 \u0432 \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u0445 \u0441\u0435\u0440\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u042d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u044f \u0432\u044b\u043f\u0438\u0441\u0430\u043b \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u043a\u043e\u0434\u044b \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"bash\">human colors ------------------------------------------- body front #6a6a6a 0.41 0.41 0.41 body up #959595 0.58 0.58 0.58 arm #a6a6a6  0.65 0.65 0.65 arm blick  #c1c1c1  0.75 0.75 0.75 arm blacked #8a8a8a  0.23 body down #5b5b5b 0.35 0.35 0.35 left legs blacked #4c4c4c 0.29 0.29 0.29 left legs blick #5c5c5c 0.36 0.36 0.36 right legs blacked #656565 0.39 0.39 0.39 right legs blick #808080 0.50 0.50 0.50<\/code><\/pre>\n<p>\u0432\u043e\u0442 \u043a\u043e\u0434 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">Sprite::Sprite (int x, int y, int z, const char *path) {     this-&gt;visibility = true;     this-&gt;isAnimate = false;     this-&gt;animator = new Animator ();     this-&gt;check = 0;     this-&gt;commonData = nullptr;     this-&gt;frame = nullptr;     this-&gt;trigger_shadow = 0;          this-&gt;z = glm::vec2 ((float) z, 1.0f);          GameObject::ortho = glm::ortho (0.0f, 1.0f, 1.0f, 0.0f, -100.0f, 100.0f);          float xx = ((float) x) \/ ((float) mea_width);     float yy = ((float) y) \/ ((float) mea_height);     float zz = z;     GameObject::pos = glm::translate (glm::mat4(1.0f), glm::vec3 (xx, yy, zz));      GameObject::model = glm::mat4(1.0f);      this-&gt;shader = shaderController-&gt;program[SHADERS::SPRITE];     this-&gt;type_shader = SHADERS::SPRITE;      gl::UseProgram (shaderController-&gt;program[SHADERS::SPRITE]);     this-&gt;location_view = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"view\");     this-&gt;location_tex = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"tex\");     this-&gt;location_pos = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"pos\");     this-&gt;location_model = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"model\");     this-&gt;location_scale = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"scale\");     this-&gt;location_z = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"zCoord\");            if (path != nullptr) loadSprite (path); }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u044f \u043f\u043e\u043c\u043d\u044e, \u0432 \u0438\u0433\u0440\u0430\u0445 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0447\u0442\u043e \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 1920&#215;1080 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u043e\u0435 \u0438 \u044f \u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a &#8212; \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 mea_width = 1920 \u0438 mea_height = 1080. Ortho \u044f \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432 1.0f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0432\u0435\u0437\u0434\u0435 \u0431\u044b\u043b\u043e, \u044f \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 mea_*. \u0422\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e full hd \u044d\u043a\u0440\u0430\u043d \u0438 \u043c\u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u0435\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445. \u0412 \u0438\u0433\u0440\u0435 \u044f \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u044e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 1920&#215;1080, \u043d\u043e \u043e\u043d\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 1.0f. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0432\u043e\u0442 \u0442\u0430\u043a.<\/p>\n<pre><code>float xx = ((float) x) \/ ((float) mea_width); float yy = ((float) y) \/ ((float) mea_height);<\/code><\/pre>\n<p>\u041f\u043e\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0441\u043f\u0440\u0430\u0439\u0442, \u0434\u043b\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u0438\u043f \u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">void Sprite::setShader (int shader) {     this-&gt;type_shader = shader;      switch (shader) {         case SHADERS::SPRITE:             this-&gt;shader = shaderController-&gt;program[SHADERS::SPRITE];             shader = this-&gt;shader;             gl::UseProgram (shader);             this-&gt;location_view = gl::GetUniformLocation (shader, \"view\");             this-&gt;location_tex = gl::GetUniformLocation (shader, \"tex\");             this-&gt;location_pos = gl::GetUniformLocation (shader, \"pos\");             this-&gt;location_model = gl::GetUniformLocation (shader, \"model\");             this-&gt;location_scale = gl::GetUniformLocation (shader, \"scale\");             this-&gt;location_z = gl::GetUniformLocation (shader, \"zCoord\");         break;         case SHADERS::SPRITE_WITH_ALPHA_COLORS:             this-&gt;shader = shaderController-&gt;program[SHADERS::SPRITE_WITH_ALPHA_COLORS];             shader = this-&gt;shader;             gl::UseProgram (shader);             this-&gt;location_view = gl::GetUniformLocation (shader, \"view\");             this-&gt;location_tex = gl::GetUniformLocation (shader, \"tex\");             this-&gt;location_pos = gl::GetUniformLocation (shader, \"pos\");             this-&gt;location_model = gl::GetUniformLocation (shader, \"model\");             this-&gt;location_scale = gl::GetUniformLocation (shader, \"scale\");             this-&gt;location_z = gl::GetUniformLocation (shader, \"zCoord\");             this-&gt;location_one = gl::GetUniformLocation (shader, \"color_wall\");             this-&gt;location_two = gl::GetUniformLocation (shader, \"color_floor\");         break;         case SHADERS::SPRITE_HUMAN:             this-&gt;shader = shaderController-&gt;program[SHADERS::SPRITE_HUMAN];             shader = this-&gt;shader;             gl::UseProgram (shader);             this-&gt;location_view = gl::GetUniformLocation (shader, \"view\");             this-&gt;location_tex = gl::GetUniformLocation (shader, \"tex\");             this-&gt;location_pos = gl::GetUniformLocation (shader, \"pos\");             this-&gt;location_model = gl::GetUniformLocation (shader, \"model\");             this-&gt;location_scale = gl::GetUniformLocation (shader, \"scale\");             this-&gt;location_z = gl::GetUniformLocation (shader, \"zCoord\");             this-&gt;location_one = gl::GetUniformLocation (shader, \"color_up\");             this-&gt;location_two = gl::GetUniformLocation (shader, \"color_down\");         break;     }      }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e within 1920&#215;1080.<\/p>\n<pre><code class=\"cpp\">void Sprite::setPos (int x, int y, int z) {     float xx = ((float) x) \/ ((float) mea_width);     float yy = ((float) y) \/ ((float) mea_height);     float zz = z;     GameObject::pos = glm::translate (glm::mat4(1.0f), glm::vec3 (xx, yy, zz));     this-&gt;x = x;     this-&gt;y = y; }<\/code><\/pre>\n<p>\u0442\u043e\u0442 \u0436\u0435 \u0440\u0430\u0441\u0447\u0435\u0442 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0438 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430, \u043d\u043e \u043a\u043e\u0434 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c.<\/p>\n<p>\u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0442\u0438\u043f\u0443 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0438 \u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u043a\u0430\u0434\u0440\u043e\u043c.<\/p>\n<pre><code class=\"cpp\">void Sprite::draw_frame_with_color (int frame) {      gl::UseProgram (this-&gt;shader);      gl::Uniform1i (this-&gt;location_tex, 0);      gl::ActiveTexture (gl::TEXTURE0);      gl::BindTexture (gl::TEXTURE_2D, this-&gt;frame[frame]);         gl::Uniform3f (this-&gt;location_one, this-&gt;color_one.r, this-&gt;color_one.g, this-&gt;color_one.b);     gl::Uniform3f (this-&gt;location_two, this-&gt;color_two.r, this-&gt;color_two.g, this-&gt;color_two.b);      gl::UniformMatrix4fv (this-&gt;location_view, 1, gl::FALSE_, &amp;GameObject::ortho[0][0]);      gl::UniformMatrix4fv (this-&gt;location_pos, 1, gl::FALSE_, &amp;GameObject::pos[0][0]);      gl::UniformMatrix4fv (this-&gt;location_model, 1, gl::FALSE_, &amp;GameObject::model[0][0]);     gl::UniformMatrix4fv (this-&gt;location_scale, 1, gl::FALSE_, &amp;GameObject::scale[0][0]);      gl::Uniform2f (this-&gt;location_z, this-&gt;z[0], this-&gt;z[1]);      gl::BindVertexArray (this-&gt;vao);      gl::EnableVertexAttribArray (0);     gl::EnableVertexAttribArray (1);      gl::DrawArrays (gl::TRIANGLES, 0, 6);    }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0432 \u0448\u0435\u0439\u0434\u0435\u0440 \u0434\u0432\u0435 uniform \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, color_one \u0438 color_two. \u041e\u043d\u0438 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0441\u043b\u0443\u0436\u0430\u0442 \u0446\u0435\u043b\u044c\u044e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043e\u0434\u0435\u0436\u0434\u044b \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430. \u0428\u0435\u0439\u0434\u0435\u0440 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0442\u0430\u043a\u043e\u0439.<\/p>\n<pre><code class=\"cpp\">#version 330 core  out vec4 fragColor;  in vec2 texCoord;  uniform sampler2D tex;  uniform vec3 color_up; uniform vec3 color_down;  void main () {     vec3 color = texture (tex, texCoord).rgb;     float r = color.r;     float g = color.g;     float b = color.b;     r *= 100;     g *= 100;     b *= 100;     int rr = int(r);     int gg = int(g);     int bb = int(b);     r = rr;     g = gg;     b = bb;     r *= 0.01;     g *= 0.01;     b *= 0.01;     color = vec3 (r, g, b);      if (color == vec3 (0.41, 0.41, 0.41)) {         fragColor = vec4 (color_up, 1.0);     } else if (color == vec3 (0.58, 0.58, 0.58)) {         vec3 col = color_up + vec3 (0.17, 0.17, 0.17);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.65, 0.65, 0.65)) {         vec3 col = color_up + vec3 (0.24, 0.24, 0.24);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.75, 0.75, 0.75)) {         vec3 col = color_up + vec3 (0.34, 0.34, 0.34);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.23, 0.23, 0.23)) {         vec3 col = color_up - vec3 (0.18, 0.18, 0.18);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.35, 0.35, 0.35)) {         fragColor = vec4 (color_down, 1.0);     } else if (color == vec3 (0.29, 0.29, 0.29)) {         vec3 col = color_down - vec3 (0.06, 0.06, 0.06);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.36, 0.36, 0.36)) {         vec3 col = color_down + vec3 (0.01, 0.01, 0.01);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.39, 0.39, 0.39)) {         vec3 col = color_down + vec3 (0.04, 0.04, 0.04);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.50, 0.50, 0.50)) {         vec3 col = color_down + vec3 (0.15, 0.15, 0.15);         fragColor = vec4 (col, 1.0);     } else {         fragColor = texture (tex, texCoord);     } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430 \u043e\u0442\u0442\u0435\u043d\u043e\u043a \u0446\u0432\u0435\u0442\u0430 \u0438 \u043f\u043b\u044e\u0441\u0443\u0435\u0442 \u0438\u043b\u0438 \u043c\u0438\u043d\u0443\u0441\u0443\u0435\u0442 \u043e\u0442\u0442\u0435\u043d\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u042f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u0438 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u043e\u0432 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u0441\u0442\u043e\u043b\u0443 \u0438 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442, \u043e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0441\u0432\u043e\u0438 \u0446\u0432\u0435\u0442\u0430 \u0441\u0442\u043e\u043b\u0443 \u0438 \u0441\u0442\u043e\u043b \u043f\u043e \u044d\u0442\u0438\u043c \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u043c \u0443\u0436\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u0446\u0432\u0435\u0442. \u0418 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b \u043a \u0441\u0442\u043e\u043b\u0443.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8d3\/f85\/23e\/8d3f8523e1cf19953cb4b0e6072ac46a.png\" width=\"1920\" height=\"1080\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a57\/308\/dc3\/a57308dc35aea1925b9bcaddd2b63939.png\" width=\"1920\" height=\"1080\"><figcaption><\/figcaption><\/figure>\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\/566468\/\"> https:\/\/habr.com\/ru\/post\/566468\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042f \u043f\u0440\u043e\u0431\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0433\u0440\u044b. \u041f\u0438\u0448\u0443 \u043a\u043e\u0434, \u043f\u0440\u043e\u0431\u0443\u044e \u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c \u0438 \u0445\u043e\u0447\u0443 \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0443\u0437\u044b\u043a\u0443. \u042f \u043f\u0440\u043e\u0440\u0438\u0441\u043e\u0432\u0430\u043b \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430 \u0438 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0446\u0432\u0435\u0442 \u043e\u0434\u0435\u0436\u0434\u044b. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0448\u043b\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0434\u043d\u043e, \u043d\u043e \u043f\u043e\u0442\u043e\u043c \u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u043f\u0435\u0440\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043e \u0447\u0435\u0433\u043e \u044f \u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0441\u044f, \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443 \u0441\u0442\u0435\u043d \u0440\u0430\u0437\u043d\u0443\u044e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0442\u043e\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c. \u0412 \u0448\u0435\u0439\u0434\u0435\u0440\u0435 \u0443\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0446\u0432\u0435\u0442. \u041c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043d\u043e \u044f \u0432\u0441\u0451 \u0442\u0430\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u0430. \u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u044b\u0439 \u0446\u0432\u0435\u0442 \u0438 \u044f \u043a\u0430\u043a \u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u0435\u0433\u043e \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u0445 \u0440\u0438\u0441\u0443\u044e \u0447\u0442\u043e-\u0442\u043e. \u0412\u043e\u0442 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u043b \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u043a\u0430.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0432\u0441\u044f \u043e\u0434\u0435\u0436\u043a\u0430 \u0432 \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u0445 \u0441\u0435\u0440\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u042d\u0442\u043e \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u044f \u0432\u044b\u043f\u0438\u0441\u0430\u043b \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0435 \u043a\u043e\u0434\u044b \u0446\u0432\u0435\u0442\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b.<\/p>\n<pre><code class=\"bash\">human colors ------------------------------------------- body front #6a6a6a 0.41 0.41 0.41 body up #959595 0.58 0.58 0.58 arm #a6a6a6  0.65 0.65 0.65 arm blick  #c1c1c1  0.75 0.75 0.75 arm blacked #8a8a8a  0.23 body down #5b5b5b 0.35 0.35 0.35 left legs blacked #4c4c4c 0.29 0.29 0.29 left legs blick #5c5c5c 0.36 0.36 0.36 right legs blacked #656565 0.39 0.39 0.39 right legs blick #808080 0.50 0.50 0.50<\/code><\/pre>\n<p>\u0432\u043e\u0442 \u043a\u043e\u0434 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">Sprite::Sprite (int x, int y, int z, const char *path) {     this-&gt;visibility = true;     this-&gt;isAnimate = false;     this-&gt;animator = new Animator ();     this-&gt;check = 0;     this-&gt;commonData = nullptr;     this-&gt;frame = nullptr;     this-&gt;trigger_shadow = 0;          this-&gt;z = glm::vec2 ((float) z, 1.0f);          GameObject::ortho = glm::ortho (0.0f, 1.0f, 1.0f, 0.0f, -100.0f, 100.0f);          float xx = ((float) x) \/ ((float) mea_width);     float yy = ((float) y) \/ ((float) mea_height);     float zz = z;     GameObject::pos = glm::translate (glm::mat4(1.0f), glm::vec3 (xx, yy, zz));      GameObject::model = glm::mat4(1.0f);      this-&gt;shader = shaderController-&gt;program[SHADERS::SPRITE];     this-&gt;type_shader = SHADERS::SPRITE;      gl::UseProgram (shaderController-&gt;program[SHADERS::SPRITE]);     this-&gt;location_view = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"view\");     this-&gt;location_tex = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"tex\");     this-&gt;location_pos = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"pos\");     this-&gt;location_model = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"model\");     this-&gt;location_scale = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"scale\");     this-&gt;location_z = gl::GetUniformLocation (shaderController-&gt;program[SHADERS::SPRITE], \"zCoord\");            if (path != nullptr) loadSprite (path); }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u044f \u043f\u043e\u043c\u043d\u044e, \u0432 \u0438\u0433\u0440\u0430\u0445 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u0447\u0442\u043e \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 1920&#215;1080 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u043c\u043e\u0435 \u0438 \u044f \u0434\u043e\u0434\u0443\u043c\u0430\u043b\u0441\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a &#8212; \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 mea_width = 1920 \u0438 mea_height = 1080. Ortho \u044f \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0432 1.0f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0432\u0435\u0437\u0434\u0435 \u0431\u044b\u043b\u043e, \u044f \u0432\u044b\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u044e \u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430 mea_*. \u0422\u043e \u0435\u0441\u0442\u044c \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0443\u0434\u043e\u0431\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e full hd \u044d\u043a\u0440\u0430\u043d \u0438 \u043c\u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u0435\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u0445. \u0412 \u0438\u0433\u0440\u0435 \u044f \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u044e \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 1920&#215;1080, \u043d\u043e \u043e\u043d\u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 1.0f. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e, \u0432\u043e\u0442 \u0442\u0430\u043a.<\/p>\n<pre><code>float xx = ((float) x) \/ ((float) mea_width); float yy = ((float) y) \/ ((float) mea_height);<\/code><\/pre>\n<p>\u041f\u043e\u0442\u043e\u043c \u0435\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 \u0441\u043f\u0440\u0430\u0439\u0442, \u0434\u043b\u044f \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u0438\u043f \u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<pre><code class=\"cpp\">void Sprite::setShader (int shader) {     this-&gt;type_shader = shader;      switch (shader) {         case SHADERS::SPRITE:             this-&gt;shader = shaderController-&gt;program[SHADERS::SPRITE];             shader = this-&gt;shader;             gl::UseProgram (shader);             this-&gt;location_view = gl::GetUniformLocation (shader, \"view\");             this-&gt;location_tex = gl::GetUniformLocation (shader, \"tex\");             this-&gt;location_pos = gl::GetUniformLocation (shader, \"pos\");             this-&gt;location_model = gl::GetUniformLocation (shader, \"model\");             this-&gt;location_scale = gl::GetUniformLocation (shader, \"scale\");             this-&gt;location_z = gl::GetUniformLocation (shader, \"zCoord\");         break;         case SHADERS::SPRITE_WITH_ALPHA_COLORS:             this-&gt;shader = shaderController-&gt;program[SHADERS::SPRITE_WITH_ALPHA_COLORS];             shader = this-&gt;shader;             gl::UseProgram (shader);             this-&gt;location_view = gl::GetUniformLocation (shader, \"view\");             this-&gt;location_tex = gl::GetUniformLocation (shader, \"tex\");             this-&gt;location_pos = gl::GetUniformLocation (shader, \"pos\");             this-&gt;location_model = gl::GetUniformLocation (shader, \"model\");             this-&gt;location_scale = gl::GetUniformLocation (shader, \"scale\");             this-&gt;location_z = gl::GetUniformLocation (shader, \"zCoord\");             this-&gt;location_one = gl::GetUniformLocation (shader, \"color_wall\");             this-&gt;location_two = gl::GetUniformLocation (shader, \"color_floor\");         break;         case SHADERS::SPRITE_HUMAN:             this-&gt;shader = shaderController-&gt;program[SHADERS::SPRITE_HUMAN];             shader = this-&gt;shader;             gl::UseProgram (shader);             this-&gt;location_view = gl::GetUniformLocation (shader, \"view\");             this-&gt;location_tex = gl::GetUniformLocation (shader, \"tex\");             this-&gt;location_pos = gl::GetUniformLocation (shader, \"pos\");             this-&gt;location_model = gl::GetUniformLocation (shader, \"model\");             this-&gt;location_scale = gl::GetUniformLocation (shader, \"scale\");             this-&gt;location_z = gl::GetUniformLocation (shader, \"zCoord\");             this-&gt;location_one = gl::GetUniformLocation (shader, \"color_up\");             this-&gt;location_two = gl::GetUniformLocation (shader, \"color_down\");         break;     }      }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0438 \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e within 1920&#215;1080.<\/p>\n<pre><code class=\"cpp\">void Sprite::setPos (int x, int y, int z) {     float xx = ((float) x) \/ ((float) mea_width);     float yy = ((float) y) \/ ((float) mea_height);     float zz = z;     GameObject::pos = glm::translate (glm::mat4(1.0f), glm::vec3 (xx, yy, zz));     this-&gt;x = x;     this-&gt;y = y; }<\/code><\/pre>\n<p>\u0442\u043e\u0442 \u0436\u0435 \u0440\u0430\u0441\u0447\u0435\u0442 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0438 \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430, \u043d\u043e \u043a\u043e\u0434 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c.<\/p>\n<p>\u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0442\u0438\u043f\u0443 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0438 \u0432\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u043a\u0430\u0434\u0440\u043e\u043c.<\/p>\n<pre><code class=\"cpp\">void Sprite::draw_frame_with_color (int frame) {      gl::UseProgram (this-&gt;shader);      gl::Uniform1i (this-&gt;location_tex, 0);      gl::ActiveTexture (gl::TEXTURE0);      gl::BindTexture (gl::TEXTURE_2D, this-&gt;frame[frame]);         gl::Uniform3f (this-&gt;location_one, this-&gt;color_one.r, this-&gt;color_one.g, this-&gt;color_one.b);     gl::Uniform3f (this-&gt;location_two, this-&gt;color_two.r, this-&gt;color_two.g, this-&gt;color_two.b);      gl::UniformMatrix4fv (this-&gt;location_view, 1, gl::FALSE_, &amp;GameObject::ortho[0][0]);      gl::UniformMatrix4fv (this-&gt;location_pos, 1, gl::FALSE_, &amp;GameObject::pos[0][0]);      gl::UniformMatrix4fv (this-&gt;location_model, 1, gl::FALSE_, &amp;GameObject::model[0][0]);     gl::UniformMatrix4fv (this-&gt;location_scale, 1, gl::FALSE_, &amp;GameObject::scale[0][0]);      gl::Uniform2f (this-&gt;location_z, this-&gt;z[0], this-&gt;z[1]);      gl::BindVertexArray (this-&gt;vao);      gl::EnableVertexAttribArray (0);     gl::EnableVertexAttribArray (1);      gl::DrawArrays (gl::TRIANGLES, 0, 6);    }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u044f \u043f\u0435\u0440\u0435\u0434\u0430\u044e \u0432 \u0448\u0435\u0439\u0434\u0435\u0440 \u0434\u0432\u0435 uniform \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, color_one \u0438 color_two. \u041e\u043d\u0438 \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0441\u043b\u0443\u0436\u0430\u0442 \u0446\u0435\u043b\u044c\u044e \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0446\u0432\u0435\u0442\u0430 \u0434\u043b\u044f \u043e\u0434\u0435\u0436\u0434\u044b \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430. \u0428\u0435\u0439\u0434\u0435\u0440 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043d\u044b\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0442\u0430\u043a\u043e\u0439.<\/p>\n<pre><code class=\"cpp\">#version 330 core  out vec4 fragColor;  in vec2 texCoord;  uniform sampler2D tex;  uniform vec3 color_up; uniform vec3 color_down;  void main () {     vec3 color = texture (tex, texCoord).rgb;     float r = color.r;     float g = color.g;     float b = color.b;     r *= 100;     g *= 100;     b *= 100;     int rr = int(r);     int gg = int(g);     int bb = int(b);     r = rr;     g = gg;     b = bb;     r *= 0.01;     g *= 0.01;     b *= 0.01;     color = vec3 (r, g, b);      if (color == vec3 (0.41, 0.41, 0.41)) {         fragColor = vec4 (color_up, 1.0);     } else if (color == vec3 (0.58, 0.58, 0.58)) {         vec3 col = color_up + vec3 (0.17, 0.17, 0.17);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.65, 0.65, 0.65)) {         vec3 col = color_up + vec3 (0.24, 0.24, 0.24);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.75, 0.75, 0.75)) {         vec3 col = color_up + vec3 (0.34, 0.34, 0.34);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.23, 0.23, 0.23)) {         vec3 col = color_up - vec3 (0.18, 0.18, 0.18);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.35, 0.35, 0.35)) {         fragColor = vec4 (color_down, 1.0);     } else if (color == vec3 (0.29, 0.29, 0.29)) {         vec3 col = color_down - vec3 (0.06, 0.06, 0.06);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.36, 0.36, 0.36)) {         vec3 col = color_down + vec3 (0.01, 0.01, 0.01);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.39, 0.39, 0.39)) {         vec3 col = color_down + vec3 (0.04, 0.04, 0.04);         fragColor = vec4 (col, 1.0);     } else if (color == vec3 (0.50, 0.50, 0.50)) {         vec3 col = color_down + vec3 (0.15, 0.15, 0.15);         fragColor = vec4 (col, 1.0);     } else {         fragColor = texture (tex, texCoord);     } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043a\u043e\u0434\u0430, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043d\u0430 \u043e\u0442\u0442\u0435\u043d\u043e\u043a \u0446\u0432\u0435\u0442\u0430 \u0438 \u043f\u043b\u044e\u0441\u0443\u0435\u0442 \u0438\u043b\u0438 \u043c\u0438\u043d\u0443\u0441\u0443\u0435\u0442 \u043e\u0442\u0442\u0435\u043d\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430. \u042f \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043b \u0438 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u043e\u0432 \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u043a \u0441\u0442\u043e\u043b\u0443 \u0438 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442, \u043e\u043d \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0441\u0432\u043e\u0438 \u0446\u0432\u0435\u0442\u0430 \u0441\u0442\u043e\u043b\u0443 \u0438 \u0441\u0442\u043e\u043b \u043f\u043e \u044d\u0442\u0438\u043c \u043e\u0442\u0442\u0435\u043d\u043a\u0430\u043c \u0443\u0436\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u0446\u0432\u0435\u0442. \u0418 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b \u043a \u0441\u0442\u043e\u043b\u0443.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\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\/566468\/\"> https:\/\/habr.com\/ru\/post\/566468\/<\/a><br \/><\/br><\/br><\/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-326062","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326062","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=326062"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/326062\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=326062"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=326062"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=326062"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}