maxscript创建穹顶灯

软件环境是3dsmax 2021版本,vray版本5,使用maxscript语言,创建一个穹顶灯并添加hdr文件到穹顶灯里,通过vray渲染;

目的是在户外环境模型中优化灯光渲染时间。

 3dsmax页面操作步骤:

 

 

 

renderers.current = VRay()
Teapot pos:[-20.5525,-14.0071,0] isSelected:on radius:26.7084
lig = VRayLight()
lig.type = 1  -- 设置灯光类型为1"dome"穹顶灯
lig.pos = [0,90,0]  -- 将穹顶光图标移动中心点位置
lig.multiplier = 1.0  -- 方法1:直接赋值
lig.size0 = 150
lig.size1 = 100
lig.enabled = true
lig.on = true
lig.texmap_on = true  -- 确保贴图启用
lig.texmap_locktodome = 1  -- 将纹理贴图锁定到穹顶灯,需要HDR环境贴图跟随穹顶灯旋转
select lig

texmap = VRayBitmap()
texmap.HDRIMapName = @"D:\3ds-item\baitian.hdr"
texmap.color_space = 1  -- 0=线性 1=伽马校正 2=自动
texmap.gamma = 1.0
texmap.maptype = 2  -- 穹顶灯通常使用球形映射来正确显示HDR环境贴图 2=Spherical
texmap.horizontalFlip = true  -- Flip horizont 
texmap.horizontalRotation = (-horizontal_rotation)  -- 水平旋转

lig.texmap = texmap
actionMan.executeAction 0 "50048"  -- Tools: 材质编辑器切换

  

 

过程中遇到问题:

1.开始绑定了贴图,但贴图仍然没有显示,是因为映射类型不正确。在V-Ray中,穹顶灯通常使用球形映射来正确显示HDR环境贴图,特别是当贴图需要环绕场景时。

-- 配置球形映射参数 12 vrayBmp.coords.mappingType = 1 -- 1=Spherical

 

posted @ 2025-05-07 18:44  chengdex  阅读(13)  评论(0)    收藏  举报