{"id":4339,"date":"2016-08-09T14:40:14","date_gmt":"2016-08-09T06:40:14","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=4339"},"modified":"2019-12-12T17:09:51","modified_gmt":"2019-12-12T09:09:51","slug":"shader-z-fight-offset","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2016\/08\/09\/shader-z-fight-offset\/","title":{"rendered":"Shader Z-Fight Offset"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"4340\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2016\/08\/09\/shader-z-fight-offset\/shader_surface_offset\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/08\/shader_surface_offset.gif?fit=441%2C193&amp;ssl=1\" data-orig-size=\"441,193\" 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=\"shader_surface_offset\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/08\/shader_surface_offset.gif?fit=441%2C193&amp;ssl=1\" class=\"alignnone size-full wp-image-4340\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/08\/shader_surface_offset.gif?resize=441%2C193\" alt=\"shader_surface_offset\" width=\"441\" height=\"193\" \/><br \/>\n(screenshot with Quad mesh placed on top of Plane with raycast hit.point)<\/p>\n<p>If you want to use Raycast hit.point to place quad on a flat surface, it will most likely create Z fighting issue..<br \/>\nYou could add position offset by hit.point+Vector3(0,0.1f,0),<br \/>\nOr use modified shader to add offset:<\/p>\n<p>Tags {&#8220;Queue&#8221;=&#8221;Transparent&#8221; &#8220;IgnoreProjector&#8221;=&#8221;True&#8221; &#8220;RenderType&#8221;=&#8221;Transparent&#8221;}<br \/>\nLOD 100<\/p>\n<p>ZWrite Off<br \/>\nBlend SrcAlpha OneMinusSrcAlpha<br \/>\nOffset -1,-1 \/\/ This line is added to default Unlit\/Transparent shader<\/p>\n<blockquote><p>Offset: &#8220;This allows you to force one polygon to be drawn on top of another although they are actually in the same position&#8221;<\/p><\/blockquote>\n<p><a href=\"https:\/\/docs.unity3d.com\/Manual\/SL-CullAndDepth.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/docs.unity3d.com\/Manual\/SL-CullAndDepth.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>(screenshot with Quad mesh placed on top of Plane with raycast hit.point) If you want to use Raycast hit.point to place quad on a flat surface, it will most likely create Z fighting issue.. You could add position offset by hit.point+Vector3(0,0.1f,0), Or use modified shader [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4340,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Shader Offset","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":[13,797,3],"tags":[902,900,903,14,259,901],"class_list":["post-4339","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shaders","category-tips","category-unity3d","tag-flat","tag-offset","tag-over","tag-shader","tag-surface","tag-z-fight"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2016\/08\/shader_surface_offset.gif?fit=441%2C193&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-17Z","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4339","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=4339"}],"version-history":[{"count":3,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4339\/revisions"}],"predecessor-version":[{"id":5132,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4339\/revisions\/5132"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/4340"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=4339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=4339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=4339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}