memo
をテンプレートにして作成
[
トップ
] [
タイトル一覧
|
ページ一覧
|
新規
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*** Memo
- https://yusuke-hata.hatenablog.com/entry/2014/12/04/230...
- https://pknight.hatenablog.com/entry/20130201/1359713754
https://qiita.com/TestUser2021/questions/def62cf06f1da5d1...
#If VBA7 Then
openFile.nMaxFile = LenB(openFile.lpstrFile) - 1
openFile.lStructSize = LenB(openFile)
#Else
openFile.nMaxFile = Len(openFile.lpstrFile) - 1
openFile.lStructSize = Len(openFile)
#End If
https://stackoverflow.com/questions/4982680/getopenfilena...
- https://tyfkda.github.io/blog/2018/08/29/unity-render-m...
//
// SelectOARShader for oarconv by Fumi.Iseki 2015-2024 (C...
//
// see also https://github.com/MTSGJ/oarconv
//
//
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
public class SelectOARShader2 : UnityEditor.AssetPostproc...
{
private static string GeneralShader;
private static string TreeShader;
private static string EarthShader;
private static string SpecularShader;
private static string GlowShader;
private static string BrightShader;
private static string TransShader; // Alpha ...
private static string TransCutShader; // Alpha ...
private static string TransCutSoftShader; // Alpha ...
private static string TransSpecShader; // Alpha ...
private static string TransCutSpecShader; // Alpha ...
private static float colorRed = 0.0f;
private static float colorGreen = 0.0f;
private static float colorBlue = 0.0f;
private static float transparent = 1.0f; //
private static float cutoff = 0.0f;
private static float shininess = 0.0f;
private static float glow = 0.0f;
private static float bright = 0.0f;
private static float light = 0.0f;
private static int alphaMode = 0; // 0: NON...
private static bool hasAlpha = false;
// private static float shiftU = 0.0f;
// private static float shiftV = 0.0f;
// private static float scaleU = 1.0f;
// private static float scaleV = 1.0f;
// private static float rotate = 0.0f;
private static char kind = 'O'; // O: Obj...
private const string HDRP_Shader = "HDRP/Lit";
private const string URP_Shader = "Universal Rende...
private const string BINP_Shader = "Legacy Shaders/...
private const string NONE_Shader = "NONE";
private const string PhantomFolder = "Phantoms";
public enum ShaderMode
{
Opaque,
Cutout,
Fade,
Transparent,
}
void OnPreprocessModel()
{
string currentFolder = Path.GetDirectoryName(asse...
ModelImporter modelImporter = assetImporter as Mo...
modelImporter.materialImportMode = ModelImporterM...
//modelImporter.materialLocation = ModelImporterM...
modelImporter.addCollider = true;
if (currentFolder.EndsWith("/" + PhantomFolder) |...
modelImporter.addCollider = false;
}
}
static void InitialShader()
{
string _generalShader = HDRP_Shader;
Shader shdr = Shader.Find(_generalShader);
if (shdr == null) {
_generalShader = URP_Shader;
shdr = Shader.Find(_generalShader);
}
if (shdr == null) {
_generalShader = BINP_Shader;
shdr = Shader.Find(_generalShader);
}
if (shdr == null) {
GeneralShader = NONE_Shader;
}
else {
GeneralShader = _generalShader;
}
//
if (GeneralShader == HDRP_Shader) {
TreeShader = "Unlit/Transparent";
EarthShader = "HDRP/Lit";
SpecularShader = "HDRP/Lit";
//GlowShader = "HDRP/Lit";
//BrightShader = "HDRP/Lit";
TransShader = "Unlit/Transparent"; ...
//TransCutShader = "Unlit/Transparent"; ...
//TransCutSoftShader= "Unlit/Transparent"; ...
//TransSpecShader = "Unlit/Transparent"; ...
//TransCutSpecShader= "Unlit/Transparent"; ...
}
else if (GeneralShader == URP_Shader) {
TreeShader = "Unlit/Transparent";
EarthShader = "Universal Render Pipel...
SpecularShader = "Universal Render Pipel...
//GlowShader = "Universal Render Pipel...
//BrightShader = "Universal Render Pipel...
TransShader = "Unlit/Transparent"; ...
//TransCutShader = "Unlit/Transparent"; ...
//TransCutSoftShader= "Unlit/Transparent"; ...
//TransSpecShader = "Unlit/Transparent"; ...
//TransCutSpecShader= "Unlit/Transparent"; ...
}
else if (GeneralShader == BINP_Shader) {
TreeShader = "Legacy Shaders/Transpa...
EarthShader = "Standard";
SpecularShader = "Standard";
GlowShader = "Standard";
BrightShader = "Legacy Shaders/Self-Il...
TransShader = "Legacy Shaders/Transpa...
TransCutShader = "Legacy Shaders/Transpa...
TransCutSoftShader = "Legacy Shaders/Transpa...
TransSpecShader = "Legacy Shaders/Transpa...
TransCutSpecShader = "Legacy Shaders/Transpa...
}
//Debug.Log("General Shadr = " + GeneralShader);
return;
}
static void OnPostprocessAllAssets(string[] importedA...
{
InitialShader();
if (GeneralShader == NONE_Shader) return;
//
foreach (string asset in importedAssets) {
UnityEngine.Object[] objects = null;
if (!typeof(SceneAsset).Equals(AssetDatabase....
objects = AssetDatabase.LoadAllAssetsAtPa...
}
//
if (objects!=null) {
foreach (UnityEngine.Object obj in object...
Material material = obj as Material;
if (material != null) {
if (material.name.StartsWith("MAT...
//
if (GeneralShader == HDRP_Sha...
SetMaterialShader_HDRP(ma...
}
else if (GeneralShader == URP...
SetMaterialShader_URP(mat...
}
else {
SetMaterialShader_BRP(mat...
}
//
EditorUtility.SetDirty(materi...
AssetDatabase.SaveAssetIfDirt...
}
}
}
}
}
AssetDatabase.Refresh(ImportAssetOptions.ForceUpd...
}
static void SetMaterialShader_HDRP(Material material)
{
string materialName = material.name;
getParamsFromMaterialName(materialName);
// Shader の選択 開始
material.shader = Shader.Find(GeneralShader);
if (material.HasProperty("_Smoothness")) material...
if (kind == 'T' || kind == 'G') { // Tree or Gr...
material.shader = Shader.Find(TreeShader);
}
else if (kind == 'E') { // Terrain
material.shader = Shader.Find(EarthShader);
}
// Alpha Channell
else if (hasAlpha) {
material.shader = Shader.Find(TransShader);
if (cutoff>0.0f) {
if (material.HasProperty("_AlphaCutoffEna...
if (material.HasProperty("_AlphaCutoff"))...
}
}
// Shininess
else if (shininess > 0.01f) {
material.shader = Shader.Find(SpecularShader);
}
// Shader の選択終わり
// Color
if (material.HasProperty("_BaseColor")) {
material.SetColor("_BaseColor", new Color(col...
}
else {
material.SetColor("_Color", new Color(colorRe...
}
// Shininess
if (shininess > 0.01f) {
if (material.HasProperty("_Smoothness")) mate...
if (material.HasProperty("_Metallic")) materi...
}
/*
if (material.HasProperty("_EmissiveColor")) {
//material.EnableKeyword("_EmissiveIntensity");
Color col = material.GetColor("_Color");
float fac = col.maxColorComponent;
if (fac > 0.01f) {
if (glow > 0.99f) glow = 0.99f;
col = col * (glow / fac);
}
material.SetColor("_EmissiveColor", col);
material.SetFloat("_EmissiveIntensity", 1.0f);
}*/
return;
}
static void SetMaterialShader_URP(Material material)
{
string materialName = material.name;
getParamsFromMaterialName(materialName);
// Shader の選択 開始
material.shader = Shader.Find(GeneralShader);
if (kind == 'T' || kind == 'G') { // Tree or Gr...
material.shader = Shader.Find(TreeShader);
}
else if (kind == 'E') { // Terrain
material.shader = Shader.Find(EarthShader);
}
// Alpha Channell
else if (hasAlpha) {
material.shader = Shader.Find(TransShader);
if (cutoff > 0.0f) {
if (material.HasProperty("_AlphaCutoffEna...
if (material.HasProperty("_AlphaCutoff"))...
}
}
// Shininess
else if (shininess > 0.01f) {
material.shader = Shader.Find(SpecularShader);
}
// Shader の選択終わり
//
// Color
if (material.HasProperty("_BaseColor")) {
material.SetColor("_BaseColor", new Color(col...
}
else {
material.SetColor("_Color", new Color(colorRe...
}
// Shininess
if (shininess > 0.01f) {
if (material.HasProperty("_Metallic")) materi...
}
return;
}
static void SetMaterialShader_BRP(Material material)
{
string materialName = material.name;
getParamsFromMaterialName(materialName);
//material.shader = Shader.Find(GeneralShader);
material.shader = Shader.Find("Standard");
material.SetOverrideTag("RenderType", "Tree or Gr...
material.SetFloat("_Mode", (float)ShaderMode.Cuto...
if (material.HasProperty("_Cutoff")) material.Set...
return;
if (kind == 'T' || kind == 'G') { // Tree or Gr...
material.SetOverrideTag("RenderType", "Tree o...
material.SetFloat("_Mode", (float)ShaderMode....
if (material.HasProperty("_Cutoff")) material...
return;
}
if (kind == 'E') { // Terrain
//material.shader = Shader.Find(EarthShader);
material.SetOverrideTag("RenderType", "Terrai...
material.SetFloat("_Mode", (float)ShaderMode....
if (material.HasProperty("_Metallic")) materi...
if (material.HasProperty("_SpecularHighlights...
return;
}
//
if (hasAlpha) {
if (shininess > 0.01f) {
if (cutoff > 0.01f) { // Alpha Cutoff
//material.shader = Shader.Find(Trans...
material.SetFloat("_Mode", (float)Sha...
if (material.HasProperty("_Cutoff")) ...
if (material.HasProperty("_SpecularHi...
}
else { // Alpha Blending
if (!hasAlpha) {
material.SetFloat("_Mode", (float...
//material.shader = Shader.Find(T...
if (material.HasProperty("_Cutoff...
}
else {
//material.shader = Shader.Find(T...
}
}
if (material.HasProperty("_Shininess")) m...
}
//
else {
if (cutoff > 0.01f) { // Alpha Cutoff
material.shader = Shader.Find(TransCu...
if (material.HasProperty("_Cutoff")) ...
}
else { // Alpha Blending
if (!hasAlpha) {
material.shader = Shader.Find(Tra...
if (material.HasProperty("_Cutoff...
}
else {
material.shader = Shader.Find(Tra...
}
}
}
}
//
if (transparent < 0.99f) {
material.SetFloat("_Mode", (float)ShaderMode....
material.shader = Shader.Find(TransShader);
if (material.HasProperty("_Cutoff")) material...
}
//
else if (glow > 0.02f) {
material.EnableKeyword("_EMISSION");
material.shader = Shader.Find(GlowShader);
if (material.HasProperty("_EmissionColor")) {
Color col = material.GetColor("_Color");
float fac = col.maxColorComponent;
if (fac > 0.01f) {
if (glow > 0.99f) glow = 0.99f;
col = col * (glow / fac);
}
material.SetColor("_EmissionColor", col);
}
if (material.HasProperty("_Glossiness")) mate...
}
//
else if (bright > 0.01f) {
material.shader = Shader.Find(BrightShader);
if (material.HasProperty("_Shininess")) mater...
}
//
else if (shininess > 0.01f) {
material.shader = Shader.Find(SpecularShader);
if (material.HasProperty("_Metallic")) materi...
if (material.HasProperty("_Glossiness")) mate...
}
// Color
if (material.HasProperty("_BaseColor")) {
material.SetColor("_BaseColor", new Color(col...
}
else {
material.SetColor("_Color", new Color(colorRe...
}
return;
}
private static void getParamsFromMaterialName(string ...
{
int atr_len = 32; // MTRL_ATTR_LEN /3*4 (36/3*...
//
if (name.Length >= atr_len) {
string sub = name.Substring(name.Length - atr...
string enc = sub.Replace('-', '/');
enc = enc.Replace('$', '/'); // for...
//
if (enc.Length == atr_len) {
try {
byte[] dec = Convert.FromBase64String...
colorRed = 1.0f - (float)dec[0] / ...
colorGreen = 1.0f - (float)dec[1] / ...
colorBlue = 1.0f - (float)dec[2] / ...
transparent = 1.0f - (float)dec[3] / ...
cutoff = (float)dec[4] / 255.0f;
shininess = (float)dec[5] / 255.0f;
glow = (float)dec[6] / 255.0f;
bright = (float)dec[7] / 255.0f;
light = (float)dec[8] / 255.0f;
alphaMode = (int)dec[9]/10; ...
int has_alp = (int)dec[9]%10; ...
/*
short[] tmp = new short[1];
Buffer.BlockCopy(dec, 13, tmp, 0, 2);
shiftU = (float)tmp[0] / 2000.0f;
Buffer.BlockCopy(dec, 15, tmp, 0, 2);
shiftV = (float)tmp[0] / 2000.0f;
Buffer.BlockCopy(dec, 17, tmp, 0, 2);
scaleU = (float)tmp[0] / 100.0f;
Buffer.BlockCopy(dec, 19, tmp, 0, 2);
scaleV = (float)tmp[0] / 100.0f;
Buffer.BlockCopy(dec, 21, tmp, 0, 2);
rotate = (float)tmp[0] / 2000.0f;
*/
kind = (char)dec[23];
if (cutoff > 0.9f) cutoff = 0.9f;
if (has_alp == 1) hasAlpha = true;
else hasAlpha = false;
}
catch {
UnityEngine.Debug.Log("SelectOARShade...
}
}
}
}
}
** aaaa
終了行:
*** Memo
- https://yusuke-hata.hatenablog.com/entry/2014/12/04/230...
- https://pknight.hatenablog.com/entry/20130201/1359713754
https://qiita.com/TestUser2021/questions/def62cf06f1da5d1...
#If VBA7 Then
openFile.nMaxFile = LenB(openFile.lpstrFile) - 1
openFile.lStructSize = LenB(openFile)
#Else
openFile.nMaxFile = Len(openFile.lpstrFile) - 1
openFile.lStructSize = Len(openFile)
#End If
https://stackoverflow.com/questions/4982680/getopenfilena...
- https://tyfkda.github.io/blog/2018/08/29/unity-render-m...
//
// SelectOARShader for oarconv by Fumi.Iseki 2015-2024 (C...
//
// see also https://github.com/MTSGJ/oarconv
//
//
using UnityEngine;
using UnityEditor;
using System;
using System.IO;
public class SelectOARShader2 : UnityEditor.AssetPostproc...
{
private static string GeneralShader;
private static string TreeShader;
private static string EarthShader;
private static string SpecularShader;
private static string GlowShader;
private static string BrightShader;
private static string TransShader; // Alpha ...
private static string TransCutShader; // Alpha ...
private static string TransCutSoftShader; // Alpha ...
private static string TransSpecShader; // Alpha ...
private static string TransCutSpecShader; // Alpha ...
private static float colorRed = 0.0f;
private static float colorGreen = 0.0f;
private static float colorBlue = 0.0f;
private static float transparent = 1.0f; //
private static float cutoff = 0.0f;
private static float shininess = 0.0f;
private static float glow = 0.0f;
private static float bright = 0.0f;
private static float light = 0.0f;
private static int alphaMode = 0; // 0: NON...
private static bool hasAlpha = false;
// private static float shiftU = 0.0f;
// private static float shiftV = 0.0f;
// private static float scaleU = 1.0f;
// private static float scaleV = 1.0f;
// private static float rotate = 0.0f;
private static char kind = 'O'; // O: Obj...
private const string HDRP_Shader = "HDRP/Lit";
private const string URP_Shader = "Universal Rende...
private const string BINP_Shader = "Legacy Shaders/...
private const string NONE_Shader = "NONE";
private const string PhantomFolder = "Phantoms";
public enum ShaderMode
{
Opaque,
Cutout,
Fade,
Transparent,
}
void OnPreprocessModel()
{
string currentFolder = Path.GetDirectoryName(asse...
ModelImporter modelImporter = assetImporter as Mo...
modelImporter.materialImportMode = ModelImporterM...
//modelImporter.materialLocation = ModelImporterM...
modelImporter.addCollider = true;
if (currentFolder.EndsWith("/" + PhantomFolder) |...
modelImporter.addCollider = false;
}
}
static void InitialShader()
{
string _generalShader = HDRP_Shader;
Shader shdr = Shader.Find(_generalShader);
if (shdr == null) {
_generalShader = URP_Shader;
shdr = Shader.Find(_generalShader);
}
if (shdr == null) {
_generalShader = BINP_Shader;
shdr = Shader.Find(_generalShader);
}
if (shdr == null) {
GeneralShader = NONE_Shader;
}
else {
GeneralShader = _generalShader;
}
//
if (GeneralShader == HDRP_Shader) {
TreeShader = "Unlit/Transparent";
EarthShader = "HDRP/Lit";
SpecularShader = "HDRP/Lit";
//GlowShader = "HDRP/Lit";
//BrightShader = "HDRP/Lit";
TransShader = "Unlit/Transparent"; ...
//TransCutShader = "Unlit/Transparent"; ...
//TransCutSoftShader= "Unlit/Transparent"; ...
//TransSpecShader = "Unlit/Transparent"; ...
//TransCutSpecShader= "Unlit/Transparent"; ...
}
else if (GeneralShader == URP_Shader) {
TreeShader = "Unlit/Transparent";
EarthShader = "Universal Render Pipel...
SpecularShader = "Universal Render Pipel...
//GlowShader = "Universal Render Pipel...
//BrightShader = "Universal Render Pipel...
TransShader = "Unlit/Transparent"; ...
//TransCutShader = "Unlit/Transparent"; ...
//TransCutSoftShader= "Unlit/Transparent"; ...
//TransSpecShader = "Unlit/Transparent"; ...
//TransCutSpecShader= "Unlit/Transparent"; ...
}
else if (GeneralShader == BINP_Shader) {
TreeShader = "Legacy Shaders/Transpa...
EarthShader = "Standard";
SpecularShader = "Standard";
GlowShader = "Standard";
BrightShader = "Legacy Shaders/Self-Il...
TransShader = "Legacy Shaders/Transpa...
TransCutShader = "Legacy Shaders/Transpa...
TransCutSoftShader = "Legacy Shaders/Transpa...
TransSpecShader = "Legacy Shaders/Transpa...
TransCutSpecShader = "Legacy Shaders/Transpa...
}
//Debug.Log("General Shadr = " + GeneralShader);
return;
}
static void OnPostprocessAllAssets(string[] importedA...
{
InitialShader();
if (GeneralShader == NONE_Shader) return;
//
foreach (string asset in importedAssets) {
UnityEngine.Object[] objects = null;
if (!typeof(SceneAsset).Equals(AssetDatabase....
objects = AssetDatabase.LoadAllAssetsAtPa...
}
//
if (objects!=null) {
foreach (UnityEngine.Object obj in object...
Material material = obj as Material;
if (material != null) {
if (material.name.StartsWith("MAT...
//
if (GeneralShader == HDRP_Sha...
SetMaterialShader_HDRP(ma...
}
else if (GeneralShader == URP...
SetMaterialShader_URP(mat...
}
else {
SetMaterialShader_BRP(mat...
}
//
EditorUtility.SetDirty(materi...
AssetDatabase.SaveAssetIfDirt...
}
}
}
}
}
AssetDatabase.Refresh(ImportAssetOptions.ForceUpd...
}
static void SetMaterialShader_HDRP(Material material)
{
string materialName = material.name;
getParamsFromMaterialName(materialName);
// Shader の選択 開始
material.shader = Shader.Find(GeneralShader);
if (material.HasProperty("_Smoothness")) material...
if (kind == 'T' || kind == 'G') { // Tree or Gr...
material.shader = Shader.Find(TreeShader);
}
else if (kind == 'E') { // Terrain
material.shader = Shader.Find(EarthShader);
}
// Alpha Channell
else if (hasAlpha) {
material.shader = Shader.Find(TransShader);
if (cutoff>0.0f) {
if (material.HasProperty("_AlphaCutoffEna...
if (material.HasProperty("_AlphaCutoff"))...
}
}
// Shininess
else if (shininess > 0.01f) {
material.shader = Shader.Find(SpecularShader);
}
// Shader の選択終わり
// Color
if (material.HasProperty("_BaseColor")) {
material.SetColor("_BaseColor", new Color(col...
}
else {
material.SetColor("_Color", new Color(colorRe...
}
// Shininess
if (shininess > 0.01f) {
if (material.HasProperty("_Smoothness")) mate...
if (material.HasProperty("_Metallic")) materi...
}
/*
if (material.HasProperty("_EmissiveColor")) {
//material.EnableKeyword("_EmissiveIntensity");
Color col = material.GetColor("_Color");
float fac = col.maxColorComponent;
if (fac > 0.01f) {
if (glow > 0.99f) glow = 0.99f;
col = col * (glow / fac);
}
material.SetColor("_EmissiveColor", col);
material.SetFloat("_EmissiveIntensity", 1.0f);
}*/
return;
}
static void SetMaterialShader_URP(Material material)
{
string materialName = material.name;
getParamsFromMaterialName(materialName);
// Shader の選択 開始
material.shader = Shader.Find(GeneralShader);
if (kind == 'T' || kind == 'G') { // Tree or Gr...
material.shader = Shader.Find(TreeShader);
}
else if (kind == 'E') { // Terrain
material.shader = Shader.Find(EarthShader);
}
// Alpha Channell
else if (hasAlpha) {
material.shader = Shader.Find(TransShader);
if (cutoff > 0.0f) {
if (material.HasProperty("_AlphaCutoffEna...
if (material.HasProperty("_AlphaCutoff"))...
}
}
// Shininess
else if (shininess > 0.01f) {
material.shader = Shader.Find(SpecularShader);
}
// Shader の選択終わり
//
// Color
if (material.HasProperty("_BaseColor")) {
material.SetColor("_BaseColor", new Color(col...
}
else {
material.SetColor("_Color", new Color(colorRe...
}
// Shininess
if (shininess > 0.01f) {
if (material.HasProperty("_Metallic")) materi...
}
return;
}
static void SetMaterialShader_BRP(Material material)
{
string materialName = material.name;
getParamsFromMaterialName(materialName);
//material.shader = Shader.Find(GeneralShader);
material.shader = Shader.Find("Standard");
material.SetOverrideTag("RenderType", "Tree or Gr...
material.SetFloat("_Mode", (float)ShaderMode.Cuto...
if (material.HasProperty("_Cutoff")) material.Set...
return;
if (kind == 'T' || kind == 'G') { // Tree or Gr...
material.SetOverrideTag("RenderType", "Tree o...
material.SetFloat("_Mode", (float)ShaderMode....
if (material.HasProperty("_Cutoff")) material...
return;
}
if (kind == 'E') { // Terrain
//material.shader = Shader.Find(EarthShader);
material.SetOverrideTag("RenderType", "Terrai...
material.SetFloat("_Mode", (float)ShaderMode....
if (material.HasProperty("_Metallic")) materi...
if (material.HasProperty("_SpecularHighlights...
return;
}
//
if (hasAlpha) {
if (shininess > 0.01f) {
if (cutoff > 0.01f) { // Alpha Cutoff
//material.shader = Shader.Find(Trans...
material.SetFloat("_Mode", (float)Sha...
if (material.HasProperty("_Cutoff")) ...
if (material.HasProperty("_SpecularHi...
}
else { // Alpha Blending
if (!hasAlpha) {
material.SetFloat("_Mode", (float...
//material.shader = Shader.Find(T...
if (material.HasProperty("_Cutoff...
}
else {
//material.shader = Shader.Find(T...
}
}
if (material.HasProperty("_Shininess")) m...
}
//
else {
if (cutoff > 0.01f) { // Alpha Cutoff
material.shader = Shader.Find(TransCu...
if (material.HasProperty("_Cutoff")) ...
}
else { // Alpha Blending
if (!hasAlpha) {
material.shader = Shader.Find(Tra...
if (material.HasProperty("_Cutoff...
}
else {
material.shader = Shader.Find(Tra...
}
}
}
}
//
if (transparent < 0.99f) {
material.SetFloat("_Mode", (float)ShaderMode....
material.shader = Shader.Find(TransShader);
if (material.HasProperty("_Cutoff")) material...
}
//
else if (glow > 0.02f) {
material.EnableKeyword("_EMISSION");
material.shader = Shader.Find(GlowShader);
if (material.HasProperty("_EmissionColor")) {
Color col = material.GetColor("_Color");
float fac = col.maxColorComponent;
if (fac > 0.01f) {
if (glow > 0.99f) glow = 0.99f;
col = col * (glow / fac);
}
material.SetColor("_EmissionColor", col);
}
if (material.HasProperty("_Glossiness")) mate...
}
//
else if (bright > 0.01f) {
material.shader = Shader.Find(BrightShader);
if (material.HasProperty("_Shininess")) mater...
}
//
else if (shininess > 0.01f) {
material.shader = Shader.Find(SpecularShader);
if (material.HasProperty("_Metallic")) materi...
if (material.HasProperty("_Glossiness")) mate...
}
// Color
if (material.HasProperty("_BaseColor")) {
material.SetColor("_BaseColor", new Color(col...
}
else {
material.SetColor("_Color", new Color(colorRe...
}
return;
}
private static void getParamsFromMaterialName(string ...
{
int atr_len = 32; // MTRL_ATTR_LEN /3*4 (36/3*...
//
if (name.Length >= atr_len) {
string sub = name.Substring(name.Length - atr...
string enc = sub.Replace('-', '/');
enc = enc.Replace('$', '/'); // for...
//
if (enc.Length == atr_len) {
try {
byte[] dec = Convert.FromBase64String...
colorRed = 1.0f - (float)dec[0] / ...
colorGreen = 1.0f - (float)dec[1] / ...
colorBlue = 1.0f - (float)dec[2] / ...
transparent = 1.0f - (float)dec[3] / ...
cutoff = (float)dec[4] / 255.0f;
shininess = (float)dec[5] / 255.0f;
glow = (float)dec[6] / 255.0f;
bright = (float)dec[7] / 255.0f;
light = (float)dec[8] / 255.0f;
alphaMode = (int)dec[9]/10; ...
int has_alp = (int)dec[9]%10; ...
/*
short[] tmp = new short[1];
Buffer.BlockCopy(dec, 13, tmp, 0, 2);
shiftU = (float)tmp[0] / 2000.0f;
Buffer.BlockCopy(dec, 15, tmp, 0, 2);
shiftV = (float)tmp[0] / 2000.0f;
Buffer.BlockCopy(dec, 17, tmp, 0, 2);
scaleU = (float)tmp[0] / 100.0f;
Buffer.BlockCopy(dec, 19, tmp, 0, 2);
scaleV = (float)tmp[0] / 100.0f;
Buffer.BlockCopy(dec, 21, tmp, 0, 2);
rotate = (float)tmp[0] / 2000.0f;
*/
kind = (char)dec[23];
if (cutoff > 0.9f) cutoff = 0.9f;
if (has_alp == 1) hasAlpha = true;
else hasAlpha = false;
}
catch {
UnityEngine.Debug.Log("SelectOARShade...
}
}
}
}
}
** aaaa
ページ名: