没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Unity3d 烘焙到材質 腳本 BakeMaterial.js
这个脚本可以将复杂的材质,比如有法线贴图的材质进行"烘焙",转变为单一的贴图,可用来
将 Unity 的游戏移植到移动平台时候使用.
将这个脚本放 Editor 文件夹里,使用时选择一个 Material 材质,然后在菜单种"Custom/
Bake Material"打开并调整照明和其他参数,点击 Bake 按钮,就会生成一个单一的贴图.
JavaScript - BakeMaterial.js
class BakeMaterialSettings
{
private static var kEditorPrefsName = "BakeMaterialSettings";
static var kBakingLayerShouldBeUnusedInScene = 30;
static var kStandardTexNames = new Array ("_MainTex", "_BumpMap",
"_Detail", "_ParallaxMap", "_Parallax");
var bakeAlpha = false;
var bakeMainTexAsWhite = false;
var minTextureResolution = 8;
var maxTextureResolution = 2048;
var emptyScene = false;
var useCustomLights = false;
var ambient = Color.black;
static var kLights = 3;
var enableLight = new boolean[kLights];
var colorLight = new Color[kLights];
var dirLight = new Vector2[kLights];
function BakeMaterialSettings ()
{
Load ();
}
function Load ()
{
bakeAlpha = EditorPrefs.GetBool(kEditorPrefsName + ".bakeAlpha");
bakeMainTexAsWhite = EditorPrefs.GetBool(kEditorPrefsName +
".bakeMainTexAsWhite");
minTextureResolution = EditorPrefs.GetInt(kEditorPrefsName +
".minTextureResolution", 8);
maxTextureResolution = EditorPrefs.GetInt(kEditorPrefsName +
".maxTextureResolution", 2048);
emptyScene = EditorPrefs.GetBool(kEditorPrefsName + ".emptyScene");
useCustomLights = EditorPrefs.GetBool(kEditorPrefsName +
".useCustomLights");
ambient.r = EditorPrefs.GetFloat(kEditorPrefsName + ".ambient.r");
ambient.g = EditorPrefs.GetFloat(kEditorPrefsName + ".ambient.g");
ambient.b = EditorPrefs.GetFloat(kEditorPrefsName + ".ambient.b");
ambient.a = EditorPrefs.GetFloat(kEditorPrefsName + ".ambient.a", 1.0f);
for (var q = 0; q < kLights; ++q)
{
enableLight[q] = EditorPrefs.GetBool(kEditorPrefsName + ".enableLight" + q);
colorLight[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(kEditorPrefsName + ".color.a" + q,
1.0f);
dirLight[q].x = EditorPrefs.GetFloat(kEditorPrefsName + ".dir.x" + q);
dirLight[q].y = EditorPrefs.GetFloat(kEditorPrefsName + ".dir.y" + q);
}
}
function Save ()
{
EditorPrefs.SetBool(kEditorPrefsName + ".bakeAlpha", bakeAlpha);
EditorPrefs.SetBool(kEditorPrefsName + ".bakeMainTexAsWhite",
bakeMainTexAsWhite);
EditorPrefs.SetInt(kEditorPrefsName + ".minTextureResolution",
minTextureResolution);
EditorPrefs.SetInt(kEditorPrefsName + ".maxTextureResolution",
maxTextureResolution);
EditorPrefs.GetBool(kEditorPrefsName + ".emptyScene", emptyScene);
EditorPrefs.SetBool(kEditorPrefsName + ".useCustomLights",
useCustomLights);
EditorPrefs.SetFloat(kEditorPrefsName + ".ambient.r", ambient.r);
EditorPrefs.SetFloat(kEditorPrefsName + ".ambient.g", ambient.g);
EditorPrefs.SetFloat(kEditorPrefsName + ".ambient.b", ambient.b);
EditorPrefs.SetFloat(kEditorPrefsName + ".ambient.a", ambient.a);
for (var q = 0; q < kLights; ++q)
{
EditorPrefs.SetBool(kEditorPrefsName + ".enableLight" + q, enableLight[q]);
EditorPrefs.SetFloat(kEditorPrefsName + ".color.r" + q, colorLight[q].r);
EditorPrefs.SetFloat(kEditorPrefsName + ".color.g" + q, colorLight[q].g);
EditorPrefs.SetFloat(kEditorPrefsName + ".color.b" + q, colorLight[q].b);
EditorPrefs.SetFloat(kEditorPrefsName + ".color.a" + q, colorLight[q].a);
EditorPrefs.SetFloat(kEditorPrefsName + ".dir.x" + q, dirLight[q].x);
EditorPrefs.SetFloat(kEditorPrefsName + ".dir.y" + q, dirLight[q].y);
}
}
}
剩余11页未读,继续阅读
资源评论
- would20082017-11-09不错的东西!!!
- qq_304867072019-12-23打不开没法用
alexyuanlei
- 粉丝: 4
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功