[Soc-2018-dev] Weekly report #08 - Implementing a Hair Shader for Cycles

Brecht Van Lommel brechtvanlommel at gmail.com
Mon Jul 9 00:30:21 CEST 2018


Regarding the reference render charts, it's best to not include any text in
them, so that it can be translated to other languages. Any credits can then
also be put at the bottom of the page instead of repeated in each image.

It also would be good if the image were not square, it's better if they
have dimensions like 1024x256 so that more fits on a page, the entire
height of the curl is not really needed.


It did a deeper review of the principled hair shader code, here are my
notes.

We named undercoat incorrectly, it is the primary reflection roughness
which is not the same. I got confused because there two different effects
described in section 4.3 of the paper, and we only implement the first
part. I still don't like the Primary Reflection Roughness though. The
purpose of this is to simulate a shiny coat, so perhaps we can name it just
"Coat" that is (1 - primary_reflection_roughness) and defaults to 0.0.

I also would still like to see the Melanin become a slider in the 0..1
range, as we try to do for parameters in shaders whenever possible. I did
some tests and found this mapping to work pretty well, basically using a log()
to invert the exp() that will be applied to the absorption, and scaling the
melanin coefficients. Note this means Melanin becomes a PROP_FACTOR with
max 1.0.

/* Map melanin 0..inf to more perceptually linear 0..1. */
melanin_qty = -logf(fmaxf(1.0f - melanin_qty, 0.0001f));
...
/* Normalized absorption coefficients to 1.0. */
float3 melanin_sigma = eumelanin*make_float3(0.506f, 0.841f, 1.653f) +
pheomelanin*make_float3(0.343f, 0.733f, 1.924f);

And some smaller notes:
* Bug: the OSL shader is using the longitudinal roughness instead of the
azimuthal roughness for the reflectance to absorption mapping.
* Can this mapping be made into a separate function? Since it's used both
for tint and color would be nice not to duplicate code.
* The Random socket should use SOCK_HIDE_VALUE to make it clear the value
is ignored if nothing is connected.
* In the OSL shader, use lower_case_names for local variables, only the
parameters should use CamelCase.
* Before merging, any debug code like printf's, curve_center(), and other
commented out code should be removed.
* No need to store a random value in the PrincipledHairBSDF and have it as
a parameter in the OSL closure if we are not going to use it.
* As an optimization, variables needed for only one of the 3 color
parameterizations should be computed in the appropriate if/case instead of
before. So factor_random_color, pheomelanin, etc. should only be computed
for the Melanin parameterization.
* For the Color parametrization, can we set the default to a brown color
similar to the melanin one? Doesn't have to be an exact match, just
something better than white.
* Suggest to rename "Color Randomization" to "Random Color", sounds a
little less technical and to the point. Same for "Roughness Randomization".
* In nodes.h, rename "float melanin_concentration" to "float melanin" and
"float melanin_redness_ratio" to "float melanin_redness", these should
match the socket names.


On Fri, Jul 6, 2018 at 10:46 PM Leonardo E. Segovia <
leonardo.segovia at cs.uns.edu.ar> wrote:

> Week 8
>
> Hi everyone! This is my report for the present week.
> Objectives
>
> This week, I dealt with the objectives for Weeks 10 and 11:
>
>    - User documentation revision.
>    - Developer documentation revision.
>
> I got my desktop back from the tech on Wednesday, and yesterday I had a
> French test, so I could only resume work today.
> What's been done
>
>    - The usual merging commits from master (
>    rB7551a0389c5929ddf6feaeac3a203987907e1988
>    <http://developer.blender.org/rB7551a0389c5929ddf6feaeac3a203987907e1988>,
>    rBaedb148ed4dd47d5a8491e3de0a207cdd3701e30
>    <http://developer.blender.org/rBaedb148ed4dd47d5a8491e3de0a207cdd3701e30>
>    ).
>    - Same as above, but for the Blender manual (
>    7a6ae1b6d279cfbd58a05a598c36f6730b3c2bac
>    <https://github.com/amyspark/blender-manual/commit/7a6ae1b6d279cfbd58a05a598c36f6730b3c2bac>,
>    a248590db512159febfa1998fcb36bf0c548a0ae
>    <https://github.com/amyspark/blender-manual/commit/a248590db512159febfa1998fcb36bf0c548a0ae>
>    )
>    - The missing documentation for Python and RNA has been added, along
>    with extra cleanup (rB98357a85c8f024fcfc7dca01f43d60ab0f781d02
>    <http://developer.blender.org/rB98357a85c8f024fcfc7dca01f43d60ab0f781d02>
>    ).
>    - The first chart is now up, Melanin Redness (
>    b3cfbef5a40ef2beb8aa5043a3a42a072f17206f
>    <https://github.com/amyspark/blender-manual/commit/b3cfbef5a40ef2beb8aa5043a3a42a072f17206f>)
>
>       - This one was based on nirved's port of the Hair Curls scene.
>       - I reduced the curls and tweaked the camera a bit to get the extra
>       space needed for the text.
>
> Next up
>
>    - Finish the Roughnesses and Randomization charts
>    - Reference renders with the custom shader
>
> Questions
>
> I'd be grateful if you could review and post your opinions on the
> different charts. I'll be uploading them during the weekend, so that on
> Monday we can get reasonable reviews.
>
> --
> Lic. Leonardo E. Segovia
> Departamento de Ciencias e Ingeniería de la Computación
> Universidad Nacional del Sur
> San Andrés 800 - Campus Palihue, B8000 Bahía Blanca, Argentina
> --
> Soc-2018-dev mailing list
> Soc-2018-dev at blender.org
> https://lists.blender.org/mailman/listinfo/soc-2018-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/soc-2018-dev/attachments/20180709/a2d889a4/attachment.html>


More information about the Soc-2018-dev mailing list