Download - Introduction to Materials
Introduction to Materials
Contents
• Materials• Editing materials• Quick methods for editing materials in UDK
Introduction to Materials
• Materials affect the appearances of games• Let objects appear to be what they should
look like
What are Materials ?
• Simple approach: the pigment r of a surface• pigment controls colors• Materials make the surface apear to be
something what they should look like
Material vs Texture
• Texture is an image• Materials contains textures and more, for
example, transparency, emittance and etc.
Texture UV Coordinates
• A texture is defined a two-dimensional space• We have to map the 2D texture to the surface
of an object in three-dimensional space
Texture UV Coordinates
• Horzontal axis : U-axis• Vertical axis : V-axis • Sometimes, the texture coordinate is called
the tangent space 。• Each vertex should be assoicated with a
texture coordinates
Example
Source:http://en.wikipedia.org/wiki/File:UVMapping.png
U Direction
V Direction
1.0
1.0
0, 0
Example
• Cube Representative UV
Source : http://en.wikipedia.org/wiki/File:Cube_Representative_UV_Unwrapping.png
A representation of the UV mapping of a cube. The flattened cube net may then be textured to texture the cube
• Set instructions to compute the appearance of a material
• There are default values for each instruction for simulating the the lit surface
• Remember to turn on light in order to see the materials.
Material Components
• Components:• Material Nodes ( 材质节点 )• Basic components• Material Channels ( 材质通道 )• Set the specific properties of a material
• 材质表达式( Material Expressions )。• A building block for creating materials. • Each expression defines a specific function, for example,
connecting textures, adding two values, vectors or modify coordinates of textures.
Material Components
Material Nodes
Material Channels
Material Expressions
Example: Creation of a Material
• 1. Run UnrealEd• 2. Open Generic browser• 3. File - > New• 文件包( Package) : MyFirstGameLevel• 组 (Group): Materials • 名称 (Name): mat_test_01 • 组件工厂 (Factory): Material
Double click the new material, you will see the following:Left hand side: the appearance of the materialA material node represent the new material
Material Channels
• Diffuse ( 漫射 )• Emissive (自发光)• Specular (高光)• Specular Power (高光次幂)• Opacity (不透明)• Opacity Mask (不透明蒙板)• Distortion (扭曲)• Transmission Mask/Transmission Color (透射蒙板 / 透射
色) • Normal (法线) • Custom Lighting (自定义光照)
Show demo for the following items
• Diffuse ( 漫射 )• Emissive (自发光)• Specular (高光)• Specular Power (高光次
幂)
Diffuse
Emissive
Opacity (不透明)
-Set“LightingModel” (光照模型) as MLM_Unlit
- Set BlendMode” (混合模式) as BLEND_Masked 、 BLEND_Translucent 、BLEND_Additive 或 BLEND_Modulate
BLEND_OPAQUE
BLEND_Translucent
Opacity Mask (不透明蒙板)
A simplified version of the opacity.Can be used if MLM_Phong is not available.
It’s value boolean map. 1 for on0 for offIf the pixel value is smaller than a clipping value, it’s computed value is 0; otherwise it is 1.
Opacity Mask (不透明蒙板)
BLEND_MODE = BLEND_Masked
Distortion (扭曲) Model refraction effect
Used when MLM_Unlit is used.
http://upload.wikimedia.org/wikipedia/en/e/eb/Rays_incident_on_medium.png
Transmission Mask/Transmission Color
- Model sub-surface scattering (次表面散射)
-Subsurface scattering (or SSS) : a mechanism of light transport in which light penetrates the surface of a translucent object, is scattered by interacting with the material, and exits the surface at a different point.
Source: wikipedia
Subsurface scattering
http://en.wikipedia.org/wiki/File:Subsurface_scattering.png
Normal Map or "Dot3 bump mapping", is a technique used for faking the lighting of bumps and dents. It is used to add details without using more polygons. A normal map is usually an RGB image that corresponds to the X, Y, and Z coordinates of a surface normal from a more detailed version of the object.
Normal map
Normal Map
WithoutNormal Map
Transmission + Normal
BLEND_Translucent
Custom Lighting (自定义光照)
Define your own lighting function
You must enable this channel by setting lighting model as MLM_Custom
Custom Lighting
Material Expressions– Abs (求绝对值)– Add (加法)– AppendVector (向量合并)– BumpOffset (凹凸偏移)– CameraVector (相机位向量)– Ceil (值上限取整)– Clamp (区间值限定)– ComponentMask (分量蒙板)– 常量表达式
» Constant (常量)» Constant2Vector (二维常数向量)» Constant3Vector (三维常数向量)» Constant4Vector (四维常数向量)
Desaturation (冲淡颜色)DestColor (目标色)DestDepth (目标深度)Divide (除法)DotProduct (点乘、内积 )Cosine (余弦)CrossProduct (叉乘、外积)DepthBiasedAlpha (深度偏移 Alpha ) DepthBiasedBlend (深度偏移混合)
Material Expressions
FlipBookSample (翻书采样)Floor (值下限取整) Frac (取小数值)Fresnel (菲涅尔)If (条件表达式)LightVector (光照向量)LinearInterpolate (线性插值)
Material Expressions
MeshEmitterVertexColor (网格物体发射器顶点色) MeshSubUV (网格物体子 UV ) Multiply (乘法表达式) Normalize (单位化)OneMinus (一减去)Panner (平移器)ParticleSubUV (粒子子 UV )PixelDepth (像素深度)Power (求幂值)ReflectionVector (反射向量)
Material Expressions
Rotator (旋转器)ScalarParameter (标量参数)SceneDepth (场景深度)SceneTexture (场景贴图)ScreenPosition (屏幕位置)Sine (正弦)SquareRoot (开平方根)Subtract (减法)TextureCoordinate (贴图坐标 )
Material Expressions
TextureSample (贴图采样)TextureSampleParameter2D (贴图采样参数: 2D )TextureSampleParameterCube (贴图采样参数:立方体) TextureSampleParameterMovie (贴图采样参数:影片)Time (计时)Transform (变换)
Material Expressions
VectorParameter (向量参数) VertexColor (顶点色)
Material Expressions
Issues about designing your own materials•Texture format: Targa ( .TGA )。 It can accept other formats too.• Dimension of the texture: the power of 2. • Need not to be a square, e.g. 32, 1024, etc.• The number of pixels in width or height is not larger than 2048.• Make sure the resolution matches your need. For example, if you use a texture with resolution 2048x2048 but the players never have a chance to see it. Don’t do it.
Import textures1. Generic browser->File> Import 。2. Click OK3. A dialogue is shown to ask for more information
Package (包) : MyMaterials Group (組) : Textures If DeferCompression (不壓縮) is
checked, the package is not compressed before saving.
4. Save
A Walkthrough to build new materials
How to set a texture for TextureSample?
- Generic browser (Content Browser)->select a texture (highlight it)- Go back to Material Editor- Click the block of TextureSample
- at the line “Texture” (bottom of viewport)- Click “use the selected object in Content Browser”
Example
Example
• Try Pan• Try Rotation• Try Scaling• Try Relative
Alignment- Select the planes that you want to adjust, i.e. aligning all- Open Surface Properties -> Alignment->Planar
Hints
• After you select an object, press right mouse button.
• Additional actions will be shown for manipulating the object
• Select Geometry Mode (left hand side)• After you select a BSP, you can change the
texture coordinates by using widgets too.
BumpOffsetPurpose : Virtual Displacement MappingTo generate the illusion of height differences when normal map is used.Inputs : Height (高度值)和 UVs
Height: a scaling factor for heightHeightRatio (高度比) :pixel height / surface areaReferencePlane (参考平面)。 Determine how the displacement is computed, value in [0, 1]. Denote as h.
- If pixel height > h, move along the direction of camera- If pixel height <h, move in the negative direction of camera
BumpOffset
• Change “height value” from -1.0 to 2.0 and observe the effect
• Change ReferencePlane and observe the effect
Fresnel (value in [0,1])
Examples
• TexCoord• Panner• Rotator• OneMinus• Power• etc.
SpecularInstead of applying an intensity of specular uniformly over a surface, you can assign the intensity of specular to it based on a texture.
Exercises• Learn from UDK examples.
Exercises• Learn from UDK examples.
Summary
• Learn how to create materials.
• Material editing:http://www.youtube.com/watch?v=GP0jX5nUB50&feature=relatedhttp://www.youtube.com/watch?v=RIxQS66oIQE&feature=related