{"id":141,"date":"2014-12-27T18:37:36","date_gmt":"2014-12-27T16:37:36","guid":{"rendered":"http:\/\/heikkili.kapsi.fi\/blog\/?p=141"},"modified":"2017-01-22T19:47:03","modified_gmt":"2017-01-22T17:47:03","slug":"cg-study-8","status":"publish","type":"post","link":"http:\/\/heikkili.kapsi.fi\/blog\/?p=141","title":{"rendered":"DirectX11 book exercises chapter 11"},"content":{"rendered":"<p>I Did some more exercises from Directx 11 book. Chapter 11 The Geometry Shader had couple interesting exercises.<\/p>\n<p>First one was exercise 3 that asked to implement a simple explosion effect in geometry shader to an icosahedron where each triangle are translated to the direction of their face normal as a function of time. The geometry shader counts the face normal then translates the three vertices of the triangle. I added this to previous modified crate demo that had nice fire texture and changed also the box in it to icosahedron.<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/\/ simple explosion geometry shader\r\n&#x5B;maxvertexcount(3)]\r\nvoid GS(triangle VertexOut gin&#x5B;3],\r\n\tuint primID: SV_PrimitiveID,\r\n\tinout TriangleStream&lt;GeoOut&gt; triStream)\r\n{\r\n\tfloat3 u = gin&#x5B;1].PosW - gin&#x5B;0].PosW;\r\n\tfloat3 v = gin&#x5B;2].PosW - gin&#x5B;0].PosW;\r\n\r\n\tfloat3 n = cross(u, v);\r\n\tn = normalize(n);\r\n\r\n\tfloat3 speed = 0.02f * primID%5;\r\n\r\n\tfloat4 tri&#x5B;3];\r\n\ttri&#x5B;0] = float4(gin&#x5B;0].PosW + speed*gTime*n, 1.0f);\r\n\ttri&#x5B;1] = float4(gin&#x5B;1].PosW + speed*gTime*n, 1.0f);\r\n\ttri&#x5B;2] = float4(gin&#x5B;2].PosW + speed*gTime*n, 1.0f);\r\n\r\n\tGeoOut gout;\r\n\t&#x5B;unroll]\r\n\tfor (int i = 0; i &lt; 3; ++i)\r\n\t{\r\n\t\tgout.PosH = mul(tri&#x5B;i], gWorldViewProj);\r\n\t\tgout.PosW = tri&#x5B;i].xyz;\r\n\t\tgout.NormalW = gin&#x5B;i].NormalW;\r\n\t\tgout.Tex = gin&#x5B;i].Tex;\r\n\r\n\t\ttriStream.Append(gout);\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech11ex3.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"142\" data-permalink=\"http:\/\/heikkili.kapsi.fi\/blog\/?attachment_id=142\" data-orig-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech11ex3.png?fit=816%2C639\" data-orig-size=\"816,639\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Capturech11ex3\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech11ex3.png?fit=300%2C235\" data-large-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech11ex3.png?fit=650%2C509\" tabindex=\"0\" role=\"button\" class=\" size-medium wp-image-142 alignleft\" src=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech11ex3.png?resize=300%2C235\" alt=\"Capturech11ex3\" width=\"300\" height=\"235\" srcset=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech11ex3.png?resize=300%2C235 300w, https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech11ex3.png?resize=383%2C300 383w, https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech11ex3.png?w=816 816w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>5 subdivisions and black background in 0.1 second starts to look nice:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capture5sub.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"143\" data-permalink=\"http:\/\/heikkili.kapsi.fi\/blog\/?attachment_id=143\" data-orig-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capture5sub.png?fit=816%2C639\" data-orig-size=\"816,639\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Capture5sub\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capture5sub.png?fit=300%2C235\" data-large-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capture5sub.png?fit=650%2C509\" tabindex=\"0\" role=\"button\" class=\"alignleft size-medium wp-image-143\" src=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capture5sub.png?resize=300%2C235\" alt=\"Capture5sub\" width=\"300\" height=\"235\" srcset=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capture5sub.png?resize=300%2C235 300w, https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capture5sub.png?resize=383%2C300 383w, https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capture5sub.png?w=816 816w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Other exercises where drawing cylinder from circle in gs and subdividing icosahedron and also experimenting with tree billboards demo with different draw calls together with size of the quads and primitive id.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I Did some more exercises from Directx 11 book. Chapter 11 The Geometry Shader had couple interesting exercises. First one was exercise 3 that asked to implement a simple explosion effect in geometry shader to an icosahedron where each triangle are translated to the direction of their face normal as a function of time. The&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[5],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-explosion"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7k3DT-2h","_links":{"self":[{"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/posts\/141"}],"collection":[{"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=141"}],"version-history":[{"count":8,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":235,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions\/235"}],"wp:attachment":[{"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}