Material材质 翻译:titan-志广
- color
- CopyPropertiesFromMaterial
- GetColor
- GetFloat
- GetMatrix
- GetTag
- GetTextureOffset
- GetTextureScale
- GetTexture
- GetVector
- HasProperty
- Lerp
- mainTextureOffset
- mainTextureScale
- mainTexture
- Material
- passCount
- renderQueue
- SetColor
- SetFloat
- SetMatrix
- SetPass
- SetTextureOffset
- SetTextureScale
- SetTexture
- SetVector
- shader
Material.SetMatrix 设置矩阵
function SetMatrix (propertyName : string, matrix : Matrix4x4) : void
Description描述
Set a named matrix for the shader.
为这个shader设置一个命名矩阵
This is mostly used with custom shaders that need extra matrix parameters. Matrix parameters are not exposed in the material inspector, but can be set and queried with SetMatrix and GetMatrix from scripts.
这主要是与需要额外的矩阵参数的自定义着色器一起使用的。矩阵参数不会将其公开在材质的检视面板中,但可以在脚本中通过SetMatrix 和 GetMatrix设置和查询。
var rotateSpeed = 30;
var texture : Texture ;
function Start() {
// Create a new material with a shader
//使用shader创建 一个新的材质
// that rotates the texture. Texture rotation
//旋转纹理
// is performed with a _Rotation matrix.
//执行_Rotation 矩阵
var m : Material = new Material (
" Shader \"Rotating Texture \" {" +
"Properties { _MainTex (\"Base\", 2D) = \"white\" {} }" +
"SubShader {" +
" Pass {" +
" Material { Diffuse (1,1,1,0) Ambient (1,1,1,0) }" +
" Lighting On" +
" SetTexture [_MainTex] {" +
" matrix [_Rotation]" +
" combine texture * primary double, texture" +
" }" +
" }" +
"}" +
"}"
);
m.mainTexture = texture;
renderer.material = m;
}
function Update() {
// Construct a rotation matrix and set it for the shader
// 构建旋转矩阵,并将其设置为着色器
var rot = Quaternion.Euler (0, 0, Time.time * rotateSpeed);
var m = Matrix4x4.TRS ( Vector3.zero , rot, Vector3 (1,1,1) );
renderer.material.SetMatrix ("_Rotation", m);
}
最后修改:2011年1月22日 Saturday 21:18