{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/9349","repository_url":"https://api.github.com/repos/mrdoob/three.js","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/9349/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/9349/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/9349/events","html_url":"https://github.com/mrdoob/three.js/pull/9349","id":165976330,"number":9349,"title":"Fix broken RawShaderMaterials when using defines","user":{"login":"sirxemic","id":831538,"avatar_url":"https://avatars.githubusercontent.com/u/831538?v=3","gravatar_id":"","url":"https://api.github.com/users/sirxemic","html_url":"https://github.com/sirxemic","followers_url":"https://api.github.com/users/sirxemic/followers","following_url":"https://api.github.com/users/sirxemic/following{/other_user}","gists_url":"https://api.github.com/users/sirxemic/gists{/gist_id}","starred_url":"https://api.github.com/users/sirxemic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirxemic/subscriptions","organizations_url":"https://api.github.com/users/sirxemic/orgs","repos_url":"https://api.github.com/users/sirxemic/repos","events_url":"https://api.github.com/users/sirxemic/events{/privacy}","received_events_url":"https://api.github.com/users/sirxemic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-07-17T13:17:18Z","updated_at":"2016-07-18T16:59:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mrdoob/three.js/pulls/9349","html_url":"https://github.com/mrdoob/three.js/pull/9349","diff_url":"https://github.com/mrdoob/three.js/pull/9349.diff","patch_url":"https://github.com/mrdoob/three.js/pull/9349.patch"},"body":"Currently instantiating a raw shader material like:\r\n\r\n```js\r\nmaterial = new THREE.RawShaderMaterial( {\r\n  defines: {\r\n    DUMMY_DEFINE: true\r\n  },\r\n  vertexShader: \"precision highp float;\\n....\",\r\n  fragmentShader: \"precision highp float;\\n....\",\r\n} );\r\n```\r\n\r\n...will always construct invalid shader code. Now I have to use a workaround where I need to prepend the shader code with a newline.\r\n\r\nAnyway, I fixed this by always joining the shader prefixes and bodies with a newline. Another approach would have been to append the `prefixVertex` and `prefixFragment` strings with a newline for raw shaders, but I figured the current approach is more scalable. "},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/233390244","html_url":"https://github.com/mrdoob/three.js/pull/9349#issuecomment-233390244","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/9349","id":233390244,"user":{"login":"sirxemic","id":831538,"avatar_url":"https://avatars.githubusercontent.com/u/831538?v=3","gravatar_id":"","url":"https://api.github.com/users/sirxemic","html_url":"https://github.com/sirxemic","followers_url":"https://api.github.com/users/sirxemic/followers","following_url":"https://api.github.com/users/sirxemic/following{/other_user}","gists_url":"https://api.github.com/users/sirxemic/gists{/gist_id}","starred_url":"https://api.github.com/users/sirxemic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirxemic/subscriptions","organizations_url":"https://api.github.com/users/sirxemic/orgs","repos_url":"https://api.github.com/users/sirxemic/repos","events_url":"https://api.github.com/users/sirxemic/events{/privacy}","received_events_url":"https://api.github.com/users/sirxemic/received_events","type":"User","site_admin":false},"created_at":"2016-07-18T16:59:01Z","updated_at":"2016-07-18T16:59:01Z","body":"I meant your latest example - https://jsfiddle.net/e46g8ccf/3/\r\n\r\nWhen you use Firefox' shader inspector, you'll see the vertex shader is like I just showed you. It's not broken per sé, but it's not correct either, as the `DUMMY_DEFINE` define in that case gets a strange value (as you can see) and most definitely would cause code to break if the define was actually used."}}
{"actor":{"display_login":"sirxemic"}}