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

The previous article is here.

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

## Shading Model

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

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

where 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 . So we need two a. In contrast, if cloth contains no gap.

Each is defined by

※ This is BRDF, so is a hemisphere.

Where 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.

※ 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"

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

Where M depend on only . The reason is clear at Fig 13 in this paper.

※ 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 angle.

Next, why we use 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.

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

So, visibility is .

### 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.

But this assumption has well-known problem at e.g. 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.

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

Finally, we interpolate linearly to by "similarity between incident direction and outgoing direction ".

Where "similarity between incident direction and outgoing direction" is a unit-height gaussian function that taking as its argument

Where 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

## Reweighting

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

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 .

※ 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.

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

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

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

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

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 that is considering of radiance density variation. So I think it is a little bit overkill. But it has a difference that term depends on only , 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.

Where is . This is same idea to .

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

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

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

The outside box has a unit area (= 1) in this figure. And it separated by parameters . 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 added into shading model scale the each area. So we must normalize by division by a sum of scaled area. The right term support 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.

## 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.

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

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

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.

connecting to Vellum Solver for simulation.

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.

** it's easy!**

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

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

※ 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. )

These image by Table Ⅱ parameter in this paper.

### Linen Plain

Thread | A | (deg) | (deg) | 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

Thread | A | (deg) | (deg) | 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

Thread | A | (deg) | (deg) | 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)

Thread | A | (deg) | (deg) | 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

Thread | A | (deg) | (deg) | 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.

Thread | A | (deg) | (deg) | 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

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.

「近似」は物理でとっても大事にゃ♡鉛筆では絶対に解けない(と証明されてる)積分や方程式も極端な状況や本質的な部分に着目してそれ以外を無視する「近似」を入れると解けたりして、そしてそれでオッケーって事も多いのっ 何を重要とみなすかはその時々、物理屋の実力が問われるにゃ＞＜ →

— 物理学科に入学した凛ちゃんbot (@RinPhysBot) 2016年10月19日

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

※ 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"

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

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"