{"id":135,"date":"2014-12-25T13:39:10","date_gmt":"2014-12-25T11:39:10","guid":{"rendered":"http:\/\/heikkili.kapsi.fi\/blog\/?p=135"},"modified":"2024-09-15T14:15:47","modified_gmt":"2024-09-15T12:15:47","slug":"cg-study-7","status":"publish","type":"post","link":"http:\/\/heikkili.kapsi.fi\/blog\/?p=135","title":{"rendered":"CG study #7"},"content":{"rendered":"<p>Chapter 10 teach about stencil buffer and using it to mark a mirror from drawing a reflection or to use it to draw planar shadows.<\/p>\n<p><strong>ex 3<\/strong> asked to produce image on figure 10.1 left side where all of the reflected skull was rendered not only the mirror part. This can be achieved by changing render state used when drawing mirror. In the <strong>D3D11_DEPTH_STENCIL_DESC drawReflectionDesc<\/strong> the FrontFace StencilFunc need to be changed to\u00a0 <strong>D3D11_COMPARISON_ALWAYS<\/strong> so all of the reflection will drawn.<\/p>\n<p><strong>ex. 4<\/strong> asked to produce left of the figure 10.10 this could be achieved by hanging front face stencil function to\u00a0<strong>D3D11_STENCIL_OP_KEEP<\/strong> so all the reflected triangles on shadow would be drawn on top of each other showing those parts as darker.<\/p>\n<p><strong>ex. 7<\/strong> was exercise about drawing cylinder with a bolt texture animation with additive blending. The cylinder had to be drawn last in the scene so that blend works correctly.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex7.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"137\" data-permalink=\"http:\/\/heikkili.kapsi.fi\/blog\/?attachment_id=137\" data-orig-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex7.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=\"Capturech10ex7\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex7.png?fit=300%2C235\" data-large-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex7.png?fit=650%2C509\" tabindex=\"0\" role=\"button\" class=\"size-medium wp-image-137 aligncenter\" src=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex7.png?resize=300%2C235\" alt=\"Capturech10ex7\" width=\"300\" height=\"235\" srcset=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex7.png?resize=300%2C235 300w, https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex7.png?resize=383%2C300 383w, https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex7.png?w=816 816w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Here is definition of <strong>additive blending<\/strong> blend state description:<\/p>\n<pre><pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\nD3D11_BLEND_DESC additiveBlendDesc = { 0 };\nadditiveBlendDesc.AlphaToCoverageEnable = false;\nadditiveBlendDesc.IndependentBlendEnable = false;\n\nadditiveBlendDesc.RenderTarget&#x5B;0].BlendEnable = true;\nadditiveBlendDesc.RenderTarget&#x5B;0].SrcBlend = D3D11_BLEND_ONE;\nadditiveBlendDesc.RenderTarget&#x5B;0].DestBlend = D3D11_BLEND_ONE;\nadditiveBlendDesc.RenderTarget&#x5B;0].BlendOp = D3D11_BLEND_OP_ADD;\nadditiveBlendDesc.RenderTarget&#x5B;0].SrcBlendAlpha = D3D11_BLEND_ZERO;\nadditiveBlendDesc.RenderTarget&#x5B;0].DestBlendAlpha = D3D11_BLEND_ZERO;\nadditiveBlendDesc.RenderTarget&#x5B;0].BlendOpAlpha = D3D11_BLEND_OP_ADD;\nadditiveBlendDesc.RenderTarget&#x5B;0].RenderTargetWriteMask = 0x0F;\n\nHR(device-&amp;amp;amp;amp;gt;CreateBlendState(&amp;amp;amp;amp;amp;additiveBlendDesc, &amp;amp;amp;amp;amp;additiveBS));\n<\/pre>\n<p><strong>\u00a0ex.11<\/strong> asked to modify the mirror demo so that the floor is also reflected into the mirror.<\/p>\n<p>This was done same way as drawing the skull reflection before drawing the mirror with alpha blending.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex11.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"139\" data-permalink=\"http:\/\/heikkili.kapsi.fi\/blog\/?attachment_id=139\" data-orig-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex11.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=\"Capturech10ex11\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex11.png?fit=300%2C235\" data-large-file=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex11.png?fit=650%2C509\" tabindex=\"0\" role=\"button\" class=\"alignleft size-medium wp-image-139\" src=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex11.png?resize=300%2C235\" alt=\"Capturech10ex11\" width=\"300\" height=\"235\" srcset=\"https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex11.png?resize=300%2C235 300w, https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex11.png?resize=383%2C300 383w, https:\/\/i0.wp.com\/heikkili.kapsi.fi\/blog\/wp-content\/uploads\/2014\/12\/Capturech10ex11.png?w=816 816w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Chapter 10 teach about stencil buffer and using it to mark a mirror from drawing a reflection or to use it to draw planar shadows. ex 3 asked to produce image on figure 10.1 left side where all of the reflected skull was rendered not only the mirror part. This can be achieved by changing&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":[6],"tags":[4,2,31],"class_list":["post-135","post","type-post","status-publish","format-standard","hentry","category-computer-graphics","tag-c","tag-directx11","tag-study"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7k3DT-2b","_links":{"self":[{"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/posts\/135"}],"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=135"}],"version-history":[{"count":11,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/posts\/135\/revisions"}],"predecessor-version":[{"id":639,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=\/wp\/v2\/posts\/135\/revisions\/639"}],"wp:attachment":[{"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=135"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=135"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/heikkili.kapsi.fi\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=135"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}