{"id":4331,"date":"2016-08-04T14:22:36","date_gmt":"2016-08-04T06:22:36","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=4331"},"modified":"2016-08-07T18:57:36","modified_gmt":"2016-08-07T10:57:36","slug":"shader-error-cannot-map-expression-to-vertex-shader-instruction","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2016\/08\/04\/shader-error-cannot-map-expression-to-vertex-shader-instruction\/","title":{"rendered":"Shader error: cannot map expression to vertex shader instruction"},"content":{"rendered":"<p>Had a strange looking error today:<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">Shader error in 'Custom\/WhatAFineShader': cannot map expression to vertex shader instruction set at line 60 (on d3d9)<\/pre>\n<p>Turns out it was just that the function which was called inside vertex shader, was below the vertex shader,<br \/>\nso just moved it above the v2f vert (appdata v) and it works..<\/p>\n<p>*Actually it was more complicated:<br \/>\nThis one gives error: (maybe because noise is reserved word)<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nv2f vert (appdata v)\r\n{\r\nv2f o;\r\nfloat var = noise(float2(0,0));\r\no.vertex = mul(UNITY_MATRIX_MVP, v.vertex+var);\r\nreturn o;\r\n}\r\n\r\nfloat noise(float2 xy)\r\n{\r\nreturn 0;\r\n}\r\n<\/pre>\n<p>This one doesn&#8217;t<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfloat noise(float2 xy)\r\n{\r\nreturn 0;\r\n}\r\n\r\nv2f vert (appdata v)\r\n{\r\nv2f o;\r\nfloat var = noise(float2(0,0));\r\no.vertex = mul(UNITY_MATRIX_MVP, v.vertex+var);\r\nreturn o;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Had a strange looking error today: Shader error in &#8216;Custom\/WhatAFineShader&#8217;: cannot map expression to vertex shader instruction set at line 60 (on d3d9) Turns out it was just that the function which was called inside vertex shader, was below the vertex shader, so just moved [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"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":"Shader error: cannot map expression to vertex shader instruction","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}},"categories":[797,3],"tags":[481,24,400,899,14,33],"class_list":["post-4331","post","type-post","status-publish","format-standard","hentry","category-tips","category-unity3d","tag-error","tag-function","tag-map","tag-method","tag-shader","tag-vertex"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-17R","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4331","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=4331"}],"version-history":[{"count":6,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4331\/revisions"}],"predecessor-version":[{"id":4338,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/4331\/revisions\/4338"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=4331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=4331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=4331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}