initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
|
@ -0,0 +1,92 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor.Rendering.Universal;
|
||||
|
||||
namespace UnityEditor.Rendering.Universal.ShaderGUI
|
||||
{
|
||||
internal class BakedLitShader : BaseShaderGUI
|
||||
{
|
||||
// Properties
|
||||
private BakedLitGUI.BakedLitProperties shadingModelProperties;
|
||||
|
||||
// collect properties from the material properties
|
||||
public override void FindProperties(MaterialProperty[] properties)
|
||||
{
|
||||
base.FindProperties(properties);
|
||||
shadingModelProperties = new BakedLitGUI.BakedLitProperties(properties);
|
||||
}
|
||||
|
||||
// material changed check
|
||||
public override void ValidateMaterial(Material material)
|
||||
{
|
||||
SetMaterialKeywords(material);
|
||||
}
|
||||
|
||||
// material main surface options
|
||||
public override void DrawSurfaceOptions(Material material)
|
||||
{
|
||||
if (material == null)
|
||||
throw new ArgumentNullException("material");
|
||||
|
||||
// Use default labelWidth
|
||||
EditorGUIUtility.labelWidth = 0f;
|
||||
|
||||
base.DrawSurfaceOptions(material);
|
||||
}
|
||||
|
||||
// material main surface inputs
|
||||
public override void DrawSurfaceInputs(Material material)
|
||||
{
|
||||
base.DrawSurfaceInputs(material);
|
||||
BakedLitGUI.Inputs(shadingModelProperties, materialEditor);
|
||||
DrawTileOffset(materialEditor, baseMapProp);
|
||||
}
|
||||
|
||||
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
|
||||
{
|
||||
if (material == null)
|
||||
throw new ArgumentNullException("material");
|
||||
|
||||
// _Emission property is lost after assigning Standard shader to the material
|
||||
// thus transfer it before assigning the new shader
|
||||
if (material.HasProperty("_Emission"))
|
||||
{
|
||||
material.SetColor("_EmissionColor", material.GetColor("_Emission"));
|
||||
}
|
||||
|
||||
base.AssignNewShaderToMaterial(material, oldShader, newShader);
|
||||
|
||||
if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
|
||||
{
|
||||
SetupMaterialBlendMode(material);
|
||||
return;
|
||||
}
|
||||
|
||||
SurfaceType surfaceType = SurfaceType.Opaque;
|
||||
BlendMode blendMode = BlendMode.Alpha;
|
||||
if (oldShader.name.Contains("/Transparent/Cutout/"))
|
||||
{
|
||||
surfaceType = SurfaceType.Opaque;
|
||||
material.SetFloat("_AlphaClip", 1);
|
||||
}
|
||||
else if (oldShader.name.Contains("/Transparent/"))
|
||||
{
|
||||
// NOTE: legacy shaders did not provide physically based transparency
|
||||
// therefore Fade mode
|
||||
surfaceType = SurfaceType.Transparent;
|
||||
blendMode = BlendMode.Alpha;
|
||||
}
|
||||
material.SetFloat("_Blend", (float)blendMode);
|
||||
|
||||
material.SetFloat("_Surface", (float)surfaceType);
|
||||
if (surfaceType == SurfaceType.Opaque)
|
||||
{
|
||||
material.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8176ef27c50d1485084b4ab6f1554353
|
||||
timeCreated: 1504689095
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Rendering.Universal.ShaderGUI
|
||||
{
|
||||
internal class LitShader : BaseShaderGUI
|
||||
{
|
||||
static readonly string[] workflowModeNames = Enum.GetNames(typeof(LitGUI.WorkflowMode));
|
||||
|
||||
private LitGUI.LitProperties litProperties;
|
||||
private LitDetailGUI.LitProperties litDetailProperties;
|
||||
|
||||
public override void FillAdditionalFoldouts(MaterialHeaderScopeList materialScopesList)
|
||||
{
|
||||
materialScopesList.RegisterHeaderScope(LitDetailGUI.Styles.detailInputs, Expandable.Details, _ => LitDetailGUI.DoDetailArea(litDetailProperties, materialEditor));
|
||||
}
|
||||
|
||||
// collect properties from the material properties
|
||||
public override void FindProperties(MaterialProperty[] properties)
|
||||
{
|
||||
base.FindProperties(properties);
|
||||
litProperties = new LitGUI.LitProperties(properties);
|
||||
litDetailProperties = new LitDetailGUI.LitProperties(properties);
|
||||
}
|
||||
|
||||
// material changed check
|
||||
public override void ValidateMaterial(Material material)
|
||||
{
|
||||
SetMaterialKeywords(material, LitGUI.SetMaterialKeywords, LitDetailGUI.SetMaterialKeywords);
|
||||
}
|
||||
|
||||
// material main surface options
|
||||
public override void DrawSurfaceOptions(Material material)
|
||||
{
|
||||
// Use default labelWidth
|
||||
EditorGUIUtility.labelWidth = 0f;
|
||||
|
||||
if (litProperties.workflowMode != null)
|
||||
DoPopup(LitGUI.Styles.workflowModeText, litProperties.workflowMode, workflowModeNames);
|
||||
|
||||
base.DrawSurfaceOptions(material);
|
||||
}
|
||||
|
||||
// material main surface inputs
|
||||
public override void DrawSurfaceInputs(Material material)
|
||||
{
|
||||
base.DrawSurfaceInputs(material);
|
||||
LitGUI.Inputs(litProperties, materialEditor, material);
|
||||
DrawEmissionProperties(material, true);
|
||||
DrawTileOffset(materialEditor, baseMapProp);
|
||||
}
|
||||
|
||||
// material main advanced options
|
||||
public override void DrawAdvancedOptions(Material material)
|
||||
{
|
||||
if (litProperties.reflections != null && litProperties.highlights != null)
|
||||
{
|
||||
materialEditor.ShaderProperty(litProperties.highlights, LitGUI.Styles.highlightsText);
|
||||
materialEditor.ShaderProperty(litProperties.reflections, LitGUI.Styles.reflectionsText);
|
||||
}
|
||||
|
||||
base.DrawAdvancedOptions(material);
|
||||
}
|
||||
|
||||
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
|
||||
{
|
||||
if (material == null)
|
||||
throw new ArgumentNullException("material");
|
||||
|
||||
// _Emission property is lost after assigning Standard shader to the material
|
||||
// thus transfer it before assigning the new shader
|
||||
if (material.HasProperty("_Emission"))
|
||||
{
|
||||
material.SetColor("_EmissionColor", material.GetColor("_Emission"));
|
||||
}
|
||||
|
||||
base.AssignNewShaderToMaterial(material, oldShader, newShader);
|
||||
|
||||
if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
|
||||
{
|
||||
SetupMaterialBlendMode(material);
|
||||
return;
|
||||
}
|
||||
|
||||
SurfaceType surfaceType = SurfaceType.Opaque;
|
||||
BlendMode blendMode = BlendMode.Alpha;
|
||||
if (oldShader.name.Contains("/Transparent/Cutout/"))
|
||||
{
|
||||
surfaceType = SurfaceType.Opaque;
|
||||
material.SetFloat("_AlphaClip", 1);
|
||||
}
|
||||
else if (oldShader.name.Contains("/Transparent/"))
|
||||
{
|
||||
// NOTE: legacy shaders did not provide physically based transparency
|
||||
// therefore Fade mode
|
||||
surfaceType = SurfaceType.Transparent;
|
||||
blendMode = BlendMode.Alpha;
|
||||
}
|
||||
material.SetFloat("_Blend", (float)blendMode);
|
||||
|
||||
material.SetFloat("_Surface", (float)surfaceType);
|
||||
if (surfaceType == SurfaceType.Opaque)
|
||||
{
|
||||
material.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
|
||||
}
|
||||
|
||||
if (oldShader.name.Equals("Standard (Specular setup)"))
|
||||
{
|
||||
material.SetFloat("_WorkflowMode", (float)LitGUI.WorkflowMode.Specular);
|
||||
Texture texture = material.GetTexture("_SpecGlossMap");
|
||||
if (texture != null)
|
||||
material.SetTexture("_MetallicSpecGlossMap", texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.SetFloat("_WorkflowMode", (float)LitGUI.WorkflowMode.Metallic);
|
||||
Texture texture = material.GetTexture("_MetallicGlossMap");
|
||||
if (texture != null)
|
||||
material.SetTexture("_MetallicSpecGlossMap", texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a72ab9c46e7987c40bcd48bcf9e7c0dd
|
||||
timeCreated: 1504689095
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Rendering.Universal.ShaderGUI
|
||||
{
|
||||
internal class ParticlesLitShader : BaseShaderGUI
|
||||
{
|
||||
// Properties
|
||||
private LitGUI.LitProperties litProperties;
|
||||
private ParticleGUI.ParticleProperties particleProps;
|
||||
|
||||
// List of renderers using this material in the scene, used for validating vertex streams
|
||||
List<ParticleSystemRenderer> m_RenderersUsingThisMaterial = new List<ParticleSystemRenderer>();
|
||||
|
||||
public override void FindProperties(MaterialProperty[] properties)
|
||||
{
|
||||
base.FindProperties(properties);
|
||||
litProperties = new LitGUI.LitProperties(properties);
|
||||
particleProps = new ParticleGUI.ParticleProperties(properties);
|
||||
}
|
||||
|
||||
public override void ValidateMaterial(Material material)
|
||||
{
|
||||
SetMaterialKeywords(material, LitGUI.SetMaterialKeywords, ParticleGUI.SetMaterialKeywords);
|
||||
}
|
||||
|
||||
public override void DrawSurfaceOptions(Material material)
|
||||
{
|
||||
base.DrawSurfaceOptions(material);
|
||||
DoPopup(ParticleGUI.Styles.colorMode, particleProps.colorMode, Enum.GetNames(typeof(ParticleGUI.ColorMode)));
|
||||
}
|
||||
|
||||
public override void DrawSurfaceInputs(Material material)
|
||||
{
|
||||
base.DrawSurfaceInputs(material);
|
||||
LitGUI.Inputs(litProperties, materialEditor, material);
|
||||
DrawEmissionProperties(material, true);
|
||||
}
|
||||
|
||||
public override void DrawAdvancedOptions(Material material)
|
||||
{
|
||||
materialEditor.ShaderProperty(particleProps.flipbookMode, ParticleGUI.Styles.flipbookMode);
|
||||
ParticleGUI.FadingOptions(material, materialEditor, particleProps);
|
||||
ParticleGUI.DoVertexStreamsArea(material, m_RenderersUsingThisMaterial, true);
|
||||
|
||||
DrawQueueOffsetField();
|
||||
}
|
||||
|
||||
public override void OnOpenGUI(Material material, MaterialEditor materialEditor)
|
||||
{
|
||||
CacheRenderersUsingThisMaterial(material);
|
||||
base.OnOpenGUI(material, materialEditor);
|
||||
}
|
||||
|
||||
void CacheRenderersUsingThisMaterial(Material material)
|
||||
{
|
||||
m_RenderersUsingThisMaterial.Clear();
|
||||
|
||||
ParticleSystemRenderer[] renderers = UnityEngine.Object.FindObjectsOfType(typeof(ParticleSystemRenderer)) as ParticleSystemRenderer[];
|
||||
foreach (ParticleSystemRenderer renderer in renderers)
|
||||
{
|
||||
if (renderer.sharedMaterial == material)
|
||||
m_RenderersUsingThisMaterial.Add(renderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace UnityEditor
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9818dc043dbe84466a71ed6178bbffda
|
||||
timeCreated: 1509367878
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Rendering.Universal.ShaderGUI
|
||||
{
|
||||
internal class ParticlesSimpleLitShader : BaseShaderGUI
|
||||
{
|
||||
// Properties
|
||||
private SimpleLitGUI.SimpleLitProperties shadingModelProperties;
|
||||
private ParticleGUI.ParticleProperties particleProps;
|
||||
|
||||
// List of renderers using this material in the scene, used for validating vertex streams
|
||||
List<ParticleSystemRenderer> m_RenderersUsingThisMaterial = new List<ParticleSystemRenderer>();
|
||||
|
||||
public override void FindProperties(MaterialProperty[] properties)
|
||||
{
|
||||
base.FindProperties(properties);
|
||||
shadingModelProperties = new SimpleLitGUI.SimpleLitProperties(properties);
|
||||
particleProps = new ParticleGUI.ParticleProperties(properties);
|
||||
}
|
||||
|
||||
public override void ValidateMaterial(Material material)
|
||||
{
|
||||
SetMaterialKeywords(material, SimpleLitGUI.SetMaterialKeywords, ParticleGUI.SetMaterialKeywords);
|
||||
}
|
||||
|
||||
public override void DrawSurfaceOptions(Material material)
|
||||
{
|
||||
base.DrawSurfaceOptions(material);
|
||||
DoPopup(ParticleGUI.Styles.colorMode, particleProps.colorMode, Enum.GetNames(typeof(ParticleGUI.ColorMode)));
|
||||
}
|
||||
|
||||
public override void DrawSurfaceInputs(Material material)
|
||||
{
|
||||
base.DrawSurfaceInputs(material);
|
||||
SimpleLitGUI.Inputs(shadingModelProperties, materialEditor, material);
|
||||
DrawEmissionProperties(material, true);
|
||||
}
|
||||
|
||||
public override void DrawAdvancedOptions(Material material)
|
||||
{
|
||||
SimpleLitGUI.Advanced(shadingModelProperties);
|
||||
|
||||
materialEditor.ShaderProperty(particleProps.flipbookMode, ParticleGUI.Styles.flipbookMode);
|
||||
ParticleGUI.FadingOptions(material, materialEditor, particleProps);
|
||||
ParticleGUI.DoVertexStreamsArea(material, m_RenderersUsingThisMaterial, true);
|
||||
|
||||
DrawQueueOffsetField();
|
||||
}
|
||||
|
||||
public override void OnOpenGUI(Material material, MaterialEditor materialEditor)
|
||||
{
|
||||
CacheRenderersUsingThisMaterial(material);
|
||||
base.OnOpenGUI(material, materialEditor);
|
||||
}
|
||||
|
||||
void CacheRenderersUsingThisMaterial(Material material)
|
||||
{
|
||||
m_RenderersUsingThisMaterial.Clear();
|
||||
|
||||
ParticleSystemRenderer[] renderers = UnityEngine.Object.FindObjectsOfType(typeof(ParticleSystemRenderer)) as ParticleSystemRenderer[];
|
||||
foreach (ParticleSystemRenderer renderer in renderers)
|
||||
{
|
||||
if (renderer.sharedMaterial == material)
|
||||
m_RenderersUsingThisMaterial.Add(renderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace UnityEditor
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3d80ff2d19402463c8a2a52558deaf43
|
||||
timeCreated: 1509367878
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Rendering.Universal.ShaderGUI
|
||||
{
|
||||
internal class ParticlesUnlitShader : BaseShaderGUI
|
||||
{
|
||||
// Properties
|
||||
private BakedLitGUI.BakedLitProperties shadingModelProperties;
|
||||
private ParticleGUI.ParticleProperties particleProps;
|
||||
|
||||
// List of renderers using this material in the scene, used for validating vertex streams
|
||||
List<ParticleSystemRenderer> m_RenderersUsingThisMaterial = new List<ParticleSystemRenderer>();
|
||||
|
||||
public override void FindProperties(MaterialProperty[] properties)
|
||||
{
|
||||
base.FindProperties(properties);
|
||||
shadingModelProperties = new BakedLitGUI.BakedLitProperties(properties);
|
||||
particleProps = new ParticleGUI.ParticleProperties(properties);
|
||||
}
|
||||
|
||||
public override void ValidateMaterial(Material material)
|
||||
{
|
||||
SetMaterialKeywords(material, null, ParticleGUI.SetMaterialKeywords);
|
||||
}
|
||||
|
||||
public override void DrawSurfaceOptions(Material material)
|
||||
{
|
||||
base.DrawSurfaceOptions(material);
|
||||
DoPopup(ParticleGUI.Styles.colorMode, particleProps.colorMode, Enum.GetNames(typeof(ParticleGUI.ColorMode)));
|
||||
}
|
||||
|
||||
public override void DrawSurfaceInputs(Material material)
|
||||
{
|
||||
base.DrawSurfaceInputs(material);
|
||||
BakedLitGUI.Inputs(shadingModelProperties, materialEditor);
|
||||
DrawEmissionProperties(material, true);
|
||||
}
|
||||
|
||||
public override void DrawAdvancedOptions(Material material)
|
||||
{
|
||||
materialEditor.ShaderProperty(particleProps.flipbookMode, ParticleGUI.Styles.flipbookMode);
|
||||
ParticleGUI.FadingOptions(material, materialEditor, particleProps);
|
||||
ParticleGUI.DoVertexStreamsArea(material, m_RenderersUsingThisMaterial);
|
||||
|
||||
DrawQueueOffsetField();
|
||||
}
|
||||
|
||||
public override void OnOpenGUI(Material material, MaterialEditor materialEditor)
|
||||
{
|
||||
CacheRenderersUsingThisMaterial(material);
|
||||
base.OnOpenGUI(material, materialEditor);
|
||||
}
|
||||
|
||||
void CacheRenderersUsingThisMaterial(Material material)
|
||||
{
|
||||
m_RenderersUsingThisMaterial.Clear();
|
||||
|
||||
ParticleSystemRenderer[] renderers = UnityEngine.Object.FindObjectsOfType(typeof(ParticleSystemRenderer)) as ParticleSystemRenderer[];
|
||||
foreach (ParticleSystemRenderer renderer in renderers)
|
||||
{
|
||||
if (renderer.sharedMaterial == material)
|
||||
m_RenderersUsingThisMaterial.Add(renderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace UnityEditor
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 84e6c97ce450449128b4f193da9c0263
|
||||
timeCreated: 1509367878
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Rendering.Universal.ShaderGUI
|
||||
{
|
||||
internal class SimpleLitShader : BaseShaderGUI
|
||||
{
|
||||
// Properties
|
||||
private SimpleLitGUI.SimpleLitProperties shadingModelProperties;
|
||||
|
||||
// collect properties from the material properties
|
||||
public override void FindProperties(MaterialProperty[] properties)
|
||||
{
|
||||
base.FindProperties(properties);
|
||||
shadingModelProperties = new SimpleLitGUI.SimpleLitProperties(properties);
|
||||
}
|
||||
|
||||
// material changed check
|
||||
public override void ValidateMaterial(Material material)
|
||||
{
|
||||
SetMaterialKeywords(material, SimpleLitGUI.SetMaterialKeywords);
|
||||
}
|
||||
|
||||
// material main surface options
|
||||
public override void DrawSurfaceOptions(Material material)
|
||||
{
|
||||
if (material == null)
|
||||
throw new ArgumentNullException("material");
|
||||
|
||||
// Use default labelWidth
|
||||
EditorGUIUtility.labelWidth = 0f;
|
||||
|
||||
base.DrawSurfaceOptions(material);
|
||||
}
|
||||
|
||||
// material main surface inputs
|
||||
public override void DrawSurfaceInputs(Material material)
|
||||
{
|
||||
base.DrawSurfaceInputs(material);
|
||||
SimpleLitGUI.Inputs(shadingModelProperties, materialEditor, material);
|
||||
DrawEmissionProperties(material, true);
|
||||
DrawTileOffset(materialEditor, baseMapProp);
|
||||
}
|
||||
|
||||
public override void DrawAdvancedOptions(Material material)
|
||||
{
|
||||
SimpleLitGUI.Advanced(shadingModelProperties);
|
||||
base.DrawAdvancedOptions(material);
|
||||
}
|
||||
|
||||
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
|
||||
{
|
||||
if (material == null)
|
||||
throw new ArgumentNullException("material");
|
||||
|
||||
// _Emission property is lost after assigning Standard shader to the material
|
||||
// thus transfer it before assigning the new shader
|
||||
if (material.HasProperty("_Emission"))
|
||||
{
|
||||
material.SetColor("_EmissionColor", material.GetColor("_Emission"));
|
||||
}
|
||||
|
||||
base.AssignNewShaderToMaterial(material, oldShader, newShader);
|
||||
|
||||
if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
|
||||
{
|
||||
SetupMaterialBlendMode(material);
|
||||
return;
|
||||
}
|
||||
|
||||
SurfaceType surfaceType = SurfaceType.Opaque;
|
||||
BlendMode blendMode = BlendMode.Alpha;
|
||||
if (oldShader.name.Contains("/Transparent/Cutout/"))
|
||||
{
|
||||
surfaceType = SurfaceType.Opaque;
|
||||
material.SetFloat("_AlphaClip", 1);
|
||||
}
|
||||
else if (oldShader.name.Contains("/Transparent/"))
|
||||
{
|
||||
// NOTE: legacy shaders did not provide physically based transparency
|
||||
// therefore Fade mode
|
||||
surfaceType = SurfaceType.Transparent;
|
||||
blendMode = BlendMode.Alpha;
|
||||
}
|
||||
material.SetFloat("_Surface", (float)surfaceType);
|
||||
material.SetFloat("_Blend", (float)blendMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b31b6386794884dfbb8513e510144b19
|
||||
timeCreated: 1504689095
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Rendering.Universal.ShaderGUI
|
||||
{
|
||||
internal class UnlitShader : BaseShaderGUI
|
||||
{
|
||||
// material changed check
|
||||
public override void ValidateMaterial(Material material)
|
||||
{
|
||||
SetMaterialKeywords(material);
|
||||
}
|
||||
|
||||
// material main surface options
|
||||
public override void DrawSurfaceOptions(Material material)
|
||||
{
|
||||
if (material == null)
|
||||
throw new ArgumentNullException("material");
|
||||
|
||||
// Use default labelWidth
|
||||
EditorGUIUtility.labelWidth = 0f;
|
||||
|
||||
base.DrawSurfaceOptions(material);
|
||||
}
|
||||
|
||||
// material main surface inputs
|
||||
public override void DrawSurfaceInputs(Material material)
|
||||
{
|
||||
base.DrawSurfaceInputs(material);
|
||||
DrawTileOffset(materialEditor, baseMapProp);
|
||||
}
|
||||
|
||||
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)
|
||||
{
|
||||
if (material == null)
|
||||
throw new ArgumentNullException("material");
|
||||
|
||||
// _Emission property is lost after assigning Standard shader to the material
|
||||
// thus transfer it before assigning the new shader
|
||||
if (material.HasProperty("_Emission"))
|
||||
{
|
||||
material.SetColor("_EmissionColor", material.GetColor("_Emission"));
|
||||
}
|
||||
|
||||
base.AssignNewShaderToMaterial(material, oldShader, newShader);
|
||||
|
||||
if (oldShader == null || !oldShader.name.Contains("Legacy Shaders/"))
|
||||
{
|
||||
SetupMaterialBlendMode(material);
|
||||
return;
|
||||
}
|
||||
|
||||
SurfaceType surfaceType = SurfaceType.Opaque;
|
||||
BlendMode blendMode = BlendMode.Alpha;
|
||||
if (oldShader.name.Contains("/Transparent/Cutout/"))
|
||||
{
|
||||
surfaceType = SurfaceType.Opaque;
|
||||
material.SetFloat("_AlphaClip", 1);
|
||||
}
|
||||
else if (oldShader.name.Contains("/Transparent/"))
|
||||
{
|
||||
// NOTE: legacy shaders did not provide physically based transparency
|
||||
// therefore Fade mode
|
||||
surfaceType = SurfaceType.Transparent;
|
||||
blendMode = BlendMode.Alpha;
|
||||
}
|
||||
material.SetFloat("_Blend", (float)blendMode);
|
||||
|
||||
material.SetFloat("_Surface", (float)surfaceType);
|
||||
if (surfaceType == SurfaceType.Opaque)
|
||||
{
|
||||
material.DisableKeyword("_SURFACE_TYPE_TRANSPARENT");
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ed8ed178d5584da0874d4c69e3624a9
|
||||
timeCreated: 1504689095
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue