{"action":"created","comment":{"url":"https://api.github.com/repos/Samsung/GearVRf/pulls/comments/54048285","id":54048285,"diff_hunk":"@@ -0,0 +1,118 @@\n+/* Copyright 2015 Samsung Electronics Co., LTD\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+/***************************************************************************\n+ * Renders the textures of light map plus the main texutre.\n+ ***************************************************************************/\n+\n+#include \"lightmap_shader.h\"\n+\n+#include \"gl/gl_program.h\"\n+#include \"objects/material.h\"\n+#include \"objects/mesh.h\"\n+#include \"objects/components/render_data.h\"\n+#include \"objects/textures/texture.h\"\n+#include \"util/gvr_gl.h\"\n+\n+namespace gvr {\n+static const char VERTEX_SHADER[] = \"attribute vec4 a_position;\\n\"\n+        \"attribute vec3 a_normal;\\n\"\n+        \"attribute vec2 a_tex_coord;\\n\"\n+        \"uniform mat4 u_mvp;\\n\"\n+        \"varying vec2 coord;\\n\"\n+        \"void main() {\\n\"\n+        \" vec4 pos = u_mvp * a_position;\\n\"\n+        \" coord = a_tex_coord;\\n\"\n+        \" gl_Position = pos;\\n\"\n+        \"}\";\n+\n+static const char FRAGMENT_SHADER[] = \"precision mediump float;\\n\"\n+        \"varying vec2  coord;\\n\"\n+        \"uniform sampler2D u_main_texture;\\n\"\n+        \"uniform sampler2D u_lightmap_texture;\\n\"\n+        \"uniform vec2  u_lightmap_offset;\\n\"\n+        \"uniform vec2  u_lightmap_scale;\\n\"\n+        \"void main() {\\n\"\n+        \" vec4 color;\\n\"\n+        \" vec4 lightmap_color;\\n\"\n+        \" vec2 lightmap_coord = (coord * u_lightmap_scale) + u_lightmap_offset;\\n\"\n+        // Beast exports the texture with vertical flip\n+        \" lightmap_color = texture2D(u_lightmap_texture, vec2(lightmap_coord.x, 1.0 - lightmap_coord.y));\\n\"\n+        \" color = texture2D(u_main_texture, coord);\\n\"\n+        \" gl_FragColor = color * lightmap_color;\\n\"\n+        \"}\";\n+\n+LightMapShader::LightMapShader() :\n+        program_(0), u_mvp_(0), u_texture_(0), u_lightmap_texture_(0),\n+        u_lightmap_offset_(0), u_lightmap_scale_(0) {\n+    program_ = new GLProgram(VERTEX_SHADER, FRAGMENT_SHADER);\n+    u_mvp_ = glGetUniformLocation(program_->id(), \"u_mvp\");\n+    u_texture_ = glGetUniformLocation(program_->id(), \"u_texture\");\n+\n+    u_lightmap_texture_ = glGetUniformLocation(program_->id(), \"u_lightmap_texture\");\n+    u_lightmap_offset_ = glGetUniformLocation(program_->id(), \"u_lightmap_offset\");\n+    u_lightmap_scale_ = glGetUniformLocation(program_->id(), \"u_lightmap_scale\");\n+}\n+\n+LightMapShader::~LightMapShader() {\n+    delete program_;\n+}\n+\n+void LightMapShader::render(const glm::mat4& mvp_matrix,\n+        RenderData* render_data, Material* material) {\n+    Mesh* mesh = render_data->mesh();\n+    Texture* texture = material->getTexture(\"main_texture\");\n+    Texture* lightmap_texture = material->getTexture(\"lightmap_texture\");\n+    glm::vec2 lightmap_offset = material->getVec2(\"lightmap_offset\");\n+    glm::vec2 lightmap_scale = material->getVec2(\"lightmap_scale\");\n+\n+#if _GVRF_USE_GLES3_","path":"GVRf/Framework/jni/shaders/material/lightmap_shader.cpp","position":81,"original_position":81,"commit_id":"d05fd309d96622dc21f84dc58145d73f0d5007d3","original_commit_id":"d05fd309d96622dc21f84dc58145d73f0d5007d3","user":{"login":"danke-sra","id":13282142,"avatar_url":"https://avatars.githubusercontent.com/u/13282142?v=3","gravatar_id":"","url":"https://api.github.com/users/danke-sra","html_url":"https://github.com/danke-sra","followers_url":"https://api.github.com/users/danke-sra/followers","following_url":"https://api.github.com/users/danke-sra/following{/other_user}","gists_url":"https://api.github.com/users/danke-sra/gists{/gist_id}","starred_url":"https://api.github.com/users/danke-sra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danke-sra/subscriptions","organizations_url":"https://api.github.com/users/danke-sra/orgs","repos_url":"https://api.github.com/users/danke-sra/repos","events_url":"https://api.github.com/users/danke-sra/events{/privacy}","received_events_url":"https://api.github.com/users/danke-sra/received_events","type":"User","site_admin":false},"body":"I don't think we need to support GLES2 now. So you may safely remove this check. Others have any comments?","created_at":"2016-02-25T04:45:11Z","updated_at":"2016-02-25T04:45:11Z","html_url":"https://github.com/Samsung/GearVRf/pull/425#discussion_r54048285","pull_request_url":"https://api.github.com/repos/Samsung/GearVRf/pulls/425","_links":{"self":{"href":"https://api.github.com/repos/Samsung/GearVRf/pulls/comments/54048285"},"html":{"href":"https://github.com/Samsung/GearVRf/pull/425#discussion_r54048285"},"pull_request":{"href":"https://api.github.com/repos/Samsung/GearVRf/pulls/425"}}},"pull_request":{"url":"https://api.github.com/repos/Samsung/GearVRf/pulls/425","id":60586687,"html_url":"https://github.com/Samsung/GearVRf/pull/425","diff_url":"https://github.com/Samsung/GearVRf/pull/425.diff","patch_url":"https://github.com/Samsung/GearVRf/pull/425.patch","issue_url":"https://api.github.com/repos/Samsung/GearVRf/issues/425","number":425,"state":"open","locked":false,"title":"Add light map shader","user":{"login":"ragner","id":1492412,"avatar_url":"https://avatars.githubusercontent.com/u/1492412?v=3","gravatar_id":"","url":"https://api.github.com/users/ragner","html_url":"https://github.com/ragner","followers_url":"https://api.github.com/users/ragner/followers","following_url":"https://api.github.com/users/ragner/following{/other_user}","gists_url":"https://api.github.com/users/ragner/gists{/gist_id}","starred_url":"https://api.github.com/users/ragner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ragner/subscriptions","organizations_url":"https://api.github.com/users/ragner/orgs","repos_url":"https://api.github.com/users/ragner/repos","events_url":"https://api.github.com/users/ragner/events{/privacy}","received_events_url":"https://api.github.com/users/ragner/received_events","type":"User","site_admin":false},"body":"Add a implementation of light map shader to render baked light map from Beast SDK.\r\n\r\nI have tried to simplify this API to not add complexity to GearVRf. But further more\r\nwe could add support to apply different types of atlas texture to the scene, not just light map.\r\nBecause of this  I placed some methods with the prefix \"[set,get]TextureAtlas\" at Material class.\r\nYou may use latest updated branch  https://github.com/gearvrf/GearVRf-Demos/pull/15\r\nto test it.\r\n\r\nGearVRf-DCO-1.0-Signed-off-by: Ragner Magalhaes <ragner.n@samsung.com>","created_at":"2016-02-24T22:03:27Z","updated_at":"2016-02-25T04:45:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7dc2879480b9d0ec4ac02f818c84c40d49ec1e17","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Samsung/GearVRf/pulls/425/commits","review_comments_url":"https://api.github.com/repos/Samsung/GearVRf/pulls/425/comments","review_comment_url":"https://api.github.com/repos/Samsung/GearVRf/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Samsung/GearVRf/issues/425/comments","statuses_url":"https://api.github.com/repos/Samsung/GearVRf/statuses/d05fd309d96622dc21f84dc58145d73f0d5007d3","head":{"label":"ragner:beast_lightmap","ref":"beast_lightmap","sha":"d05fd309d96622dc21f84dc58145d73f0d5007d3","user":{"login":"ragner","id":1492412,"avatar_url":"https://avatars.githubusercontent.com/u/1492412?v=3","gravatar_id":"","url":"https://api.github.com/users/ragner","html_url":"https://github.com/ragner","followers_url":"https://api.github.com/users/ragner/followers","following_url":"https://api.github.com/users/ragner/following{/other_user}","gists_url":"https://api.github.com/users/ragner/gists{/gist_id}","starred_url":"https://api.github.com/users/ragner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ragner/subscriptions","organizations_url":"https://api.github.com/users/ragner/orgs","repos_url":"https://api.github.com/users/ragner/repos","events_url":"https://api.github.com/users/ragner/events{/privacy}","received_events_url":"https://api.github.com/users/ragner/received_events","type":"User","site_admin":false},"repo":{"id":42545168,"name":"GearVRf","full_name":"ragner/GearVRf","owner":{"login":"ragner","id":1492412,"avatar_url":"https://avatars.githubusercontent.com/u/1492412?v=3","gravatar_id":"","url":"https://api.github.com/users/ragner","html_url":"https://github.com/ragner","followers_url":"https://api.github.com/users/ragner/followers","following_url":"https://api.github.com/users/ragner/following{/other_user}","gists_url":"https://api.github.com/users/ragner/gists{/gist_id}","starred_url":"https://api.github.com/users/ragner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ragner/subscriptions","organizations_url":"https://api.github.com/users/ragner/orgs","repos_url":"https://api.github.com/users/ragner/repos","events_url":"https://api.github.com/users/ragner/events{/privacy}","received_events_url":"https://api.github.com/users/ragner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ragner/GearVRf","description":"The GearVR framework(GearVRf) is an Open Source VR rendering library for application development on VR-supported Android devices. ","fork":true,"url":"https://api.github.com/repos/ragner/GearVRf","forks_url":"https://api.github.com/repos/ragner/GearVRf/forks","keys_url":"https://api.github.com/repos/ragner/GearVRf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ragner/GearVRf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ragner/GearVRf/teams","hooks_url":"https://api.github.com/repos/ragner/GearVRf/hooks","issue_events_url":"https://api.github.com/repos/ragner/GearVRf/issues/events{/number}","events_url":"https://api.github.com/repos/ragner/GearVRf/events","assignees_url":"https://api.github.com/repos/ragner/GearVRf/assignees{/user}","branches_url":"https://api.github.com/repos/ragner/GearVRf/branches{/branch}","tags_url":"https://api.github.com/repos/ragner/GearVRf/tags","blobs_url":"https://api.github.com/repos/ragner/GearVRf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ragner/GearVRf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ragner/GearVRf/git/refs{/sha}","trees_url":"https://api.github.com/repos/ragner/GearVRf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ragner/GearVRf/statuses/{sha}","languages_url":"https://api.github.com/repos/ragner/GearVRf/languages","stargazers_url":"https://api.github.com/repos/ragner/GearVRf/stargazers","contributors_url":"https://api.github.com/repos/ragner/GearVRf/contributors","subscribers_url":"https://api.github.com/repos/ragner/GearVRf/subscribers","subscription_url":"https://api.github.com/repos/ragner/GearVRf/subscription","commits_url":"https://api.github.com/repos/ragner/GearVRf/commits{/sha}","git_commits_url":"https://api.github.com/repos/ragner/GearVRf/git/commits{/sha}","comments_url":"https://api.github.com/repos/ragner/GearVRf/comments{/number}","issue_comment_url":"https://api.github.com/repos/ragner/GearVRf/issues/comments{/number}","contents_url":"https://api.github.com/repos/ragner/GearVRf/contents/{+path}","compare_url":"https://api.github.com/repos/ragner/GearVRf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ragner/GearVRf/merges","archive_url":"https://api.github.com/repos/ragner/GearVRf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ragner/GearVRf/downloads","issues_url":"https://api.github.com/repos/ragner/GearVRf/issues{/number}","pulls_url":"https://api.github.com/repos/ragner/GearVRf/pulls{/number}","milestones_url":"https://api.github.com/repos/ragner/GearVRf/milestones{/number}","notifications_url":"https://api.github.com/repos/ragner/GearVRf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ragner/GearVRf/labels{/name}","releases_url":"https://api.github.com/repos/ragner/GearVRf/releases{/id}","deployments_url":"https://api.github.com/repos/ragner/GearVRf/deployments","created_at":"2015-09-15T20:37:52Z","updated_at":"2015-09-15T20:38:04Z","pushed_at":"2016-02-24T20:57:29Z","git_url":"git://github.com/ragner/GearVRf.git","ssh_url":"git@github.com:ragner/GearVRf.git","clone_url":"https://github.com/ragner/GearVRf.git","svn_url":"https://github.com/ragner/GearVRf","homepage":"http://www.gearvrf.org","size":603875,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Samsung:master","ref":"master","sha":"7a94fbf061fe118ca05f5f30dcdc79dff1072d52","user":{"login":"Samsung","id":6210390,"avatar_url":"https://avatars.githubusercontent.com/u/6210390?v=3","gravatar_id":"","url":"https://api.github.com/users/Samsung","html_url":"https://github.com/Samsung","followers_url":"https://api.github.com/users/Samsung/followers","following_url":"https://api.github.com/users/Samsung/following{/other_user}","gists_url":"https://api.github.com/users/Samsung/gists{/gist_id}","starred_url":"https://api.github.com/users/Samsung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Samsung/subscriptions","organizations_url":"https://api.github.com/users/Samsung/orgs","repos_url":"https://api.github.com/users/Samsung/repos","events_url":"https://api.github.com/users/Samsung/events{/privacy}","received_events_url":"https://api.github.com/users/Samsung/received_events","type":"Organization","site_admin":false},"repo":{"id":32836701,"name":"GearVRf","full_name":"Samsung/GearVRf","owner":{"login":"Samsung","id":6210390,"avatar_url":"https://avatars.githubusercontent.com/u/6210390?v=3","gravatar_id":"","url":"https://api.github.com/users/Samsung","html_url":"https://github.com/Samsung","followers_url":"https://api.github.com/users/Samsung/followers","following_url":"https://api.github.com/users/Samsung/following{/other_user}","gists_url":"https://api.github.com/users/Samsung/gists{/gist_id}","starred_url":"https://api.github.com/users/Samsung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Samsung/subscriptions","organizations_url":"https://api.github.com/users/Samsung/orgs","repos_url":"https://api.github.com/users/Samsung/repos","events_url":"https://api.github.com/users/Samsung/events{/privacy}","received_events_url":"https://api.github.com/users/Samsung/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Samsung/GearVRf","description":"The GearVR framework(GearVRf) is an Open Source VR rendering library for application development on VR-supported Android devices. ","fork":false,"url":"https://api.github.com/repos/Samsung/GearVRf","forks_url":"https://api.github.com/repos/Samsung/GearVRf/forks","keys_url":"https://api.github.com/repos/Samsung/GearVRf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Samsung/GearVRf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Samsung/GearVRf/teams","hooks_url":"https://api.github.com/repos/Samsung/GearVRf/hooks","issue_events_url":"https://api.github.com/repos/Samsung/GearVRf/issues/events{/number}","events_url":"https://api.github.com/repos/Samsung/GearVRf/events","assignees_url":"https://api.github.com/repos/Samsung/GearVRf/assignees{/user}","branches_url":"https://api.github.com/repos/Samsung/GearVRf/branches{/branch}","tags_url":"https://api.github.com/repos/Samsung/GearVRf/tags","blobs_url":"https://api.github.com/repos/Samsung/GearVRf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Samsung/GearVRf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Samsung/GearVRf/git/refs{/sha}","trees_url":"https://api.github.com/repos/Samsung/GearVRf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Samsung/GearVRf/statuses/{sha}","languages_url":"https://api.github.com/repos/Samsung/GearVRf/languages","stargazers_url":"https://api.github.com/repos/Samsung/GearVRf/stargazers","contributors_url":"https://api.github.com/repos/Samsung/GearVRf/contributors","subscribers_url":"https://api.github.com/repos/Samsung/GearVRf/subscribers","subscription_url":"https://api.github.com/repos/Samsung/GearVRf/subscription","commits_url":"https://api.github.com/repos/Samsung/GearVRf/commits{/sha}","git_commits_url":"https://api.github.com/repos/Samsung/GearVRf/git/commits{/sha}","comments_url":"https://api.github.com/repos/Samsung/GearVRf/comments{/number}","issue_comment_url":"https://api.github.com/repos/Samsung/GearVRf/issues/comments{/number}","contents_url":"https://api.github.com/repos/Samsung/GearVRf/contents/{+path}","compare_url":"https://api.github.com/repos/Samsung/GearVRf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Samsung/GearVRf/merges","archive_url":"https://api.github.com/repos/Samsung/GearVRf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Samsung/GearVRf/downloads","issues_url":"https://api.github.com/repos/Samsung/GearVRf/issues{/number}","pulls_url":"https://api.github.com/repos/Samsung/GearVRf/pulls{/number}","milestones_url":"https://api.github.com/repos/Samsung/GearVRf/milestones{/number}","notifications_url":"https://api.github.com/repos/Samsung/GearVRf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Samsung/GearVRf/labels{/name}","releases_url":"https://api.github.com/repos/Samsung/GearVRf/releases{/id}","deployments_url":"https://api.github.com/repos/Samsung/GearVRf/deployments","created_at":"2015-03-25T02:02:18Z","updated_at":"2016-02-23T06:49:17Z","pushed_at":"2016-02-25T02:41:46Z","git_url":"git://github.com/Samsung/GearVRf.git","ssh_url":"git@github.com:Samsung/GearVRf.git","clone_url":"https://github.com/Samsung/GearVRf.git","svn_url":"https://github.com/Samsung/GearVRf","homepage":"http://www.gearvrf.org","size":710473,"stargazers_count":90,"watchers_count":90,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":89,"mirror_url":null,"open_issues_count":74,"forks":89,"open_issues":74,"watchers":90,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Samsung/GearVRf/pulls/425"},"html":{"href":"https://github.com/Samsung/GearVRf/pull/425"},"issue":{"href":"https://api.github.com/repos/Samsung/GearVRf/issues/425"},"comments":{"href":"https://api.github.com/repos/Samsung/GearVRf/issues/425/comments"},"review_comments":{"href":"https://api.github.com/repos/Samsung/GearVRf/pulls/425/comments"},"review_comment":{"href":"https://api.github.com/repos/Samsung/GearVRf/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Samsung/GearVRf/pulls/425/commits"},"statuses":{"href":"https://api.github.com/repos/Samsung/GearVRf/statuses/d05fd309d96622dc21f84dc58145d73f0d5007d3"}}}}