A Practical Microcylinder Appearance Model for Cloth Rendering to implementation (2)

The previous article is here.

ushiostarfish.hatenablog.com

日本語でも良い方はこちらを ( If you like Japanese, please check this )

ushiostarfish.hatenablog.com

Shading Model

Like the following figure, this paper makes shading model from warp and weft that is orthogonal.

f:id:ushiostarfish:20181229174211p:plain

※Fig. 2 IMAN SADEGHI, OLEG BISKER, JOACHIM DE DEKEN, HENRIK WANN JENSEN, UC San Diego, "Practical Microcylinder Appearance Model for Cloth Rendering"

It shows that each thread has different areas. So the following radiance formulation uses this fact.

 
\displaystyle {
L_{ r }\left( \omega _{ r } \right) =a_{ 1 }L_{ r,1 }\left( \omega _{ r } \right) +a_{ 2 }L_{ r,2 }\left( \omega _{ r } \right) 
}

where  a_1, a_2 is simply parameters. If this is an interpolation, two a is unnecessary. But fig. 2 left picture shows there are cases that cloth contains some gap. In this case  a_1 + a_2 \lt 1. So we need two a. In contrast,  a_1 + a_2=1 if cloth contains no gap.

Each  L_{ r,j }\left( \omega _{ r } \right) is defined by

 
\displaystyle {
L_{ r,j }\left( \omega _{ r } \right) =\frac { 1 }{ N_{ j } } \sum _{ t }^{  }{ \int _{ \Omega  }^{  }{ L_{ i } } f_{ s }\left( t,\omega _{ i },\omega _{ r } \right) \cos { \theta _{ i }d\omega _{ i } }  } 
}

※ This is BRDF, so  \Omega is a hemisphere.

Where  N_{ j } is sample count of tangents because a thread is weaving at least one. We must evaluate each tangent contribution and the average is the final value.

f:id:ushiostarfish:20181229180255p:plain

※ Fig. 12, Polyester Satin Charmeuse fabric IMAN SADEGHI, OLEG BISKER, JOACHIM DE DEKEN, HENRIK WANN JENSEN, UC San Diego, "Practical Microcylinder Appearance Model for Cloth Rendering"

 f_{ s }\left( t,\omega _{ i },\omega _{ r } \right) is previous thread model.

There was no reference for how to concretely sample in the paper. In this time I decided to use the control point at Table II in the paper as the sample point. Although this may not be good, I got an image that has a good match with the rendered image of the paper. I think it is a possible stochastic unbiased evaluation, but I think it is not clear whether the final result will lead to better results.

Although the whole flow can be covered above, in this paper, two more adjustments are presented to make it closer to the measurement result. This is "Shadowing and Masking" and "Reweighting".

Shadowing and Masking

Shadowing, masking function must be chosen suitable this shading model that is based on orthogonal warp and weft. So it is defined by

 
\displaystyle {
M\left( t,\omega _{ r } \right) =max\left( \cos { \phi _{ r } } ,0 \right) \\ M\left( t,\omega _{ i } \right) =max\left( \cos { \phi _{ i } } ,0 \right) 
}

Where M depend on only  \phi _{ i }, \phi _{ r }. The reason is clear at Fig 13 in this paper.

f:id:ushiostarfish:20181229221524p:plain

※ Fig. 13, Center, Right Figure, Polyester Satin Charmeuse fabric IMAN SADEGHI, OLEG BISKER, JOACHIM DE DEKEN, HENRIK WANN JENSEN, UC San Diego, "Practical Microcylinder Appearance Model for Cloth Rendering"

In left-hand side, the thread isn't shadowed by other thread because the tilt direction is same to thread direction. But right-hand side, the thread can be shadowed by other thread. So, Shadowing, Masking use only  \phi angle.

Next, why we use  \cos { \phi _{ r } } in Shadowing, Masking ? This is because of a cylinder shadow. Please check following two cylinders in cylinder array. A white one cast a shadow on some of the gray one.

f:id:ushiostarfish:20190102161556p:plain

I'll show visibility in expression. These cylinder radius is 0.5.

f:id:ushiostarfish:20181229225827p:plain

So, visibility is  \cos { \phi }.

Correlations of Shadowing, Masking

If Shadowing, Masking are assumed that has no correlations, Shadowing & Masking is defined by the following formulation using a simple product.

 
\displaystyle {
M_{ no-correlation }\left( t,\omega _{ i },\omega _{ r } \right) =M\left( t,\omega _{ i } \right) M\left( t,\omega _{ r } \right) 
}

But this assumption has well-known problem at e.g.  \omega _{ i } = \omega _{ o } case. The visible area is exactly the same in this case, Masking both express surface visibility. Despite only on one side is enough to express the visibility, the product of the above formulation is overkill. This is a typical case that no-correlation assumption does not work well. Against this, a shadowing & masking combination method proposed at Michael Ashikhmin, Simon Premoze, Peter Shirley, "A Microfacet-based BRDF Generator" is chosen in this paper.

This idea is simple, we define the following expression as Shadowing & Masking function with strong correlation contrast to no correlation formulation.

 
\displaystyle {
M_{ correlation }\left( t,\omega _{ i },\omega _{ r } \right) =max\left( M\left( t,\omega _{ i } \right) ,M\left( t,\omega _{ r } \right)  \right) 
}

I think "Shadowing area contains Masking area" or "Masking area contains Shadowing area".

Finally, we interpolate linearly  M_{ no-correlation } to  M_{ correlation } by "similarity between incident direction and outgoing direction ".

 
\displaystyle {
M\left( t,\omega _{ i },\omega _{ r } \right) =\left( 1-u\left( \phi _{ d } \right)  \right) M\left( t,\omega _{ i } \right) M\left( t,\omega _{ r } \right) +u\left( \phi _{ d } \right) max\left( M\left( t,\omega _{ i } \right) ,M\left( t,\omega _{ r } \right)  \right) 
}

Where "similarity between incident direction and outgoing direction" is a unit-height gaussian function that taking  \phi _{ d } as its argument

 
\displaystyle {
u\left( \phi _{ d } \right) =\left( -\frac { \phi _{ d }^{ 2 } }{ 2\sigma ^{ 2 } }  \right) 
}

Where  \sigma is between 15 deg to 25 deg, I chose 20 deg for my implementation. However, it will not change so much when it is 15 degrees or 25 degrees.

And we can rewrite each shading model by

 
\displaystyle {
L_{ r,j }\left( \omega _{ r } \right) =\frac { 1 }{ N_{ j } } \sum _{ t }^{  }{ \int _{ \Omega  }^{  }{ L_{ i } } f_{ s }\left( t,\omega _{ i },\omega _{ r } \right) M\left( t,\omega _{ i },\omega _{ r } \right) \cos { \theta _{ i }d\omega _{ i } }  } 
}

Reweighting

Let's start with fig 13 in this paper for thinking of Reweighting.

f:id:ushiostarfish:20181230124255p:plain

※ Fig 13 Left IMAN SADEGHI, OLEG BISKER, JOACHIM DE DEKEN, HENRIK WANN JENSEN, UC San Diego, "Practical Microcylinder Appearance Model for Cloth Rendering"

It looks the blue thread at the center is strong and its edge (=grazing angle) is weak blue. Because an apparent length( projected length to view direction ) of a thread is shorter by tilting it. Conversely, the orange thread apparent length looks uniform in any position.

So apparent length depends on only  \psi.

※ I have another idea that the blue thread weakness variation is caused by the orange thread apparent density. But the orange thread apparent density depends on the projected length of the blue thread to view direction. So, it is equivalent.

We can imagine this phenomenon like this.

f:id:ushiostarfish:20181230134818p:plain

It looks like "distribution of visible normal" in microfacet theory.

 \psi is not exist in my "Coordinate System" section. It is shown at Fig 14 in this paper.

f:id:ushiostarfish:20181230125716p:plain

※ Fig 14 IMAN SADEGHI, OLEG BISKER, JOACHIM DE DEKEN, HENRIK WANN JENSEN, UC San Diego, "Practical Microcylinder Appearance Model for Cloth Rendering"

It is a clear definition. The angle is in plane of thread direction and cloth normal.

A apparent length is expressed by  \cos \psi . The new weight function is defined by

 
\displaystyle {
P\left( t,\omega _{ r } \right) =max\left( \cos { \psi _{ r } } ,0 \right) \\ P\left( t,\omega _{ i } \right) =max\left( \cos { \psi _{ i } } ,0 \right) 
}

Coincidentally it is the same formula as Shadowing, Masking. Why considering not only outgoing direction but also incident direction is that there is the same phenomenon when light receives at a thread. The final contribution increases as apparent length are longer because it can receive more light. However, LTE contains  \cos \theta_i that is considering of radiance density variation. So I think it is a little bit overkill. But it has a difference that  P term depends on only  \psi, so it may have different significance.

In the paper, because the idea is similar to Shadowing, Masking, the same definitions for incoming and outgoing is chosen.

 
\displaystyle {
P\left( t,\omega _{ i },\omega _{ r } \right) =\left( 1-u\left( \psi _{ d } \right)  \right) P\left( t,\omega _{ i } \right) P\left( t,\omega _{ r } \right) +u\left( \psi _{ d } \right) max\left( P\left( t,\omega _{ i } \right) ,P\left( t,\omega _{ r } \right)  \right) 
}

Where  \psi_d is  \psi_r - \psi_i . This is same idea to  \phi _d .

We can rewrite the shading model with adding new weighting function.

 
\displaystyle {
L_{ r,j }\left( \omega _{ r } \right) =\frac { 1 }{ Q } \frac { 1 }{ N_{ j } } \sum _{ t }^{  }{ \int _{ \Omega  }^{  }{ L_{ i } } f_{ s }\left( t,\omega _{ i },\omega _{ r } \right) M\left( t,\omega _{ i },\omega _{ r } \right) P\left( t,\omega _{ i },\omega _{ r } \right) \cos { \theta _{ i }d\omega _{ i } }  } 
}

There is normalize term  Q. It is because that  P cause energy scaling as A sum of  P weight is not 1. It different from Shadowing, Masking.  Q is

 
\displaystyle {
Q=\frac { a_{ 1 } }{ N_{ 1 } } \sum _{ t }^{  }{ P\left( t \right)  } +\frac { a_{ 2 } }{ N_{ 2 } } \sum _{ t }^{  }{ P\left( t \right)  } +\left( 1-a_{ 1 }-a_{ 2 } \right) a_{ 2 }\cdot n
}

It is a bit confusing. So I'll check each sample weight before adding Reweighting with the following figure.

f:id:ushiostarfish:20181230142635p:plain

The outside box has a unit area (= 1) in this figure. And it separated by parameters  a_1, a_2. Each thread has samples at least one, it is assigned a uniform weight in its thread. Where each weight is area assigned to sample.

We can regard that  P added into shading model scale the each area. So we must normalize by division by a sum of scaled area. The right term  \left( 1-a_{ 1 }-a_{ 2 } \right) a_{ 2 }\cdot n support  a_{ 1 } + a_{ 1 } \lt 1 case, it handle no-thread part using simply normal.

Implementation

My implantation is straightforward. I'll show this without embed by link because it is too long.

microcylindercloth · GitHub

material · GitHub

3d Model

I have prepared the shading model but It needs a 3d model for cloth. And I need to reproduce this paper rendering image, so I want to 3d model very close to the paper image. I heard Houdini 17 got new simulation module Vellum, so I'll try it.

※ Houdini17 have crashed sometime in My MSI laptop pc because of Nahimic. Houdini 17 crashing constantly - General Houdini Questions - od|forum And it has an initialization problem for OpenCL [Solved] OpenCL setup for 17? | Forums | SideFX. But this is maybe environment-dependent, so stop to talk about this problem.

Vellum is constraint-based solver highly inspired by Matthias Müller, Bruno Heidelberger, Marcus Hennix, John Ratcliff, "Position Based Dynamics". It is easy for example it can be completed only on "sop". So I'll introduce it.

Vellum

First, I make simple ground with Tube and Grid.

f:id:ushiostarfish:20181230150113p:plain

Next, I prepare cloth with appropriate density above the ground. it must be added uv by "uvflatten" for tangent vector calculation.

f:id:ushiostarfish:20181230150315p:plain

Next, I prepare constraint. There is cloth preset in houdini for a shortcut.

f:id:ushiostarfish:20181230150557p:plain

The stiffness at Bend can control difficulty in cloth bending. Since there are not so many parameters, if you don't like it, it is a good idea to modify the parameters. However, I heard from my friend who familiar with the simulation, "if it is possible, you should try experimenting with the cloth in hand" . There is a case you don't notice that approach is wrong with the only simulation.

We can check the constraint by connecting to null.

f:id:ushiostarfish:20181230151232p:plain

connecting to Vellum Solver for simulation.

f:id:ushiostarfish:20181230151406p:plain

We can tune friction with about "Forces/Friction/Static Threshold" parameters. If the constraints don't converge, I suggest increasing "Solver/Substeps".

Finally, Let's start the timeline.

f:id:ushiostarfish:20181230151738g:plain

it's easy!

I export obj at the appropriate frame by "File Cache" after "Smooth", "Subdivide" for adjustment.

f:id:ushiostarfish:20181230152009p:plain

The tangent vector can be prepared any method any timing but I precalculate it by "polyframe" in houdini.

f:id:ushiostarfish:20181230152645p:plain

※ This is vertex-based calculation. so I adjusted it the vector orthogonal in primitive.

That's all for preparation of 3d model.

Results

I used the following scene. (Actually, it arranged so as to approach the rendered image of the paper. )

f:id:ushiostarfish:20181230153241p:plain

These image by Table Ⅱ parameter in this paper.

Linen Plain

f:id:ushiostarfish:20181230154032p:plain

 \eta Thread A  k_d  \gamma_s (deg)  \gamma_v (deg)  a Tangent Offsets (deg)
1.46 Both (0.2, 0.8, 1.0) * 0.3 0.3 12 24 0.33 -25, 25

Silk Crepe de Chine

f:id:ushiostarfish:20181230154233p:plain

 \eta Thread A  k_d  \gamma_s (deg)  \gamma_v (deg)  a Tangent Offsets (deg)
1.345 Flat (1.0, 0.95, 0.05) * 0.12 0.2 5 10 0.75 -35, -35, 35, 35
1.345 Twist (1.0, 0.95, 0.05) * 0.16 0.3 18 32 0.25 0, 0

Polyester Satin Charmeuse

f:id:ushiostarfish:20181230154800p:plain

 \eta Thread A  k_d  \gamma_s (deg)  \gamma_v (deg)  a Tangent Offsets (deg)
1.539 Flat (1.0, 0.37, 0.3) * 0.035 0.1 2.5 5 0.9 -32, -32, -18, 0, 0 , 18, 32, 32
1.539 Twist (1.0, 0.37, 0.3) * 0.02 0.7 30 60 0.1 0, 0

Polyester Satin Charmeuse (Back-side)

f:id:ushiostarfish:20181230155451p:plain

 \eta Thread A  k_d  \gamma_s (deg)  \gamma_v (deg)  a Tangent Offsets (deg)
1.539 Flat (1.0, 0.37, 0.3) * 0.035 0.1 2.5 5 0.67 -30, -30, 30, 30, -5, -5, 5, 5
1.539 Twist (1.0, 0.37, 0.3) * 0.02 0.7 30 60 0.33 0, 0

Silk Shot

f:id:ushiostarfish:20181230155850p:plain

 \eta Thread A  k_d  \gamma_s (deg)  \gamma_v (deg)  a Tangent Offsets (deg)
1.345 Dir 1 (0.1, 1.0, 0.4) * 0.2 0.1 4 8 0.86 -25, -25, 25, 25
1.345 Dir2 (1.0, 0.0, 0.1) * 0.6 0.1 5 10 0.14 0, 0

Velvet

For some reason my Velvet did not match the result with the pictures of the papers. Perhaps it may be adjusting lighting and normals map to show the Siggraph logo.

f:id:ushiostarfish:20181230160224p:plain

 \eta Thread A  k_d  \gamma_s (deg)  \gamma_v (deg)  a Tangent Offsets (deg)
1.46 Dir 1 (0.05, 0.02, 0.0) * 0.3 0.1 6 12 0.5 -90, -50
1.46 Dir2 (0.05, 0.02, 0.0) * 0.3 0.1 6 12 0.5 -90, -55, 55, 90

Fig. 24 in the paper

f:id:ushiostarfish:20181230160515p:plain

I could reproduce these render image except Velvet.

Impressions and Conclusion

I implemented velvet shading at ray tracing camp 6 . but I would try because I was short of the survey. The implementation of "A Practical Microcylinder Appearance Model for Cloth Rendering" looks not so heavy for me. However, the source code example could not be obtained, so it took quite some time.

This method might not be a sophisticated method, or it might be difficult to say Mathematically well defined. But this method is using minimum formulation for matching to measurement data, although it is only Far Field, I feel a pretty real taste. I think the point of view of this paper is so great.

She says...

"approximate" is very important in Physics ♡. An integral, equation that can't be solved (Proofed) exist but if these take "approximate" that ignoring some part excluding the extreme conditions or essentials component, it could be solved, and it's often no problem. What it is treated as important depends on the circumstance, so this is a good time to show their skills. ><

※ にゃ=meow, (her favorite way of talking)

On the other hand, energy conservation problems and the cost of shaders still have many tasks, and in particular, I think that it is difficult to intuitively prepare the parameters of Tangent Offsets. In addition, we easy to see details of the cloth, so far-field rendering is important.

Cloth shading technology has many compatibilities to hair and fur shading so we can see a wide range of knowledge on the way. If you are interested in this field, it would be interesting to look it up.

Acknowledgment

In implementing, Mr. Henrik W. Jensen has answered some questions by e-mail and helped me to understand well. Thank you so much.

References

IMAN SADEGHI, OLEG BISKER, JOACHIM DE DEKEN, HENRIK WANN JENSEN, UC San Diego, "Practical Microcylinder Appearance Model for Cloth Rendering"

※ You can see their presentation video if you purchase at ACM Digital Library

Iman Sadeghi, "Controlling the Appearance of Specular Microstructures"

信州大学繊維学部, はじめて学ぶ繊維

Michael Ashikhmin, Simon Premoze, Peter Shirley, "A microfacet-based brdf generator"

Piti Irawan, "Appearance of Woven Cloth"

Wenzel Jakob, Adam Arbree, Jonathan T. Moon, Kavita Bala, Steve Marschner, "radiative transfer framework for rendering, materials with anisotropic structure"

Stephen R. Marschner, Henrik Wann Jensen, Mike Cammarano, "Light Scattering from Human Hair Fibers"

Eugene d’Eon, Guillaume Francois, Martin Hill, Joe Letteri, Jean-Marie Aubry, "An Energy-Conserving Hair Reflectance Model"

Bruce Walter, Stephen R. Marschner, Hongsong Li, Kenneth E. Torrance, "Microfacet Models for Refraction through Rough Surfaces"

Subrahmanyan Chandrasekhar, "Radiative Transfer"

Michael Ashikhmin, Simon Premoze, Peter Shirley, "A Microfacet-based BRDF Generator"

Matthias Müller, Bruno Heidelberger, Marcus Hennix, John Ratcliff, "Position Based Dynamics"