OSL
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的更多相关文章
- Major OSL changes to catch up
flat_map optimization for runtime specialization: https://github.com/imageworks/OpenShadingLanguage/ ...
- hibernate入门案例
最近准备学ssh,今天学了一下hibernate,用的是hibernate4,现在已经出5了:配置文件很容易写错,写配置文件的时候尽量复制. 需要的jar包如下:(jar包我是直接放在项目工程里面了, ...
- 在Linux环境下,将Solr部署到tomcat7中,导入Mysql数据库数据, 定时更新索引
什么是solr solr是基于Lucene的全文搜索服务器,对Lucene进行了扩展优化. 准备工作 首先,去下载以下软件包: JDK8:jdk-8u60-linux-x64.tar.gz TOMCA ...
- SQL Server 2008 R2——CROSS APPLY 根据数据出现的次数和时间来给新字段赋值
=================================版权声明================================= 版权声明:原创文章 禁止转载 请通过右侧公告中的“联系邮 ...
- BOOST.Asio——Tutorial
=================================版权声明================================= 版权声明:原创文章 谢绝转载 啥说的,鄙视那些无视版权随 ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- c++程序员必知的几个库
c++程序员必知的几个库 1.C++各大有名库的介绍——C++标准库 2.C++各大有名库的介绍——准标准库Boost 3.C++各大有名库的介绍——GUI 4.C++各大有名库的介绍——网络通信 5 ...
- Servlet高级
1. 获取初始化参数 在web.xml中配置Servlet时,可以配置一些初始化参数.而在Servlet中可以通过ServletConfig接口提供的方法来取得这些参数. index.jsp < ...
- OAF_文件系列10_实现OAF将数据资料导出Excel到本地JXL(案例)
20150729 Created By BaoXinjian
随机推荐
- 清除 x-code 缓存
https://www.jianshu.com/p/5673d8333544 之前由于经费不足,购置的128的mac,现在发现一不注意盘就满了,悔之晚矣...a).清除 x-code CoreSimu ...
- clipboardjs复制到粘贴板
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat=&qu ...
- Making every developer more productive with Visual Studio 2019
Today, in the Microsoft Connect(); 2018 keynote, Scott Guthrie announced the availability of Visual ...
- leanote使用本地账户+坚果云同步
1. 换机器后笔记无法显示 这是因为新建账户与原账户userid不一致. 正确的同步方式为: 下载leanote并解压,不运行,不新建账户 从坚果云同步leanote数据 创建leanote的数据目录 ...
- LVS负载均衡DR模式实现
LVS负载均衡之DR模式配置 DR 模式架构图: 操作步骤 实验环境准备:(centos7平台) 所有服务器上配置 # systemctl stop firewalld //关闭防火墙 # sed - ...
- winform项目导入数据
一.点击导入按钮,弹出文件选择框 这个方法的使用要引用下面两个命名空间: using System.Windows.Forms;using DevExpress.XtraEditors; privat ...
- localhost 和 127.0.0.1 认识
概念和工作原理 1.概念: localhost:也叫local ,正确的解释是:本地服务器 127.0.0.1:在windows等系统的正确解释是:本机地址(本机服务器) 2.工作原理 localho ...
- python图形用户
1)使用GUI 1.GUI:Graphical user interface 2.tkinter:GUI libary for Python自带的库 3.GUI:Example 2)Ubuntu18. ...
- Java基础 -- Collection和Iterator接口的实现
Collection是描述所有序列容器(集合)共性的根接口,它可能被认为是一个“附属接口”,即因为要表示其他若干个接口的共性而出现的接口.另外,java.util.AbstractCollection ...
- 20175206迭代与JDB测试
迭代与JDB测试 C(n,m)组合数的判定 实验要求 1 使用C(n,m)=C(n-1,m-1)+C(n-1,m)公式进行递归编程实现求组合数C(m,n)的功能 2 m,n 要通过命令行传入 实验案例 ...