{"action":"created","comment":{"url":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/50466058","id":50466058,"diff_hunk":"@@ -0,0 +1,229 @@\n+<!\n+//  AmbientOcclusion.slh\n+//  libraries/render-utils/src\n+//\n+//  Created by Sam Gateau on 1/1/16.\n+//  Copyright 2016 High Fidelity, Inc.\n+//\n+//  Distributed under the Apache License, Version 2.0.\n+//  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html\n+!>\n+<@if not SSAO_SLH@>\n+<@def SSAO_SLH@>\n+\n+<@func declarePackOcclusionDepth()@>\n+\n+const float FAR_PLANE_Z = -300.0;\n+\n+float CSZToDephtKey(float z) {\n+    return clamp(z * (1.0 / FAR_PLANE_Z), 0.0, 1.0);\n+}\n+vec3 packOcclusionDepth(float occlusion, float depth) {\n+    // Round to the nearest 1/256.0\n+    float temp = floor(depth * 256.0);\n+    return vec3(occlusion, temp * (1.0 / 256.0), depth * 256.0 - temp);\n+}\n+vec2 unpackOcclusionDepth(vec3 raw) {\n+    float z = raw.y * (256.0 / 257.0) + raw.z * (1.0 / 257.0);\n+    return vec2(raw.x, z);\n+}\n+<@endfunc@>\n+\n+<@func declareAmbientOcclusion()@>\n+\n+struct AmbientOcclusionFrameTransform {\n+    vec4 _pixelInfo;\n+    vec4 _depthInfo;\n+    vec4 _stereoInfo;\n+    mat4 _projection[2];\n+};\n+\n+struct AmbientOcclusionParams {\n+    vec4 _resolutionInfo;\n+    vec4 _radiusInfo;\n+    vec4 _ditheringInfo;\n+    vec4 _sampleInfo;\n+    vec4 _blurInfo;\n+    float _gaussianCoefs[8];\n+};\n+\n+uniform ambientOcclusionFrameTransformBuffer {\n+    AmbientOcclusionFrameTransform frameTransform;\n+};\n+uniform ambientOcclusionParamsBuffer {\n+    AmbientOcclusionParams params;\n+};\n+\n+\n+int getResolutionLevel() {\n+    return int(params._resolutionInfo.x);\n+}\n+\n+vec2 getWidthHeight() {\n+    return vec2(ivec2(frameTransform._pixelInfo.zw) >> getResolutionLevel());\n+}\n+float getProjScale() {\n+    return getWidthHeight().y * frameTransform._projection[0][1][1] * 0.5;\n+}\n+mat4 getProjection(int side) {\n+    return frameTransform._projection[side];\n+}\n+\n+bool isStereo() {\n+    return frameTransform._stereoInfo.x > 0.0f;\n+}\n+\n+float getStereoSideWidth() {\n+    return float(int(frameTransform._stereoInfo.y) >>  getResolutionLevel());\n+}\n+\n+ivec2 getStereoSideInfo(int xPos) {\n+    int sideWidth = int(getStereoSideWidth());\n+    return (xPos < sideWidth ? ivec2(0, 0) : ivec2(1, sideWidth) );\n+}\n+\n+\n+float evalZeyeFromZdb(float depth) {\n+    return frameTransform._depthInfo.x / (depth * frameTransform._depthInfo.y + frameTransform._depthInfo.z);\n+}\n+\n+vec3 evalEyeNormal(vec3 C) {\n+    //return normalize(cross(dFdy(C), dFdx(C)));\n+    return normalize(cross(dFdx(C), dFdy(C)));\n+}\n+\n+\n+float getRadius() {\n+    return params._radiusInfo.x;\n+}\n+float getRadius2() {\n+    return params._radiusInfo.y;\n+}\n+float getInvRadius6() {\n+    return params._radiusInfo.z;\n+}\n+float getObscuranceScaling() {\n+    return params._radiusInfo.z * params._radiusInfo.w;\n+}\n+\n+float isDitheringEnabled() {\n+    return params._ditheringInfo.x;\n+}\n+float getFrameDithering() {\n+    return params._ditheringInfo.y;\n+}\n+\n+float getFalloffBias() {\n+    return params._ditheringInfo.z;\n+}\n+\n+float getNumSamples() {\n+    return params._sampleInfo.x;\n+}\n+float getInvNumSamples() {\n+    return params._sampleInfo.y;\n+}\n+float getNumSpiralTurns() {\n+    return params._sampleInfo.z;\n+}\n+\n+float getBlurEdgeSharpness() {\n+    return params._blurInfo.x;\n+}\n+\n+#ifdef CONSTANT_GAUSSIAN\n+const int BLUR_RADIUS = 4;\n+const float gaussian[BLUR_RADIUS + 1] =\n+//    float[](0.356642, 0.239400, 0.072410, 0.009869);\n+//    float[](0.398943, 0.241971, 0.053991, 0.004432, 0.000134);  // stddev = 1.0\n+float[](0.153170, 0.144893, 0.122649, 0.092902, 0.062970);  // stddev = 2.0\n+//float[](0.197413, 0.17467, 0.12098,0.065591,0.040059);\n+//      float[](0.111220, 0.107798, 0.098151, 0.083953, 0.067458, 0.050920, 0.036108); // stddev = 3.0\n+\n+int getBlurRadius() {\n+    return BLUR_RADIUS;\n+    return int(params._blurInfo.y);\n+}\n+\n+float getBlurCoef(int c) {\n+    return gaussian[c];\n+    return params._gaussianCoefs[c];\n+}\n+#else\n+int getBlurRadius() {\n+    return int(params._blurInfo.y);\n+}\n+\n+float getBlurCoef(int c) {\n+    return params._gaussianCoefs[c];\n+}\n+#endif\n+\n+<@endfunc@>\n+\n+<@func declareBlurPass(axis)@>\n+\n+<$declarePackOcclusionDepth()$>\n+<$declareAmbientOcclusion()$>\n+\n+// the source occlusion texture\n+uniform sampler2D occlusionMap;\n+\n+vec2 fetchOcclusionDepthRaw(ivec2 coords, out vec3 raw) {\n+    raw = texelFetch(occlusionMap, coords, 0).xyz;\n+    return unpackOcclusionDepth(raw);\n+}\n+\n+vec2 fetchOcclusionDepth(ivec2 coords) {\n+    return unpackOcclusionDepth(texelFetch(occlusionMap, coords, 0).xyz);\n+}\n+\n+const int RADIUS_SCALE = 2;\n+\n+vec2 evalTapWeightedValue(int r, ivec2 ssC, float key) {\n+    ivec2 tapOffset = <$axis$> * (r * RADIUS_SCALE);\n+    vec2 tapOZ = fetchOcclusionDepth(ssC + tapOffset);\n+\n+    // spatial domain: offset gaussian tap\n+    float weight = 0.3 + getBlurCoef(abs(r));","path":"libraries/render-utils/src/ssao.slh","position":188,"original_position":188,"commit_id":"8d1ab01018e38a3e6a96f3681254b64950b2955e","original_commit_id":"8d1ab01018e38a3e6a96f3681254b64950b2955e","user":{"login":"ZappoMan","id":2093195,"avatar_url":"https://avatars.githubusercontent.com/u/2093195?v=3","gravatar_id":"","url":"https://api.github.com/users/ZappoMan","html_url":"https://github.com/ZappoMan","followers_url":"https://api.github.com/users/ZappoMan/followers","following_url":"https://api.github.com/users/ZappoMan/following{/other_user}","gists_url":"https://api.github.com/users/ZappoMan/gists{/gist_id}","starred_url":"https://api.github.com/users/ZappoMan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZappoMan/subscriptions","organizations_url":"https://api.github.com/users/ZappoMan/orgs","repos_url":"https://api.github.com/users/ZappoMan/repos","events_url":"https://api.github.com/users/ZappoMan/events{/privacy}","received_events_url":"https://api.github.com/users/ZappoMan/received_events","type":"User","site_admin":false},"body":"coding standard: magic numbers","created_at":"2016-01-21T21:20:59Z","updated_at":"2016-01-21T21:20:59Z","html_url":"https://github.com/highfidelity/hifi/pull/6766#discussion_r50466058","pull_request_url":"https://api.github.com/repos/highfidelity/hifi/pulls/6766","_links":{"self":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/comments/50466058"},"html":{"href":"https://github.com/highfidelity/hifi/pull/6766#discussion_r50466058"},"pull_request":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/6766"}}},"pull_request":{"url":"https://api.github.com/repos/highfidelity/hifi/pulls/6766","id":55035647,"html_url":"https://github.com/highfidelity/hifi/pull/6766","diff_url":"https://github.com/highfidelity/hifi/pull/6766.diff","patch_url":"https://github.com/highfidelity/hifi/pull/6766.patch","issue_url":"https://api.github.com/repos/highfidelity/hifi/issues/6766","number":6766,"state":"open","locked":false,"title":"Ambient Occlusion","user":{"login":"samcake","id":2230265,"avatar_url":"https://avatars.githubusercontent.com/u/2230265?v=3","gravatar_id":"","url":"https://api.github.com/users/samcake","html_url":"https://github.com/samcake","followers_url":"https://api.github.com/users/samcake/followers","following_url":"https://api.github.com/users/samcake/following{/other_user}","gists_url":"https://api.github.com/users/samcake/gists{/gist_id}","starred_url":"https://api.github.com/users/samcake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samcake/subscriptions","organizations_url":"https://api.github.com/users/samcake/orgs","repos_url":"https://api.github.com/users/samcake/repos","events_url":"https://api.github.com/users/samcake/events{/privacy}","received_events_url":"https://api.github.com/users/samcake/received_events","type":"User","site_admin":false},"body":"This is the first version of the effect that i m considering ready\r\n- to see ambient occlusion make sure to turn on the \"Ambient occlusion\" menu item in deverloper/render\r\n- To look at what is going on, load the script renderENgineDebug.js (from this PR) and go checkout the different buffers in developer/render/debug Deferred Buffer\r\n","created_at":"2016-01-04T23:15:46Z","updated_at":"2016-01-21T21:20:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"473ebe0abcbe3c6fd226e2a06e8bf7212fb2206c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/highfidelity/hifi/pulls/6766/commits","review_comments_url":"https://api.github.com/repos/highfidelity/hifi/pulls/6766/comments","review_comment_url":"https://api.github.com/repos/highfidelity/hifi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/highfidelity/hifi/issues/6766/comments","statuses_url":"https://api.github.com/repos/highfidelity/hifi/statuses/8d1ab01018e38a3e6a96f3681254b64950b2955e","head":{"label":"samcake:hdr","ref":"hdr","sha":"8d1ab01018e38a3e6a96f3681254b64950b2955e","user":{"login":"samcake","id":2230265,"avatar_url":"https://avatars.githubusercontent.com/u/2230265?v=3","gravatar_id":"","url":"https://api.github.com/users/samcake","html_url":"https://github.com/samcake","followers_url":"https://api.github.com/users/samcake/followers","following_url":"https://api.github.com/users/samcake/following{/other_user}","gists_url":"https://api.github.com/users/samcake/gists{/gist_id}","starred_url":"https://api.github.com/users/samcake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samcake/subscriptions","organizations_url":"https://api.github.com/users/samcake/orgs","repos_url":"https://api.github.com/users/samcake/repos","events_url":"https://api.github.com/users/samcake/events{/privacy}","received_events_url":"https://api.github.com/users/samcake/received_events","type":"User","site_admin":false},"repo":{"id":24736064,"name":"hifi","full_name":"samcake/hifi","owner":{"login":"samcake","id":2230265,"avatar_url":"https://avatars.githubusercontent.com/u/2230265?v=3","gravatar_id":"","url":"https://api.github.com/users/samcake","html_url":"https://github.com/samcake","followers_url":"https://api.github.com/users/samcake/followers","following_url":"https://api.github.com/users/samcake/following{/other_user}","gists_url":"https://api.github.com/users/samcake/gists{/gist_id}","starred_url":"https://api.github.com/users/samcake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samcake/subscriptions","organizations_url":"https://api.github.com/users/samcake/orgs","repos_url":"https://api.github.com/users/samcake/repos","events_url":"https://api.github.com/users/samcake/events{/privacy}","received_events_url":"https://api.github.com/users/samcake/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/samcake/hifi","description":"Open, decentralized virtual worlds using sensors to control avatars and dynamically assigned devices as servers.  San Francisco based startup, we are hiring: http://highfidelity.io/jobs  Contribute by reporting bugs & doing jobs on http://worklist.net","fork":true,"url":"https://api.github.com/repos/samcake/hifi","forks_url":"https://api.github.com/repos/samcake/hifi/forks","keys_url":"https://api.github.com/repos/samcake/hifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/samcake/hifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/samcake/hifi/teams","hooks_url":"https://api.github.com/repos/samcake/hifi/hooks","issue_events_url":"https://api.github.com/repos/samcake/hifi/issues/events{/number}","events_url":"https://api.github.com/repos/samcake/hifi/events","assignees_url":"https://api.github.com/repos/samcake/hifi/assignees{/user}","branches_url":"https://api.github.com/repos/samcake/hifi/branches{/branch}","tags_url":"https://api.github.com/repos/samcake/hifi/tags","blobs_url":"https://api.github.com/repos/samcake/hifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/samcake/hifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/samcake/hifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/samcake/hifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/samcake/hifi/statuses/{sha}","languages_url":"https://api.github.com/repos/samcake/hifi/languages","stargazers_url":"https://api.github.com/repos/samcake/hifi/stargazers","contributors_url":"https://api.github.com/repos/samcake/hifi/contributors","subscribers_url":"https://api.github.com/repos/samcake/hifi/subscribers","subscription_url":"https://api.github.com/repos/samcake/hifi/subscription","commits_url":"https://api.github.com/repos/samcake/hifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/samcake/hifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/samcake/hifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/samcake/hifi/issues/comments{/number}","contents_url":"https://api.github.com/repos/samcake/hifi/contents/{+path}","compare_url":"https://api.github.com/repos/samcake/hifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/samcake/hifi/merges","archive_url":"https://api.github.com/repos/samcake/hifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/samcake/hifi/downloads","issues_url":"https://api.github.com/repos/samcake/hifi/issues{/number}","pulls_url":"https://api.github.com/repos/samcake/hifi/pulls{/number}","milestones_url":"https://api.github.com/repos/samcake/hifi/milestones{/number}","notifications_url":"https://api.github.com/repos/samcake/hifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/samcake/hifi/labels{/name}","releases_url":"https://api.github.com/repos/samcake/hifi/releases{/id}","created_at":"2014-10-02T20:49:37Z","updated_at":"2015-04-02T23:12:49Z","pushed_at":"2016-01-21T02:33:27Z","git_url":"git://github.com/samcake/hifi.git","ssh_url":"git@github.com:samcake/hifi.git","clone_url":"https://github.com/samcake/hifi.git","svn_url":"https://github.com/samcake/hifi","homepage":"","size":179156,"stargazers_count":0,"watchers_count":0,"language":"C++","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":"highfidelity:master","ref":"master","sha":"0da4df93b81514e6ac75cf58758d5de95df30d80","user":{"login":"highfidelity","id":1565370,"avatar_url":"https://avatars.githubusercontent.com/u/1565370?v=3","gravatar_id":"","url":"https://api.github.com/users/highfidelity","html_url":"https://github.com/highfidelity","followers_url":"https://api.github.com/users/highfidelity/followers","following_url":"https://api.github.com/users/highfidelity/following{/other_user}","gists_url":"https://api.github.com/users/highfidelity/gists{/gist_id}","starred_url":"https://api.github.com/users/highfidelity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/highfidelity/subscriptions","organizations_url":"https://api.github.com/users/highfidelity/orgs","repos_url":"https://api.github.com/users/highfidelity/repos","events_url":"https://api.github.com/users/highfidelity/events{/privacy}","received_events_url":"https://api.github.com/users/highfidelity/received_events","type":"Organization","site_admin":false},"repo":{"id":5372872,"name":"hifi","full_name":"highfidelity/hifi","owner":{"login":"highfidelity","id":1565370,"avatar_url":"https://avatars.githubusercontent.com/u/1565370?v=3","gravatar_id":"","url":"https://api.github.com/users/highfidelity","html_url":"https://github.com/highfidelity","followers_url":"https://api.github.com/users/highfidelity/followers","following_url":"https://api.github.com/users/highfidelity/following{/other_user}","gists_url":"https://api.github.com/users/highfidelity/gists{/gist_id}","starred_url":"https://api.github.com/users/highfidelity/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/highfidelity/subscriptions","organizations_url":"https://api.github.com/users/highfidelity/orgs","repos_url":"https://api.github.com/users/highfidelity/repos","events_url":"https://api.github.com/users/highfidelity/events{/privacy}","received_events_url":"https://api.github.com/users/highfidelity/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/highfidelity/hifi","description":"Open source software for shared virtual worlds using HMDs and dynamically assigned devices as servers.  San Francisco based startup, we are hiring: http://highfidelity.com/jobs  Documentation at http://docs.highfidelity.com  Contribute by reporting bugs & doing jobs on http://worklist.net","fork":false,"url":"https://api.github.com/repos/highfidelity/hifi","forks_url":"https://api.github.com/repos/highfidelity/hifi/forks","keys_url":"https://api.github.com/repos/highfidelity/hifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/highfidelity/hifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/highfidelity/hifi/teams","hooks_url":"https://api.github.com/repos/highfidelity/hifi/hooks","issue_events_url":"https://api.github.com/repos/highfidelity/hifi/issues/events{/number}","events_url":"https://api.github.com/repos/highfidelity/hifi/events","assignees_url":"https://api.github.com/repos/highfidelity/hifi/assignees{/user}","branches_url":"https://api.github.com/repos/highfidelity/hifi/branches{/branch}","tags_url":"https://api.github.com/repos/highfidelity/hifi/tags","blobs_url":"https://api.github.com/repos/highfidelity/hifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/highfidelity/hifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/highfidelity/hifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/highfidelity/hifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/highfidelity/hifi/statuses/{sha}","languages_url":"https://api.github.com/repos/highfidelity/hifi/languages","stargazers_url":"https://api.github.com/repos/highfidelity/hifi/stargazers","contributors_url":"https://api.github.com/repos/highfidelity/hifi/contributors","subscribers_url":"https://api.github.com/repos/highfidelity/hifi/subscribers","subscription_url":"https://api.github.com/repos/highfidelity/hifi/subscription","commits_url":"https://api.github.com/repos/highfidelity/hifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/highfidelity/hifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/highfidelity/hifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/highfidelity/hifi/issues/comments{/number}","contents_url":"https://api.github.com/repos/highfidelity/hifi/contents/{+path}","compare_url":"https://api.github.com/repos/highfidelity/hifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/highfidelity/hifi/merges","archive_url":"https://api.github.com/repos/highfidelity/hifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/highfidelity/hifi/downloads","issues_url":"https://api.github.com/repos/highfidelity/hifi/issues{/number}","pulls_url":"https://api.github.com/repos/highfidelity/hifi/pulls{/number}","milestones_url":"https://api.github.com/repos/highfidelity/hifi/milestones{/number}","notifications_url":"https://api.github.com/repos/highfidelity/hifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/highfidelity/hifi/labels{/name}","releases_url":"https://api.github.com/repos/highfidelity/hifi/releases{/id}","created_at":"2012-08-10T18:26:22Z","updated_at":"2016-01-18T01:29:50Z","pushed_at":"2016-01-21T20:31:35Z","git_url":"git://github.com/highfidelity/hifi.git","ssh_url":"git@github.com:highfidelity/hifi.git","clone_url":"https://github.com/highfidelity/hifi.git","svn_url":"https://github.com/highfidelity/hifi","homepage":"","size":225223,"stargazers_count":345,"watchers_count":345,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":204,"mirror_url":null,"open_issues_count":59,"forks":204,"open_issues":59,"watchers":345,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/6766"},"html":{"href":"https://github.com/highfidelity/hifi/pull/6766"},"issue":{"href":"https://api.github.com/repos/highfidelity/hifi/issues/6766"},"comments":{"href":"https://api.github.com/repos/highfidelity/hifi/issues/6766/comments"},"review_comments":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/6766/comments"},"review_comment":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/highfidelity/hifi/pulls/6766/commits"},"statuses":{"href":"https://api.github.com/repos/highfidelity/hifi/statuses/8d1ab01018e38a3e6a96f3681254b64950b2955e"}}}}