<div dir="ltr">I don&#39;t have a preference here. I am not that familiar with the code base. So I am ok with anything as long as it produces correct results. I am going to try out this extra output only because it would not break any existing shaders and it feels like it could be done easily and would allow for very robust material control.<div>
It might not work, but at least I will have a better understanding of what&#39;s going on there. Mix and Add things do something sketchy in the compiler, wondering is it will work with that.<br><div><br></div><div style>Fresnel handling has to be fixed for sure. Just looked at OSL glass yesterday and it wrong as well (uses average normal).</div>
<div style><br></div><div style>The bottom like is to create a separate BSDF that will handle all those things consistently. What you really define is a layer, it&#39;s thickness, absorption coefficients (color), IOR ramp (it might be dielectric or metal), normal distribution. And then, like in that paper, you just have an extra node that would do the layering. So light hits the top layer, reflects, then refracts from the same normal, passes thru the layer and gives you transmitted component. Then you can plug it into a different layer node and so on.</div>
<div style><br></div><div style>Current mixing and adding closures is only good think layer blending and for general material mixing, like when you want to get a more complex distribution. But you have to respect microfacet normals or else it&#39;s going to break.</div>
<div style><br></div><div style>- Dmitry</div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 31, 2013 at 5:01 AM, storm <span dir="ltr">&lt;<a href="mailto:kartochka22@yandex.ru" target="_blank">kartochka22@yandex.ru</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Very interesting paper, thanks. What is your preference to implement<br>
that, another BSDF output &quot;Microfacet facing&quot;? Make it as ShaderData<br>
member, expose in BSDF nodes GUI, and allow general (not only mix/other<br>
bsdf) connect to them ? It will require to respect that in every other<br>
BSDF as additional &quot;hidden&quot; mix ?<br>
<br>
<br>
<br><br>---------- Forwarded message ----------<br>From: Dmitry Andreev &lt;<a href="mailto:andcoder@gmail.com">andcoder@gmail.com</a>&gt;<br>To: <a href="mailto:bf-cycles@blender.org">bf-cycles@blender.org</a><br>Cc: <br>
Date: Fri, 31 May 2013 04:26:24 -0700<br>Subject: Re: [Bf-cycles] Cycles and Fresnel<br><div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">&gt;Probably it makes sense to include the fresnel in the Glossy BSDF node</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">&gt;itself yes, if it needs to depend on the specific BSDF normal.</span><br>
<div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">That&#39;s an option. Though I think it&#39;s a common issue for Refraction and Glass BSDFs. Anisotropic Ward BSDF doesn&#39;t even have fresnel term in theory that causes other issues.</span></div>

<div><br></div><div>For layering (in a long term I think) it would be nice to have this “Arbitrarily LayeredMicro-Facet Surfaces” by Weidlich and Wilkie. <a href="http://www.cg.tuwien.ac.at/research/publications/2007/weidlich_2007_almfs/weidlich_2007_almfs-paper.pdf" target="_blank">http://www.cg.tuwien.ac.at/research/publications/2007/weidlich_2007_almfs/weidlich_2007_almfs-paper.pdf</a></div>

<div>Generalized coating that also has to work with proper microfacet normals. Mixing or Adding shaders can&#39;t do that. I think of those are really interleaving different materials in the same layer on micro level.<br>

</div><div><br></div><div>One way, I guess, to make layering work currently is to output Fresnel component from BSDF nodes themselves and then you it for Mixing when needed. Generally speaking you can&#39;t do stuff like mix( diffuse, specular, fresnel ). Yes, it guarantees that the energy is conserved, but it&#39;s too conservative. For plastics, for instance, one would do things like diffuse * Fresnel( at normal angle ) + specular * Fresnel( half angle ).</div>

<div>Ashikhmin Shirley while using Fresnel( half angle ) for specular modifies diffuse in a different way which also doesn&#39;t always work. Not for all materials.<br></div><div><br></div><div>It looks to me that there is no good generalized solution for that. So it&#39;s up to an artist, which is ok.</div>

<div><br></div><div>So BSDFs output F and anyone can use it for mixing/weighting if they want to.</div><div>Then the second question is how to handle metals there. Metals are colored at normal incidence and then get darker at some point and then get desaturated at 90 degrees.</div>

<div>It could be a separate BSDF with more parameters just for metals.</div><div>Or if instead of Fresnel they output partial Fresnel like pow( 1 - dot( n, h ), 5 ) or just simple microfacet facing (dot(n, h), then for dielectrics you would plug it first into MixRGB node with Color1=0.04 and Color2=1 which would correspond to IOR 1.5 and then you plug it into Mix Shader node.</div>

<div>For metals you would plug that value into ColorRamp and get the desired effect there so you could do really advanced metals with spectral curves. That would require modification to Mix Shader node so it could mix channels separately but it already does it internally with Weight and SetWeight operations (in SVM).</div>

<div>Then you can do really advanced artistic stuff along with realistic things. You can take n,k data and convert them into ramps like this:... (I attached examples of what you can generate from n,k data for aluminum, chromium, copper, gold, nikel). You can represent any metal like that.</div>

<div><br></div><div>Of course very few people would figure how to use it. But with some tutorial one could do a lot of fun cool.</div><div><br></div><div>Some render engines only give you IOR, or IOR + color of normal reflectance, or raw n,k data. But all of them are hard to control. Especially with n,k data. Most or real world metals are alloys and covered with oxides but ramps like that would give you more artistic control while being plausible.</div>

<div><br></div><div>Anyway, that&#39;s just an idea.</div><div><br></div><div>Alternatively, BSDFs might take another BSDF as an input that they cover, and then handle all that stuff inside.</div><div>
<br></div><div>Sorry for throwing so much stuff in here. I guess I&#39;ll think more about it over the weekend and maybe try this extra BSDF output thing.</div><div class="gmail_extra"><br></div><div class="gmail_extra">

- Dmitry<br><br><div class="gmail_quote">On Thu, May 30, 2013 at 6:17 PM, Brecht Van Lommel <span dir="ltr">&lt;<a href="mailto:brechtvanlommel@pandora.be" target="_blank">brechtvanlommel@pandora.be</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Dmitry,<br>
<div><br>
On Fri, May 31, 2013 at 12:43 AM, Dmitry Andreev &lt;<a href="mailto:andcoder@gmail.com" target="_blank">andcoder@gmail.com</a>&gt; wrote:<br>
&gt; I have local changes only for Glossy BSDF with GGX distribution but would<br>
&gt; like to generalize it to everything. The question is how to do it best<br>
&gt; within Cycles kernels and SVM (without side effects) ?<br>
&gt;<br>
&gt; I have/had a few ideas of how to do it best but some of them had side<br>
&gt; effects. The one that I am thinking of right now is that everything has<br>
&gt; basic IOR input, but you could plug a special advanced Fresnel node into it<br>
&gt; that would be evaluated withing closures themselves. That advanced node<br>
&gt; could have multiple options: 1. simple dielectric IOR, 2. spectral n,k data<br>
&gt; that could be pre-integrated into LUTs using standard CIE illuminant and<br>
&gt; standard CIE observer. It would look something similar to ColorRamp node.<br>
&gt; And add some presets there that could be easily generated from n,k<br>
&gt; databases.<br>
<br>
</div>Probably it makes sense to include the fresnel in the Glossy BSDF node<br>
itself yes, if it needs to depend on the specific BSDF normal.<br>
<div><br>
&gt; Another idea was to have closures leave something on stack like microfacet<br>
&gt; normal. So by default it would be average geometry/pixel normal, but it<br>
&gt; closure is microfacet based it would override that with H vector. Then<br>
&gt; Fresnel node that is connected to its output will use that. But this would<br>
&gt; not work with all the mixing and other stuff unless you plug that Fresnel<br>
&gt; node directly after the BSDF.<br>
<br>
</div>I don&#39;t think this woud work, node should be self contained and only<br>
pass data forward through node links.<br>
<br>
When we put the fresnel in the BSDF node, the main issue is how you<br>
mix / layer such BSDF&#39;s. I haven&#39;t figured out a design yet for more<br>
advanced layering of BSDF&#39;s. Maybe the BSDF node needs to output some<br>
mix / layer weight, or we need a new Layer Shader node, or something<br>
else entirely? What would need to be done is look at some layered BSDF<br>
models, write down the equations and figure out how we can split that<br>
in composable nodes.<br>
<br>
I&#39;m not familiar enough yet with this stuff to give good advice, would<br>
need to do a lot more reading and thinking for that. The design would<br>
have to fit in the OSL closure model, where the result of a shader<br>
evaluation is a linear combination of closures. If a linear<br>
combination is not possible then a special layering closure could be<br>
created too, which takes other closures as parameters but I&#39;m not sure<br>
if this will be needed.<br>
<br>
Brecht.<br>
_______________________________________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org" target="_blank">Bf-cycles@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-cycles" target="_blank">http://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
</blockquote></div><br></div></div>
<br>_______________________________________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-cycles" target="_blank">http://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
<br>_______________________________________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-cycles" target="_blank">http://lists.blender.org/mailman/listinfo/bf-cycles</a><br>
<br></blockquote></div><br></div>