{"action":"opened","number":407,"pull_request":{"url":"https://api.github.com/repos/tangrams/tangram/pulls/407","id":84202223,"html_url":"https://github.com/tangrams/tangram/pull/407","diff_url":"https://github.com/tangrams/tangram/pull/407.diff","patch_url":"https://github.com/tangrams/tangram/pull/407.patch","issue_url":"https://api.github.com/repos/tangrams/tangram/issues/407","number":407,"state":"open","locked":false,"title":"More useful default lighting + remove alpha from lights","user":{"login":"bcamper","id":16733,"avatar_url":"https://avatars.githubusercontent.com/u/16733?v=3","gravatar_id":"","url":"https://api.github.com/users/bcamper","html_url":"https://github.com/bcamper","followers_url":"https://api.github.com/users/bcamper/followers","following_url":"https://api.github.com/users/bcamper/following{/other_user}","gists_url":"https://api.github.com/users/bcamper/gists{/gist_id}","starred_url":"https://api.github.com/users/bcamper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcamper/subscriptions","organizations_url":"https://api.github.com/users/bcamper/orgs","repos_url":"https://api.github.com/users/bcamper/repos","events_url":"https://api.github.com/users/bcamper/events{/privacy}","received_events_url":"https://api.github.com/users/bcamper/received_events","type":"User","site_admin":false},"body":"This PR has two parts:\r\n\r\n### More useful default lighting\r\nThe previous default, if on `lights` are defined, has been to assume *100% omnidirectional diffuse light*. In other words, all geometry is lit with the vertex color (compounded by the material's `diffuse` component if present) at 100%.\r\n\r\nThe problem with this approach is that it is a poor default for extruded geometry, which end up showing as silhouettes with no depth.\r\n\r\nThis PR changes the default to a more useful value, a [directional](https://github.com/tangrams/tangram/compare/default-light?expand=1#diff-7a3c51617962d8b132a43dbe5d63e862R231) light that maintains 100% illumination for ground plane objects, with typical flat shading for extruded objects. The default is configured to provide *0.5 strength diffuse* and *0.5 strength ambient*. The default directional light angle in the XY plane is hardcoded for now, but could be made configurable if we want to provide a friendlier interface for controlling directional lights (since it turns out asking people to provide full XYZ vectors that happen to normalize to a length that provides the desired light intensity is unreasonable...).\r\n\r\nOld:\r\n![tangram- 16 5072 40 7652 -73 9739_2016-09-06_17 21 54](https://cloud.githubusercontent.com/assets/16733/18291563/702eb01c-7456-11e6-8d5b-da98bc7cab36.png)\r\n\r\nNew:\r\n![tangram- 16 5072 40 7652 -73 9739_2016-09-06_17 21 20](https://cloud.githubusercontent.com/assets/16733/18291564/73fa6f74-7456-11e6-9c01-b55ce4d33121.png)\r\n\r\n### Remove alpha from lights\r\nIn the course of changing the light default, I also discovered some very strange behavior with our lights and transparency in the scene. It turns out this is caused by *our lights having and \"casting\" an alpha component*. Examples of a point light casting full transparency outside its radius:\r\n\r\n![tangram- 16 7195 40 7643 -73 9716_2016-08-26_17 48 09 1](https://cloud.githubusercontent.com/assets/16733/18291925/a6a7bc9a-7458-11e6-81a1-d971c34d0260.png)\r\n\r\nCool-looking but ultimately wrong and unhelpful :)\r\n\r\nTo fix, this PR *changes all lighting components from `vec4` to `vec3`*, and changes all of the \"light accumulation\" logic (that sums the `light_accumulator_*` variables) to only operate on the RGB components (with alpha set to 1).\r\n\r\nAdditionally, to allow a material's alpha components to have some effect in while using the default \"opaque\" blend mode, the material's alpha is now multiplied into its RGB components, e.g. diffuse light is calculated as (note **material.diffuse.rgb * material.diffuse.a**):\r\n\r\n`color.rgb += light_accumulator_diffuse.rgb * _color.rgb * material.diffuse.rgb * material.diffuse.a;`\r\n\r\nBehavior is unchanged for other blending modes, where alpha is used in the blending equation. [See more here.](https://github.com/tangrams/tangram/compare/default-light?expand=1#diff-7a3c51617962d8b132a43dbe5d63e862R145\r\n)\r\n\r\nHere is a final side by side from Differ showing previous (left) and corrected behavior (right):\r\n![screen shot 2016-09-06 at 5 36 12 pm](https://cloud.githubusercontent.com/assets/16733/18291941/b28d2e64-7458-11e6-8228-249a78f5d4df.png)\r\n","created_at":"2016-09-06T21:46:15Z","updated_at":"2016-09-06T21:46:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"56a86c16aaa147d409822991dd552e414f6c986d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/tangrams/tangram/pulls/407/commits","review_comments_url":"https://api.github.com/repos/tangrams/tangram/pulls/407/comments","review_comment_url":"https://api.github.com/repos/tangrams/tangram/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tangrams/tangram/issues/407/comments","statuses_url":"https://api.github.com/repos/tangrams/tangram/statuses/067688a796a74910c0e91b3390cb1a9a55e6592f","head":{"label":"tangrams:default-light","ref":"default-light","sha":"067688a796a74910c0e91b3390cb1a9a55e6592f","user":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"repo":{"id":13203894,"name":"tangram","full_name":"tangrams/tangram","owner":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tangrams/tangram","description":"Real-Time WebGL Maps","fork":false,"url":"https://api.github.com/repos/tangrams/tangram","forks_url":"https://api.github.com/repos/tangrams/tangram/forks","keys_url":"https://api.github.com/repos/tangrams/tangram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tangrams/tangram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tangrams/tangram/teams","hooks_url":"https://api.github.com/repos/tangrams/tangram/hooks","issue_events_url":"https://api.github.com/repos/tangrams/tangram/issues/events{/number}","events_url":"https://api.github.com/repos/tangrams/tangram/events","assignees_url":"https://api.github.com/repos/tangrams/tangram/assignees{/user}","branches_url":"https://api.github.com/repos/tangrams/tangram/branches{/branch}","tags_url":"https://api.github.com/repos/tangrams/tangram/tags","blobs_url":"https://api.github.com/repos/tangrams/tangram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tangrams/tangram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tangrams/tangram/git/refs{/sha}","trees_url":"https://api.github.com/repos/tangrams/tangram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tangrams/tangram/statuses/{sha}","languages_url":"https://api.github.com/repos/tangrams/tangram/languages","stargazers_url":"https://api.github.com/repos/tangrams/tangram/stargazers","contributors_url":"https://api.github.com/repos/tangrams/tangram/contributors","subscribers_url":"https://api.github.com/repos/tangrams/tangram/subscribers","subscription_url":"https://api.github.com/repos/tangrams/tangram/subscription","commits_url":"https://api.github.com/repos/tangrams/tangram/commits{/sha}","git_commits_url":"https://api.github.com/repos/tangrams/tangram/git/commits{/sha}","comments_url":"https://api.github.com/repos/tangrams/tangram/comments{/number}","issue_comment_url":"https://api.github.com/repos/tangrams/tangram/issues/comments{/number}","contents_url":"https://api.github.com/repos/tangrams/tangram/contents/{+path}","compare_url":"https://api.github.com/repos/tangrams/tangram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tangrams/tangram/merges","archive_url":"https://api.github.com/repos/tangrams/tangram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tangrams/tangram/downloads","issues_url":"https://api.github.com/repos/tangrams/tangram/issues{/number}","pulls_url":"https://api.github.com/repos/tangrams/tangram/pulls{/number}","milestones_url":"https://api.github.com/repos/tangrams/tangram/milestones{/number}","notifications_url":"https://api.github.com/repos/tangrams/tangram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tangrams/tangram/labels{/name}","releases_url":"https://api.github.com/repos/tangrams/tangram/releases{/id}","deployments_url":"https://api.github.com/repos/tangrams/tangram/deployments","created_at":"2013-09-30T01:59:45Z","updated_at":"2016-09-06T08:42:02Z","pushed_at":"2016-09-06T21:46:15Z","git_url":"git://github.com/tangrams/tangram.git","ssh_url":"git@github.com:tangrams/tangram.git","clone_url":"https://github.com/tangrams/tangram.git","svn_url":"https://github.com/tangrams/tangram","homepage":"http://tangrams.github.io/tangram","size":126692,"stargazers_count":734,"watchers_count":734,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":108,"mirror_url":null,"open_issues_count":38,"forks":108,"open_issues":38,"watchers":734,"default_branch":"master"}},"base":{"label":"tangrams:master","ref":"master","sha":"49283a1f4419629154ca6a09448ebc471feced83","user":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"repo":{"id":13203894,"name":"tangram","full_name":"tangrams/tangram","owner":{"login":"tangrams","id":8495302,"avatar_url":"https://avatars.githubusercontent.com/u/8495302?v=3","gravatar_id":"","url":"https://api.github.com/users/tangrams","html_url":"https://github.com/tangrams","followers_url":"https://api.github.com/users/tangrams/followers","following_url":"https://api.github.com/users/tangrams/following{/other_user}","gists_url":"https://api.github.com/users/tangrams/gists{/gist_id}","starred_url":"https://api.github.com/users/tangrams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tangrams/subscriptions","organizations_url":"https://api.github.com/users/tangrams/orgs","repos_url":"https://api.github.com/users/tangrams/repos","events_url":"https://api.github.com/users/tangrams/events{/privacy}","received_events_url":"https://api.github.com/users/tangrams/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tangrams/tangram","description":"Real-Time WebGL Maps","fork":false,"url":"https://api.github.com/repos/tangrams/tangram","forks_url":"https://api.github.com/repos/tangrams/tangram/forks","keys_url":"https://api.github.com/repos/tangrams/tangram/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tangrams/tangram/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tangrams/tangram/teams","hooks_url":"https://api.github.com/repos/tangrams/tangram/hooks","issue_events_url":"https://api.github.com/repos/tangrams/tangram/issues/events{/number}","events_url":"https://api.github.com/repos/tangrams/tangram/events","assignees_url":"https://api.github.com/repos/tangrams/tangram/assignees{/user}","branches_url":"https://api.github.com/repos/tangrams/tangram/branches{/branch}","tags_url":"https://api.github.com/repos/tangrams/tangram/tags","blobs_url":"https://api.github.com/repos/tangrams/tangram/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tangrams/tangram/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tangrams/tangram/git/refs{/sha}","trees_url":"https://api.github.com/repos/tangrams/tangram/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tangrams/tangram/statuses/{sha}","languages_url":"https://api.github.com/repos/tangrams/tangram/languages","stargazers_url":"https://api.github.com/repos/tangrams/tangram/stargazers","contributors_url":"https://api.github.com/repos/tangrams/tangram/contributors","subscribers_url":"https://api.github.com/repos/tangrams/tangram/subscribers","subscription_url":"https://api.github.com/repos/tangrams/tangram/subscription","commits_url":"https://api.github.com/repos/tangrams/tangram/commits{/sha}","git_commits_url":"https://api.github.com/repos/tangrams/tangram/git/commits{/sha}","comments_url":"https://api.github.com/repos/tangrams/tangram/comments{/number}","issue_comment_url":"https://api.github.com/repos/tangrams/tangram/issues/comments{/number}","contents_url":"https://api.github.com/repos/tangrams/tangram/contents/{+path}","compare_url":"https://api.github.com/repos/tangrams/tangram/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tangrams/tangram/merges","archive_url":"https://api.github.com/repos/tangrams/tangram/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tangrams/tangram/downloads","issues_url":"https://api.github.com/repos/tangrams/tangram/issues{/number}","pulls_url":"https://api.github.com/repos/tangrams/tangram/pulls{/number}","milestones_url":"https://api.github.com/repos/tangrams/tangram/milestones{/number}","notifications_url":"https://api.github.com/repos/tangrams/tangram/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tangrams/tangram/labels{/name}","releases_url":"https://api.github.com/repos/tangrams/tangram/releases{/id}","deployments_url":"https://api.github.com/repos/tangrams/tangram/deployments","created_at":"2013-09-30T01:59:45Z","updated_at":"2016-09-06T08:42:02Z","pushed_at":"2016-09-06T21:46:15Z","git_url":"git://github.com/tangrams/tangram.git","ssh_url":"git@github.com:tangrams/tangram.git","clone_url":"https://github.com/tangrams/tangram.git","svn_url":"https://github.com/tangrams/tangram","homepage":"http://tangrams.github.io/tangram","size":126692,"stargazers_count":734,"watchers_count":734,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":108,"mirror_url":null,"open_issues_count":38,"forks":108,"open_issues":38,"watchers":734,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tangrams/tangram/pulls/407"},"html":{"href":"https://github.com/tangrams/tangram/pull/407"},"issue":{"href":"https://api.github.com/repos/tangrams/tangram/issues/407"},"comments":{"href":"https://api.github.com/repos/tangrams/tangram/issues/407/comments"},"review_comments":{"href":"https://api.github.com/repos/tangrams/tangram/pulls/407/comments"},"review_comment":{"href":"https://api.github.com/repos/tangrams/tangram/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tangrams/tangram/pulls/407/commits"},"statuses":{"href":"https://api.github.com/repos/tangrams/tangram/statuses/067688a796a74910c0e91b3390cb1a9a55e6592f"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":8,"additions":121,"deletions":65,"changed_files":10}}
{"actor":{"display_login":"bcamper"}}