1,SimpleColorShader:

shader gamma(color cin = color(,,),output color Cout=color(,,))
{
Cout = cin;
}

Katana启动时候会自动编译:

Arnold里bin文件夹里有oslc编译osl文件。但是在centos的GLIB不是2.14,所以单独运行不行。 但是在Katana启动调用时候为何自动编译,猜测是Arnold bin文件夹里已经把GLIB2.14一些符号编译成静态库了。

如果需要手动编译osl.编译GLIBC2.14.

编译glibc2.14 放到/opt/glibc-2.14

cd build
../configure --prefix=/opt/glibc-2.14 make -j
make install
#如果编译错误:
cp /etc/ld.so.conf /opt/glibc-2.14/etc/

再创建个bash文件调用GLIBC2.14,然后执行oslc,起名为:run_oslc

#!/usr/bin/env bash

GLIB_LIB_PATH=/opt/glibc-2.14/lib
KTOA_ROOT=/opt/solidangle/KtoA-2.2.0.2-kat3.-linux/
export LD_LIBRARY_PATH=${GLIB_LIB_PATH}:${LD_LIBRARY_PATH}
exec "${KTOA_ROOT}/bin/oslc" "$@"

则编译shader是:./run_oslc gamma.osl

Katana要加载osl shader 必须:export ARNOLD_PLUGIN_PATH=/mnt/Proj_Lighting/RD/katana3_plugin/Arnold/OSL_Shaders 要指定这个环境变量,

把shader放到这个里面,Katana会自动编译这些oslshader, 不用自己去手动编译

2,添加辅助信息 :

shader gamma[[ string help = "Simple mat" ]]
(color cin = color(,,)[[string help="InputColor",float min = , float max = ]],output color Cout=color(,,))
{
Cout = cin;
}

3,Diffuse with noise

#include <stdosl.h>

shader SimpleShader(
color diffuse_color = color(0.6, 0.8, 0.6),
float noise_factor = 0.5,
output closure color bsdf = diffuse(N))
{
color material_color = diffuse_color * mix(1.0, noise(P * 10.0), noise_factor);
bsdf = material_color * diffuse(N);
}

bsdf默认是个diffuse材质,下面只是乘以一些颜色

4,Metal Reflection

#include <stdosl.h>

shader GOSL_Metal(
color diffuse_color = color(0.6, 0.8, 0.6),
output closure color bsdf =)
{
bsdf = diffuse_color * reflection(N);
}

diffuse(N):

5,Depth Color Channel:

#include <stdosl.h>

shader GOSL_Metal(
float divide_value = ,
output color bsdf =[[float min=,float max=]])
{
point camera;
camera = transform("camera","world",point(,,));
bsdf = sqrt(dot(camera-P,camera-P))/divide_value; }

6,Noise shader:

#include <stdosl.h>

/*
Coding Time:2018/9/10
liuyangping207@qq.com
*/ vector getNoise(vector inputPos,float amp,vector offset,vector freq,int turbulence, float rough){
vector fp = ;
vector sum=;
vector sample_p = (inputPos + offset) * freq;
float contrib = ;
for(int i=;i<turbulence;i++)
{
vector ns = snoise(sample_p);
sum += ns*contrib;
sample_p *=2.6;
contrib *= rough;
}
fp += sum*amp;
return fp;
} shader GOSL_Metal(
vector inputPosition = ,
float amplitude = ,
float roughness = 0.55,
int turbulence = ,
vector offset = ,
vector frequency = ,
int useRestNoise = ,
output color bsdf =)
{
if(useRestNoise)
bsdf = getNoise(inputPosition,amplitude,offset,frequency,turbulence,roughness);
else{
bsdf = getNoise(P,amplitude,offset,frequency,turbulence,roughness);
} }

7,metadata in katana

#include <stdosl.h>

/*
Coding Time:2018/9/10
liuyangping207@qq.com
*/ #define OPTION_A 0
#define OPTION_B 1
#define OPTION_C 2 shader TestCode(
int booleanvalue = [[ string widget = "boolean" ]],
int enumvalue = [[ string widget = "popup", string options = "OptionA|OptionB|OptionC" ]],
output color cout=
)
{
if (booleanvalue)
cout=color(,,);
if (enumvalue == OPTION_B)
cout=color(,,);
}

8,Bounding obj color:

#include <stdosl.h>

/*
Coding Time:2018/9/10
liuyangping207@qq.com
*/ int zero_compare(float a ) {
return a >= -0.00001 && a <= 0.00001;
} float fit(float var, float omin, float omax, float nmin, float nmax) {
float d = omax - omin;
if (zero_compare(d)) {
return (nmin + nmax) * 0.5;
}
if (omin < omax) {
if (var < omin) return nmin;
if (var > omax) return nmax;
} else {
if (var < omax) return nmax;
if (var > omin) return nmin;
}
return nmin + (nmax - nmin) * (var - omin) / d;
} shader TestCode(
output color cout=
)
{ point Po = transform("object", P); point rbound[];
getattribute("geom:objbounds", rbound); point pmin = rbound[];
point pmax = rbound[]; float bx = fit(Po[],pmin[],pmax[],,);
float by = fit(Po[],pmin[],pmax[],,);
float bz = fit(Po[],pmin[],pmax[],,); cout = color(bx,by,bz);
}

9,Fake Caustic In Katana

新项目要用焦散. OSL这个时候快速派上用场。思维就是在灯光上用gobo投射UV Caustic, 顺便也做了个三维的,因为在三维就是x,y,z, uv的就是u,v,0

10,Gradient Voronoise

If F(x,y,z) =

WIKI Tell us :

So GradF will display this picture.

Display the Grad vector:

REF:

https://blog.csdn.net/clirus/article/details/62425498

https://answers.arnoldrenderer.com/questions/489/how-to-setup-osl-shader.html

http://thhube.github.io/tutorials/osl/osl.html

https://docs.arnoldrenderer.com/display/A5ARP/OSL+Shaders

https://blog.selfshadow.com/publications/s2012-shading-course/martinez/s2012_pbs_osl_notes_v3.pdf

OSL的更多相关文章

  1. Major OSL changes to catch up

    flat_map optimization for runtime specialization: https://github.com/imageworks/OpenShadingLanguage/ ...

  2. hibernate入门案例

    最近准备学ssh,今天学了一下hibernate,用的是hibernate4,现在已经出5了:配置文件很容易写错,写配置文件的时候尽量复制. 需要的jar包如下:(jar包我是直接放在项目工程里面了, ...

  3. 在Linux环境下,将Solr部署到tomcat7中,导入Mysql数据库数据, 定时更新索引

    什么是solr solr是基于Lucene的全文搜索服务器,对Lucene进行了扩展优化. 准备工作 首先,去下载以下软件包: JDK8:jdk-8u60-linux-x64.tar.gz TOMCA ...

  4. SQL Server 2008 R2——CROSS APPLY 根据数据出现的次数和时间来给新字段赋值

    =================================版权声明================================= 版权声明:原创文章 禁止转载  请通过右侧公告中的“联系邮 ...

  5. BOOST.Asio——Tutorial

    =================================版权声明================================= 版权声明:原创文章 谢绝转载  啥说的,鄙视那些无视版权随 ...

  6. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  7. c++程序员必知的几个库

    c++程序员必知的几个库 1.C++各大有名库的介绍——C++标准库 2.C++各大有名库的介绍——准标准库Boost 3.C++各大有名库的介绍——GUI 4.C++各大有名库的介绍——网络通信 5 ...

  8. Servlet高级

    1. 获取初始化参数 在web.xml中配置Servlet时,可以配置一些初始化参数.而在Servlet中可以通过ServletConfig接口提供的方法来取得这些参数. index.jsp < ...

  9. OAF_文件系列10_实现OAF将数据资料导出Excel到本地JXL(案例)

    20150729 Created By BaoXinjian

随机推荐

  1. 【算法】C语言趣味程序设计编程百例精解

    C语言趣味程序设计编程百例精解 C/C++语言经典.实用.趣味程序设计编程百例精解(1)  https://wenku.baidu.com/view/b9f683c08bd63186bcebbc3c. ...

  2. Tomcat7 JDK8 Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000540000000, 5368709120, 0) failed; error='Cannot allocate memory' (errno=12)

    [root@crm-web- bin]# shutdown.sh bash: shutdown.sh: command not found [root@crm-web- bin]# sh shutdo ...

  3. NodeJs操作MongoDB之多表查询($lookup)与常见问题

    NodeJs操作MongoDB之多表查询($lookup)与常见问题 一,方法介绍 aggregate()方法来对数据进行聚合操作.aggregate()方法的语法如下 1 aggregate(ope ...

  4. 'python'不是内部或外部命令,也不是可运行程序或批处理文件

    配置两个环境变量: 我的电脑——属性——高级系统设置——环境变量——用户变量——path(新建) 1.配置python\python.exe所在的路径       path新建:C:\Users\Py ...

  5. Win 10 Edge不能上网,微软商店打不开的问题

    微软商店(Microsoft Store)的 Code: 0x80072EE7 Check Your Connection问题,和Edge的Can't Reach this page的问题.网上找了很 ...

  6. 基于Vue cli生成的Vue项目的webpack4升级

    前面的话 本文将详细介绍从webpack3到webpack4的升级过程 概述 相比于webpack3,webpack4可以零配置运行,打包速度比之前提高了90%,可以直接到ES6的代码进行无用代码剔除 ...

  7. 【linux】Python3.6安装报错 configure: error: no acceptable C compiler found in $PATH

    安装python的时候出现如下的错误: [root@master ~]#./configure --prefix=/usr/local/python3.6 checking build system ...

  8. Codeforces Round #522 (Div. 2, based on Technocup 2019 Elimination Round 3) C. Playing Piano

    题意:给出一个数列 a1 a2......an  让你构造一个序列(该序列取值(1-5)) 如果a(i+1)>a(i) b(i+1)>b(i) 如果a(i+1)<a(i)  那么b( ...

  9. luogu4365 秘密袭击 (生成函数+线段树合并+拉格朗日插值)

    求所有可能联通块的第k大值的和,考虑枚举这个值: $ans=\sum\limits_{i=1}^{W}{i\sum\limits_{S}{[i是第K大]}}$ 设cnt[i]为连通块中值>=i的 ...

  10. 项目经理的“时间管理法则”(内含10G项目管理书籍)

    项目经理特别是大型项目的项目经理往往琐事缠身,好象每件事情都很重要都需要处理,如何在“百事缠身”的环境下,管理和充分利用好自己的时间,是困扰项目经理的一个大问题.有人会问,为什么我努力善用每分每秒,却 ...