資源描述:
《unity烘焙材質(zhì)到單一貼圖的腳本》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫(kù)。
1、本文由麥可網(wǎng)收集整理,轉(zhuǎn)載請(qǐng)注明出處。Unity烘焙材質(zhì)到單一貼圖的腳本這個(gè)腳本由CocoaChina版主“四角錢”分享,可以將復(fù)雜的材質(zhì)(比如有法線貼圖的材質(zhì))進(jìn)行"烘焙",轉(zhuǎn)變?yōu)閱我坏馁N圖??捎脕?lái)將Unity的游戲移植到移動(dòng)平臺(tái)時(shí)候使用。請(qǐng)將腳本放Editor文件夾里,使用時(shí)選擇一個(gè)Material材質(zhì),然后在菜單種"Custom/BakeMaterial"打開并調(diào)整照明和其他參數(shù),點(diǎn)擊Bake按鈕就會(huì)生成一個(gè)單一的貼圖。classBakeMaterialSettings{privatestaticvarkEditorPrefsN
2、ame="BakeMaterialSettings";staticvarkBakingLayerShouldBeUnusedInScene=30;staticvarkStandardTexNames=newArray("_MainTex","_BumpMap","_Detail","_ParallaxMap","_Parallax");varbakeAlpha=false;varbakeMainTexAsWhite=false;varminTextureResolution=8;varmaxTextureResolution=2048
3、;varemptyScene=false;varuseCustomLights=false;varambient=Color.black;本文由麥可網(wǎng)收集整理,轉(zhuǎn)載請(qǐng)注明出處。staticvarkLights=3;varenableLight=newboolean[kLights];varcolorLight=newColor[kLights];vardirLight=newVector2[kLights];functionBakeMaterialSettings(){Load();}functionLoad(){bakeAlpha=
4、EditorPrefs.GetBool(kEditorPrefsName+".bakeAlpha");bakeMainTexAsWhite=EditorPrefs.GetBool(kEditorPrefsName+".bakeMainTexAsWhite");minTextureResolution=EditorPrefs.GetInt(kEditorPrefsName+".minTextureResolution",8);maxTextureResolution=EditorPrefs.GetInt(kEditorPrefsName
5、+".maxTextureResolution",2048);本文由麥可網(wǎng)收集整理,轉(zhuǎn)載請(qǐng)注明出處。emptyScene=EditorPrefs.GetBool(kEditorPrefsName+".emptyScene");useCustomLights=EditorPrefs.GetBool(kEditorPrefsName+".useCustomLights");ambient.r=EditorPrefs.GetFloat(kEditorPrefsName+".ambient.r");ambient.g=EditorPrefs.
6、GetFloat(kEditorPrefsName+".ambient.g");ambient.b=EditorPrefs.GetFloat(kEditorPrefsName+".ambient.b");ambient.a=EditorPrefs.GetFloat(kEditorPrefsName+".ambient.a",1.0f);for(varq=0;q7、Light[q].r=EditorPrefs.GetFloat(kEditorPrefsName+".color.r"+q,0.5f);colorLight[q].g=EditorPrefs.GetFloat(kEditorPrefsName+".color.g"+q,0.5f);colorLight[q].b=EditorPrefs.GetFloat(kEditorPrefsName+本文由麥可網(wǎng)收集整理,轉(zhuǎn)載請(qǐng)注明出處。".color.b"+q,0.5f);colorLight[q].a=EditorPrefs.GetFloat(
8、kEditorPrefsName+".color.a"+q,1.0f);dirLight[q].x=EditorPrefs.GetFloat(kEditorPrefsName+".dir.x"+q);dirLight[q