{"id":2228,"date":"2016-09-20T20:06:21","date_gmt":"2016-09-20T20:06:21","guid":{"rendered":"http:\/\/julius-ihle.de\/?p=2228"},"modified":"2018-04-04T08:39:19","modified_gmt":"2018-04-04T08:39:19","slug":"smoothing-harsh-specular-highlights-in-motionblur","status":"publish","type":"post","link":"https:\/\/julius-ihle.de\/?p=2228","title":{"rendered":"Smoothing dotty Specular Highlights in Motionblur"},"content":{"rendered":"<p><a href=\"https:\/\/julius-ihle.de\/?p=2228\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-2229\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/mblurroughness.png\" alt=\"mblurroughness\" width=\"800\" height=\"333\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/mblurroughness.png 1280w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/mblurroughness-300x125.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/mblurroughness-1024x426.png 1024w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>One of the worst things to sample for any brute-force ray tracer are specular highlights \/ reflections with a low roughness in motion blur. Even worse so on fine displacements or bump. And EVEN more worse with lots of small highlights. When all of these things come together sampling these highlights in motionblur is going to become really hard and with conventional methods you will end up having to rely on extemely\u00a0high AA samples and even then the highlight-streaks will most likely still be dotty&#8230; And you won&#8217;t make any friends if they have to paint these streaks\u00a0smooth in Comp :) So during the crunch time of a recent project I was brain storming with some of my collegues how this could potentially be fixed without needing too much samples and I&#8217;ve been working on implementing that idea which seems to work quite nicely.<\/p>\n<p><!--more--><\/p>\n<figure id=\"attachment_2233\" aria-describedby=\"caption-attachment-2233\" style=\"width: 800px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/vlcsnap-2016-09-20-22h38m54s198.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2233\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/vlcsnap-2016-09-20-22h38m54s198.png\" alt=\"vlcsnap-2016-09-20-22h38m54s198\" width=\"800\" height=\"453\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/vlcsnap-2016-09-20-22h38m54s198.png 1920w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/vlcsnap-2016-09-20-22h38m54s198-300x170.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/vlcsnap-2016-09-20-22h38m54s198-1024x580.png 1024w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><figcaption id=\"caption-attachment-2233\" class=\"wp-caption-text\">If you try to sample this speedy fella in an environment like that with this look you will inevitably end up with streaky specs.<\/figcaption><\/figure>\n<p style=\"text-align: left;\">So how do you fix it without changing the look?\u00a0Let&#8217;s say you have a simple scene like the following:<\/p>\n<p style=\"text-align: left;\"><a href=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/01_base_nomblur.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2234\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/01_base_nomblur.png\" alt=\"01_base_nomblur\" width=\"1679\" height=\"579\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/01_base_nomblur.png 1679w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/01_base_nomblur-300x103.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/01_base_nomblur-1024x353.png 1024w\" sizes=\"auto, (max-width: 1679px) 100vw, 1679px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">In this case\u00a0I&#8217;m using Arnold, but the base concept is the same with any renderer. Low roughness on the specs + bumpy surface + lots of harsh highlights result in something like this when you turn on motionblur:<\/p>\n<p style=\"text-align: left;\"><a href=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblur_base.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2235\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblur_base.png\" alt=\"02_mblur_base\" width=\"1679\" height=\"580\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblur_base.png 1679w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblur_base-300x104.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblur_base-1024x354.png 1024w\" sizes=\"auto, (max-width: 1679px) 100vw, 1679px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">This one already has 12 AA samples + 2 light samples. It won&#8217;t get much smoother just cranking up the samples, but trust me it will render longer :) One way to smooth the streaks out however would be to<strong> increase the roughness<\/strong> and <strong>decrease the bump \/ displacement<\/strong>.<\/p>\n<p style=\"text-align: left;\"><a href=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblurrough.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2236\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblurrough.png\" alt=\"02_mblurrough\" width=\"1679\" height=\"555\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblurrough.png 1679w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblurrough-300x99.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/02_mblurrough-1024x338.png 1024w\" sizes=\"auto, (max-width: 1679px) 100vw, 1679px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">That looks way better. However the problem with this is that these adjustments will affect the look a lot and the asset will look very different in non-motionblurred frames. So let&#8217;s make it work only when the character is in motionblur.<br \/>\nMost renderers offer some sort of a node that allows you to extract the motion vectors from a moving object, which basically define\u00a0what distance each point on an object travels from one frame to another in XYZ.<br \/>\n<a href=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/03_mvector_base_annotated.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2241\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/03_mvector_base_annotated.png\" alt=\"03_mvector_base_annotated\" width=\"1679\" height=\"578\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/03_mvector_base_annotated.png 1679w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/03_mvector_base_annotated-300x103.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/03_mvector_base_annotated-1024x353.png 1024w\" sizes=\"auto, (max-width: 1679px) 100vw, 1679px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">As you can see we get quite big values for this frame just outputting the raw motion vectors. It&#8217;s very important that they are in a raw format and not normalized, because otherwise you won&#8217;t have the actual movement distance but just something normalized (positive values between 0-1) to make it better visible.<br \/>\nNow these negative values won&#8217;t help us much. Eventually we want to be able to use this infortmation as a mask to switch between rough\/blurry (for motion blur areas) and sharp reflections (for non-motionblurred areas).<br \/>\nSo let&#8217;s make sure these values are always absolute.<\/p>\n<p style=\"text-align: left;\"><a href=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/04_abs_mvector1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2242\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/04_abs_mvector1.png\" alt=\"04_abs_mvector\" width=\"1679\" height=\"576\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/04_abs_mvector1.png 1679w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/04_abs_mvector1-300x103.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/04_abs_mvector1-1024x351.png 1024w\" sizes=\"auto, (max-width: 1679px) 100vw, 1679px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">This way no matter what the motionvector outputs, they will always be positive.\u00a0Now we need to convert this to a float to make it useable\u00a0as a mask.\u00a0In this case a simple RGB to luminance won&#8217;t quite cut it as you will have a weighted average of the movement in X,Y and Z. You can use a max or a sum of all the three channels to always make sure you grab the biggest motion.<\/p>\n<p style=\"text-align: left;\"><a href=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/05_rgbtofloat.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2239\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/05_rgbtofloat.png\" alt=\"05_rgbtofloat\" width=\"1679\" height=\"578\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/05_rgbtofloat.png 1679w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/05_rgbtofloat-300x103.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/05_rgbtofloat-1024x353.png 1024w\" sizes=\"auto, (max-width: 1679px) 100vw, 1679px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">The only thing left to do is to bring the whole thing into a suitable normalized range to be able to use it as a mask. How you are remapping it, depends on at which point you want to completely switch from one roughness to the other. If you have your usual range\/remap node you can specify with the input max at which point the value of the resulting mask should be 1. If I&#8217;d set it to 30 for example, as soon as the motionvector reaches a value of 30 it will result in a white mask and it will smoothly blend to 0 for areas\/frames with no motion. We can use this mask then to mix between 2 roughness and bump values or textures. This way we retain the look of the original asset and have nice and smooth motion blur.<br \/>\nHere&#8217;s a before and after frame with this method. Both have the same sampling settings<\/p>\n<p style=\"text-align: left;\"><a href=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/06_mix_result.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2240\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/06_mix_result.png\" alt=\"06_mix_result\" width=\"1679\" height=\"578\" srcset=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/06_mix_result.png 1679w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/06_mix_result-300x103.png 300w, https:\/\/julius-ihle.de\/wp-content\/uploads\/2016\/09\/06_mix_result-1024x353.png 1024w\" sizes=\"auto, (max-width: 1679px) 100vw, 1679px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<br \/>\n<span style=\"color: #808080;\">_________________________________________________<\/span><br \/>\n<span style=\"color: #808080;\"><span style=\"font-size: small;\"> If this post has helped you in any way you can express your gratefulness by using the <em>Donate\u00a0<\/em>Button below to buy me a coffee! :)<\/span><\/span><br \/>\n<a href=\"https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_s-xclick&amp;hosted_button_id=VH5RW3YDWDJSQ\" target=\"_blank\" rel=\"nofollow\"><img decoding=\"async\" src=\"https:\/\/www.paypal.com\/en_US\/i\/btn\/x-click-but21.gif\" alt=\"\" \/><\/a><\/p>\n<div class=\"moz-text-html\" lang=\"x-unicode\">\n<div><span style=\"font-size: small;\"><span style=\"color: #808080;\">3M5xNSV7g2NzVpHMqzYKhgoKJZ8CWa644m<\/span><\/span><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-full wp-image-2576\" src=\"https:\/\/julius-ihle.de\/wp-content\/uploads\/2018\/03\/bc_ldgr_qrcode.png\" alt=\"bc_ldgr_qrcode\" width=\"128\" height=\"128\" \/><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the worst things to sample for any brute-force ray tracer are specular highlights \/ reflections with a low roughness in motion blur. Even worse so on fine displacements or bump. And EVEN more worse with lots of small highlights. When all of these things come together sampling these highlights in motionblur is going [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[11,105,25,106,104,102,103,26,6,101,96,24,92,28],"class_list":["post-2228","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-arnold","tag-fireflies","tag-lighting","tag-mblur","tag-noise","tag-path-tracer","tag-raytracing","tag-rendering","tag-renderman","tag-sampling","tag-shading","tag-vfx","tag-visual-effects","tag-workflow"],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3MXK6-zW","jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/julius-ihle.de\/index.php?rest_route=\/wp\/v2\/posts\/2228","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/julius-ihle.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/julius-ihle.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/julius-ihle.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/julius-ihle.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2228"}],"version-history":[{"count":9,"href":"https:\/\/julius-ihle.de\/index.php?rest_route=\/wp\/v2\/posts\/2228\/revisions"}],"predecessor-version":[{"id":2593,"href":"https:\/\/julius-ihle.de\/index.php?rest_route=\/wp\/v2\/posts\/2228\/revisions\/2593"}],"wp:attachment":[{"href":"https:\/\/julius-ihle.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/julius-ihle.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2228"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/julius-ihle.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}