Transcript
Page 1: Introduction to Materials

Introduction to Materials

Page 2: Introduction to Materials

Contents

• Materials• Editing materials• Quick methods for editing materials in UDK

Page 3: Introduction to Materials

Introduction to Materials

• Materials affect the appearances of games• Let objects appear to be what they should

look like

Page 4: Introduction to Materials

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

Page 5: Introduction to Materials

Material vs Texture

• Texture is an image• Materials contains textures and more, for

example, transparency, emittance and etc.

Page 6: Introduction to Materials

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

Page 7: Introduction to Materials

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

Page 8: Introduction to Materials

Example

Source:http://en.wikipedia.org/wiki/File:UVMapping.png

U Direction

V Direction

1.0

1.0

0, 0

Page 9: Introduction to Materials

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

Page 10: Introduction to Materials

• 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.

Page 11: Introduction to 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.

Page 12: Introduction to Materials

Material Components

Material Nodes

Material Channels

Material Expressions

Page 13: Introduction to Materials

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

Page 14: Introduction to Materials
Page 15: Introduction to Materials

Double click the new material, you will see the following:Left hand side: the appearance of the materialA material node represent the new material

Page 16: Introduction to Materials

Material Channels

• Diffuse ( 漫射 )• Emissive (自发光)• Specular (高光)• Specular Power (高光次幂)• Opacity (不透明)• Opacity Mask (不透明蒙板)• Distortion (扭曲)• Transmission Mask/Transmission Color (透射蒙板 / 透射

色) • Normal (法线) • Custom Lighting (自定义光照)

Page 17: Introduction to Materials

Show demo for the following items

• Diffuse ( 漫射 )• Emissive (自发光)• Specular (高光)• Specular Power (高光次

幂)

Page 18: Introduction to Materials

Diffuse

Emissive

Page 19: Introduction to Materials

Opacity (不透明)

-Set“LightingModel” (光照模型) as MLM_Unlit

- Set BlendMode” (混合模式) as BLEND_Masked 、 BLEND_Translucent 、BLEND_Additive 或 BLEND_Modulate

Page 20: Introduction to Materials

BLEND_OPAQUE

BLEND_Translucent

Page 21: Introduction to Materials

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.

Page 22: Introduction to Materials

Opacity Mask (不透明蒙板)

BLEND_MODE = BLEND_Masked

Page 23: Introduction to Materials

Distortion (扭曲) Model refraction effect

Used when MLM_Unlit is used.

http://upload.wikimedia.org/wikipedia/en/e/eb/Rays_incident_on_medium.png

Page 24: Introduction to Materials

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

Page 25: Introduction to Materials

Subsurface scattering

http://en.wikipedia.org/wiki/File:Subsurface_scattering.png

Page 26: Introduction to Materials

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

Page 27: Introduction to Materials

Normal Map

WithoutNormal Map

Page 28: Introduction to Materials

Transmission + Normal

BLEND_Translucent

Page 29: Introduction to Materials

Custom Lighting (自定义光照)

Define your own lighting function

You must enable this channel by setting lighting model as MLM_Custom

Page 30: Introduction to Materials

Custom Lighting

Page 31: Introduction to Materials

Material Expressions– Abs (求绝对值)– Add (加法)– AppendVector (向量合并)– BumpOffset (凹凸偏移)– CameraVector (相机位向量)– Ceil (值上限取整)– Clamp (区间值限定)– ComponentMask (分量蒙板)– 常量表达式

» Constant (常量)» Constant2Vector (二维常数向量)» Constant3Vector (三维常数向量)» Constant4Vector (四维常数向量)

Page 32: Introduction to Materials

Desaturation (冲淡颜色)DestColor (目标色)DestDepth (目标深度)Divide (除法)DotProduct (点乘、内积 )Cosine (余弦)CrossProduct (叉乘、外积)DepthBiasedAlpha (深度偏移 Alpha ) DepthBiasedBlend (深度偏移混合)

Material Expressions

Page 33: Introduction to Materials

FlipBookSample (翻书采样)Floor (值下限取整) Frac (取小数值)Fresnel (菲涅尔)If (条件表达式)LightVector (光照向量)LinearInterpolate (线性插值)

Material Expressions

Page 34: Introduction to Materials

MeshEmitterVertexColor (网格物体发射器顶点色) MeshSubUV (网格物体子 UV ) Multiply (乘法表达式) Normalize (单位化)OneMinus (一减去)Panner (平移器)ParticleSubUV (粒子子 UV )PixelDepth (像素深度)Power (求幂值)ReflectionVector (反射向量)

Material Expressions

Page 35: Introduction to Materials

Rotator (旋转器)ScalarParameter (标量参数)SceneDepth (场景深度)SceneTexture (场景贴图)ScreenPosition (屏幕位置)Sine (正弦)SquareRoot (开平方根)Subtract (减法)TextureCoordinate (贴图坐标 )

Material Expressions

Page 36: Introduction to Materials

TextureSample (贴图采样)TextureSampleParameter2D (贴图采样参数: 2D )TextureSampleParameterCube (贴图采样参数:立方体) TextureSampleParameterMovie (贴图采样参数:影片)Time (计时)Transform (变换)

Material Expressions

Page 37: Introduction to Materials

VectorParameter (向量参数) VertexColor (顶点色)

Material Expressions

Page 38: Introduction to Materials

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.

Page 39: Introduction to Materials

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

Page 40: Introduction to Materials

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”

Page 41: Introduction to Materials

Example

Page 42: Introduction to Materials

Example

• Try Pan• Try Rotation• Try Scaling• Try Relative

Page 43: Introduction to Materials

Alignment- Select the planes that you want to adjust, i.e. aligning all- Open Surface Properties -> Alignment->Planar

Page 44: Introduction to Materials

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.

Page 45: Introduction to Materials

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

Page 46: Introduction to Materials

BumpOffset

• Change “height value” from -1.0 to 2.0 and observe the effect

• Change ReferencePlane and observe the effect

Page 47: Introduction to Materials

Fresnel (value in [0,1])

Page 48: Introduction to Materials

Examples

• TexCoord• Panner• Rotator• OneMinus• Power• etc.

Page 49: Introduction to Materials

SpecularInstead of applying an intensity of specular uniformly over a surface, you can assign the intensity of specular to it based on a texture.

Page 50: Introduction to Materials

Exercises• Learn from UDK examples.

Page 51: Introduction to Materials

Exercises• Learn from UDK examples.

Page 52: Introduction to Materials

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


Top Related