Materials for models:ko

From Valve Developer Community
Jump to: navigation, search
English (en)Русский (ru)日本語 (ja)中文 (zh)한국어 (ko)
... Icon-Important.png

개 요

소스 엔진을 위한 캐릭터, 물체 형태의 프롭 모델을 만드는 데는 최소한 3가지의 요소를 필요로 합니다.

  • 기본 메쉬모델(주로 티자 포즈형태의 인간형 모델 이거나 주변 사물들의 모양을 따한 정점값 정보가 기록된 파일)과 시퀀스 애니메이션 정보가 포함된 파일은 시퀀스 SMD 파일들을 StudioMDL로 파일로 컴파일하면 나오는 파일인 mdl 확장자의 모델(Model) 파일.
  • 빛의 반사 특성및 재질, 양감, 반사등의 특성값을 지정해주는 VMT (Valve Material Texture) 확장자의 텍스쳐 파일. **FIXIT**
  • 물체의 질량 무게 파손등을 시뮬레이팅 해주기 위한 값의 정보를 VTF

소스엔진에서 쓰이는 모델의 종류

  • 프롭스: 스카이박스 및 배경 그리고 총기 및 주변에 널려 있는 물체들.
  • 캐릭터 모델 및 조정이 가능한 자동차 같은 리깅된 물체들.
    • 주로 쓰이는 티 포즈 (T-Pose) 형태의 메쉬 테이터만을 가지고 있는 레퍼런스 모델 파일.
    • SMD, DMX 파일에 추가로 애니메이션 동작 정보를 쥐고 있는 파일.
  • 뷰모델 Viewmodel : 주로 총을 든 모습을 1인칭 형태로 카메라로 찍은듯이 보여줍니다.

정확히 말해서 세 확장자의 파일 MDL이 메쉬 데이타가 포함된 파일, VMT 텍스쳐 파일 정보를 지니고 있는 파일 VTF 게임에 쓰이는 텍스쳐 파일로 딱 나눌수는 없지만 대략 주요한 특징임을 받아 들이시고 앞으로 공부하면서 발견 되는 특성들은 이곳에 적어 주시기를 바랍니다. 그리고 세 파일의 정보는 컴파일 고정에서 각 파일의 정보를 서로 공유하게 됩니다.

이제 이 3파일을 StudioMDL을 가지고 컴파일을 해야 합니다. [Crowbar]을 추천합니다.

모델 작성의 VMT와 관련된 순서로만 추리자면:

  1. 모델 작성 - 메쉬 모델 작성후 텍스쳐를 입히고
  2. 텍스쳐 파일들을 VMFTool을 이용해서 벨브 텍스쳐 파일등으로 바꾸어 주면 됩니다.

TODO QC 명령어중 VMT 관련 내용 적기.

소프트이미지 모드툴에서

  • 소프트 이미지에서 텍스쳐를 입히는 방법에 대해서 알아보자면:
  1. 만들어진 모델을 선택.
  2. 소프트 이미지를 렌더러 모들 전환 합니다. - 단축키 3번을 누르면 전환됩니다.
  3. 옆에 메뉴 버튼 중에서 Render 버튼을 누르면 나오는 메뉴에서 Blinn 을 선택하면 선택한 모델에 블린(Blinn) 재질이 적용됩니다.
  4. Texture 버튼 메뉴에서 Image 를 누르면 이미지-텍스쳐 윈도우(Image-Texture window) 가 나타납니다:
  5. 윈도우를 잘 찾아보면 New 버튼이 보이는데 이걸 누르면 파일 고르는 윈도우가 뜨게 됩니다.
  • 잘못 만들어진 텍스쳐 맵핑을 지워야 한다면:
  1. 단축키 8을 눌러서 씬익스플로러를 불러들입니다.

-> 사각형 폴리고 (Cube) --> Polygon Mesh ---> Clusters


> Texture_Coordiantes_Auto

2 레프트 클릭 후에 "Texture Projection (Explicit UVWs)" 선택하자. 단축키 Delete 키를 눌러 삭제.
3. 오른쪽 큐브 박스 위에 있는 Wireframe 되어 있는 곳을 누르면 나오는 메뉴에서 Textured 라는 놈을 선택하면 텍스쳐가 입혀진 형태의 화면으로 전환이 된다. 원치 않게 삭제가 되었거나 이전 작업으로 돌아가는것은 단축키 "Ctrl+z"를 눌러서 안되유~(Undo)를 실행하자.

Proper Previewing

  • Making judgments about the progress of your textured character should be done directly in the Source engine, before getting too far with your material, export a vtf, create a vmt, build you mdl and look at the model in the engine. Working the fine points of texturing and shader parameters can only really happen after you’ve seen your model in the Engine.

만들어둔 체커보드 텍스쳐 응용

  • 체커 보드 텍스쳐를 이용한 작업.
    • 검은색 흰색 사각형 모양의 체스 보드 처럼 생긴 텍스쳐를 이용하면 UV 일그러짐이나 팀 등의 여러 증상들을 시각적으로 발견이 가능합니다.
    • 체커 보드 텍스쳐의 모양을 살핌으로서 폴리곤이 좀 더 필요한지 아니면 줄일수도 있는지를 조절 가능합니다.
    • 소프트 이미지에서 기본 제공이 되고 있는 Noicon.pic 파일도 이 종류입니다만 좀 더 섬세한 형태의 체커보드 도구입니다. 체커 보드 텍스쳐는 SDK에 포함이 되어 있습니다.

가장 적당한 텍스쳐 크기?

  • VTF 벨브 텍스쳐 파일을 엔진내에서 한시라도 빨리 시험을 해보고 싶다면 자신이 생성한 모드에서 소스엔진 게임을 실행한뒤에 콘솔(단축키 "~")을 열어서 mat_showmiplevels 실행을 해보면 알수 있습니다. (확인 요망.) 게임 속이 캐릭터를 움직여 보면서 해당 텍스쳐가 작동에 이상이 없는지를 테스트해봅시다. 일반적으로 사이즈가 큰 텍스쳐가 선명한 해상도를 좋은 출력물을 뽑게 되는것은 사실이지만, 텍스쳐 사이즈가 커지게 되면 텍스쳐 로딩 시간이 지연이 생기게 되어 결국 블러 효과 처럼 잠시 탁해지다가 원상태로 돌아오는 경우가 있습니다. 텍스쳐 팝인.

이글은 보충이 필요합니다. 더 많은 사용례와 알기 쉬운 단어 선정으로 모두에게 이로운 문서로 만들어봅시다.

다단계 형태의 텍스쳐 (Multi-layered Textures)

이제까지 단일 계층 텍스쳐만을 이용한 모델만을 만들어 보았겠지요? 하지만 세상은 좀 더 복잡한것이 필요로 할때가 있습니다. 크고 다양한 형태위 재질, 텍스쳐등을 이용해서 다양한 조건을 만족하는 작품을 만들어 봅시다. 하지만 그렇다고 해서 너무 남용하면 리얼타임 형태라 하더라도 프레잉을 깍아 먹거나 렌더링이 오래 걸리게 되는 요소가 되기도 합니다.

자 이제 한모델에서 여러가지 형태의 재질이 포함이 된 하나의 모델 파일을 원한다면 클러스터 지정만 그 답이 될것입니다.

  • 원하는 만큼의 폴리곤을 선택을 한뒤에 단축키 CTRL+L 을 누르면 선택된 폴리곤이 하나의 클러스터로 그룹화 됩니다.
    • 다양한 클러스터를 만들고 원하지 않는다면 해당 클러스터만 지워두면 됩니다.
    • 엔진 에서 조작이 된다면 다양한 스킨 형태의 모델이 단지 게임엔진에서 파일 지정만 바꾸어주거나 하는 형태로 다른 팀 모델로 보여지게 됩니다.
    • 폴리곤 덩어리 하나로 한쪽은 나무, 한쪽은 강철 재질 같은 아수라 백작 같은 표현이 가능합니다.
  • TIP Preference - 설정에서 "reload externally modified images on focus" 로 설정해 놓으면 Alt + tab 을 할 때마다 소프트 이미지에서 텍스쳐 파일을 다시 불러들이게 됩니다. 포토샵으로 작업을 할시에 아주 편리한 기능이죠.

VTF로 컴파일 하자.

  • 노트 : 베테랑 모더인 캡틴빅벗의 말에 따르면 PNG 형태의 파일을 쓰게 되면 약간 흐릿하거나 바스락 거리는듯 한 느낌이 있다고 하므로 김프, 페인트.net, 포토샵 cs3[무료] 등을 구해서 플러그인 깔아넣고 VTF로 바로 저장을 하는것을 권합니다. 하지만 주워온 모델이 이미 PNG등의 확장자를 사용한다면 의미가 없으므로 그냥 VTFEdit 등을 통해서 변환 작업을 속행하는것을 추천합니다.

소프트 이미지 어드온을 찾아보면 씬에 로드된 이미지 파일들을 전부 VTF 형태로 익스포트하는 기능이 있습니다. 마테리얼들 또한 컴파일 작업에 일부 정보가 모델 파일에 적용되기는 하지만 마테리얼 속성을 담고 있는 스크립트 파일인 VMT 파일을 StudioMDL이 바이너리 파일로 컴파일 하지는 않습니다.

기본 디렉토리 game_directory/materials/models 디렉토리를 기준으로 VMT 파일들을 전부 읽어 들입니다. 단 서브 디렉토리는 $cdmaterial 명령등을 통해 추가를 해야만 합니다. VTF 파일은 TGA 파일을 소스엔진에서 읽을수 형태로 변환을 하는 작업입니다. VMT 파일 작성한 내역을 기반으로 텍스쳐 파일들을 찾게 됩니다. 모델 작업시에 보였던 재질 이름 그대로 VMT 파일 이름을 맞쳐 주고 VMT 안에 필요한 재질의 성질및 VTF로 변환한 SourceSDK/bin 을 VTEX.exe 라는 프로그램이 있습니다.


  1. 6분 20초 부분을 보면 VTF 파일을 불러옵니다.
  2. Tools 메뉴를 눌러서 Create VMT FIle 아이템을 눌러서 서브창을 한 뛰운뒤에 옵션탭을 누릅니다.
  3. Shader 에서 LightmappedGeneric 이라고 써지 부분 옆에 밑으로 꺽인 화살표 버튼을 누른뒤에 해당 아이템을 VertexlitGeneric 으로 바꾸어줍니다.
  • includes Vtex.exe, the application used to compile to .VTFs. The simplest way to use Vtex is to create a shortcut to vtex.exe on your desktop, and drag .TGA files onto the shortcut. This will create a .VTF file with the same name as your .TGA file in the materials directory. When you drag open a tga file with Vtex, a .TXT file is also created in the same directory as your .TGA, in this file you can issue commands to Vtex to alter your compression.

{{note|For quick material creation, try adding "-shader VertexLitGeneric" to your target field in the Vtex shortcut properties. this works with any shadertype. Dragging a texture on to this modified shortcut will then create a .VTF file as usual, and create a .VMT file with the shader and basetexture defined for you.}

Compiling your.VMT : Valve Material Type

Each Material for the Source engine is defined by a .VMT file. It specifies the lighting model, the basetexture (VTF), and any other additional channels you may have like: specularity, self-illumination, normalmap, transparency, translucency, and proxy shaders.

For models, your.VMT must be written by hand (using notepad, etc) and placed in the game_directory/materials/models folder so that your.MDL can find it. The $basetexture (your.VTF) referenced in your.VMT must also be in the same game_directory/materials/models folder so that your.VMT can find it.

Tip.pngTip:The QC command $cdmaterials can be used to specify further subfolders.
Warning.pngWarning:All materials for models must use the VertexLitGeneric shader. Model Materials will not work properly with LightmappedGeneric or UnlitGeneric.

Here’s an example VMT file from HL2:

"VertexLitGeneric"
{
     "$basetexture" "Models/Combine_soldier/Combine_elite"
     "$bumpmap" "models/combine_soldier/combine_elite_normal"
     "$envmap" "env_cubemap"
     "$normalmapalphaenvmapmask" 1
     "$envmapcontrast" 1
     "$model" 1
     "$selfillum" 1
}

This example is a material used on a polygonal model, using the VertexLitGeneric shader. The $basetexture or diffusemap is specified as "Models/Combine_soldier/Combine_elite" The $bumpmap or normalmap is imported from "models/combine_soldier/combine_elite_normal". The $envmap or environmentmap is set to "env_cubemap", which refers to cubemap entities placed in the level; the specular reflections of this character will always reflect the world around it - assuming you have cubemap entities placed appropriately in you level. You can use a custom cubemap instead, if you choose. The next line, "$normalmapalphaenvmapmask" 1 tells the renderer that this material has a mask for the specularity, so only some areas of the model will reflect the env_cubemap information, as defined in this case by the alpha channel of the normal map, the specular mask can be here, in the alpha of the basetexture "$basealphaenvmapmask 1" or in a separate mask file "$envmapmask" "models/modelname/mymask". The "$envmapcontrast" 1 command means the brightness of the envmap reflections is multiplied by itself one time; to create brighter highlights and deeper shadows. All models need to contain the command, "$model" 1 which tells the renderer that this material is being used on a polygonal model compiled by Studiomdl.exe. The last line "$selfillum" 1 tells the renderer that the alpha channel of the $basetexture contains self illuminated areas, these areas of the alpha channel show up as glowing areas of the model.

Alpha-channel

To get materials with alpha-channel to work, you have to insert the command "$translucent" 1 to your VMT file. Sometimes this leads to rendering errors in the model (e.g. theres convex 1 in the back of convex 2, but convex 2 gets hidden by convex 1 => Rendering error). If this happens, using the command "$alphatest" 1 instead of "$translucent" 1 should fix it.

Proxy shaders

A powerful component of the source engine material system is the Proxy shader system. Examples of what proxy shaders are capable of are shown in the shaderzoo map contained in the sdk, and further documentation on their creation can be found in the materials documents.