MaxScript 例子 渲染
MaxScript 渲染的例子
macroScript NewTextureRender category:"WJL"
(
--烘焙函数
fn BakeDiffuseAndLighting obj size =
(
--清空所有渲染元素
obj.iNodeBakeProperties.removeAllBakeElements()
--准备烘焙元素
be1 = diffusemap()
be1.outputSzX = be1.outputSzY = size --set the size of the baked map
be1.fileType = (getDir #image+"\\"+obj.name+"_diffuse.tga")
be1.fileName = filenameFromPath be1.fileType
be1.filterOn = true --enable filtering
be1.shadowsOn = false --disable shadows
be1.lightingOn = false --disable lighting
be1.enabled = true --enable baking
be2 = LightingMap() -- 实例灯光烘焙元素
be2.outputSzX = be2.outputSzY = size --set the size of the baked map
be2.fileType = (getDir #image+"\\"+obj.name+"_lighting.tga")
be2.fileName = filenameFromPath be2.fileType
be2.filterOn = true --enable filtering
be2.shadowsOn =true --enable shadows
be2.enabled = true --enable baking
--准备烘焙
obj.INodeBakeProperties.addBakeElement be1 --add first element
obj.INodeBakeProperties.addBakeElement be2 --add second element
obj.INodeBakeProperties.bakeEnabled = true --enabling baking
obj.INodeBakeProperties.bakeChannel = 1 --channel to bake
obj.INodeBakeProperties.nDilations = 1 --expand the texture a bit
--烘焙选中项,所以选中obj
select obj
--调用渲染烘焙
render rendertype:#bakeSelected vfb:off progressBar:true outputSize:[size,size]
--创建一个复合纹理
theComp = CompositeTextureMap()
theComp.add() --添加第二个层
theComp.blendMode = #(0,5) --设置层位模式 5:Multiply
--创建两个纹理,一个拥有diffuse,另一个用于lighting 纹理
theMap1 = bitmaptexture filename:be1.fileType
theMap2 = bitmaptexture filename:be2.fileType
--复合两个纹理
theComp.mapList = #(theMap1, theMap2)
--设置灯光纹理为70%的透明度
theComp.opacity = #(100,70)
--创建一个标准的纹理,并设置diffuseMap为 theComp,纹理光照强度为100
bakedMat = standard diffusemap:theComp selfIllumAmount:100
--创建一个Shell_Material纹理并赋值给obj
obj.material = Shell_Material originalMaterial:obj.material \
bakedMaterial:bakedMat viewportMtlIndex:1 renderMtlIndex:1
--显示烘焙纹理到视口中
showTextureMap obj.material obj.material.bakedMaterial true
)--end fn
--重置场景
resetMaxFile #noprompt
--创建灯光
theLight = omniLight pos:[0,-60,100] rgb:white
theLight.baseobject.castshadows = true
--创建一个纹理球
theObject = Sphere segs:32 mapcoords:true pos:[0,0,25]
--创建一个网格纹理
theMap = cellular cellColor:blue divColor1:red divColor2:yellow size:15
theObject.material = standard diffusemap:theMap
--调用烘焙函数
BakeDiffuseAndLighting theObject 256
--创建一个带有纹理的平面对象
theObject = Plane width:200 length:200 mapcoords:true
--创建一个 checker map ,设置 tiling 为 4x4
theMap = checker Color1:green Color2:orange
theMap.coordinates.uTiling = theMap.coordinates.vTiling = 4
theObject.material = standard diffusemap:theMap
--调用烘焙函数
BakeDiffuseAndLighting theObject 256
delete theLight
max select none
)
效果图:
MaxScript 例子 渲染相关推荐
- Maxscript中渲染中文版Vray完成贴图(VrayCompleteMap)的方法
Objbakeproperties = $.INodeBakeProperties; --选定对象的烘培节点 Prjbakeproperties = $.INodeBakeProjProperties ...
- Opengl入门基础-shader着色器画方形并且填颜色
文章目录 一.目的 二.结果 三.详细过程 下载 一.目的 opengl shader画方形并且填颜色 二.结果 成功画方形并用shader填充彩色 三.详细过程 https://blog.csdn. ...
- 图片压缩的正确打开方式
图片压缩的正确打开方式 图像通常占据了页面大小的绝大部分,并且占据的绝大部分视觉空间.因此,优化图片通常会节省大量字节数和提升性能:浏览器下载的字节数越少,客户端带宽的争抢越少,浏览器的下载和屏幕加载 ...
- Windows下编译Mitsuba 3
1. 获取源码 打开cmd,打开(cd)要放置Mitsuba3的文件夹,从Mitsuba 3的github仓库上将其拉到本地,执行: git clone --recursive https://git ...
- DirectX 3D灯光和材质
前面所介绍的东西都假设模型有自己的颜色,即认为模型自己发光.其实自然界的大部分物体并不发光.当光线照射到物体上,物体吸收某些颜色的光,反射另一些颜色的光,反射的光的颜色就是我们所看到的物体的颜色.这里 ...
- 模板引擎art-template的介绍
一 简介 art-template: 下载地址:https://github.com/aui/art-template 通常所说的渲染分为: //1. 浏览器端渲染//对应 template-web. ...
- layui循环数据并渲染_layui使用表格渲染获取行数据的例子
需求:使用前端框架layui生成表格,点击表格中一行数据中的按钮,获取到这行数据. 解决办法: 在render中增加字段: done: function (res, curr, count) { // ...
- Unity GeometryShader(从一个线框渲染的例子开始)
GeometryShader这个概念,已经出现很久了,但由于性能不佳,所以使用的并不多.甚至移动平台根本就不支持.移动平台的硬件更新速度也是越来越快,GS的应用普及应该不会太远.就现阶段而言,GS来做 ...
- [react] 写个例子说明什么是JSX的内联条件渲染
[react] 写个例子说明什么是JSX的内联条件渲染 ifTrue ? <ComA /> : <ComB>ifTrue && <ComC/> 个人 ...
- 一个vue请求接口渲染页面的例子
new Vue({el:'#bodylist',data: {list: [{"type_id": "1","type_name": &qu ...
最新文章
- 当支持向量机遇上神经网络......
- css3 混合,瞧瞧CSS3的混合模式
- 计算机外观类型,知道你的笔记本电脑是什么类型的吗?五大类型派对号入座
- C++学习笔记6:多文件编程
- java struts1_struts1.x
- 打开d盘由于这台计算机的限制,又出现限制我想打开D盘、E盘,就是打不开,电脑提示:限制本 爱问知识人...
- 查找(四)-------基于B树的查找和所谓的B树
- iframe在ios设备宽度不能100%
- Xib中用自动布局设置UIScrollView的ContenSize
- elasticsearch索引模块缓存
- matlab 傅里叶变换 频谱图,傅里叶变换与信号频谱图.PDF
- python可以手眼定标吗_机器人无标定手眼协调
- 达梦数据库大小写这个参数敏感怎样设置
- 和ChatGPT的一番对话
- 每日一练-10-求矩阵主对角线及副对角线元素的和
- Dubbo (五) ---------监控中心
- incremental backups
- python输入一个小数,提取整数部分
- input光标位置设置至行末端
- 避免重要数据泄露的8种方式