如何给女孩的皮肤上色

如何给女孩的皮肤上色

我通常我今天能计划什么结果是:

一个女孩的表面情节

它基于以下数学函数米库斯泽夫斯基发表于mathematica.stackexchange.com

我在 TeX 中使用pgfplots以下方式实现它:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{
  width  = 7cm,
  compat = 1.14,
  /pgf/declare function = {
    bx(\a,\b,\c,\d,\e) = tanh(\d*(\a-\b)) + tanh(-1*\e*(\a-\c));
    ex(\x,\y,\z)       = exp(-1*(\x-\y)^2/\z);
    ra(\x,\y)          = 0.4*(1-0.4*ex(\x,0.8,0.15) + sin(2*pi*\y)^2
       + 0.6*ex(\x,0.8,0.25)*cos(2*pi*\y)^2
       + 0.3*cos(2*pi*\y))*0.5*(1+tanh(4*\x))
       + (1-0.2*ex(\x,-1.3,0.9))*0.5*(1+tanh(-4*\x))*(0.5*(1+sin(2*pi*\y)^2
       + 0.3*cos(2*pi*\y))*((abs(sin(2*pi*\y)))^1.3+0.08*(1+tanh(4*\x))))
       + 0.13*bx(cos(pi*\y),-0.45,0.45,5,5)*bx(\x,-0.5,0.2,4,2)
       - 0.1*bx(cos(pi*\y),-0.008,0.008,30,30)*bx(\x,-0.4,0.25,8,6)
       - 0.05*sin(pi*\y)^16*bx(\x,-0.55,-0.35,8,18);
  }
}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
      small,
      trig format plots = rad,% radian instead of deg
      grid              = major,% thin gray grid lines 
      z post scale      = 3,% scaling height
      samples           = 100,% use 20 for low res quicker compiling
      samples y         = 30,%  use 20 for low res quicker compiling
      z buffer          = sort,% sort according to depth of point
      zmax              = 2,
      colormap          = {skin}{rgb255=(255,105,180) rgb255=(255,240,245)},
      draw              = mapped color!95!black,% lighter mesh lines
      view              = {-45}{10},
      %view             = {45}{15},% different view
    ]
    \addplot3[
      surf,
      shader   = faceted interp,
      domain   = 0:1,
      domain y = -1.5:1.5,
    ] 
    ( { 0.1*exp(-1*(y-0.8)^2/0.6)-0.18*exp(-1*(y-0.1)^2/0.4) +
        ra(y,x)*cos(2*pi*x) },
      { ra(y,x)*sin(2*pi*x) },
      { y } );
  \end{axis}
\end{tikzpicture}
\end{document}

我想知道是否可以改进表面,例如使用更好的阴影(shader=interp看起来不太好),没有网格或像样的网格,其他补丁类型,不同的颜色图 - 你如何让这个女孩看起来很棒?

(PS:就在今天和明天(星期一),我的两本充满示例的书每本售价 5 美元,请参阅:博客文章。不过封面上没有裸女。)

答案1

使用interpx 方向颜色为线性的着色器,您可以获得有趣的照明。我还更改了颜色,使其具有古董雕塑的外观:

渲染

\documentclass[border=10pt]{standalone}
\usepackage[svgnames]{xcolor}
\usepackage{pgfplots}
\pgfplotsset{
  width  = 7cm,
  compat = 1.14,
  /pgf/declare function = {
    bx(\a,\b,\c,\d,\e) = tanh(\d*(\a-\b)) + tanh(-1*\e*(\a-\c));
    ex(\x,\y,\z)       = exp(-1*(\x-\y)^2/\z);
    ra(\x,\y)          = 0.4*(1-0.4*ex(\x,0.8,0.15) + sin(2*pi*\y)^2
       + 0.6*ex(\x,0.8,0.25)*cos(2*pi*\y)^2
       + 0.3*cos(2*pi*\y))*0.5*(1+tanh(4*\x))
       + (1-0.2*ex(\x,-1.3,0.9))*0.5*(1+tanh(-4*\x))*(0.5*(1+sin(2*pi*\y)^2
       + 0.3*cos(2*pi*\y))*((abs(sin(2*pi*\y)))^1.3+0.08*(1+tanh(4*\x))))
       + 0.13*bx(cos(pi*\y),-0.45,0.45,5,5)*bx(\x,-0.5,0.2,4,2)
       - 0.1*bx(cos(pi*\y),-0.008,0.008,30,30)*bx(\x,-0.4,0.25,8,6)
       - 0.05*sin(pi*\y)^16*bx(\x,-0.55,-0.35,8,18);
  }
}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
      small,
      trig format plots = rad,% radian instead of deg
      z post scale      = 3,% scaling height
      samples           = 100,% use 20 for low res quicker compiling
      samples y         = 30,%  use 20 for low res quicker compiling
      z buffer          = sort,% sort according to depth of point
      zmax              = 2,
      colormap          = {skin}{color=(AntiqueWhite) color=(AntiqueWhite!40!DimGrey)},
      view              = {-45}{10},
      %view             = {45}{15},% different view
    ]
    \addplot3[
      surf,
      shader   = interp,
      domain   = 0:1,
      domain y = -1.5:1.5,
      point meta={x},
    ] 
    ( { 0.1*exp(-1*(y-0.8)^2/0.6)-0.18*exp(-1*(y-0.1)^2/0.4) +
        ra(y,x)*cos(2*pi*x) },
      { ra(y,x)*sin(2*pi*x) },
      { y } );
  \end{axis}
\end{tikzpicture}
\end{document}

相关内容