마야(Maya)는 3D 그래픽 작업을 수행하는 데 널리 사용되는 프로그램 중 하나입니다.
3D 프로젝트를 작업하면서 종종 조명을 설정해야 할 때가 있습니다.
이 글에서는 마야에서 V-Ray Dome Light와 Directional Light를 생성하고 설정하는 방법을 소개합니다.
1. V-Ray Dome Light 생성
V-Ray Dome Light는 환경 조명을 시뮬레이션하기 위해 사용됩니다.
아래 코드를 사용하여 V-Ray Dome Light를 생성하고 설정할 수 있습니다.
“HDRI 경로를 넣어주세요!” 부분에는 HDRI파일의 경로를 파일이름까지 넣어줘야 합니다.
import maya.cmds as cmds
# V-Ray Dome Light 생성
dome_light = cmds.createNode("VRayLightDomeShape")
cmds.setAttr(f"{dome_light}.intensityMult", 0.5)
cmds.setAttr(f"{dome_light}.useDomeTex", 1)
# 텍스쳐 노드 생성
dome_tex = cmds.shadingNode("file", asTexture=True)
cmds.setAttr(f"{dome_tex}.fileTextureName", "<strong>HDRI 경로를 넣어주세요!</strong>", type="string")
# 텍스쳐 노드를 V-Ray Dome Light에 연결
cmds.connectAttr(f"{dome_tex}.outColor", f"{dome_light}.domeTex")
# V-Ray Dome Light를 Invisible로 설정
cmds.setAttr(f"{dome_light}.invisible", 1)
2. Directional Light 생성
Directional Light는 햇빛과 유사한 방향에서 비추는 라이트입니다.
아래 코드를 사용하여 Directional Light를 생성하고 방향을 설정할 수 있습니다.
# Directional Light 생성
directional_light_shape = cmds.directionalLight()
directional_light_transform = cmds.listRelatives(directional_light_shape, parent=True)[0]
# Directional Light의 transform 노드의 회전 값을 수정
cmds.setAttr(f"{directional_light_transform}.rotateX", -44.114)
cmds.setAttr(f"{directional_light_transform}.rotateY", 104.888)
통합된 코드
아래는 V-Ray Dome Light와 Directional Light를 생성하고 설정하는 통합된 코드입니다.
import maya.cmds as cmds
# V-Ray Dome Light 생성
dome_light = cmds.createNode("VRayLightDomeShape")
cmds.setAttr(f"{dome_light}.intensityMult", 0.5)
cmds.setAttr(f"{dome_light}.useDomeTex", 1)
# 텍스쳐 노드 생성
dome_tex = cmds.shadingNode("file", asTexture=True)
cmds.setAttr(f"{dome_tex}.fileTextureName", "<strong>HDRI 경로를 넣어주세요!</strong>", type="string")
# 텍스쳐 노드를 V-Ray Dome Light에 연결
cmds.connectAttr(f"{dome_tex}.outColor", f"{dome_light}.domeTex")
# V-Ray Dome Light를 Invisible로 설정
cmds.setAttr(f"{dome_light}.invisible", 1)
# Directional Light 생성
directional_light_shape = cmds.directionalLight()
directional_light_transform = cmds.listRelatives(directional_light_shape, parent=True)[0]
# Directional Light의 transform 노드의 회전 값을 수정
cmds.setAttr(f"{directional_light_transform}.rotateX", -44.114)
cmds.setAttr(f"{directional_light_transform}.rotateY", 104.888)
위 코드를 스크립트 에디터의 python 창에서 실행하거나 shelf에 버튼으로 등록하여 사용하시면 됩니다.