Materials for models:ko

From Valve Developer Community
Revision as of 23:19, 9 April 2016 by Mochan77 (talk | contribs) (소스엔진에서 쓰이는 모델의 종류)
Jump to: navigation, search
English Русский 日本語

개 요

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

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

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

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

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

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

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

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

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

소프트이미지 모드툴에서

  • 소프트 이미지에서 텍스쳐를 입히는 방법에 대해서 알아보자면:
  1. 만들어진 모델을 선택.
  2. 소프트 이미지를 렌더러 모들 전환 합니다. - 단축키 3번을 누르면 전환됩니다.
  1. select XSI's Render mode (top of left sidebar).
  2. from Render>Get-Material select Blinn (close the Material window)
  3. from Render>Get-Texture select Image to open the Image-Texture window:
  4. in Image-Texture tab>Image press "New" to locate & import your new TGA texture file.
  5. in Image-Texture tab>Texture Projection press "New" and select Unique UVs (polymesh) (close the Image window)
  6. Press "Alt+7" to open the XSI Texture Editor window.
  • If you mess up your texture mapping and want to start over:
1. Press "8" to open the Scene Explorer, then navigate to the Texture Projection like this:
-> Cube (or your base object)
--> Polygon Mesh
---> Clusters
----> Texture_Coordinates_Auto
-----> Texture Projection (Explicit UVWs) 
2. Now left-click "Texture Projection (Explicit UVWs)" to select it, then press your "Delete" key to delete it.
3. Check the 3D view (in 'textured' mode) to make sure you got the right one. If not, press "Ctrl+Z" to undo and take another shot at it.

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.

Checkerboard Template Texture

  • Using a checkerboard texture is a good way to start laying out your UV coordinates; this lets you see very quickly if you have any distortions, streaks, or seams that may need to be corrected. Also, using a checkerboard texture gives you a very good way to measure how much texel density you have on the various parts of your model, as you define the UV’s, some areas like faces may need a bit of extra density, but overall you should strive for even and consistent texel density across your model. The default noicon.pic file in XSI is a good choice or you may use this file, Checkerboard Starter Texture (right-click save as...) included in the SDK.

What size should my texture be?

  • Export a .VTF as early as possible and load preview your model in the engine, using the mat_showmiplevels command at the console, check what mip level you’re seeing at some of the most common encounters your character is going to have during gameplay. While it may seem that bigger is better, this isn’t always the case, mipmapping can force your large texture down in size until blurriness becomes a problem.

Multi-layered Textures

  • You should try to only use one basetexture, unless material demands require otherwise. Multiple textures on a model can drastically affect rendering time. If you do need to create multiple textures on one model, you must first select a group of polygons, make a cluster of them, then apply the material and image to your cluster. Make sure that you have your preferences set to "reload externally modified images on focus". This reloads textures when you alt-tab back to XSI from another program like Photoshop, a good time saver.

Compiling your.VTF : Valve Texture Format

Any Texture that has been mapped to a model (before exporting your.SMD from XSI) must be converted from a TGA to a VTF file before it can be used in the Source Engine. The VTF filename must remain the same as the TGA used to compiling your.SMD (eg: your.TGA -> your.VTF) and the VTF placed in the game_directory/materials/models folder.

  • SourceSDK/bin 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.png 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.
  • Cannonfodder's StudioCompiler provides a more user-friendly GUI to Vtex (and Studiomdl). It is able to compile/decompile VTF, VMT and MDL files from/to TGA and SMD files.

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.png Tip: The QC command $cdmaterials can be used to specify further subfolders.
Warning.png Warning: 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:

     "$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.


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.