This results in the effect that you can see through lace curtains quite well if they are more or less straight and you are viewing them head on but that it is impossible to see anything behind them if seen from a glancing angle. The effect is visible quite well on the part of the curtain in front of the blue cube. Even though there isn't much specular light on the rightmost fold in front of the blue cube, it still looks brighter.
Calculating occlusion
This behavior is reminiscent of fresnel reflection but the formula is a bit different. In the diagram below the threads of the fabric are approximated by black squares. In the gap between these squares a portion is obscured from view depending on the angle α between the surface normalN
and the incident ray I
. The ratio between the occluded portion (pink) and the side of the square is tan(α)
. From the diagram it can be seen that at a certain point α
is so large that the occluded portion is bigger than the gap is wide, rendering the surface effectively opaque. Code sample and node setup
The code implementing this setup is very short and straightforward:shader sheet_occlusion ( normal Normal=N, float Radius=0.05, output float Fac=1 ){ // calculate angle of incidence float alpha = acos(dot(I,Normal)); // treat front and back the same alpha = alpha > M_PI_2 ? M_PI - alpha : alpha; //printf("%.2f %.2f\n",alpha,tan(alpha)); // calculate the non occluded fraction Fac = 1 - Radius - Radius * tan(alpha); }The Fac output can be used to mix a fabric shader and a transparent shader as shown in the node setup below:
To get a pattern you could plug a black and white texture of real lace into the
Radius
socket.
No comments:
Post a Comment