{"action":"created","issue":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/5805","labels_url":"https://api.github.com/repos/mrdoob/three.js/issues/5805/labels{/name}","comments_url":"https://api.github.com/repos/mrdoob/three.js/issues/5805/comments","events_url":"https://api.github.com/repos/mrdoob/three.js/issues/5805/events","html_url":"https://github.com/mrdoob/three.js/pull/5805","id":52680580,"number":5805,"title":"use diffuseColor and outgoingLight instead of repeatedly redefining what gl_FragColor is","user":{"login":"bhouston","id":588541,"avatar_url":"https://avatars.githubusercontent.com/u/588541?v=3","gravatar_id":"","url":"https://api.github.com/users/bhouston","html_url":"https://github.com/bhouston","followers_url":"https://api.github.com/users/bhouston/followers","following_url":"https://api.github.com/users/bhouston/following{/other_user}","gists_url":"https://api.github.com/users/bhouston/gists{/gist_id}","starred_url":"https://api.github.com/users/bhouston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhouston/subscriptions","organizations_url":"https://api.github.com/users/bhouston/orgs","repos_url":"https://api.github.com/users/bhouston/repos","events_url":"https://api.github.com/users/bhouston/events{/privacy}","received_events_url":"https://api.github.com/users/bhouston/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":41,"created_at":"2014-12-22T19:32:24Z","updated_at":"2015-03-12T16:26:26Z","closed_at":"2015-03-09T23:12:59Z","pull_request":{"url":"https://api.github.com/repos/mrdoob/three.js/pulls/5805","html_url":"https://github.com/mrdoob/three.js/pull/5805","diff_url":"https://github.com/mrdoob/three.js/pull/5805.diff","patch_url":"https://github.com/mrdoob/three.js/pull/5805.patch"},"body":"Right now lightMap is modulating the gl_FragColor after the lighting calculation modifies gl_FragColor to include specular and diffuse lighting contributions.  This is not correct.\r\n\r\nlightMap should be considered un-directional incoming light that should get modulated by the surface color (diffuseColor) and then it should be added to the result.\r\n\r\nThis is what this PR does by introducing the new ```diffuseColor``` variable into all the shaders that is properly modulated by the ```map``` and the vertex colors, as well as an ```outgoingLight``` that accumulates the outgoing light contributions from the various shading calculations.\r\n\r\nThis fixes a lot of issues where gl_FragColor was repeatedly modified by multiple shader blocks, but its definition of what it was supposed to represent was constantly changing.\r\n\r\nThis new formulation clarifies both how diffuseColor is built up and also what is going into the resulting gl_FragColor via outgoingLight.\r\n\r\nMotivated by this discussion here: https://github.com/mrdoob/three.js/pull/5741#issuecomment-67876234"},"comment":{"url":"https://api.github.com/repos/mrdoob/three.js/issues/comments/78517087","html_url":"https://github.com/mrdoob/three.js/pull/5805#issuecomment-78517087","issue_url":"https://api.github.com/repos/mrdoob/three.js/issues/5805","id":78517087,"user":{"login":"WestLangley","id":1000017,"avatar_url":"https://avatars.githubusercontent.com/u/1000017?v=3","gravatar_id":"","url":"https://api.github.com/users/WestLangley","html_url":"https://github.com/WestLangley","followers_url":"https://api.github.com/users/WestLangley/followers","following_url":"https://api.github.com/users/WestLangley/following{/other_user}","gists_url":"https://api.github.com/users/WestLangley/gists{/gist_id}","starred_url":"https://api.github.com/users/WestLangley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WestLangley/subscriptions","organizations_url":"https://api.github.com/users/WestLangley/orgs","repos_url":"https://api.github.com/users/WestLangley/repos","events_url":"https://api.github.com/users/WestLangley/events{/privacy}","received_events_url":"https://api.github.com/users/WestLangley/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T16:26:26Z","updated_at":"2015-03-12T16:26:26Z","body":"@titansoftime A simple example to reproduce the problem would be helpful. Please see \"How to report a bug\" in the [guidelines](https://github.com/mrdoob/three.js/blob/master/CONTRIBUTING.md)."}}