{"id":3993,"date":"2014-08-05T03:54:17","date_gmt":"2014-08-04T18:54:17","guid":{"rendered":"http:\/\/mirror.boy.jp\/?p=1772"},"modified":"2014-08-05T03:54:17","modified_gmt":"2014-08-04T18:54:17","slug":"jit-gl-shader-glsl-%e3%81%a7%e3%83%95%e3%82%a9%e3%82%b0-maxmsp-jitter-glsl","status":"publish","type":"post","link":"https:\/\/inage.ksd6700.net\/?p=3993","title":{"rendered":"jit.gl.shader \/ GLSL \u3067\u30d5\u30a9\u30b0 #maxmsp #jitter #glsl"},"content":{"rendered":"<p><a href=\"http:\/\/mirror.boy.jp\/wp-content\/uploads\/2014\/08\/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2014-08-05-03.50.41.jpeg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/mirror.boy.jp\/wp-content\/uploads\/2014\/08\/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2014-08-05-03.50.41-1024x576.jpeg\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-08-05 03.50.41\" width=\"1024\" height=\"576\" class=\"alignnone size-large wp-image-1773\" \/><\/a><\/p>\n<p><a href=\"http:\/\/www.amazon.co.jp\/gp\/product\/0321498828?ie=UTF8&#038;camp=1207&#038;%23038;creative=8411&#038;%23038;creativeASIN=0321498828&#038;%23038;linkCode=shr&#038;%23038;tag=mrr05-22&#038;%23038;qid=1407162710&#038;%23038;sr=8-3&#038;%23038;keywords=opengl+superbible\">OpenGL Superbible<\/a>\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<h2>JXS \/ GLSL<\/h2>\n<pre class=\"brush: xml; title: ; notranslate\">\r\n&lt;jittershader name=&quot;mrr-3colored-lights&quot;&gt;\r\n\t&lt;description&gt;\r\n\t&lt;\/description&gt;\r\n\r\n\t&lt;language name=&quot;glsl&quot; version=&quot;1.2&quot;&gt;\r\n\t\t&lt;program name=&quot;vp&quot; type=&quot;vertex&quot;&gt;\r\n&lt;![CDATA[\r\n\r\n#version 120 \r\n\r\nvoid main(void)\r\n{\r\n\tgl_Position = gl_ModelViewProjectionMatrix *gl_Vertex;\r\n\t\r\n\tvec3 lightPos = gl_LightSource[0].position.xyz;\r\n\t\r\n\tvec3 N = normalize(gl_NormalMatrix * gl_Normal);\r\n\tvec4 V = gl_ModelViewMatrix *gl_Vertex;\r\n\tvec3 L = normalize(lightPos - V.xyz);\r\n\tvec3 H = normalize(L + vec3(0,0,1));\r\n\t\r\n\tconst float specularExp = 128.0;\r\n\t\r\n\t\r\n\tfloat NdotL =max(0,dot(N,L));\r\n\tvec4 diffuse = gl_Color * vec4(NdotL);\r\n\t\r\n\tfloat NdotH = max(0,dot(N,H));\r\n\tvec4 specular = vec4(0);\r\n\t\r\n\tif(NdotL &gt;0){\r\n\t\tspecular = vec4(pow ( NdotH,specularExp));\r\n\t}\r\n\t\r\n\tgl_FogFragCoord =length(V);\r\n\tgl_FrontColor = (diffuse + specular);\r\n}\r\n]]&gt;\r\n\t\t&lt;\/program&gt;\r\n\t\t&lt;program name=&quot;fp&quot; type=&quot;fragment&quot;&gt;\r\n&lt;![CDATA[\r\n\r\n#version 120\r\n\r\nvoid main()\r\n{\r\n\t const float e = 2.71828;\r\n\t float fogFactor = pow(0.5 *gl_FogFragCoord,2);\r\n\t fogFactor = clamp(pow(e,-fogFactor),0,1);\r\n\t \r\n\t const vec4 fogColor =vec4(0.5,0.5,0.5,0.4);\r\n\t gl_FragColor = mix(fogColor,gl_Color,fogFactor);\r\n}\r\n]]&gt;\r\n\t\t&lt;\/program&gt;\r\n\t&lt;\/language&gt;\r\n&lt;\/jittershader&gt;\r\n<\/pre>\n<p>Vertex Shader\u306e\u65b9\u3067\u30ab\u30e1\u30e9\u304b\u3089\u306e\u8ddd\u96e2\u3092\u7b97\u51fa\u3057\u3066\u304a\u3044\u3066\u3001Fragment Shadre\u3067\u8272\u3092\u8a08\u7b97\u3059\u308b\u6642\u306bFog\u306e\u65b9\u7a0b\u5f0f\u3092\u4f7f\u3063\u3066Fog\u91cf\u3092\u6c7a\u3081\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenGL Superbible&#12398;&#12469;&#12531;&#12503;&#12523;&#12467;&#12540;&#12489;&#12391;&#12377;&#12290; JXS \/  &#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/3993"}],"collection":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3993"}],"version-history":[{"count":0,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/3993\/revisions"}],"wp:attachment":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}