{"action":"created","comment":{"url":"https://api.github.com/repos/appleseedhq/appleseed/pulls/comments/173655445","pull_request_review_id":102882693,"id":173655445,"diff_hunk":"@@ -311,44 +368,218 @@ double Camera::extract_near_z() const\n \n namespace\n {\n+//\n+// Used in map_to_shutter_curve_impl_nonlinear()\n+//\n+inline float inverse_sample_curve_patch(\n+    const foundation::Polynomial<float, float, 6>& curve,\n+    const float value,\n+    const float t0,\n+    const float t1,\n+    const float t2,\n+    const float t3,\n+    const Camera& camera)\n+{\n+    const float eps = 1e-6;\n+    const float a = 0.0f;\n+    const float b = 1.0f;\n+    const float max_param = foundation::shift(b, -1);\n+\n+    float root;\n+\n+    const auto f = [&curve, &value](float param)\n+        {\n+            return curve.evaluate(param) - value;\n+        };\n+\n+    const auto d = [&curve](float param)\n+        {\n+            return curve.evaluate_derivative(param);\n+        };\n+\n+    bool success = foundation::find_root_newton(\n+        f,\n+        d,\n+        a,\n+        b,\n+        eps,\n+        10,\n+        root\n+    );\n+\n+    if (success)\n+    {\n+        // make sure neuton method didn't push root slightly out of bounds\n+        root = foundation::clamp(root, a, max_param);\n+\n+        return foundation::evaluate_bezier3(t0, t1, t2, t3, root);\n+    }\n+\n     //\n-    // Shutter curves. Used in Camera::map_to_shutter_curve().\n+    // Fallback to bisection.\n     //\n \n-    // Integrate and inverse opening/closing curve y = a * x + b to transform samples.\n-    float map_sample_to_linear_curve(const float a, const float b, const float x)\n+    success = foundation::find_root_bisection(\n+        f,\n+        a,\n+        b,\n+        eps,\n+        21, // This would be enough to get 10e-6 accuracy for the whole [a,b] interval.\n+        root);\n+\n+    if (!success)\n     {\n-        float constant;\n-        if (a > 0.0f)\n-        {\n-            // Shutter is opening.\n-            constant = 0.0f;\n-        }\n-        else\n-        {\n-            // Shutter is closing.\n-            constant = 1.0f - (a / 2.0f) - b;\n-        }\n-        return (sqrt(2.0f * a * (x - constant) + b * b) - b) / a;\n+        assert(false && \"Cannot inverse sample shutter curve CDF\");\n+        RENDERER_LOG_ERROR(\"Cannot inverse sample shutter curve CDF of camera \\\"%s\\\"\", camera.get_path().c_str());\n     }\n+\n+    return foundation::evaluate_bezier3(t0, t1, t2, t3, root);\n }\n \n-float Camera::map_to_shutter_curve(const float sample) const\n+} // namespace\n+\n+// Linear curve consists of multiple linear patches\n+float Camera::map_to_shutter_curve_impl_linear(const float sample) const\n {\n-    if (0.0f <= sample && sample < m_inverse_cdf_open_point)\n+    if (sample < m_inverse_cdf_open_point)\n     {\n         // Shutter is opening.\n-        return map_sample_to_linear_curve(m_open_linear_curve_slope, 0.0f, sample);\n+        return sqrt(m_shutter_curve_linear_open_multiplier * sample);\n     }\n-    else if (1.0f >= sample && sample > m_inverse_cdf_close_point)\n+    else if (sample > m_inverse_cdf_close_point)\n     {\n         // Shutter is closing.\n-        return map_sample_to_linear_curve(m_close_linear_curve_slope, -m_close_linear_curve_slope, sample);\n+        return 1.0f - sqrt(m_shutter_curve_linear_close_multiplier * (sample - 1.0f));\n     }\n     else\n     {\n         // Shutter is fully opened.\n-        return sample / m_shutter_pdf_max_height + m_normalized_open_end_time_half;\n+        return m_shutter_curve_linear_fully_opened_multiplier * sample + m_shutter_open_end_time / 2.0f;\n+    }\n+}\n+\n+// Nonlinear curve consists of two bezier curves and constant patch between them\n+float Camera::map_to_shutter_curve_impl_nonlinear(const float sample) const","path":"src/appleseed/renderer/modeling/camera/camera.cpp","position":218,"original_position":218,"commit_id":"7ee409cc52d2487a8ad565cc37756d1016053789","original_commit_id":"7ee409cc52d2487a8ad565cc37756d1016053789","user":{"login":"fedormatantsev","id":36549098,"avatar_url":"https://avatars1.githubusercontent.com/u/36549098?v=4","gravatar_id":"","url":"https://api.github.com/users/fedormatantsev","html_url":"https://github.com/fedormatantsev","followers_url":"https://api.github.com/users/fedormatantsev/followers","following_url":"https://api.github.com/users/fedormatantsev/following{/other_user}","gists_url":"https://api.github.com/users/fedormatantsev/gists{/gist_id}","starred_url":"https://api.github.com/users/fedormatantsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedormatantsev/subscriptions","organizations_url":"https://api.github.com/users/fedormatantsev/orgs","repos_url":"https://api.github.com/users/fedormatantsev/repos","events_url":"https://api.github.com/users/fedormatantsev/events{/privacy}","received_events_url":"https://api.github.com/users/fedormatantsev/received_events","type":"User","site_admin":false},"body":"Let it be bezier then.","created_at":"2018-03-11T13:51:00Z","updated_at":"2018-03-11T13:51:00Z","html_url":"https://github.com/appleseedhq/appleseed/pull/1895#discussion_r173655445","pull_request_url":"https://api.github.com/repos/appleseedhq/appleseed/pulls/1895","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/appleseedhq/appleseed/pulls/comments/173655445"},"html":{"href":"https://github.com/appleseedhq/appleseed/pull/1895#discussion_r173655445"},"pull_request":{"href":"https://api.github.com/repos/appleseedhq/appleseed/pulls/1895"}},"in_reply_to_id":173650578},"pull_request":{"url":"https://api.github.com/repos/appleseedhq/appleseed/pulls/1895","id":174184290,"html_url":"https://github.com/appleseedhq/appleseed/pull/1895","diff_url":"https://github.com/appleseedhq/appleseed/pull/1895.diff","patch_url":"https://github.com/appleseedhq/appleseed/pull/1895.patch","issue_url":"https://api.github.com/repos/appleseedhq/appleseed/issues/1895","number":1895,"state":"open","locked":false,"title":"Add shutter curve functionality","user":{"login":"fedormatantsev","id":36549098,"avatar_url":"https://avatars1.githubusercontent.com/u/36549098?v=4","gravatar_id":"","url":"https://api.github.com/users/fedormatantsev","html_url":"https://github.com/fedormatantsev","followers_url":"https://api.github.com/users/fedormatantsev/followers","following_url":"https://api.github.com/users/fedormatantsev/following{/other_user}","gists_url":"https://api.github.com/users/fedormatantsev/gists{/gist_id}","starred_url":"https://api.github.com/users/fedormatantsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedormatantsev/subscriptions","organizations_url":"https://api.github.com/users/fedormatantsev/orgs","repos_url":"https://api.github.com/users/fedormatantsev/repos","events_url":"https://api.github.com/users/fedormatantsev/events{/privacy}","received_events_url":"https://api.github.com/users/fedormatantsev/received_events","type":"User","site_admin":false},"body":"- Fixed linear curve inverse sampling;\r\n- Implemented parametric curve-based shutter;\r\n\r\n![constant](https://user-images.githubusercontent.com/36549098/37245744-eb9d28ec-24ad-11e8-8d75-b37610d97316.png)\r\n![curve_linear](https://user-images.githubusercontent.com/36549098/37245745-ebbc6e96-24ad-11e8-8c56-a4d67e9e2d72.png)\r\n![curve_nonlinear](https://user-images.githubusercontent.com/36549098/37245746-ebd859bc-24ad-11e8-8cb6-949e9d89bde8.png)\r\n\r\n","created_at":"2018-03-10T18:59:53Z","updated_at":"2018-03-11T13:51:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f0e694681a45394702b5b744c54479011791713","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/appleseedhq/appleseed/pulls/1895/commits","review_comments_url":"https://api.github.com/repos/appleseedhq/appleseed/pulls/1895/comments","review_comment_url":"https://api.github.com/repos/appleseedhq/appleseed/pulls/comments{/number}","comments_url":"https://api.github.com/repos/appleseedhq/appleseed/issues/1895/comments","statuses_url":"https://api.github.com/repos/appleseedhq/appleseed/statuses/7ee409cc52d2487a8ad565cc37756d1016053789","head":{"label":"fedormatantsev:shutter_curve","ref":"shutter_curve","sha":"7ee409cc52d2487a8ad565cc37756d1016053789","user":{"login":"fedormatantsev","id":36549098,"avatar_url":"https://avatars1.githubusercontent.com/u/36549098?v=4","gravatar_id":"","url":"https://api.github.com/users/fedormatantsev","html_url":"https://github.com/fedormatantsev","followers_url":"https://api.github.com/users/fedormatantsev/followers","following_url":"https://api.github.com/users/fedormatantsev/following{/other_user}","gists_url":"https://api.github.com/users/fedormatantsev/gists{/gist_id}","starred_url":"https://api.github.com/users/fedormatantsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedormatantsev/subscriptions","organizations_url":"https://api.github.com/users/fedormatantsev/orgs","repos_url":"https://api.github.com/users/fedormatantsev/repos","events_url":"https://api.github.com/users/fedormatantsev/events{/privacy}","received_events_url":"https://api.github.com/users/fedormatantsev/received_events","type":"User","site_admin":false},"repo":{"id":121793974,"name":"appleseed","full_name":"fedormatantsev/appleseed","owner":{"login":"fedormatantsev","id":36549098,"avatar_url":"https://avatars1.githubusercontent.com/u/36549098?v=4","gravatar_id":"","url":"https://api.github.com/users/fedormatantsev","html_url":"https://github.com/fedormatantsev","followers_url":"https://api.github.com/users/fedormatantsev/followers","following_url":"https://api.github.com/users/fedormatantsev/following{/other_user}","gists_url":"https://api.github.com/users/fedormatantsev/gists{/gist_id}","starred_url":"https://api.github.com/users/fedormatantsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fedormatantsev/subscriptions","organizations_url":"https://api.github.com/users/fedormatantsev/orgs","repos_url":"https://api.github.com/users/fedormatantsev/repos","events_url":"https://api.github.com/users/fedormatantsev/events{/privacy}","received_events_url":"https://api.github.com/users/fedormatantsev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fedormatantsev/appleseed","description":"A modern open source rendering engine for animation and visual effects","fork":true,"url":"https://api.github.com/repos/fedormatantsev/appleseed","forks_url":"https://api.github.com/repos/fedormatantsev/appleseed/forks","keys_url":"https://api.github.com/repos/fedormatantsev/appleseed/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fedormatantsev/appleseed/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fedormatantsev/appleseed/teams","hooks_url":"https://api.github.com/repos/fedormatantsev/appleseed/hooks","issue_events_url":"https://api.github.com/repos/fedormatantsev/appleseed/issues/events{/number}","events_url":"https://api.github.com/repos/fedormatantsev/appleseed/events","assignees_url":"https://api.github.com/repos/fedormatantsev/appleseed/assignees{/user}","branches_url":"https://api.github.com/repos/fedormatantsev/appleseed/branches{/branch}","tags_url":"https://api.github.com/repos/fedormatantsev/appleseed/tags","blobs_url":"https://api.github.com/repos/fedormatantsev/appleseed/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fedormatantsev/appleseed/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fedormatantsev/appleseed/git/refs{/sha}","trees_url":"https://api.github.com/repos/fedormatantsev/appleseed/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fedormatantsev/appleseed/statuses/{sha}","languages_url":"https://api.github.com/repos/fedormatantsev/appleseed/languages","stargazers_url":"https://api.github.com/repos/fedormatantsev/appleseed/stargazers","contributors_url":"https://api.github.com/repos/fedormatantsev/appleseed/contributors","subscribers_url":"https://api.github.com/repos/fedormatantsev/appleseed/subscribers","subscription_url":"https://api.github.com/repos/fedormatantsev/appleseed/subscription","commits_url":"https://api.github.com/repos/fedormatantsev/appleseed/commits{/sha}","git_commits_url":"https://api.github.com/repos/fedormatantsev/appleseed/git/commits{/sha}","comments_url":"https://api.github.com/repos/fedormatantsev/appleseed/comments{/number}","issue_comment_url":"https://api.github.com/repos/fedormatantsev/appleseed/issues/comments{/number}","contents_url":"https://api.github.com/repos/fedormatantsev/appleseed/contents/{+path}","compare_url":"https://api.github.com/repos/fedormatantsev/appleseed/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fedormatantsev/appleseed/merges","archive_url":"https://api.github.com/repos/fedormatantsev/appleseed/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fedormatantsev/appleseed/downloads","issues_url":"https://api.github.com/repos/fedormatantsev/appleseed/issues{/number}","pulls_url":"https://api.github.com/repos/fedormatantsev/appleseed/pulls{/number}","milestones_url":"https://api.github.com/repos/fedormatantsev/appleseed/milestones{/number}","notifications_url":"https://api.github.com/repos/fedormatantsev/appleseed/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fedormatantsev/appleseed/labels{/name}","releases_url":"https://api.github.com/repos/fedormatantsev/appleseed/releases{/id}","deployments_url":"https://api.github.com/repos/fedormatantsev/appleseed/deployments","created_at":"2018-02-16T19:52:15Z","updated_at":"2018-02-16T19:52:29Z","pushed_at":"2018-03-11T09:11:18Z","git_url":"git://github.com/fedormatantsev/appleseed.git","ssh_url":"git@github.com:fedormatantsev/appleseed.git","clone_url":"https://github.com/fedormatantsev/appleseed.git","svn_url":"https://github.com/fedormatantsev/appleseed","homepage":"http://appleseedhq.net/","size":1197290,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"appleseedhq:master","ref":"master","sha":"1cd900478babe4e27e7a15b86dd9fe23df9e8639","user":{"login":"appleseedhq","id":6373510,"avatar_url":"https://avatars3.githubusercontent.com/u/6373510?v=4","gravatar_id":"","url":"https://api.github.com/users/appleseedhq","html_url":"https://github.com/appleseedhq","followers_url":"https://api.github.com/users/appleseedhq/followers","following_url":"https://api.github.com/users/appleseedhq/following{/other_user}","gists_url":"https://api.github.com/users/appleseedhq/gists{/gist_id}","starred_url":"https://api.github.com/users/appleseedhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appleseedhq/subscriptions","organizations_url":"https://api.github.com/users/appleseedhq/orgs","repos_url":"https://api.github.com/users/appleseedhq/repos","events_url":"https://api.github.com/users/appleseedhq/events{/privacy}","received_events_url":"https://api.github.com/users/appleseedhq/received_events","type":"Organization","site_admin":false},"repo":{"id":753784,"name":"appleseed","full_name":"appleseedhq/appleseed","owner":{"login":"appleseedhq","id":6373510,"avatar_url":"https://avatars3.githubusercontent.com/u/6373510?v=4","gravatar_id":"","url":"https://api.github.com/users/appleseedhq","html_url":"https://github.com/appleseedhq","followers_url":"https://api.github.com/users/appleseedhq/followers","following_url":"https://api.github.com/users/appleseedhq/following{/other_user}","gists_url":"https://api.github.com/users/appleseedhq/gists{/gist_id}","starred_url":"https://api.github.com/users/appleseedhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appleseedhq/subscriptions","organizations_url":"https://api.github.com/users/appleseedhq/orgs","repos_url":"https://api.github.com/users/appleseedhq/repos","events_url":"https://api.github.com/users/appleseedhq/events{/privacy}","received_events_url":"https://api.github.com/users/appleseedhq/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/appleseedhq/appleseed","description":"A modern open source rendering engine for animation and visual effects","fork":false,"url":"https://api.github.com/repos/appleseedhq/appleseed","forks_url":"https://api.github.com/repos/appleseedhq/appleseed/forks","keys_url":"https://api.github.com/repos/appleseedhq/appleseed/keys{/key_id}","collaborators_url":"https://api.github.com/repos/appleseedhq/appleseed/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/appleseedhq/appleseed/teams","hooks_url":"https://api.github.com/repos/appleseedhq/appleseed/hooks","issue_events_url":"https://api.github.com/repos/appleseedhq/appleseed/issues/events{/number}","events_url":"https://api.github.com/repos/appleseedhq/appleseed/events","assignees_url":"https://api.github.com/repos/appleseedhq/appleseed/assignees{/user}","branches_url":"https://api.github.com/repos/appleseedhq/appleseed/branches{/branch}","tags_url":"https://api.github.com/repos/appleseedhq/appleseed/tags","blobs_url":"https://api.github.com/repos/appleseedhq/appleseed/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/appleseedhq/appleseed/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/appleseedhq/appleseed/git/refs{/sha}","trees_url":"https://api.github.com/repos/appleseedhq/appleseed/git/trees{/sha}","statuses_url":"https://api.github.com/repos/appleseedhq/appleseed/statuses/{sha}","languages_url":"https://api.github.com/repos/appleseedhq/appleseed/languages","stargazers_url":"https://api.github.com/repos/appleseedhq/appleseed/stargazers","contributors_url":"https://api.github.com/repos/appleseedhq/appleseed/contributors","subscribers_url":"https://api.github.com/repos/appleseedhq/appleseed/subscribers","subscription_url":"https://api.github.com/repos/appleseedhq/appleseed/subscription","commits_url":"https://api.github.com/repos/appleseedhq/appleseed/commits{/sha}","git_commits_url":"https://api.github.com/repos/appleseedhq/appleseed/git/commits{/sha}","comments_url":"https://api.github.com/repos/appleseedhq/appleseed/comments{/number}","issue_comment_url":"https://api.github.com/repos/appleseedhq/appleseed/issues/comments{/number}","contents_url":"https://api.github.com/repos/appleseedhq/appleseed/contents/{+path}","compare_url":"https://api.github.com/repos/appleseedhq/appleseed/compare/{base}...{head}","merges_url":"https://api.github.com/repos/appleseedhq/appleseed/merges","archive_url":"https://api.github.com/repos/appleseedhq/appleseed/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/appleseedhq/appleseed/downloads","issues_url":"https://api.github.com/repos/appleseedhq/appleseed/issues{/number}","pulls_url":"https://api.github.com/repos/appleseedhq/appleseed/pulls{/number}","milestones_url":"https://api.github.com/repos/appleseedhq/appleseed/milestones{/number}","notifications_url":"https://api.github.com/repos/appleseedhq/appleseed/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/appleseedhq/appleseed/labels{/name}","releases_url":"https://api.github.com/repos/appleseedhq/appleseed/releases{/id}","deployments_url":"https://api.github.com/repos/appleseedhq/appleseed/deployments","created_at":"2010-07-02T16:33:51Z","updated_at":"2018-03-11T04:18:07Z","pushed_at":"2018-03-11T09:11:20Z","git_url":"git://github.com/appleseedhq/appleseed.git","ssh_url":"git@github.com:appleseedhq/appleseed.git","clone_url":"https://github.com/appleseedhq/appleseed.git","svn_url":"https://github.com/appleseedhq/appleseed","homepage":"http://appleseedhq.net/","size":1197269,"stargazers_count":911,"watchers_count":911,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":178,"mirror_url":null,"archived":false,"open_issues_count":332,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":178,"open_issues":332,"watchers":911,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/appleseedhq/appleseed/pulls/1895"},"html":{"href":"https://github.com/appleseedhq/appleseed/pull/1895"},"issue":{"href":"https://api.github.com/repos/appleseedhq/appleseed/issues/1895"},"comments":{"href":"https://api.github.com/repos/appleseedhq/appleseed/issues/1895/comments"},"review_comments":{"href":"https://api.github.com/repos/appleseedhq/appleseed/pulls/1895/comments"},"review_comment":{"href":"https://api.github.com/repos/appleseedhq/appleseed/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/appleseedhq/appleseed/pulls/1895/commits"},"statuses":{"href":"https://api.github.com/repos/appleseedhq/appleseed/statuses/7ee409cc52d2487a8ad565cc37756d1016053789"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"fedormatantsev"}}