Octane利用OSL创建贴图混合节点

digest [复制链接]
查看1973 | 回复2 | 2019-12-22 17:58 | 显示全部楼层 |阅读模式
个人很喜欢RS的Color Layer节点,因为那样混合贴图非常方便。而OC默认最多只能混合2张贴图,碰巧看到GSG的材质预设,就把这段代码拿了出来。虽然只有4种混合模式,不过OC终于可以同时混合多个贴图了。

新建一个OSL节点,并把一下代码复制替换进去
color comp(color a, color b, float m, int t)
{
    color c=0;
    if(t==0) c=mix(a,b,m);
    else if(t==1) c=a*(mix(1,b,m));
    else if(t==2) c=a+(mix(0,b,m));
    else if(t==3) c=a+(mix(0,b,m));
    else if(t==4) c=a-(mix(0,b,m));

    return c;
}

shader Add( 
    color tex1 = 0,

    float amout2 = 0.5[[float min=0, float max=1]],
    int mode2=0 [[string widget = "mapper", string options = "mix:0|multiply:1|add:2|sub:3"]],
    color tex2 = 0,

    float amout3 = 0.0[[float min=0, float max=1]],
    int mode3=0 [[string widget = "mapper", string options = "mix:0|multiply:1|add:2|sub:3"]],
    color tex3 = 0,

    float amout4 = 0.0[[float min=0, float max=1]],
    int mode4=0 [[string widget = "mapper", string options = "mix:0|multiply:1|add:2|sub:3"]],
    color tex4 = 0,

    float amout5 = 0.0[[float min=0, float max=1]],
    int mode5=0 [[string widget = "mapper", string options = "mix:0|multiply:1|add:2|sub:3"]],
    color tex5 = 0,

    output color out = 0)
{

    out = comp(tex1,tex2,amout2,mode2);
    if(amout3>0) out = comp(out,tex3,amout3,mode3);
    if(amout4>0) out = comp(out,tex4,amout4,mode4);
    if(amout5>0) out = comp(out,tex5,amout5,mode5);

}

点击Compile按钮,然后控制面板就显示出来了

7029-02.png

最近访客

  • 凡羽
    2023-04-30
  • 布丁薛
    2022-11-17
  • c4d_845a506413
    2022-11-15
  • sleepycyborg
    2022-03-03
  • 九月萤
    2022-02-22
  • 行走距离
    2021-11-04
  • 安东
    2021-07-19
  • Sorrow丶星期八
    2021-05-31
  • 最佳新秀
    2021-04-06
回复 呼我投币

使用道具 举报

sumi | 2020-4-9 15:07 | 显示全部楼层
陆吾先生 发表于 2020-4-9 14:23
可是为啥链接上年材质漫射没效果

可能是amout数值,默认是0,你需要调高
点评回复 呼我投币

使用道具 举报

陆吾先生 | 2020-4-9 14:23 | 显示全部楼层
可是为啥链接上年材质漫射没效果
点评回复 呼我投币

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

最近参与
19年第1期周练

67

主题

523 小时

在线时间

5万

C币

管理3级

Rank: 7Rank: 7Rank: 7

积分
59316
所在小组
A组
我的组号
18
注册时间
2019-10-24

2020年周练成员推荐周练成员2019年周练成员专栏分享作者