머티리얼 및 조명 파라미터는 빌트인 버텍스 조명을 제어하는 데 사용됩니다. 버텍스 조명은 각 버텍스에 대해 계산되는 스탠다드 Direct3D/OpenGL 조명 모델입니다. Lighting on 을 선택하면 켜집니다. 조명은 Material 블록, ColorMaterial 및 SeparateSpecular 커맨드에 영향을 받습니다.
*참고: Material/Lighting 커맨드는 버텍스 프로그램을 사용하는 경우 영향이 없습니다. 이 경우 모든 연산이 셰이더에서 완전히 기술되기 때문입니다. 이제는 레거시 버텍스 조명 대신 프로그램 가능 셰이더를 사용하는 것이 좋습니다. 이런 셰이더를 사용하는 경우 여기서 설명하는 커맨드를 사용하지 않고, 대신 버텍스 및 프래그먼트 프로그램을 직접 정의하여 모든 조명, 텍스처 등의 작업을 직접 수행합니다.
버텍스 컬러링 및 조명은 렌더링된 지오메트리에 대해 가장 먼저 계산하는 효과입니다. 버텍스 레벨에서 작동하고, 텍스처 적용 전에 사용되는 베이스 컬러를 계산합니다.
최상위 커맨드는 고정 함수 조명 사용 여부와 일부 설정 옵션을 제어합니다. 메인 설정은 아래에서 자세히 설명하는 Material Block에 있습니다.
컬러(Color) color
오브젝트를 솔리드 컬러로 설정합니다. 컬러는 괄호 안에 있는 RGBA 값 4개이거나 대괄호 안에 있는 컬러 프로퍼티 이름입니다.
Material {Material Block}
머티리얼 블록은 오브젝트의 머티리얼 프로퍼티를 정의하는 데 사용됩니다.
Lighting On | Off
머티리얼 블록에 정의된 설정이 효과가 있으려면 Lighting On 커맨드를 사용하여 조명을 활성화해야 합니다. 조명이 꺼진 경우 Color 커맨드의 컬러가 직접 사용됩니다.
SeparateSpecular On | Off
커맨드를 실행하면 스페큘러 조명이 셰이더 패스 끝에 추가되므로 스페큘러 조명이 텍스처링에 영향을 받지 않습니다. Lighting On 을 사용하는 경우에만 영향이 있습니다.
ColorMaterial AmbientAndDiffuse | Emission
머티리얼에 설정된 컬러 대신 버텍스당 컬러가 사용됩니다. AmbientAndDiffuse 는 머티리얼의 앰비언트 및 디퓨즈 값을 바꾸고 Emission 은 머티리얼의 이미션 값을 바꿉니다.
머티리얼이 광원에 반응하는 방법에 대한 설정을 포함합니다. 다음 프로퍼티는 생략할 수 있으며, 그러면 검정색(즉 효과 없음)이 디폴트가 됩니다.
Diffuse color: 디퓨즈 컬러 컴포넌트로, 오브젝트의 베이스 컬러입니다.
Ambient color: 앰비언트 컬러 컴포넌트입니다. 라이팅 창에서 설정한 주변광과 닿으면 오브젝트에 이 컬러가 표시됩니다.
Specular color: 오브젝트의 스페큘러 하이라이트 컬러입니다.
Shininess number: 하이라이트의 선명도로, 0과 1 사이입니다. 0에서는 디퓨즈 조명과 매우 비슷해 보이는 커다란 하이라이트가 생기고 1에서는 작은 반점이 생깁니다.
Emission color: 오브젝트에 광원이 닿지 않을 때 오브젝트에 표시되는 컬러입니다.
오브젝트에 닿는 광원의 전체 컬러는 다음과 같습니다.
Ambient * 라이팅 창의 앰비언트 강도 설정 + (Light Color * Diffuse + Light Color * Specular) + Emission
등식의(괄호 안에 있는) 광원 부분은 오브젝트에 닿는 모든 광원에 대해 반복됩니다.
일반적으로 디퓨즈 및 앰비언트 컬러를 동일하게 유지하는 것이 좋습니다(모든 빌트인 Unity 셰이더에서 이렇게 합니다).
오브젝트를 항상 순수 빨간색으로 렌더링합니다.
Shader "Solid Red" {
SubShader {
Pass { Color (1,0,0,0) }
}
}
다음은 오브젝트에 흰색을 표시하고 버텍스 조명을 적용하는 기본 셰이더입니다.
Shader "VertexLit White" {
SubShader {
Pass {
Material {
Diffuse (1,1,1,1)
Ambient (1,1,1,1)
}
Lighting On
}
}
}
다음은 머티리얼 컬러를 머티리얼 인스펙터에 표시되는 프로퍼티로 추가하는 확장 버전입니다.
Shader "VertexLit Simple" {
Properties {
_Color ("Main Color", COLOR) = (1,1,1,1)
}
SubShader {
Pass {
Material {
Diffuse [_Color]
Ambient [_Color]
}
Lighting On
}
}
}
그리고 마지막으로 완전한 버텍스 리트 셰이더입니다. SetTexture 레퍼런스 페이지도 참조하십시오.
Shader "VertexLit" {
Properties {
_Color ("Main Color", Color) = (1,1,1,0)
_SpecColor ("Spec Color", Color) = (1,1,1,1)
_Emission ("Emmisive Color", Color) = (0,0,0,0)
_Shininess ("Shininess", Range (0.01, 1)) = 0.7
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
Material {
Diffuse [_Color]
Ambient [_Color]
Shininess [_Shininess]
Specular [_SpecColor]
Emission [_Emission]
}
Lighting On
SeparateSpecular On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.