{"id":266839,"date":"2015-10-27T09:15:02","date_gmt":"2015-10-27T06:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=266839"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=266839","title":{"rendered":"\u041e\u0442\u043b\u0430\u0434\u043a\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u043d\u0430 Java + Groovy"},"content":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/602\/ce8\/00a\/602ce800a93f4c2bb090f0b42a12259a.png\"\/><\/p>\n<p>  \u041f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432. \u0421\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c\u0438 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432, \u0434\u0435\u0431\u0430\u0433, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043a\u043e\u0434\u0430, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u043b\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 IDE. \u041e \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0432 \u0447\u0451\u043c \u043f\u043e\u0434\u0432\u043e\u0445, \u0438 \u0447\u0442\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043c\u0430\u0432\u0435\u043d\u0435\u2026<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<pre><code class=\"bash\">$ git clone https:\/\/github.com\/kravchik\/senjin <\/code><\/pre>\n<p>  \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u043a\u043e\u0440\u0435\u043d\u044c \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\">$ mvn nativedependencies:copy <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u201cmain\u201d \u043f\u043e Ctrl+Shift+F10 (\u0432 IDEA) \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438\u0437 \u043e\u043a\u043d\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430, \u043d\u0435 \u0431\u0435\u0441\u043f\u043e\u043a\u043e\u044f\u0441\u044c \u043e classpath.<\/p>\n<p>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a: \u043a\u043e\u0434 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043d\u0430 Groovy, \u0437\u0430\u0442\u0435\u043c \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 glsl \u043a\u043e\u0434. \u0428\u0435\u0439\u0434\u0435\u0440 \u0432 Groovy \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0437 Java. \u0428\u0435\u0439\u0434\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0442\u0435 \u0436\u0435 \u043f\u043e\u043b\u044f \u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0447\u0442\u043e \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 IDE \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u0448\u0435\u0439\u0434\u0435\u0440 \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u0434 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439, \u043e\u043d\u0438 \u0434\u043b\u044f \u043d\u0435\u0451 \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 Groovy \u0438 Java \u043a\u043b\u0430\u0441\u0441\u044b. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0438\u043c\u0435\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430:<\/p>\n<ul>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 IDE (\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0438, \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430)<\/li>\n<li>\u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u0448\u0438\u0431\u043e\u043a<\/li>\n<li>\u043e\u0442\u043b\u0430\u0434\u043a\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u0430<\/li>\n<li>\u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432<\/li>\n<li>\u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0431\u0443\u0444\u0435\u0440\u043e\u0432 \u0438 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432<\/li>\n<\/ul>\n<p>  \u041d\u043e \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438 \u2014 \u0432\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0432 Groovy \u0438 Java. \u0412\u044b \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u0432\u044f\u0437\u043a\u0438 \u0441 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c, \u043d\u043e \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b, \u0434\u0435\u0431\u0430\u0433, \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 IDE \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b. \u0422\u043e\u0433\u0434\u0430 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e-\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0441 glsl \u043a\u043e\u0434\u043e\u043c.<\/p>\n<h2>\u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h2>\n<p>  <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e5c\/eed\/34c\/e5ceed34c0ce4451ada8d7cba6009e67.png\" height=\"200\" width=\"200\" align=\"left\"\/><br \/>  \u041f\u043e\u043a\u0430\u0436\u0443 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 specular shader (\u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043d\u0433 \u201c\u043f\u043b\u0430\u0441\u0442\u043c\u0430\u0441\u0441\u043e\u0432\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430\u201d) \u2014 \u043e\u043d \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043d\u043e \u0432 \u043d\u0451\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f varying, uniform, attributes, \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b, \u0435\u0441\u0442\u044c \u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u043a\u0430, \u0432 \u043e\u0431\u0449\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0449\u0443\u043f\u0430\u0442\u044c \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u044e.<\/p>\n<h3>\u041f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440<\/h3>\n<p>  \u042d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 Groovy-\u043a\u043b\u0430\u0441\u0441 \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c main. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 opengl-\u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0448\u0435\u0439\u0434\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u043e. Uniform \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u043e\u043b\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u0430. \u041a\u043e\u0434 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 main, \u043d\u043e \u0435\u0451 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 glsl \u2014 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 (SpecularFi), \u0438 \u043a\u0443\u0434\u0430 \u043d\u0430\u0434\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 (StandardFrame). \u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0438\u043c\u0435\u043d \u0432\u0438\u0434\u0430 vec3, vec4, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 Groovy \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0431\u0443\u043a\u0432\u044b.<\/p>\n<pre><code class=\"java\">public class SpecularF extends FragmentShaderParent&lt;SpecularFi&gt; {     public Sampler2D txt = new Sampler2D()     public float shininess = 10;     public Vec3f ambient = Vec3f(0.1, 0.1, 0.1);     public Vec3f lightDir      def void main(SpecularFi i, StandardFrame o) {         Vec3f color = texture(txt, i.uv).xyz;         Vec3f matSpec = Vec3f(0.6, 0.5, 0.3);         Vec3f lightColor = Vec3f(1, 1, 1);          Vec3f diffuse  = color * max(0.0, dot(i.normal, lightDir)) * lightColor;         Vec3f r = normalize(reflect(normalize(i.csLightDir), normalize(i.csNormal)));         Vec3f specular = lightColor * matSpec * pow(max(0.0, dot(r, normalize(i.csEyeDir))), shininess);         o.gl_FragColor =  Vec4f(ambient + diffuse + specular, 1);     } } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0443\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u043e\u0438\u043d\u0441\u0442\u0432\u0430 \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u0414\u0435\u043b\u0430\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u0438 IDE \u0441\u0440\u0430\u0437\u0443 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/12e\/b5e\/2a1\/12eb5e2a187d460cb4873625b4169c6e.png\"\/><\/p>\n<p>  \u0421\u043c\u043e\u0442\u0440\u0438\u043c \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u043d\u0430 \u0432\u0445\u043e\u0434 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 (ctrl+space).<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/81d\/985\/9ae\/81d9859aece145b082134bb921305c9d.png\"\/><\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u044e\u043d\u0438\u0442 \u0442\u0435\u0441\u0442 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u0434\u0435\u0431\u0430\u0433\u0435 \u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/bee\/c27\/75a\/beec2775afbe4fb59ba8361c9819cf6f.png\"\/><\/p>\n<h3>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430<\/h3>\n<p>  SpecularFi (fragment input). \u041a\u043b\u0430\u0441\u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435, \u044f\u0432\u043b\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u0434\u043b\u044f \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u043c\u0438 \u0434\u043b\u044f \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u043e\u0433\u043e.<\/p>\n<pre><code class=\"java\">public class SpecularFi extends BaseVSOutput {    public Vec3f normal;    public Vec3f csNormal;\/\/cam space normal    public Vec3f csEyeDir;    public Vec2f uv;    public Vec3f csLightDir;\/\/cam space light dir } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0412\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440<\/h3>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 \u2014 \u044d\u0442\u043e Groovy-\u043a\u043b\u0430\u0441\u0441, \u0441 uniform \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u043f\u043e\u043b\u044f\u0445 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c main \u0441 \u044f\u0432\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0438 \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"java\">class SpecularV extends VertexShaderParent&lt;SpecularVi, SpecularFi&gt; {    public Matrix3 normalMatrix;    public Matrix4 modelViewProjectionMatrix;    public Vec3f lightDir     void main(SpecularVi i, SpecularFi o) {        o.normal = i.normal        o.csNormal = normalMatrix * i.normal        o.gl_Position = modelViewProjectionMatrix * Vec4f(i.pos, 1)        o.csEyeDir = o.gl_Position.xyz        o.uv = i.uv        o.csLightDir = normalMatrix * lightDir    } } <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430<\/h3>\n<p>  SpecularVi (vertex input). \u041a\u043b\u0430\u0441\u0441 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0439 \u043d\u0430 \u0432\u0445\u043e\u0434 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u043e\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443. \u0415\u0433\u043e \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0431\u0443\u0444\u0435\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0434 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0435\u0437 \u0443\u0447\u0430\u0441\u0442\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f \u0441 \u043a\u043e\u0434\u043e\u043c \u0448\u0435\u0439\u0434\u0435\u0440\u0430 (\u043f\u0440\u043e\u0449\u0430\u0439\u0442\u0435 glGetAttribLocation, glBindBuffer, glVertexAttribPointer \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0442\u0440\u043e\u0445\u0430).<\/p>\n<pre><code class=\"java\">public class SpecularVi {     public Vec3f normal;     public Vec3f pos;     public Vec2f uv; } <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438\u0445 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443:<\/p>\n<pre><code class=\"java\">SpecularF fragmentShader = new SpecularF(); SpecularV vertexShader = new SpecularV(); GShader shaderProgram = new GShader(vertexShader, fragmentShader); <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0438\u0445 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u0428\u0435\u0439\u0434\u0435\u0440\u0430 \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043d\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0435 (\u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0431\u043b\u0435\u0441\u043a\u0430, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0432\u0435\u0442\u0430, \u0438 \u0434\u0440.).<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u0431\u0443\u0444\u0435\u0440 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u0417\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u043a\u043b\u0430\u0441\u0441, \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u0434\u0430\u043b \u043d\u0430 \u0432\u0445\u043e\u0434 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u043e\u043c\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0443.<\/p>\n<pre><code class=\"java\">ReflectionVBO vbo1 = new ReflectionVBO(); vbo1.bindToShader(shaderProgram); vbo1.setData(al(        new SpecularVi(v3(-5, -5, 0), v3(-1,-1, 1).normalized(), v2(0, 1)),        new SpecularVi(v3( 5, -5, 0), v3( 1,-1, 1).normalized(), v2(1, 1)),        new SpecularVi(v3( 5,  5, 0), v3( 1, 1, 1).normalized(), v2(1, 0)),        new SpecularVi(v3(-5,  5, 0), v3(-1, 1, 1).normalized(), v2(0, 0)))); vbo1.upload(); <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432. \u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e\u043b\u0435\u0439 \u0432 Groovy-\u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432 (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u043b\u0438\u0441\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0432 \u0432\u0438\u0434\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445).<\/p>\n<pre><code class=\"java\">fragmentShader.shininess = 100; vertexShader.lightDir = new Vec3f(1, 1, 1).normalized();   \/\/enable texture texture.enable(0); fragmentShader.txt.set(texture);   \/\/give data to shader shaderProgram.currentVBO = vbo1; <\/code><\/pre>\n<p>  \u0418, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430.<\/p>\n<pre><code class=\"java\">shaderProgram.enable(); indices.draw(); <\/code><\/pre>\n<p>  \u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442 \u0448\u0435\u0439\u0434\u0435\u0440\u0430.<\/p>\n<pre><code class=\"java\">f.main(vso, frame); assertEquals(1, frame.gl_FragColor.w, 0.000001); assertEquals(1 + 0.1 + 0.6, frame.gl_FragColor.x, 0.0001); assertEquals(1 + 0.1 + 0.5, frame.gl_FragColor.y, 0.0001); assertEquals(1 + 0.1 + 0.3, frame.gl_FragColor.z, 0.0001); <\/code><\/pre>\n<p>  \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 <a href=\"https:\/\/github.com\/kravchik\/senjin\/tree\/master\/src\/main\/java\/yk\/senjin\/shaders\/gshader\/examples\/specular\">\u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0442\u0443\u0442<\/a>.<\/p>\n<pre><code class=\"java\">Test.java \/\/\u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 RawSpecular.java \/\/\u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043c\u0435\u0439\u043d\u0438\u043a \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0438\u0439 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0434\u043b\u044f \u0445\u0430\u0431\u0440\u0430 SpecularF.groovy \/\/\u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 SpecularV.groovy \/\/\u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u044b\u0439 \u0448\u0435\u0439\u0434\u0435\u0440 SpecularVi.java \/\/\u043a\u043b\u0430\u0441\u0441, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0435\u0440\u0442\u0435\u043a\u0441 (specular Vertex shader Input) SpecularFi.java \/\/\u043a\u043b\u0430\u0441\u0441, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0434\u0443\u0449\u0438\u0435 \u0438\u0437 \u0432\u0435\u0440\u0442\u0435\u043a\u0441\u043d\u043e\u0433\u043e \u0432 \u043f\u0438\u043a\u0441\u0435\u043b\u044c\u043d\u044b\u0439 (specular Fragment shader Input) \u0448\u0435\u0439\u0434\u0435\u0440 WatchSpecular.java \/\/\u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043c\u0435\u0439\u043d\u0438\u043a \u0441 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438, \u043c\u044b\u0448\u044c\u044e, \u0438 \u043f\u0440\u043e\u0447\u0438\u043c, \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u044e\u0449\u0438\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u044e\u0449\u0438\u043c \u044d\u043a\u0441\u043f\u0438\u0440\u0438\u0435\u043d\u0441 <\/code><\/pre>\n<p>  \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043b\u0435\u0433\u043a\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Maven:<\/p>\n<pre><code class=\"xml\">    &lt;dependencies&gt;         &lt;dependency&gt;             &lt;groupId&gt;yk&lt;\/groupId&gt;             &lt;artifactId&gt;senjin&lt;\/artifactId&gt;             &lt;version&gt;0.11&lt;\/version&gt;         &lt;\/dependency&gt;     &lt;\/dependencies&gt;      &lt;repositories&gt;         &lt;repository&gt;             &lt;id&gt;yk.senjin&lt;\/id&gt;             &lt;url&gt;https:\/\/github.com\/kravchik\/mvn-repo\/raw\/master&lt;\/url&gt;         &lt;\/repository&gt;     &lt;\/repositories&gt; <\/code><\/pre>\n<p>  \u041d\u0443 \u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e \u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0442\u043b\u0438\u0447\u0438\u044f\u0445:<\/p>\n<ol>\n<li>\u0432 \u0442\u0435\u043b\u0435 \u0448\u0435\u0439\u0434\u0435\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f Vec3f \u0432\u043c\u0435\u0441\u0442\u043e vec3 (\u0433\u0440\u0443\u0432\u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u0440\u0443\u0436\u0438\u0442\u044c \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c\u0441\u044f \u0441 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0431\u0443\u043a\u0432\u044b)<\/li>\n<li>\u043d\u0435\u0442 uniform \u2014 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043b\u044f \u0432 \u0448\u0435\u0439\u0434\u0435\u0440\u0435<\/li>\n<li>\u043d\u0435\u0442 varying, in, out \u2014 \u0432\u043c\u0435\u0441\u0442\u043e \u043d\u0438\u0445 \u043f\u043e\u043b\u044f \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0432 main<\/li>\n<\/ol>\n<p>  P.S. \u041f\u0440\u043e\u0435\u043a\u0442 \u044f \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u044e \u0441\u0442\u0438\u0445\u0438\u0439\u043d\u043e \u2014 \u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0447\u0442\u043e-\u0442\u043e, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u043e\u043a\u0430 \u043d\u0435 \u0443\u0441\u043f\u0435\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0438\u043b\u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f (android? geometry shaders? kotlin?) \u2014 \u043e\u0431\u0440\u0430\u0449\u0430\u0439\u0442\u0435\u0441\u044c, \u043e\u0431\u0441\u0443\u0434\u0438\u043c!<\/p>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u0445\u043e\u0447\u0443 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u044c  <a href=\"http:\/\/habrahabr.ru\/users\/oshyshko\/\" class=\"user_link\">oshyshko<\/a> \u0438  <a href=\"http:\/\/habrahabr.ru\/users\/olexiy\/\" class=\"user_link\">olexiy<\/a> \u0437\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u0442\u0430\u0442\u044c\u0438.       <\/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=\"http:\/\/habrahabr.ru\/post\/269591\/\"> http:\/\/habrahabr.ru\/post\/269591\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/602\/ce8\/00a\/602ce800a93f4c2bb090f0b42a12259a.png\"\/><\/p>\n<p>  \u041f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432. \u0421\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0448\u0435\u0439\u0434\u0435\u0440\u0430\u043c\u0438 \u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u042e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u0448\u0435\u0439\u0434\u0435\u0440\u043e\u0432, \u0434\u0435\u0431\u0430\u0433, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433, \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043a\u043e\u0434\u0430, \u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u043b\u043d\u0430\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 IDE. \u041e \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u0441\u0451 \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c, \u0432 \u0447\u0451\u043c \u043f\u043e\u0434\u0432\u043e\u0445, \u0438 \u0447\u0442\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043c\u0430\u0432\u0435\u043d\u0435\u2026  <\/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-266839","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266839","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=266839"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/266839\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}