{"id":824,"date":"2012-03-27T00:05:04","date_gmt":"2012-03-26T21:05:04","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=824"},"modified":"2013-12-15T18:23:26","modified_gmt":"2013-12-15T15:23:26","slug":"shadow-casting-convex-hull-more-fake-shadows","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/03\/27\/shadow-casting-convex-hull-more-fake-shadows\/","title":{"rendered":"Shadow Casting + Convex Hull = More Fake Shadows"},"content":{"rendered":"<p><a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/ShadowCastingConvexHull2\/\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"825\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/03\/27\/shadow-casting-convex-hull-more-fake-shadows\/fake_shadow_casting_convex_hull1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_casting_convex_hull1.jpg?fit=680%2C465&amp;ssl=1\" data-orig-size=\"680,465\" 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;}\" data-image-title=\"fake_shadow_casting_convex_hull1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_casting_convex_hull1.jpg?fit=300%2C205&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_casting_convex_hull1.jpg?fit=680%2C465&amp;ssl=1\" class=\"alignnone size-full wp-image-825\" title=\"fake_shadow_casting_convex_hull1\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_casting_convex_hull1.jpg?resize=680%2C465\" width=\"680\" height=\"465\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_casting_convex_hull1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_casting_convex_hull1.jpg?resize=300%2C205&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Combine <a title=\"http:\/\/unitycoder.com\/blog\/2012\/01\/27\/simple-shadow-casting-algorithm-unity\/\" href=\"http:\/\/unitycoder.com\/blog\/2012\/01\/27\/simple-shadow-casting-algorithm-unity\/\" target=\"_blank\">Simple Shadow Casting<\/a> &amp; <a title=\"http:\/\/unitycoder.com\/blog\/2012\/03\/26\/monotone-chain-convex-hull-algorithm-unity\/\" href=\"http:\/\/unitycoder.com\/blog\/2012\/03\/26\/monotone-chain-convex-hull-algorithm-unity\/\" target=\"_blank\">Monotone Chain Convex Hull<\/a> and you have&#8230;more fake shadows for unity indie!!1<\/p>\n<p>Works fine for a box..should try the teapot next.<\/p>\n<p><strong>Details:<\/strong><br \/>\n&#8211; Calculate vectors from the light, through every vertex in target object,\u00a0 lengthen the vector until reach ground (y=0)<br \/>\n&#8211; You get list of points in the ground, convex hull them to get shadow outline<br \/>\n&#8211; Create shadow mesh from the convex hull points<\/p>\n<p><strong>Ideas:<\/strong><br \/>\n&#8211; Try multiple lights? Multiple objects?<br \/>\n&#8211; Soft shadows? (shader)<br \/>\n&#8211; ShadowMesh could have trigger collider, to check if object enters shadow?<br \/>\n&#8211; Use ShadowMesh as a mask for something else..(?)<br \/>\n&#8211; Only cast shadows for objects in view? (or objects within _ &#8211; range from light?)<br \/>\n<strong>Webplayer:<\/strong><br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/ShadowCastingConvexHull2\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/ShadowCastingConvexHull2\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/ShadowCastingConvexHull2\/<\/a><\/p>\n<p><strong>Download source:<\/strong><br \/>\n<a title=\"Download Source\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=1333&amp;uid=un1t3c0d5r\" target=\"_blank\"> shadowhull1.unityPackage<\/a><\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#2:<\/strong> Deep profiler report (array sorting seems to take most of the time..)<\/p>\n<p><a title=\"http:\/\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1.jpg\" href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1.jpg\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"835\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/03\/27\/shadow-casting-convex-hull-more-fake-shadows\/fake_shadow_hull_profiler1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1.jpg?fit=994%2C797&amp;ssl=1\" data-orig-size=\"994,797\" 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;}\" data-image-title=\"fake_shadow_hull_profiler1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1.jpg?fit=300%2C240&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1.jpg?fit=994%2C797&amp;ssl=1\" class=\"alignnone size-medium wp-image-835\" title=\"fake_shadow_hull_profiler1\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1-300x240.jpg?resize=300%2C240\" width=\"300\" height=\"240\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1.jpg?resize=300%2C240&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1.jpg?resize=200%2C160&amp;ssl=1 200w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_hull_profiler1.jpg?w=994&amp;ssl=1 994w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Combine Simple Shadow Casting &amp; Monotone Chain Convex Hull and you have&#8230;more fake shadows for unity indie!!1 Works fine for a box..should try the teapot next. Details: &#8211; Calculate vectors from the light, through every vertex in target object,\u00a0 lengthen the vector until reach ground [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":825,"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":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4,3],"tags":[133,215,7,40,217,216],"class_list":["post-824","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-casting","tag-convex-hull","tag-fake","tag-shadow","tag-shadow-caster","tag-simple"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/fake_shadow_casting_convex_hull1.jpg?fit=680%2C465&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-di","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=824"}],"version-history":[{"count":9,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/824\/revisions"}],"predecessor-version":[{"id":2545,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/824\/revisions\/2545"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/825"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}