<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[Krzysztof Narkowicz]]></provider_name><provider_url><![CDATA[https://knarkowicz.wordpress.com]]></provider_url><author_name><![CDATA[Krzysztof Narkowicz]]></author_name><author_url><![CDATA[https://knarkowicz.wordpress.com/author/knarkowicz/]]></author_url><title><![CDATA[Cloth Shading]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>Over the holiday break I had some time to play with interesting ideas presented during the last SIGGRAPH. One thing which caught my attention was new analytical cloth BRDF from Sony Pictures Imageworks <a href="http://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_sheen.pdf">[EK17]</a>, which they use in movie production.</p>
<h1>AshikhminD</h1>
<p>Current state of the art of cloth shading in games still seems to be Ashikhmin velvet BRDF <a href="http://www.cs.utah.edu/~premoze/dbrdf/dBRDF.pdf">[AS07]</a>, which was popularized in games by Ready at Dawn <a href="http://blog.selfshadow.com/publications/s2013-shading-course/rad/s2013_pbs_rad_notes.pdf">[NP13]</a>. It basically boils down to skipping geometry term, replacing traditional microfacet BRDF denominator by a smoother version and using an inverted Gaussian for the distribution term:</p>
<p><img src="https://s0.wp.com/latex.php?latex=D%3D%7B%5Cfrac%7B1%7D%7B%5Cpi%281%2B4+%5Calpha+%5E2%29%7D%7D%281%2B%5Cfrac%7B4+%5Cexp%28-%5Cfrac%7B%5Ccot%5E2%5Ctheta%7D%7B%5Calpha+%5E2%7D%29%7D%7B%5Csin+%5E4%5Ctheta%7D%29&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="D={&#92;frac{1}{&#92;pi(1+4 &#92;alpha ^2)}}(1+&#92;frac{4 &#92;exp(-&#92;frac{&#92;cot^2&#92;theta}{&#92;alpha ^2})}{&#92;sin ^4&#92;theta})" class="latex" /></p>
<p>Full shader code (microfacet BRDF denominator and geometry term is included in V term):</p>
<pre class="brush: cpp; title: ; notranslate" title="">
float AshikhminD(float roughness, float ndoth)
{
    float m2    = roughness * roughness;
    float cos2h = ndoth * ndoth;
    float sin2h = 1. - cos2h;
    float sin4h = sin2h * sin2h;
    return (sin4h + 4. * exp(-cos2h / (sin2h * m2))) / (PI * (1. + 4. * m2) * sin4h);
}

float AshikhminV(float ndotv, float ndotl)
{
    return 1. / (4. * (ndotl + ndotv - ndotl * ndotv));
}

vec3 specular = lightColor * f * d * v * PI * ndotl;
</pre>
<h1>CharlieD</h1>
<p>Imageworks&#8217; presentation proposes a new cloth distribution term, which they call “Charlie” sheen:</p>
<p><img src="https://s0.wp.com/latex.php?latex=D%3D%5Cfrac%7B%5Cleft%282%2B%5Cfrac%7B1%7D%7B%5Calpha%7D%5Cright%29%5Csin%5E%7B%5Cfrac%7B1%7D%7B%5Calpha%7D%7D%5Ctheta%7D%7B2%5Cpi%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="D=&#92;frac{&#92;left(2+&#92;frac{1}{&#92;alpha}&#92;right)&#92;sin^{&#92;frac{1}{&#92;alpha}}&#92;theta}{2&#92;pi}" class="latex" /></p>
<p>This term has more intuitive behavior with changing roughness and solves the issue of harsh transitions (near ndotl = 1) of Ashikhnim velvet BRDF:</p>
<div data-shortcode="caption" id="attachment_1152" style="width: 410px" class="wp-caption aligncenter"><img loading="lazy" aria-describedby="caption-attachment-1152" data-attachment-id="1152" data-permalink="https://knarkowicz.wordpress.com/2018/01/04/cloth-shading/ashikhmin_charlie_compare/" data-orig-file="https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg" data-orig-size="778,367" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="ashikhmin_charlie_compare" data-image-description="" data-image-caption="&lt;p&gt;Left: Ashikhmin Right: Charlie&lt;/p&gt;
" data-medium-file="https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg?w=300" data-large-file="https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg?w=778" class="alignnone  wp-image-1152" src="https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg?w=400&#038;h=189" alt="ashikhmin_charlie_compare" width="400" height="189" srcset="https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg?w=400&amp;h=189 400w, https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg?w=150&amp;h=71 150w, https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg?w=300&amp;h=142 300w, https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg?w=768&amp;h=362 768w, https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg 778w" sizes="(max-width: 400px) 100vw, 400px" /><p id="caption-attachment-1152" class="wp-caption-text">Left: Ashikhmin Right: Charlie</p></div>
<p>Although Charlie distribution term is simpler than Ashikhmin&#8217;s, Imageworks&#8217; approximation for the physically based height correlated Smith geometry term is quite heavy for real-time rendering. Nevertheless, we can just use CharlieD and follow the same process as in <a href="http://www.cs.utah.edu/~premoze/dbrdf/dBRDF.pdf">[AS07]</a> for the geometry term and BRDF denominator:</p>
<pre class="brush: cpp; title: ; notranslate" title="">
float CharlieD(float roughness, float ndoth)
{
    float invR = 1. / roughness;
    float cos2h = ndoth * ndoth;
    float sin2h = 1. - cos2h;
    return (2. + invR) * pow(sin2h, invR * .5) / (2. * PI);
}

float AshikhminV(float ndotv, float ndotl)
{
    return 1. / (4. * (ndotl + ndotv - ndotl * ndotv));
}

vec3 specular = lightColor * f * d * v * PI * ndotl;
</pre>
<p>This results in a bit better looking, more intuitive to tweak and faster replacement of standard Ashikhmin velvet BRDF. See <a href="https://www.shadertoy.com/view/4tfBzn">this Shadertoy</a> for an interactive sample with full source code.</p>
<h1>References</h1>
<p>[NP13] David Neubelt, Matt Pettineo &#8211; <a href="http://blog.selfshadow.com/publications/s2013-shading-course/rad/s2013_pbs_rad_notes.pdf">“Crafting a Next-Gen Material Pipeline for The Order: 1886”</a>, SIGGRAPH 2013<br />
[AS07] Michael Ashikhmin, Simon Premoze &#8211; <a href="http://www.cs.utah.edu/~premoze/dbrdf/dBRDF.pdf">&#8220;Distribution-based BRDFs&#8221;</a>, 2007<br />
[EK17] Alejandro Conty Estevez, Christopher Kulla &#8211; <a href="http://blog.selfshadow.com/publications/s2017-shading-course/imageworks/s2017_pbs_imageworks_sheen.pdf">“Production Friendly Microfacet Sheen BRDF”</a>, SIGGRAPH 2017</p>
]]></html><thumbnail_url><![CDATA[https://knarkowicz.files.wordpress.com/2018/01/ashikhmin_charlie_compare.jpg?fit=440%2C330]]></thumbnail_url><thumbnail_width><![CDATA[440]]></thumbnail_width><thumbnail_height><![CDATA[208]]></thumbnail_height></oembed>