欢迎来到天天文库
浏览记录
ID:8981052
大小:78.50 KB
页数:23页
时间:2018-04-13
《unity烘焙材质到单一贴图的脚本》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、本文由麦可网收集整理,转载请注明出处。Unity烘焙材质到单一贴图的脚本这个脚本由CocoaChina版主“四角钱”分享,可以将复杂的材质(比如有法线贴图的材质)进行"烘焙",转变为单一的贴图。可用来将Unity的游戏移植到移动平台时候使用。请将脚本放Editor文件夹里,使用时选择一个Material材质,然后在菜单种"Custom/BakeMaterial"打开并调整照明和其他参数,点击Bake按钮就会生成一个单一的贴图。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;本文由麦可网收集整理,转载请注明出处。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);本文由麦可网收集整理,转载请注明出处。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+本文由麦可网收集整理,转载请注明出处。".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
7、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+本文由麦可网收集整理,转载请注明出处。".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
此文档下载收益归作者所有