{"id":3994,"date":"2014-08-05T01:58:38","date_gmt":"2014-08-04T16:58:38","guid":{"rendered":"http:\/\/mirror.boy.jp\/?p=1767"},"modified":"2014-08-05T01:58:38","modified_gmt":"2014-08-04T16:58:38","slug":"jit-gl-shader-glsl-%e3%81%a7%e3%83%97%e3%83%ad%e3%82%b7%e3%83%bc%e3%82%b8%e3%83%a3%e3%83%ab%e3%83%86%e3%82%af%e3%82%b9%e3%83%81%e3%83%a3%ef%bc%88%e6%98%9f%ef%bc%89%e7%94%9f%e6%88%90-%e3%81%9d","status":"publish","type":"post","link":"https:\/\/inage.ksd6700.net\/?p=3994","title":{"rendered":"jit.gl.shader \/ GLSL \u3067\u30d7\u30ed\u30b7\u30fc\u30b8\u30e3\u30eb\u30c6\u30af\u30b9\u30c1\u30e3\uff08\u661f\uff09\u751f\u6210 \u305d\u306e\uff12 #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-01.25.04.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-01.25.04-1024x576.jpeg\" alt=\"\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8 2014-08-05 01.25.04\" width=\"1024\" height=\"576\" class=\"alignnone size-large wp-image-1768\" \/><\/a><\/p>\n<h2>\u914d\u8272\u304cRedbull\u611f<\/h2>\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<a href=\"http:\/\/www.redbull.com\/jp\/ja\">\u30ec\u30c3\u30c9\u30d6\u30eb<\/a>\u304c\u98f2\u307f\u305f\u304f\u306a\u308b\u914d\u8272\u3002<\/p>\n<h2>JXS \/ GLSL\u30b3\u30fc\u30c9<\/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\nvarying vec3 N,L,V;\r\n\r\nvoid main(void)\r\n{\r\n\tvec3 lightPos = gl_LightSource[0].position.xyz;\r\n\r\n\tgl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\t\r\n\t\r\n\t\/\/map object-space position onto unit sphere\r\n\tV =gl_Vertex.xyz;\r\n\t\r\n\t\/\/eye-space normal\r\n\tN = gl_NormalMatrix * gl_Normal;\r\n\t\r\n\t\/\/eye-space light vector\r\n\tvec4 Veye = gl_ModelViewMatrix * gl_Vertex;\r\n\tL =lightPos - Veye.xyz;\t\r\n}\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\nvarying vec3 V;\r\nvarying vec3 N;\r\nvarying vec3 L;\r\n\r\nconst vec3 myRed \t= vec3(0.6,0,0);\r\nconst vec3 myYellow = vec3(0.6,0.5,0);\r\nconst vec3 myBlue \t= vec3(0,0.3,0.6);\r\n\r\n\/\/Star Vertex\r\nconst vec3 myHalfSpace0 = vec3(0.31,0.95,0);\r\nconst vec3 myHalfSpace1 = vec3(-0.81,0.59,0);\r\nconst vec3 myHalfSpace2 = vec3(-0.81,-0.59,0);\r\nconst vec3 myHalfSpace3 = vec3(0.31,-0.95,0);\r\nconst vec3 myHalfSpace4 = vec3(1.,0.,0.);\r\n\r\nconst float stripeThickness = 0.4;\r\nconst float starSize = 0.2;\r\nconst float smoothEdgeTol = 0.005;\r\nconst float ambientLighting = 0.5;\r\nconst float specularExp = 128.0;\r\nconst float specularIntensity = 1.;\r\n\r\nvoid main()\r\n{\r\n\tvec4 distVector;\r\n\tfloat distScalar;\r\n\t\r\n\tvec3 NN = normalize(N);\r\n\tvec3 NL = normalize(L); \/\/for ambient;\r\n\tvec3 NH = normalize(NL +vec3(0,0,1)); \/\/for specular\r\n\tvec3 NV = normalize(V);\r\n\t\r\n\tfloat myInOut = -3;\r\n\t\r\n\tdistVector.x = dot(NV, myHalfSpace0);\r\n\tdistVector.y = dot(NV, myHalfSpace1);\r\n\tdistVector.z = dot(NV, myHalfSpace2);\r\n\tdistVector.w = dot(NV, myHalfSpace3);\r\n\tdistScalar = dot(NV,myHalfSpace4);\r\n\t\r\n\tdistVector += starSize;\r\n\tdistScalar += starSize;\r\n\t\r\n\t\/\/map 0 ~ 1\r\n\tdistVector = smoothstep(0.,smoothEdgeTol, distVector);\r\n\tdistScalar = smoothstep(0.,smoothEdgeTol, distScalar);\r\n\t\r\n\tmyInOut += dot(distVector, vec4(1.0));\r\n\tmyInOut += distScalar;\r\n\tmyInOut = clamp(myInOut, 0,1);\r\n\t\r\n\tvec3 surfColor = mix(myYellow, myRed, myInOut);\r\n\t\r\n\tmyInOut = smoothstep(0,smoothEdgeTol,abs(NV.z) - stripeThickness);\r\n\tsurfColor = mix(myBlue,surfColor,myInOut);\r\n\t\r\n\tsurfColor *= (ambientLighting + vec3(max(0,dot(NN,NL))));\t\r\n\tsurfColor += (specularIntensity * vec3(pow(max(0,dot(NN,NH)),specularExp)));\r\n\t\r\n\tgl_FragColor = vec4(surfColor,1);\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>\u661f\u306e\u5404\u70b9\u3068\u306e\u5185\u7a4d\u3092\u3068\u3063\u3066\u3001\u661f\u306e\u9802\u70b9\u65b9\u5411\u306e\u9577\u3055\uff08\uff10\u4ee5\u4e0a\uff11\u4ee5\u4e0b\uff09\u3092\u5408\u8a08\u3057\u661f\u306e\u30b5\u30a4\u30ba\u3092\u30aa\u30d5\u30bb\u30c3\u30c8\u3068\u3057\u3066\u52a0\u7b97\u3002\u305d\u306e\u5024\u304c\u95be\u5024\u3092\u8d85\u3048\u305f\u3089\u8d64\u8272\u306b\u3057\u3066\u3001\u8d85\u3048\u306a\u304b\u3063\u305f\u3089\u9ec4\u8272\u306b\u5857\u3063\u3066\u661f\u3092\u63cf\u753b\u3057\u3066\u3044\u308b\u3002\u661f\u306e\u9802\u70b9\u4f4d\u7f6e\u3068Vertex\u306e\u5358\u4f4d\u30d9\u30af\u30c8\u30eb\u306e\u95a2\u4fc2\u6027\u3092\u4f7f\u3063\u3066\u661f\u306e\u5f62\u3092\u63cf\u753b\u3057\u3066\u3044\u308b\u306e\u3060\u304c\u3001\u3061\u3087\u3063\u3068\u307e\u3060\u7406\u89e3\u3057\u304d\u308c\u3066\u3044\u306a\u3044\u30fb\u30fb\u30fb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#37197;&#33394;&#12364;Redbull&#24863; OpenGL Superbible&#12398;&#12469;&#12531;&#12503;&#12523;&#12467; &#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\/3994"}],"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=3994"}],"version-history":[{"count":0,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=\/wp\/v2\/posts\/3994\/revisions"}],"wp:attachment":[{"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inage.ksd6700.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}