OCTANE-OSL 随机UV

XTT2019-05-05 15:48:02CG世界1912

QQ截图20190505154750.png

贴出····

工程:https://t.co/wAtR3qXSdw       

OSL:https://t.co/oXuC4CYMbN

本地:

shader OSL_UV_Randomizer(

/* Random U */

  float U_Offset_From = -1
  [[string label = "U_Offset_From",
  float min=-10, float max=10]],
  float U_Offset_To = 1
  [[string label = "U_Offset_To",
  float min=-10, float max=10]],

  color RND_U = 0
  [[string label = "RND_U_Coord",
  float min=0, float max=1]],


/* Random V */

  float V_Offset_From = -1
  [[string label = "V_Offset_From",
  float min=-10, float max=10]],
  float V_Offset_To = 1
  [[string label = "V_Offset_To",
  float min=-10, float max=10]],

  color RND_V = 0
  [[string label = "RND_V_Coord",
  float min=0, float max=1]],


/* Random Scale */

  float Scale_From = 0.5
  [[string label = "RND_Texture",
  float min=0, float max=10]],
  float Scale_To = 1
  [[string label = "Scale_To",
  float min=0, float max=10]],

  color RND_Scale = 0
  [[string label = "Scale_From",
  float min=0, float max=1]],


/* Random Rotation */

  float Angle_From = 0
  [[string label = "Angle_From",
  float min=-360, float max=360,
  float slidermin=0.0, float slidermax=360]],
  float Angle_To = 360
  [[string label = "Angle_To",
  float min=-360, float max=360,
  float slidermin=0, float slidermax=360]],

  color RND_Rotate = 0
  [[string label = "RND_Rotate",
  float min=0, float max=1]],

  output vector Out = 0
)

{
  float OffsetU = (RND_U[0]) / (1-0) * (U_Offset_To - U_Offset_From) + U_Offset_From;
  float OffsetV = (RND_V[0]) / (1-0) * (V_Offset_To - V_Offset_From) + V_Offset_From;
  float Scale = (RND_Scale[0]) / (1-0) * (Scale_To - Scale_From) + Scale_From;
  float RemapAngle = (RND_Rotate[0]*360) / (360-0) * (Angle_To - Angle_From) + Angle_From;
  point UVs = point(u, v, 0);
  vector axis0 = point(0.5,0.5,0);
  vector axis1 = point(0.5,0.5,1);
  float Angrmp = (RemapAngle);
  float rads = radians(Angrmp);
  point UVoffset = rotate(UVs, rads, axis0, axis1);
  point UVscale = point( (UVoffset[0] + OffsetU), (UVoffset[1] + OffsetV), 0);
  point UVout = vector( (UVscale[0] / Scale), (UVscale[1] / Scale), 0);
  Out = UVout;
}


扫描二维码推送至手机访问。

版权声明:本文由XTT的神秘根据地发布,如需转载请注明出处。

本文链接:http://xttgo.cc/post/60.html

分享给朋友: