{"id":4101,"date":"2015-12-06T17:21:55","date_gmt":"2015-12-06T14:21:55","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=4101"},"modified":"2015-12-06T17:21:55","modified_gmt":"2015-12-06T14:21:55","slug":"custom-shader-transparency-batching-issues","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2015\/12\/06\/custom-shader-transparency-batching-issues\/","title":{"rendered":"Custom shader Transparency &#038; Batching issues"},"content":{"rendered":"<p>While updating this billboard shader <a href=\"https:\/\/github.com\/unitycoder\/DoomStyleBillboardTest\" target=\"_blank\">https:\/\/github.com\/unitycoder\/DoomStyleBillboardTest<\/a> , had couple strange shader issues:<\/p>\n<p><strong>Problem#1:<br \/>\nOverlapping transparent area clips other object behind it<\/strong> (see <a href=\"https:\/\/github.com\/unitycoder\/DoomStyleBillboardTest\/issues\/6\" target=\"_blank\">issue#6<\/a>)<\/p>\n<p>This one was solved by adding &#8220;ZWrite Off&#8221; to the shader, apparently something to do how transparent objects get depth sorted..(?)<br \/>\n<a href=\"http:\/\/docs.unity3d.com\/Manual\/SL-CullAndDepth.html\" target=\"_blank\">http:\/\/docs.unity3d.com\/Manual\/SL-CullAndDepth.html<\/a><\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4102\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2015\/12\/06\/custom-shader-transparency-batching-issues\/custom_shader_transparency_issue_1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/12\/custom_shader_transparency_issue_1.gif?fit=322%2C352&amp;ssl=1\" data-orig-size=\"322,352\" 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=\"custom_shader_transparency_issue_1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/12\/custom_shader_transparency_issue_1.gif?fit=322%2C352&amp;ssl=1\" class=\"alignnone size-full wp-image-4102\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/12\/custom_shader_transparency_issue_1.gif?resize=322%2C352\" alt=\"custom_shader_transparency_issue_1\" width=\"322\" height=\"352\" \/> (image, problem#1)<\/p>\n<p>&#8212;<\/p>\n<p><strong>Problem#2:<br \/>\nIf there are multiple copies of the same object, rotation\/scale\/direction is broken, object moves to wrong direction as if they are locked together<\/strong> (see <a href=\"https:\/\/github.com\/unitycoder\/DoomStyleBillboardTest\/issues\/5\" target=\"_blank\">issue#5<\/a>)<\/p>\n<p>This one was solved by adding DisableBatching&#8221;=&#8221;True&#8221; to the shader tags. So Dynamic Batching was the issue..<\/p>\n<p>Tags {&#8220;Queue&#8221;=&#8221;Transparent&#8221; &#8220;IgnoreProjector&#8221;=&#8221;True&#8221; &#8220;RenderType&#8221;=&#8221;Transparent&#8221; <strong>&#8220;DisableBatching&#8221;=&#8221;True&#8221;<\/strong>}<\/p>\n<p>Other option was to disable [ ] Dynamic Batching from player settings.. but that would disable it for all objects..<br \/>\n<a href=\"http:\/\/docs.unity3d.com\/500\/Documentation\/Manual\/SL-SubshaderTags.html\" target=\"_blank\">http:\/\/docs.unity3d.com\/500\/Documentation\/Manual\/SL-SubshaderTags.html<\/a><\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4103\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2015\/12\/06\/custom-shader-transparency-batching-issues\/custom_shader_batching_issue_2\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/12\/custom_shader_batching_issue_2.gif?fit=322%2C352&amp;ssl=1\" data-orig-size=\"322,352\" 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=\"custom_shader_batching_issue_2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/12\/custom_shader_batching_issue_2.gif?fit=322%2C352&amp;ssl=1\" class=\"alignnone size-full wp-image-4103\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/12\/custom_shader_batching_issue_2.gif?resize=322%2C352\" alt=\"custom_shader_batching_issue_2\" width=\"322\" height=\"352\" \/>(image, problem#2)<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While updating this billboard shader https:\/\/github.com\/unitycoder\/DoomStyleBillboardTest , had couple strange shader issues: Problem#1: Overlapping transparent area clips other object behind it (see issue#6) This one was solved by adding &#8220;ZWrite Off&#8221; to the shader, apparently something to do how transparent objects get depth sorted..(?) http:\/\/docs.unity3d.com\/Manual\/SL-CullAndDepth.html [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4104,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_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":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[148,3],"tags":[816,817,815,200,481,812,813,14,814,818],"class_list":["post-4101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-help","category-unity3d","tag-batching","tag-breaks","tag-clip","tag-depth","tag-error","tag-issue","tag-problem","tag-shader","tag-transparent","tag-zwrite"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2015\/12\/custom_shader_transparency_issues.jpg?fit=322%2C352&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-149","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4101","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=4101"}],"version-history":[{"count":1,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4101\/revisions"}],"predecessor-version":[{"id":4105,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4101\/revisions\/4105"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/4104"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=4101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=4101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=4101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}