博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
OSL
阅读量:6590 次
发布时间:2019-06-24

本文共 4205 字,大约阅读时间需要 14 分钟。

1,SimpleColorShader:

 

shader gamma(color cin = color(0,0,0),output color Cout=color(0,0,0)){    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.14make -j 56make install#如果编译错误:cp /etc/ld.so.conf /opt/glibc-2.14/etc/

 

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

#!/usr/bin/env bashGLIB_LIB_PATH=/opt/glibc-2.14/libKTOA_ROOT=/opt/solidangle/KtoA-2.2.0.2-kat3.0-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(0,0,0)[[string help="InputColor",float min = 0, float max = 1]],output color Cout=color(0,0,0)){    Cout = cin;}

 

3,Diffuse with noise

#include 
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 
shader GOSL_Metal( color diffuse_color = color(0.6, 0.8, 0.6), output closure color bsdf =0){ bsdf = diffuse_color * reflection(N);}

 

diffuse(N):

 5,Depth Color Channel:

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

 

 6,Noise shader:

#include 
/*Coding Time:2018/9/10liuyangping207@qq.com*/vector getNoise(vector inputPos,float amp,vector offset,vector freq,int turbulence, float rough){ vector fp = 0; vector sum=0; vector sample_p = (inputPos + offset) * freq; float contrib = 1; for(int i=0;i

 

7,metadata in katana

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

 8,Bounding obj color:

#include 
/*Coding Time:2018/9/10liuyangping207@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=0 ){ point Po = transform("object", P); point rbound[2]; getattribute("geom:objbounds", rbound); point pmin = rbound[0]; point pmax = rbound[1]; float bx = fit(Po[0],pmin[0],pmax[0],0,1); float by = fit(Po[1],pmin[1],pmax[1],0,1); float bz = fit(Po[2],pmin[2],pmax[2],0,1); cout = color(bx,by,bz);}
View Code

 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

 

转载于:https://www.cnblogs.com/gearslogy/p/9759302.html

你可能感兴趣的文章
SharePoint 2013 error The given assembly name or codebase System.ServiceModel.dll was invalid
查看>>
第四章:Django 的模板系统(转)
查看>>
What is corresponding Cron expression to fire in every X seconds, where X > 60? --转载
查看>>
线性同余方程模板( A+C*x=B(mod D) )
查看>>
OpenCV Open Camera 打开摄像头
查看>>
2015第49周三
查看>>
CentOS6.5下安装MySQL
查看>>
7.5 数据注解特性--MaxLength&&MinLength
查看>>
企业日志分析 五大问题需重点注意
查看>>
《Android群英传》读书笔记 (5) 第十一章 搭建云端服务器 + 第十二章 Android 5.X新特性详解 + 第十三章 Android实例提高...
查看>>
MyBatis学习总结(五)——实现关联表查询
查看>>
SQLite介绍、学习笔记、性能测试
查看>>
【.NET深呼吸】基础:自定义类型转换
查看>>
java继承2——类与继承(转)
查看>>
【转载】Eclipse 的快捷键以及文档注释、多行注释的快捷键
查看>>
Android开发之IP拨号器原理
查看>>
HDU3537-Daizhenyang&#39;s Coin(博弈SG-打表)
查看>>
Android Studio快捷键每日一练(3)
查看>>
LINUX CACHE IO THREAD
查看>>
Android开发之MediaPlayer和SurfaceView组成视频播放器
查看>>