{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/6021","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/6021/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/6021/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/6021/events","html_url":"https://github.com/mrdoob/three.js/pull/6021","id":56459976,"number":6021,"title":"made 'setProgram' and 'loadUniformsGeneric' public methods","user":{"login":"arose","id":272250,"avatar_url":"https://avatars.githubusercontent.com/u/272250?v=3","gravatar_id":"","url":"https://api.github.com/users/arose","html_url":"https://github.com/arose","followers_url":"https://api.github.com/users/arose/followers","following_url":"https://api.github.com/users/arose/following{/other_user}","gists_url":"https://api.github.com/users/arose/gists{/gist_id}","starred_url":"https://api.github.com/users/arose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arose/subscriptions","organizations_url":"https://api.github.com/users/arose/orgs","repos_url":"https://api.github.com/users/arose/repos","events_url":"https://api.github.com/users/arose/events{/privacy}","received_events_url":"https://api.github.com/users/arose/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-02-04T00:07:21Z","updated_at":"2015-02-23T23:33:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mrdoob/three.js/pulls/6021","html_url":"https://github.com/mrdoob/three.js/pull/6021","diff_url":"https://github.com/mrdoob/three.js/pull/6021.diff","patch_url":"https://github.com/mrdoob/three.js/pull/6021.patch"},"body":"Changed `setProgram` and `loadUniformsGeneric` in `WebGLRenderer` so that they are public method and accessible from the outside. The goal is to be able to inject code during the object rendering phase, specifically just after or before the WebGL program is set. This allows, for instance, additional transformation matrices like `modelViewMatrixInverse` that depend on data from the to-be-rendered object without reverting to per-object materials. Please see #6010 for a discussion. Also see #5208 for another example where methods of `WebGLRenderer` were made public to allow for custom code. Thanks for considering this."},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/75661769","html_url":"https://github.com/mrdoob/three.js/pull/6021#issuecomment-75661769","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/6021","id":75661769,"user":{"login":"arose","id":272250,"avatar_url":"https://avatars.githubusercontent.com/u/272250?v=3","gravatar_id":"","url":"https://api.github.com/users/arose","html_url":"https://github.com/arose","followers_url":"https://api.github.com/users/arose/followers","following_url":"https://api.github.com/users/arose/following{/other_user}","gists_url":"https://api.github.com/users/arose/gists{/gist_id}","starred_url":"https://api.github.com/users/arose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arose/subscriptions","organizations_url":"https://api.github.com/users/arose/orgs","repos_url":"https://api.github.com/users/arose/repos","events_url":"https://api.github.com/users/arose/events{/privacy}","received_events_url":"https://api.github.com/users/arose/received_events","type":"User","site_admin":false},"created_at":"2015-02-23T23:33:40Z","updated_at":"2015-02-23T23:33:40Z","body":"> For this specific use case, would it help if Mesh had a color property that that single material could use?\r\n\r\nSo if there is `Mesh.color` (`Line`, `Sprite`, ... should be handled similarly) we could have\r\n\r\n```javascript\r\nfunction refreshUniformsCommon ( uniforms, material, object ) {\r\n    // [...]\r\n    if( object.color ){\r\n        uniforms.diffuse.value = object.color;\r\n    }else{\r\n        uniforms.diffuse.value = material.color;\r\n    }\r\n    // [...]\r\n}\r\n```\r\n\r\ninstead of\r\n\r\n```javascript\r\nfunction refreshUniformsCommon ( uniforms, material ) {\r\n    // [...]\r\n   uniforms.diffuse.value = material.color;\r\n    // [...]\r\n}\r\n```\r\n\r\nThis would work for my GPU picking use case. A more general approach to object-specific uniform values could be a `.uniformValues` property in `Mesh` (and `Line`, ...) containing a plain object with keys and values. If a key matches a material uniform name the material's uniform value is replaced with the objects value.\r\n\r\nFor my other use case I need the `modelViewMatrixInverse`, the `modelViewProjectionMatrixInverse`, the `modelViewProjectionMatrix` and the `modelViewMatrixInverseTranspose`. These could be added by looking if there are `uniforms` in the material with such names and if so updating the respective matrices.\r\n\r\nI could prepare a PR if you think this could be the way to go.\r\n\r\n\r\n"}}