Skip to content

Material

继承自 AssetObject

Material类用于控制渲染对象的外观和材质。每个渲染对象都可以关联一个 Material 对象,从而决定了其在场景中的外观和表现。

可以通过以下方式获取Material对象:

typescript
let shader = Shader.Find("Resouses/Shader/Diffuse");//加载shader
let material = new Material(shader);

成员变量

Material.shader : Shader
材质使用的着色器。
Material.renderQueue : number
当前材质的渲染队列。

成员方法

Material.HasFloat ( name : string ) : boolean
检查当前材质是否具有指定名称的 Float 属性。
Material.GetFloat ( name : string , out_result : number ) : number|undefined
根据属性名称获取当前材质的 Float 值。
Material.HasColor ( name : string ) : boolean
检查当前材质是否具有指定名称的 Color 属性。
Material.GetVector ( name : string ) : Vector4|undefined
根据属性名称获取材质的 Vector 值。
Material.GetTexture ( name : string ) : Texture|null
根据属性名称获取指定属性名的 Texture 值。
Material.GetMatrix4x4 ( name : string ) : Matrix4x4|undefined
根据属性名称从当前材质所用着色器中获取 Matrix4x4 属性值。
Material.HasVector ( name : string ) : boolean
检查当前材质是否具有给定名称的Vector属性。
Material.GetColor ( name : string ) : Color|undefined
根据属性名称获取当前材质的 Color 值。
Material.SetVector ( name : string , value : Vector4 ) : void
根据属性名称设置材质的 Vector 值。
Material.SetTexture ( name : string , tex : Texture ) : void
根据属性名设置材质的 Texture 值。
Material.HasMatrix4x4 ( name : string ) : boolean
判断当前材质所用着色器是否具有指定名称的 Matrix4x4 属性。
Material.HasTexture ( name : string ) : boolean
检查当前材质是否具有 Texture 属性。
Material.SetFloat ( name : string , value : number ) : void
设置当前材质的 Float 值。
Material.SetColor ( name : string , value : Color ) : void
根据属性名称设置材质的 Color 值。
Material.SetMatrix4x4 ( name : string , value : Matrix4x4 ) : void
设置当前材质所用着色器中 Matrix4x4 的属性值。
Material.IsKeywordEnabled ( value : string ) : boolean
检查是否为此材质启用了指定着色器关键字。
Material.DisableKeyword ( value : string ) : void
禁用此材质的本地着色器关键字。
Material.EnableKeyword ( value : string ) : void
启用此材质的本地着色器关键字。