{"id":26,"date":"2011-05-17T02:09:30","date_gmt":"2011-05-17T06:09:30","guid":{"rendered":"http:\/\/www.toadstorm.com\/blog\/?p=26"},"modified":"2014-02-27T15:00:01","modified_gmt":"2014-02-27T23:00:01","slug":"why-your-render-layers-break","status":"publish","type":"post","link":"https:\/\/www.toadstorm.com\/blog\/?p=26","title":{"rendered":"Why your render layers break."},"content":{"rendered":"<p>As promised, a useful post! And probably a long one.<\/p>\n<p>As far as rendering goes, the problem that I see people running into more often than anything else is render layers mysteriously breaking, especially when file referencing is involved. The symptoms are typically either objects disappearing or Maya simply being unwilling to switch to a specific render layer, claiming in the Script Editor that there are &#8220;overrides to a node in a missing reference&#8221; or something to that effect. A lot of less experienced or just less technical types will try to solve the problem by either importing their references into the scene (which is rarely a good idea), or by screaming obscenities (which is\u00a0exhilarating\u00a0but ineffective). There is a better way to get your scene to render with no problems, <em>and<\/em> be able to use file referencing. The trick is to use shared render layers properly, only allow certain edits to your references in your final scene,\u00a0and make sure that your references are clean.<\/p>\n<p><!--more--><\/p>\n<h3>File Referencing<\/h3>\n<div id=\"attachment_27\" style=\"width: 160px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.toadstorm.com\/blog\/wp-content\/uploads\/2011\/05\/0516_01.jpg\"><img aria-describedby=\"caption-attachment-27\" decoding=\"async\" loading=\"lazy\" class=\"size-thumbnail wp-image-27\" title=\"shared reference options\" src=\"https:\/\/www.toadstorm.com\/blog\/wp-content\/uploads\/2011\/05\/0516_01-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-27\" class=\"wp-caption-text\">Share render layers only! Not shading networks!<\/p><\/div>\n<p>If you want your references to all work properly in the final scene, you need to build all of the render layers and do all the shading work in the reference itself, IN ADDITION TO the final render scene. Then when creating your file reference, turn on Shared Nodes and Share Render Layers By Name. <em>Only share render layers!<\/em> Sharing display layers usually isn&#8217;t an issue, but sharing shading networks often leads to scenes crashing, especially in very dense scenes. In order for the render layer sharing to work, you also need to make sure that all of your assets that you want to merge together in the final scene have exactly the same set of render layers. Do all the render layer assignment and shading assignment inside the referenced files themselves.<\/p>\n<p>More often than not, your render layers are breaking in your final scene because of component shading or because of shading edits (either changes to an object&#8217;s shader assignment or to a render layer assignment). Maya keeps a record of every change made to a reference once it&#8217;s brought into a scene; you can view this by selected a reference in the Reference Editor and going to File &gt; List Reference Edits. This is fine for setting attributes or doing some animation, but rewiring shading networks and render layer sets will add a ton of edits to this list, and in some cases add even more edits each time you switch render layers. Component shading (more on this in a second) adds <em>an absolute shitload<\/em> of these. Maya will eventually get confused when you&#8217;re switching render layers and simply be unable to keep up, and that&#8217;s the big reason why you&#8217;ll see the dreaded &#8220;Connection not made&#8221; error in the Script Editor.<\/p>\n<p>To avoid filling up your scene with reference edits, just don&#8217;t reassign shaders to objects or objects to render layers in your final scene! Do this in the original file itself. It might seem like more work in the short term, but it will keep your scene clean AND you won&#8217;t lose the shading assignments you made because they&#8217;re in the original file, not the render scene. If your scene does end up breaking, the first thing to try is to list your reference edits for the reference that&#8217;s mentioned in the error and use the filter to search for &#8220;*dagSet*&#8221;. This will list all shading-related edits that have been made in this scene.\u00a0Unload the reference, highlight these edits, and then remove them. Then reload the reference. If you don&#8217;t mind losing ALL of your reference edits instead of just shading edits, you can also just unload all your references, select them, and run Clean Up Reference. This will remove all edits you made, and it&#8217;s not undoable, so save first.<\/p>\n<p>If doing this for any assets that are reporting errors doesn&#8217;t work, or your scene keeps breaking in short order, then you might just have broken assets.<\/p>\n<h3>Clean Assets<\/h3>\n<p>By far the most common reason for a referenced asset to break render layers is COMPONENT SHADING. If you&#8217;ve ever tried to &#8220;Select All Objects With Material&#8221; in the Hypershade and noticed that some objects are highlighted as whole polygon meshes and others as faces (even if all the faces belong to only one object), that&#8217;s component shading at work. If a mesh has per-face shading connections, it WILL break your render layers, it&#8217;s just a matter of when. Component shading is always a really really terrible idea, but sometimes it happens to your scenes even if you don&#8217;t intend it to, mainly when combining two polygon objects together.<\/p>\n<div id=\"attachment_28\" style=\"width: 160px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.toadstorm.com\/blog\/wp-content\/uploads\/2011\/05\/0516_02.jpg\"><img aria-describedby=\"caption-attachment-28\" decoding=\"async\" loading=\"lazy\" class=\"size-thumbnail wp-image-28\" title=\"0516_02\" src=\"https:\/\/www.toadstorm.com\/blog\/wp-content\/uploads\/2011\/05\/0516_02-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-28\" class=\"wp-caption-text\">An example of bad shading connections.<\/p><\/div>\n<p>If you try creating two polygon objects, assigning the same shader to both, and then combining them (you can even delete history after if you want), then select the shader in the Hypershade and run Select Objects With Material, you&#8217;ll see that the new object&#8217;s faces are highlighted, rather than the entire object as a whole. This is <em>bad.<\/em> <em>Even if you assign a different material to the object as a whole, it will retain per-face shading connections! <\/em>Graphing the mesh in the Hypershade, you&#8217;ll see two connections- one green and one blue- between the mesh and the shading group. \u00a0This tells you that the object has per-face set connections. Delete these connections and the object no longer has a material connection; it&#8217;ll appear as an empty wireframe in the viewport. Assign a new material now, and you&#8217;ll see one single pink connection- this is a clean shading connection applied to the mesh as a whole.<\/p>\n<div id=\"attachment_29\" style=\"width: 160px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/www.toadstorm.com\/blog\/wp-content\/uploads\/2011\/05\/0516_03.jpg\"><img aria-describedby=\"caption-attachment-29\" decoding=\"async\" loading=\"lazy\" class=\"size-thumbnail wp-image-29\" title=\"0516_03\" src=\"https:\/\/www.toadstorm.com\/blog\/wp-content\/uploads\/2011\/05\/0516_03-150x150.jpg\" alt=\"\" width=\"150\" height=\"150\" \/><\/a><p id=\"caption-attachment-29\" class=\"wp-caption-text\">Fixed shading connections for the same object.<\/p><\/div>\n<p>Doing this manually for a large number of objects is a HUGE pain in the ass, and for that I&#8217;ve written a Python script: <a href=\"http:\/\/www.toadstorm.com\/freebies\/hfFixShading.zip\" target=\"_blank\">hfFixShading.py<\/a> (right-click &gt; Save As). To check for bad shading, put the script in your Python scripts folder, and first import by running:<\/p>\n<pre>import hfFixShading as hfFS<\/pre>\n<p>Then check your scene by running:<\/p>\n<pre>hfFS.hfCheckShading()<\/pre>\n<p>If the script finds objects with component shading, it will highlight them for you. To clean them up, you can decide to either split objects into separate meshes based on shading assignment, or just fix bad shading connections (for objects like the above example). These commands are run like this:<\/p>\n<pre>hfFS.hfSplitByShader()\r\nhfFS.hfFixBadShading()<\/pre>\n<p>There are other things besides component shading that can cause your assets to break render layers in the final scene&#8230; layer overrides in an asset can cause problems, as can hidden render layers in a scene&#8230; if you referenced a file into your asset, and then imported it, any merged render layers will be hidden but they&#8217;re still in your scene! Look in your Outliner for duplicate render layers (turn off &#8220;Show DAG Only&#8221; in the Outliner). Namespaces in your asset files can also cause problems and it&#8217;s best not to have any.<\/p>\n<p>So many things to break. This is just a fraction of what can make your scene explode, but it&#8217;s what I&#8217;ve run into most often. I&#8217;ll post more about this later.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As promised, a useful post! And probably a long one. As far as rendering goes, the problem that I see people running into more often than anything else is render layers mysteriously breaking, especially when file referencing is involved. The symptoms are typically either objects disappearing or Maya simply being [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,6,19],"tags":[10,11,9,12],"_links":{"self":[{"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26"}],"version-history":[{"count":16,"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":296,"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions\/296"}],"wp:attachment":[{"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.toadstorm.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}