清源游民 gameogre@gmail.com
材質(zhì)復(fù)制
如果新的腳本只是對(duì)某個(gè)已經(jīng)存在的腳本進(jìn)行小部分的變化,那么可進(jìn)行從舊腳本復(fù)制,而不是C&P。新材質(zhì)可以修改特定technique,pass,texture,或是添加新項(xiàng)。
格式: material <NewUniqueChildName> : <ReferanceParentMaterial>
當(dāng)材質(zhì)腳本被加載到ogre中,這種繼承關(guān)系不再維系,假如父材質(zhì)在運(yùn)行時(shí)被修改,不會(huì)影響到子材質(zhì)。如果在一個(gè)technique中有5個(gè)pass,而我們只想修改第5個(gè)pass,我們可以用pass指定或是它的索引(從0計(jì))
meterial test2: test1
{
? technique 0
??? {
????? pass 4
??????? {
????????? ambient 0.5 0.7 0.3 1.0
??????? }
??? }
}
加入一個(gè)新的technique或pass到material中,可以通過(guò)賦于它們新的名稱來(lái)實(shí)現(xiàn),新名稱必須在父材質(zhì)中沒(méi)有出現(xiàn)過(guò)。指定新索引也一樣。新technique或pass會(huì)被加載到父材質(zhì)相應(yīng)technique或pass末尾.
material BumpMap2 : BumpMap1
{
? technique ati8500
? {
??? pass 0
??? {
????? texture_unit NormalMap
????? {
??????? texture BumpyMetalNM.png
????? }
??? }
? }
}
在上面的例子中,如果texture_unit的名稱NormalMap在父材質(zhì)中指定過(guò),那么現(xiàn)在的行為表示override,如果它是一個(gè)新的名字,那么表示在pass的最后新加一個(gè)texture unit。
紋理別名
在源材質(zhì)被clone時(shí),每個(gè)texture unit可以被賦于一個(gè)Texture alias(別名)。可以用這個(gè)別名來(lái)指定使用什么紋理。格式: texture_alias <name> 缺省: texutre_unit <name>( 紋理單元的名字)
texture_unit DiffuseTex
{
? texture diffuse.jpg
}
在這種情況下,texture_alias為DiffuseTex.
material TSNormalSpecMapping
{
? technique GLSL
? {
??? pass
??? {?
????? texture_unit NormalMap
????? {
??????? texture defaultNM.png
??????? tex_coord_set 0
??????? filtering trilinear
????? }
?????? texture_unit DiffuseMap
????? {
??????? texture defaultDiff.png
??????? filtering trilinear
??????? tex_coord_set 1
????? }
??????? texture_unit SpecMap
????? {
??????? texture defaultSpec.png
??????? filtering trilinear
??????? tex_coord_set 2
????? }
??? }?
? }
? technique HLSL_DX9
? {
??? pass
??? {?
??????? texture_unit
????? {
??????? texture_alias NormalMap
??????? texture defaultNM.png
??????? tex_coord_set 0
??????? filtering trilinear
????? }
????? texture_unit
????? {
??????? texture_alias DiffuseMap
??????? texture defaultDiff.png
??????? filtering trilinear
??????? tex_coord_set 1
????? }
????? texture_unit
????? {
??????? texture_alias SpecMap
??????? texture defaultSpec.png
??????? filtering trilinear
??????? tex_coord_set 2
????? }
??? }?
? }
}
例子中有兩個(gè)技術(shù),都使用相同的紋理,第一個(gè)技術(shù)使用缺省的方式定義了紋理別名,第二個(gè)技術(shù)顯式地指定紋理別名。兩者都有相對(duì)應(yīng)的同樣的紋理別名。如果想定義一個(gè)材質(zhì)只是想使用不同的紋理,那么copy父材質(zhì)時(shí)可以使用set_texture_alias來(lái)重新指定新紋理。
material fxTest : TSNormalSpecMapping
{
? set_texture_alias NormalMap fxTestNMap.png
? set_texture_alias DiffuseMap fxTestDiff.png
? set_texture_alias SpecMap fxTestMap.png
}
上面代碼就對(duì)擁有指定別名的texture unit所使用的紋理圖片進(jìn)行了重新指定。
posted on 2007-03-13 15:57
清源游民 閱讀(1517)
評(píng)論(0) 編輯 收藏 引用 所屬分類:
OGRE