{"id":757,"date":"2012-03-15T01:38:09","date_gmt":"2012-03-14T22:38:09","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=757"},"modified":"2013-10-13T19:00:02","modified_gmt":"2013-10-13T16:00:02","slug":"fake-realtime-shadows-with-surface-shader","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/03\/15\/fake-realtime-shadows-with-surface-shader\/","title":{"rendered":"Fake Realtime Shadows With Surface Shader"},"content":{"rendered":"<p><a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeShadowShader2\/\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"766\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/03\/15\/fake-realtime-shadows-with-surface-shader\/more_fake_shadows_shader2\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/more_fake_shadows_shader2.jpg?fit=680%2C570&amp;ssl=1\" data-orig-size=\"680,570\" 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=\"more_fake_shadows_shader2\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/more_fake_shadows_shader2.jpg?fit=300%2C251&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/more_fake_shadows_shader2.jpg?fit=680%2C570&amp;ssl=1\" class=\"alignnone size-full wp-image-766\" title=\"more_fake_shadows_shader2\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/more_fake_shadows_shader2.jpg?resize=680%2C570\" width=\"680\" height=\"570\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/more_fake_shadows_shader2.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/more_fake_shadows_shader2.jpg?resize=300%2C251&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Yes! After several hours of shader errors, finally got this working, fake realtime shadows using shader (2D)<\/p>\n<p>Its using obstacle map texture (see image#2), so thats the 1st downside of it,<br \/>\nbut still better than nothing..<\/p>\n<p>More info later..<\/p>\n<p><strong>Ideas to try:<\/strong><br \/>\n&#8211; Blur the wall map texture, Soft shadows?<br \/>\n&#8211; Add 2nd pass for: combining the shadow, instead of 1st pass? or use 2nd pass for blurring?<br \/>\n&#8211; Would this work as camera shader, using depthmap as an automatic obstacle map? (*problem: how to get neighbour pixel colors from vertex color..?)<br \/>\n&#8211; Fake directional light shadows should be even easier?<br \/>\n&#8211; Use light attenuation for shadow \/ light strength?<\/p>\n<p><strong>Current progress:<\/strong><br \/>\n&#8211; Can use screenshot as an automatic wall mask texture, no need to create it manually<br \/>\n&#8211; But that creates another problem, the view should be same size as plane\/texture?<br \/>\n&#8211; Using depthmap as wall mask would give realtime shadows, with moving objects also,<br \/>\nbut no idea how to use depth pass like a texture+uv with Tex2D..<\/p>\n<p><strong>Webplayer:<\/strong><br \/>\n<a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/mFakeShadowShader2\/\" target=\"_blank\">http:\/\/unitycoder.com\/upload\/demos\/mFakeShadowShader2\/<\/a><\/p>\n<p><strong>Download source:<\/strong><br \/>\n<a title=\"Download Source\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=1329&amp;uid=un1t3c0d5r\" target=\"_blank\"> fakeShadowShader.unityPackage<\/a><\/p>\n<p>&#8212;<\/p>\n<p>*image#2: obstacle texture map<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"760\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/03\/15\/fake-realtime-shadows-with-surface-shader\/wallmap\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/wallmap.jpg?fit=300%2C300&amp;ssl=1\" data-orig-size=\"300,300\" 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=\"wallmap\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/wallmap.jpg?fit=300%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/wallmap.jpg?fit=300%2C300&amp;ssl=1\" class=\"alignnone size-full wp-image-760\" title=\"wallmap\" alt=\"\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/wallmap.jpg?resize=300%2C300\" width=\"300\" height=\"300\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/wallmap.jpg?w=300&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/wallmap.jpg?resize=150%2C150&amp;ssl=1 150w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yes! After several hours of shader errors, finally got this working, fake realtime shadows using shader (2D) Its using obstacle map texture (see image#2), so thats the 1st downside of it, but still better than nothing.. More info later.. Ideas to try: &#8211; Blur the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":766,"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":[7,154,205,48,14,132],"class_list":["post-757","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-fake","tag-free","tag-indie","tag-realtime","tag-shader","tag-shadows"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/03\/more_fake_shadows_shader2.jpg?fit=680%2C570&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-cd","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/757","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=757"}],"version-history":[{"count":10,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/757\/revisions"}],"predecessor-version":[{"id":2483,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/757\/revisions\/2483"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/766"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}