浏览代码

Material upgrader now correctly supports standards -> lit and unlits -> unlit

/main
Remy 7 年前
当前提交
b295db15
共有 10 个文件被更改,包括 108 次插入336 次删除
  1. 2
      ScriptableRenderPipeline/Core/CoreRP/Editor/TextureCombiner/TextureCombiner.cs
  2. 2
      ScriptableRenderPipeline/Core/CoreRP/Editor/TextureCombiner/TextureCombiner.shader
  3. 67
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardsToHDLitMaterialUpgrader.cs
  4. 5
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/UpgradeStandardShaderMaterials.cs
  5. 44
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Unlit/UnlitsToHDUnlitUpgrader.cs
  6. 11
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Unlit/UnlitsToHDUnlitUpgrader.cs.meta
  7. 12
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardSpecularToHDLitMaterialUpgrader.cs.meta
  8. 12
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardToHDLitMaterialUpgrader.cs.meta
  9. 145
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardSpecularToHDLitMaterialUpgrader.cs
  10. 144
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardToHDLitMaterialUpgrader.cs

2
ScriptableRenderPipeline/Core/CoreRP/Editor/TextureCombiner/TextureCombiner.cs


AssetDatabase.ImportAsset(rawPath);
Debug.Log("Import raw texture: "+rawPath);
TextureImporter rawImporter = (TextureImporter) TextureImporter.GetAtPath(rawPath);
rawImporter.textureType = TextureImporterType.Default;
rawImporter.mipmapEnabled = false;

2
ScriptableRenderPipeline/Core/CoreRP/Editor/TextureCombiner/TextureCombiner.shader


float PlotSourcetoChanel(float4 source, float param)
{
return PlotSourcetoChanel(source, param, float2(0,1) )
return PlotSourcetoChanel(source, param, float2(0,1) );
}
float4 frag (v2f i) : SV_Target

67
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardsToHDLitMaterialUpgrader.cs


RenameFloat("_Glossiness", "_Smoothness");
RenameTexture("_BumpMap", "_NormalMap");
RenameFloat("_BumpScale", "_NormalScale");
RenameTexture("_ParallaxMap", "_HeightMap");
RenameTexture("_EmissionMap", "_EmissiveColorMap");
RenameTexture("_DetailAlbedoMap", "_DetailMap");
RenameFloat("_UVSec", "_UVDetail");

SetFloat("_MaterialID", 1f);
}
if (sourceShaderName == Standard_Rough)
if (sourceShaderName == Standard_Spec)
{
SetFloat("_MaterialID", 4f);

Texture detailMaskMap;
if (hasDetailMask) detailMaskMap = TextureCombiner.GetTextureSafe(srcMaterial, "_DetailMask", Color.white);
// Build the mask map
if ( hasMetallic || hasOcclusion || hasDetailMask )
{
Texture2D maskMap;
// Smoothness
bool hasSmoothness = false;
Texture2D smoothnessMap = TextureCombiner.TextureFromColor(Color.grey);
// Get the Smoothness value that will be passed to the map.
Texture2D smoothnessSource = TextureCombiner.TextureFromColor(Color.grey);
if (srcMaterial.shader.name == Standard_Rough)
hasSmoothness = srcMaterial.GetTexture("_SpecGlossMap")!=null;
else
{
if ( (srcMaterial.shader.name != Standard_Rough) && ( srcMaterial.GetFloat("_SmoothnessTextureChannel") == 0 ) ) // Standard Rough doesn't have the smoothness source selector
if (srcMaterial.shader.name == Standard_Rough)
smoothnessMap = (Texture2D) TextureCombiner.GetTextureSafe(srcMaterial, "_SpecGlossMap", Color.grey);
else
if (srcMaterial.shader.name == Standard) smoothnessTextureChannel = "_MetallicGlossMap";
if (srcMaterial.shader.name == Standard_Spec) smoothnessTextureChannel = "_SpecGlossMap";
if ( srcMaterial.GetFloat("_SmoothnessTextureChannel") == 0 )
{
if (srcMaterial.shader.name == Standard) smoothnessTextureChannel = "_MetallicGlossMap";
if (srcMaterial.shader.name == Standard_Spec) smoothnessTextureChannel = "_SpecGlossMap";
}
smoothnessMap = (Texture2D) srcMaterial.GetTexture( smoothnessTextureChannel );
if (smoothnessMap == null || !TextureCombiner.TextureHasAlpha(smoothnessMap))
{
hasSmoothness = true;
smoothnessMap = TextureCombiner.TextureFromColor(Color.white * srcMaterial.GetFloat("_Glossiness"));
}
}
smoothnessSource = (Texture2D) srcMaterial.GetTexture( smoothnessTextureChannel );
if (smoothnessSource == null || !TextureCombiner.TextureHasAlpha(smoothnessSource))
{
smoothnessSource = TextureCombiner.TextureFromColor(Color.white * srcMaterial.GetFloat("_Glossiness"));
}
// Build the mask map
if ( hasMetallic || hasOcclusion || hasDetailMask || hasSmoothness )
{
Texture2D maskMap;
smoothnessSource, (srcMaterial.shader.name == Standard_Rough)?-4:3 // Smoothness
smoothnessMap, (srcMaterial.shader.name == Standard_Rough)?-4:3 // Smoothness Texture
);
string maskMapPath = AssetDatabase.GetAssetPath(srcMaterial);

if (srcMaterial.GetTexture("_SpecGlossMap") != null ) dstMaterial.SetColor("_SpecularColor", Color.white);
}
// ---------- Height Map ----------
bool hasHeightMap = srcMaterial.GetTexture("_ParallaxMap") != null;
if (hasHeightMap) // Enable Parallax Occlusion Mapping
{
dstMaterial.SetFloat("_DisplacementMode", 2);
dstMaterial.SetFloat("_HeightPoMAmplitude", srcMaterial.GetFloat("_Parallax") * 2f);
}
// ---------- Detail Map ----------
bool hasDetailAlbedo = srcMaterial.GetTexture("_DetailAlbedoMap") != null;
bool hasDetailNormal = srcMaterial.GetTexture("_DetailNormalMap") != null;

);
string detailMapPath = AssetDatabase.GetAssetPath(srcMaterial);
detailMapPath = detailMapPath.Remove(detailMapPath.Length-4) + "_DetailMap.png";
if (hasDetailAlbedo) detailCombiner.SetRemapping(0, 0.5f, 1f); // Remap albedo from [0;1] to [0.5;1] to compensate the change from "Lerp to white" to "Overlay" blend mode
detailMap = detailCombiner.Combine( detailMapPath );
dstMaterial.SetTexture("_DetailMap", detailMap);
}

dstMaterial.SetFloat("_SurfaceType", 0);
dstMaterial.SetFloat("_BlendMode", 0);
dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 1);
dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 1);
case 2: // Fade -> Alpha
case 2: // Fade -> Alpha + Disable preserve specular
dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 0);
case 3: // Transparent -> Alpha pre-multiply
case 3: // Transparent -> Alpha
dstMaterial.SetFloat("_BlendMode", 4);
dstMaterial.SetFloat("_BlendMode", 0);
dstMaterial.SetFloat("_EnableBlendModePreserveSpecularLighting", 1);
break;
}

}
else
intensity = 1f;
intensity = Mathf.Pow(intensity, 2.2f); // Gamma to Linear conversion
dstMaterial.SetColor("_EmissiveColor", hdrEmission);
dstMaterial.SetFloat("_EmissiveIntensity", intensity);

5
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/UpgradeStandardShaderMaterials.cs


upgraders.Add(new StandardsToHDLitMaterialUpgrader("Standard", "HDRenderPipeline/Lit"));
upgraders.Add(new StandardsToHDLitMaterialUpgrader("Standard (Specular setup)", "HDRenderPipeline/Lit"));
upgraders.Add(new StandardsToHDLitMaterialUpgrader("Standard (Roughness setup)", "HDRenderPipeline/Lit"));
upgraders.Add(new UnlitsToHDUnlitUpgrader("Unlit/Color", "HDRenderPipeline/Unlit"));
upgraders.Add(new UnlitsToHDUnlitUpgrader("Unlit/Texture", "HDRenderPipeline/Unlit"));
upgraders.Add(new UnlitsToHDUnlitUpgrader("Unlit/Transparent", "HDRenderPipeline/Unlit"));
upgraders.Add(new UnlitsToHDUnlitUpgrader("Unlit/Transparent Cutout", "HDRenderPipeline/Unlit"));
return upgraders;
}

44
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Unlit/UnlitsToHDUnlitUpgrader.cs


using UnityEngine;
using System.Collections.Generic;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class UnlitsToHDUnlitUpgrader : MaterialUpgrader
{
string Unlit_Color = "Unlit/Color";
string Unlit_Texture = "Unlit/Texture";
string Unlit_Transparent = "Unlit/Transparent";
string Unlit_Cutout = "Unlit/Transparent Cutout";
public UnlitsToHDUnlitUpgrader(string sourceShaderName, string destShaderName, MaterialFinalizer finalizer = null)
{
RenameShader(sourceShaderName, destShaderName, finalizer);
if (sourceShaderName == Unlit_Color)
RenameColor("_Color", "_UnlitColor");
else // all other unlit have a texture
RenameTexture("_MainTex", "_UnlitColorMap");
if (sourceShaderName == Unlit_Cutout)
{
RenameFloat("_Cutoff", "_AlphaCutoff");
SetFloat("_AlphaCutoffEnable", 1f);
}
else
SetFloat("_AlphaCutoffEnable", 0f);
SetFloat("_SurfaceType", (sourceShaderName == Unlit_Transparent)? 1f : 0f );
}
public override void Convert(Material srcMaterial, Material dstMaterial)
{
//dstMaterial.hideFlags = HideFlags.DontUnloadUnusedAsset;
base.Convert(srcMaterial, dstMaterial);
HDEditorUtils.ResetMaterialKeywords(dstMaterial);
}
}
}

11
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Unlit/UnlitsToHDUnlitUpgrader.cs.meta


fileFormatVersion: 2
guid: b6a8dfccb93f0a946a7bc1521ab32f43
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

12
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardSpecularToHDLitMaterialUpgrader.cs.meta


fileFormatVersion: 2
guid: 775bef174b1e2ed47972a143845e1191
timeCreated: 1479911618
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

12
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardToHDLitMaterialUpgrader.cs.meta


fileFormatVersion: 2
guid: fedbd6bc5d95f4d768cb8077e8454b4e
timeCreated: 1479851295
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

145
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardSpecularToHDLitMaterialUpgrader.cs


using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class StandardSpecularToHDLitMaterialUpgrader : MaterialUpgrader
{
public StandardSpecularToHDLitMaterialUpgrader() : this("Standard (Specular setup)", "HDRenderPipeline/Lit", LitGUI.SetupMaterialKeywordsAndPass) {}
public StandardSpecularToHDLitMaterialUpgrader(string sourceShaderName, string destShaderName, MaterialFinalizer finalizer)
{
RenameShader(sourceShaderName, destShaderName, finalizer);
RenameTexture("_MainTex", "_BaseColorMap");
RenameColor("_Color", "_BaseColor");
RenameFloat("_Glossiness", "_Smoothness");
RenameFloat("_GlossMapScale", "SmoothnessRemapMax");
RenameTexture("_BumpMap", "_NormalMap");
RenameFloat("_BumpScale", "_NormalScale");
RenameColor("_EmissionColor", "_EmissiveColor");
RenameTexture("_EmissionMap", "_EmissiveColorMap");
RenameTexture("_DetailAlbedoMap", "DetailMap");
RenameFloat("_UVSec", "_UVDetail");
SetFloat("_LinkDetailsWithBase", 0);
RenameFloat("_DetailNormalMapScale", "_DetailNormalScale");
RenameFloat("_Cutoff", "_AlphaCutoff");
RenameKeywordToFloat("_ALPHATEST_ON", "_AlphaCutoffEnable", 1f, 0f);
SetFloat("_MaterialID", 4f);
// the HD renderloop packs detail albedo and detail normals into a single texture.
// mapping the detail normal map, if any, to the detail map, should do the right thing if
// there is no detail albedo.
// Anything reasonable that can be done here?
RenameColor("_SpecColor", "_SpecularColor");
RenameTexture("_SpecGlossMap", "_SpecularColorMap");
//@TODO: Seb. Why do we multiply color by intensity
// in shader when we can just store a color?
// builtinData.emissiveColor * builtinData.emissiveIntensity
}
public override void Convert(Material srcMaterial, Material dstMaterial)
{
dstMaterial.hideFlags = HideFlags.DontUnloadUnusedAsset;
base.Convert(srcMaterial, dstMaterial);
//@TODO: Find a good way of setting up keywords etc from properties.
// Code should be shared with material UI code.
if ( srcMaterial.GetTexture("_OcclusionMap") != null ||
srcMaterial.GetTexture("_DetailMask") != null)
{
Texture2D maskMap;
// if there is a specular map, change the specular color to white
if (srcMaterial.GetTexture("_SpecGlossMap") != null ) dstMaterial.SetColor("_SpecularColor", Color.white);
// Get the Smoothness value that will be passed to the map.
string smoothnessTextureChannel = ( srcMaterial.GetFloat("_SmoothnessTextureChannel") == 0)?"_SpecGlossMap" : "_MainTex";
Texture2D smoothnessSource = (Texture2D) srcMaterial.GetTexture( smoothnessTextureChannel );
if (smoothnessSource == null || !TextureCombiner.TextureHasAlpha(smoothnessSource))
{
smoothnessSource = TextureCombiner.TextureFromColor(Color.white * srcMaterial.GetFloat("_Glossiness"));
}
TextureCombiner maskMapCombiner = new TextureCombiner(
Texture2D.blackTexture, 1,
TextureCombiner.GetTextureSafe(srcMaterial, "_OcclusionMap", Color.white), 4,
TextureCombiner.GetTextureSafe(srcMaterial, "_DetailMask", Color.white), 4,
smoothnessSource, 3
);
string maskMapPath = AssetDatabase.GetAssetPath(srcMaterial);
maskMapPath = maskMapPath.Remove(maskMapPath.Length-4) + "_MaskMap.png";
maskMap = maskMapCombiner.Combine( maskMapPath );
dstMaterial.SetTexture("_MaskMap", maskMap);
}
dstMaterial.SetFloat("_AORemapMin", 1f - srcMaterial.GetFloat("_OcclusionStrength"));
if ( srcMaterial.GetTexture("_DetailAlbedoMap") != null ||
srcMaterial.GetTexture("_DetailNormalMap") != null
)
{
Texture2D detailMap;
TextureCombiner detailCombiner = new TextureCombiner(
TextureCombiner.GetTextureSafe(srcMaterial, "_DetailAlbedoMap", Color.grey), 4,
TextureCombiner.GetTextureSafe(srcMaterial, "_DetailNormalMap", Color.grey), 1,
TextureCombiner.midGrey, 1,
TextureCombiner.GetTextureSafe(srcMaterial, "_DetailNormalMap", Color.grey), 0
);
string detailMapPath = AssetDatabase.GetAssetPath(srcMaterial);
detailMapPath = detailMapPath.Remove(detailMapPath.Length-4) + "_DetailMap.png";
detailMap = detailCombiner.Combine( detailMapPath );
dstMaterial.SetTexture("_DetailMap", detailMap);
}
// Blend Mode
int previousBlendMode = srcMaterial.GetInt("_Mode");
switch (previousBlendMode)
{
case 0: // Opaque
dstMaterial.SetFloat("_SurfaceType", 0);
dstMaterial.SetFloat("_BlendMode", 0);
dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
break;
case 1: // Cutout
dstMaterial.SetFloat("_SurfaceType", 0);
dstMaterial.SetFloat("_BlendMode", 0);
dstMaterial.SetFloat("_AlphaCutoffEnable", 1);
break;
case 2: // Fade -> Alpha
dstMaterial.SetFloat("_SurfaceType", 1);
dstMaterial.SetFloat("_BlendMode", 0);
dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
break;
case 3: // Transparent -> alpha pre-multiply
dstMaterial.SetFloat("_SurfaceType", 1);
dstMaterial.SetFloat("_BlendMode", 4);
dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
break;
}
// Emission: Convert the HDR emissive color to ldr color + intensity
Color hdrEmission = srcMaterial.GetColor("_EmissionColor");
float intensity = Mathf.Max(hdrEmission.r, Mathf.Max(hdrEmission.g, hdrEmission.b));
if (intensity > 1f)
{
hdrEmission.r /= intensity;
hdrEmission.g /= intensity;
hdrEmission.b /= intensity;
}
else
intensity = 1f;
dstMaterial.SetColor("_EmissiveColor", hdrEmission);
dstMaterial.SetFloat("_EmissiveIntensity", intensity);
HDEditorUtils.ResetMaterialKeywords(dstMaterial);
}
}
}

144
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/StandardToHDLitMaterialUpgrader.cs


using UnityEngine;
namespace UnityEditor.Experimental.Rendering.HDPipeline
{
public class StandardToHDLitMaterialUpgrader : MaterialUpgrader
{
public StandardToHDLitMaterialUpgrader() : this("Standard", "HDRenderPipeline/Lit", LitGUI.SetupMaterialKeywordsAndPass) {}
public StandardToHDLitMaterialUpgrader(string sourceShaderName, string destShaderName, MaterialFinalizer finalizer)
{
RenameShader(sourceShaderName, destShaderName, finalizer);
RenameTexture("_MainTex", "_BaseColorMap");
RenameColor("_Color", "_BaseColor");
RenameFloat("_Glossiness", "_Smoothness");
RenameTexture("_BumpMap", "_NormalMap");
RenameFloat("_BumpScale", "_NormalScale");
RenameTexture("_EmissionMap", "_EmissiveColorMap");
RenameTexture("_DetailAlbedoMap", "DetailMap");
RenameFloat("_UVSec", "_UVDetail");
SetFloat("_LinkDetailsWithBase", 0);
RenameFloat("_DetailNormalMapScale", "_DetailNormalScale");
RenameFloat("_Cutoff", "_AlphaCutoff");
RenameKeywordToFloat("_ALPHATEST_ON", "_AlphaCutoffEnable", 1f, 0f);
SetFloat("_MaterialID", 1f);
// the HD renderloop packs detail albedo and detail normals into a single texture.
// mapping the detail normal map, if any, to the detail map, should do the right thing if
// there is no detail albedo.
// Moved to convert function
// Metallic uses [Gamma] attribute in standard shader but not in Lit.
// @Seb: Should we convert?
// RenameFloat("_Metallic", "_Metallic");
//@TODO: Seb. Why do we multiply color by intensity
// in shader when we can just store a color?
// builtinData.emissiveColor * builtinData.emissiveIntensity
}
public override void Convert(Material srcMaterial, Material dstMaterial)
{
dstMaterial.hideFlags = HideFlags.DontUnloadUnusedAsset;
base.Convert(srcMaterial, dstMaterial);
//@TODO: Find a good way of setting up keywords etc from properties.
// Code should be shared with material UI code.
if ( srcMaterial.GetTexture("_MetallicGlossMap") != null ||
srcMaterial.GetTexture("_OcclusionMap") != null ||
srcMaterial.GetTexture("_DetailMask") != null)
{
Texture2D maskMap;
// Get the Smoothness value that will be passed to the map.
string smoothnessTextureChannel = ( srcMaterial.GetFloat("_SmoothnessTextureChannel") == 0)?"_MetallicGlossMap" : "_MainTex";
Texture2D smoothnessSource = (Texture2D) srcMaterial.GetTexture( smoothnessTextureChannel );
if (smoothnessSource == null || !TextureCombiner.TextureHasAlpha(smoothnessSource))
{
smoothnessSource = TextureCombiner.TextureFromColor(Color.white * srcMaterial.GetFloat("_Glossiness"));
}
TextureCombiner maskMapCombiner = new TextureCombiner(
TextureCombiner.GetTextureSafe(srcMaterial, "_MetallicGlossMap", Color.white), 4,
TextureCombiner.GetTextureSafe(srcMaterial, "_OcclusionMap", Color.white), 4,
TextureCombiner.GetTextureSafe(srcMaterial, "_DetailMask", Color.white), 4,
smoothnessSource, 3
);
string maskMapPath = AssetDatabase.GetAssetPath(srcMaterial);
maskMapPath = maskMapPath.Remove(maskMapPath.Length-4) + "_MaskMap.png";
maskMap = maskMapCombiner.Combine( maskMapPath );
dstMaterial.SetTexture("_MaskMap", maskMap);
}
dstMaterial.SetFloat("_AORemapMin", 1f - srcMaterial.GetFloat("_OcclusionStrength"));
if ( srcMaterial.GetTexture("_DetailAlbedoMap") != null ||
srcMaterial.GetTexture("_DetailNormalMap") != null
)
{
Texture2D detailMap;
TextureCombiner detailCombiner = new TextureCombiner(
TextureCombiner.GetTextureSafe(srcMaterial, "_DetailAlbedoMap", Color.grey), 4,
TextureCombiner.GetTextureSafe(srcMaterial, "_DetailNormalMap", Color.grey), 1,
TextureCombiner.midGrey, 1,
TextureCombiner.GetTextureSafe(srcMaterial, "_DetailNormalMap", Color.grey), 0
);
string detailMapPath = AssetDatabase.GetAssetPath(srcMaterial);
detailMapPath = detailMapPath.Remove(detailMapPath.Length-4) + "_DetailMap.png";
detailMap = detailCombiner.Combine( detailMapPath );
dstMaterial.SetTexture("_DetailMap", detailMap);
}
// Blend Mode
int previousBlendMode = srcMaterial.GetInt("_Mode");
switch (previousBlendMode)
{
case 0: // Opaque
dstMaterial.SetFloat("_SurfaceType", 0);
dstMaterial.SetFloat("_BlendMode", 0);
dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
break;
case 1: // Cutout
dstMaterial.SetFloat("_SurfaceType", 0);
dstMaterial.SetFloat("_BlendMode", 0);
dstMaterial.SetFloat("_AlphaCutoffEnable", 1);
break;
case 2: // Fade -> Alpha
dstMaterial.SetFloat("_SurfaceType", 1);
dstMaterial.SetFloat("_BlendMode", 0);
dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
break;
case 3: // Transparent -> alpha pre-multiply
dstMaterial.SetFloat("_SurfaceType", 1);
dstMaterial.SetFloat("_BlendMode", 4);
dstMaterial.SetFloat("_AlphaCutoffEnable", 0);
break;
}
// Emission: Convert the HDR emissive color to ldr color + intensity
Color hdrEmission = srcMaterial.GetColor("_EmissionColor");
float intensity = Mathf.Max(hdrEmission.r, Mathf.Max(hdrEmission.g, hdrEmission.b));
if (intensity > 1f)
{
hdrEmission.r /= intensity;
hdrEmission.g /= intensity;
hdrEmission.b /= intensity;
}
else
intensity = 1f;
dstMaterial.SetColor("_EmissiveColor", hdrEmission);
dstMaterial.SetFloat("_EmissiveIntensity", intensity);
HDEditorUtils.ResetMaterialKeywords(dstMaterial);
}
}
}
正在加载...
取消
保存