浏览代码

Merge pull request #1180 from Unity-Technologies/rc-bugfixes

RC bugfixes
/main
GitHub 7 年前
当前提交
3c27f566
共有 14 个文件被更改,包括 152 次插入261 次删除
  1. 101
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightShaderGUI.cs
  2. 58
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightStandardGUI.cs
  3. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightStandardParticlesShaderGUI.cs
  4. 62
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightStandardSimpleLightingGUI.cs
  5. 117
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightUnlitGUI.cs
  6. 6
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Materials/Lightweight-Default.mat
  7. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Materials/Lightweight-StandardSimpleLighting.mat
  8. 13
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl
  9. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Particles.hlsl
  10. 2
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/ParticlesPBR.hlsl
  11. 5
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardParticles.shader
  12. 7
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardParticlesSimpleLighting.shader
  13. 10
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardParticlesUnlit.shader
  14. 20
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardUnlit.shader

101
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightShaderGUI.cs


using System;
using UnityEditor;
using UnityEngine;

Multiply
}
public abstract void FindProperties(MaterialProperty[] props);
public abstract void ShaderPropertiesGUI(Material material);
private static class Styles
{
public static string renderingOptionsLabel = "Rendering Options";
public static string surfaceType = "Surface Type";
public static string blendingMode = "Blending Mode";
public static GUIContent twoSidedText = new GUIContent("Two Sided", "Render front and back faces");
public static GUIContent alphaClipText = new GUIContent("Alpha Clip", "Enable Alpha Clip");
public static GUIContent alphaClipThresholdText = new GUIContent("Clip Threshold", "Threshold for alpha clip");
public static readonly string[] surfaceNames = Enum.GetNames(typeof(SurfaceType));
public static readonly string[] blendNames = Enum.GetNames(typeof(BlendMode));
}
protected MaterialEditor m_MaterialEditor;
protected MaterialProperty surfaceTypeProp;
protected MaterialProperty blendModeProp;
protected MaterialProperty cullingProp;
protected MaterialProperty alphaClipProp;
protected MaterialProperty alphaCutoffProp;
private bool m_FirstTimeApply = true;
public virtual void FindProperties(MaterialProperty[] properties)
{
surfaceTypeProp = FindProperty("_Surface", properties);
blendModeProp = FindProperty("_Blend", properties);
cullingProp = FindProperty("_Cull", properties);
alphaClipProp = FindProperty("_AlphaClip", properties);
alphaCutoffProp = FindProperty("_Cutoff", properties);
}
public virtual void ShaderPropertiesGUI(Material material)
{
DoPopup(Styles.surfaceType, surfaceTypeProp, Styles.surfaceNames);
if ((SurfaceType)material.GetFloat("_Surface") == SurfaceType.Transparent)
DoPopup(Styles.blendingMode, blendModeProp, Styles.blendNames);
EditorGUI.BeginChangeCheck();
bool twoSidedEnabled = EditorGUILayout.Toggle(Styles.twoSidedText, cullingProp.floatValue == 0);
if (EditorGUI.EndChangeCheck())
cullingProp.floatValue = twoSidedEnabled ? 0 : 2;
EditorGUI.BeginChangeCheck();
bool alphaClipEnabled = EditorGUILayout.Toggle(Styles.alphaClipText, alphaClipProp.floatValue == 1);
if (EditorGUI.EndChangeCheck())
alphaClipProp.floatValue = alphaClipEnabled ? 1 : 0;
if (alphaClipProp.floatValue == 1)
m_MaterialEditor.ShaderProperty(alphaCutoffProp, Styles.alphaClipThresholdText, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
EditorGUILayout.Space();
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
{
FindProperties(properties); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly

ShaderPropertiesGUI(material);
}
protected void DoPopup(string label, MaterialProperty property, string[] options)
{
EditorGUI.showMixedValue = property.hasMixedValue;
var mode = property.floatValue;
EditorGUI.BeginChangeCheck();
mode = EditorGUILayout.Popup(label, (int)mode, options);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo(label);
property.floatValue = (float)mode;
}
EditorGUI.showMixedValue = false;
}
if(alphaClip)
if (alphaClip)
if(surfaceType == SurfaceType.Opaque)
if (surfaceType == SurfaceType.Opaque)
{
material.SetOverrideTag("RenderType", "");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);

material.SetShaderPassEnabled("ShadowCaster", true);
}
else
{
{
BlendMode blendMode = (BlendMode)material.GetFloat("_Blend");
switch (blendMode)
{

}
}
protected MaterialEditor m_MaterialEditor;
private bool m_FirstTimeApply = true;
protected void DoPopup(string label, MaterialProperty property, string[] options)
{
EditorGUI.showMixedValue = property.hasMixedValue;
var mode = property.floatValue;
EditorGUI.BeginChangeCheck();
mode = EditorGUILayout.Popup(label, (int)mode, options);
if (EditorGUI.EndChangeCheck())
{
m_MaterialEditor.RegisterPropertyChangeUndo(label);
property.floatValue = (float)mode;
}
EditorGUI.showMixedValue = false;
}
protected void DoMaterialRenderingOptions()
{
EditorGUILayout.Space();
GUILayout.Label(Styles.renderingOptionsLabel, EditorStyles.boldLabel);
m_MaterialEditor.EnableInstancingField();
m_MaterialEditor.DoubleSidedGIField();
}
}

58
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightStandardGUI.cs


private static class Styles
{
public static GUIContent twoSidedText = new GUIContent("Two Sided", "Render front and back faces");
public static GUIContent alphaClipText = new GUIContent("Alpha Clip", "Enable Alpha Clip");
public static GUIContent clipThresholdText = new GUIContent("Clip Threshold", "Threshold for alpha clip");
public static GUIContent specularMapText = new GUIContent("Specular", "Specular (RGB) and Smoothness (A)");
public static GUIContent metallicMapText = new GUIContent("Metallic", "Metallic (R) and Smoothness (A)");
public static GUIContent smoothnessText = new GUIContent("Smoothness", "Smoothness value");

public static GUIContent bumpScaleNotSupported = new GUIContent("Bump scale is not supported on mobile platforms");
public static GUIContent fixNow = new GUIContent("Fix now");
public static string primaryMapsText = "Main Maps";
public static string secondaryMapsText = "Secondary Maps";
public static string forwardText = "Forward Rendering Options";
public static string surfaceProperties = "Surface Properties";
public static string surfaceType = "Surface Type";
public static string blendingMode = "Blending Mode";
public static string advancedText = "Advanced Options";
public static readonly string[] surfaceNames = Enum.GetNames(typeof(SurfaceType));
public static readonly string[] blendNames = Enum.GetNames(typeof(BlendMode));
private MaterialProperty surfaceType;
private MaterialProperty blendMode;
private MaterialProperty culling;
private MaterialProperty alphaClip;
private MaterialProperty alphaThreshold;
private MaterialProperty smoothness;
private MaterialProperty smoothnessScale;

public override void FindProperties(MaterialProperty[] properties)
{
base.FindProperties(properties);
surfaceType = FindProperty("_Surface", properties);
blendMode = FindProperty("_Blend", properties);
culling = FindProperty("_Cull", properties);
alphaClip = FindProperty("_AlphaClip", properties);
alphaThreshold = FindProperty("_Cutoff", properties);
smoothness = FindProperty("_Glossiness", properties);
smoothnessScale = FindProperty("_GlossMapScale", properties, false);

EditorGUI.BeginChangeCheck();
{
DoPopup(Styles.workflowModeText, workflowMode, Styles.workflowNames);
DoPopup(Styles.surfaceType, surfaceType, Styles.surfaceNames);
if ((SurfaceType)material.GetFloat("_Surface") == SurfaceType.Transparent)
DoPopup(Styles.blendingMode, blendMode, Styles.blendNames);
EditorGUI.BeginChangeCheck();
bool twoSidedEnabled = EditorGUILayout.Toggle(Styles.twoSidedText, culling.floatValue == 0);
if (EditorGUI.EndChangeCheck())
culling.floatValue = twoSidedEnabled ? 0 : 2;
EditorGUI.BeginChangeCheck();
bool alphaClipEnabled = EditorGUILayout.Toggle(Styles.alphaClipText, alphaClip.floatValue == 1);
if (EditorGUI.EndChangeCheck())
alphaClip.floatValue = alphaClipEnabled ? 1 : 0;
base.ShaderPropertiesGUI(material);
GUILayout.Label(Styles.surfaceProperties, EditorStyles.boldLabel);
// Primary properties
GUILayout.Label(Styles.primaryMapsText, EditorStyles.boldLabel);
DoAlbedoArea(material);
DoAlbedoArea();
DoMetallicSpecularArea();
DoNormalArea();

}
if (EditorGUI.EndChangeCheck())
{
foreach (var obj in blendMode.targets)
foreach (var obj in blendModeProp.targets)
EditorGUILayout.Space();
// NB renderqueue editor is not shown on purpose: we want to override it based on blend mode
GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
m_MaterialEditor.EnableInstancingField();
m_MaterialEditor.DoubleSidedGIField();
DoMaterialRenderingOptions();
}
public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader)

MaterialChanged(material);
}
void DoAlbedoArea(Material material)
void DoAlbedoArea()
if (material.GetFloat("_AlphaClip") == 1)
{
m_MaterialEditor.ShaderProperty(alphaThreshold, Styles.clipThresholdText.text, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
}
}
void DoNormalArea()

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightStandardParticlesShaderGUI.cs


metallicMap = FindProperty("_MetallicGlossMap", props, false);
metallic = FindProperty("_Metallic", props, false);
smoothness = FindProperty("_Glossiness", props, false);
bumpScale = FindProperty("_BumpScale", props);
bumpMap = FindProperty("_BumpMap", props);
bumpScale = FindProperty("_BumpScale", props, false);
bumpMap = FindProperty("_BumpMap", props, false);
emissionEnabled = FindProperty("_EmissionEnabled", props);
emissionColorForRendering = FindProperty("_EmissionColor", props);
emissionMap = FindProperty("_EmissionMap", props);

62
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightStandardSimpleLightingGUI.cs


public class LightweightStandardSimpleLightingGUI : LightweightShaderGUI
{
private const float kMinShininessValue = 0.01f;
private MaterialProperty surfaceTypeProp;
private MaterialProperty blendModeProp;
private MaterialProperty culling;
private MaterialProperty alphaClip;
private MaterialProperty alphaThresholdProp;
private MaterialProperty specularSourceProp;
private MaterialProperty glossinessSourceProp;
private MaterialProperty specularGlossMapProp;

private static class Styles
{
public static GUIContent twoSidedLabel = new GUIContent("Two Sided", "Render front and back faces");
public static GUIContent alphaClipLabel = new GUIContent("Alpha Clip", "Enable Alpha Clip");
public static GUIContent[] albedoGlosinessLabels =
{
new GUIContent("Base (RGB) Glossiness (A)", "Base Color (RGB) and Glossiness (A)"),

public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map");
public static GUIContent emissionMapLabel = new GUIContent("Emission Map", "Emission Map");
public static readonly string[] surfaceNames = Enum.GetNames(typeof(SurfaceType));
public static readonly string[] blendNames = Enum.GetNames(typeof(UpgradeBlendMode));
public static string surfaceTypeLabel = "Surface Type";
public static string blendingModeLabel = "Blending Mode";
public static string surfaceProperties = "Surface Properties";
public static string specularSourceLabel = "Specular";
public static string glossinessSourceLabel = "Glossiness Source";
public static string glossinessSource = "Glossiness Source";

public static string clipThresholdLabel = "Clip Threshold";
public static string advancedText = "Advanced Options";
surfaceTypeProp = FindProperty("_Surface", properties);
blendModeProp = FindProperty("_Blend", properties);
culling = FindProperty("_Cull", properties);
alphaClip = FindProperty("_AlphaClip", properties);
base.FindProperties(properties);
alphaThresholdProp = FindProperty("_Cutoff", properties);
specularSourceProp = FindProperty("_SpecSource", properties);
glossinessSourceProp = FindProperty("_GlossinessSource", properties);
specularGlossMapProp = FindProperty("_SpecGlossMap", properties);

{
EditorGUI.BeginChangeCheck();
{
base.ShaderPropertiesGUI(material);
GUILayout.Label(Styles.surfaceProperties, EditorStyles.boldLabel);
DoSurfaceArea();
DoSpecular();

m_MaterialEditor.TextureScaleOffsetProperty(albedoMapProp);
if (EditorGUI.EndChangeCheck())
emissionMapProp.textureScaleAndOffset = albedoMapProp.textureScaleAndOffset; // Apply the main texture scale and offset to the emission texture as well, for Enlighten's sake
}
GUILayout.Label(Styles.advancedText, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
m_MaterialEditor.EnableInstancingField();
EditorGUI.indentLevel--;
}
if (EditorGUI.EndChangeCheck())
{
foreach (var obj in blendModeProp.targets)

EditorGUILayout.Space();
EditorGUILayout.Space();
DoMaterialRenderingOptions();
}
public override void MaterialChanged(Material material)

private bool RequiresAlpha()
{
SurfaceType surfaceType = (SurfaceType) surfaceTypeProp.floatValue;
return alphaClip.floatValue > 0.0f || surfaceType == SurfaceType.Transparent;
return alphaClipProp.floatValue > 0.0f || surfaceType == SurfaceType.Transparent;
int surfaceTypeValue = (int)surfaceTypeProp.floatValue;
EditorGUI.BeginChangeCheck();
surfaceTypeValue = EditorGUILayout.Popup(Styles.surfaceTypeLabel, surfaceTypeValue, Styles.surfaceNames);
if (EditorGUI.EndChangeCheck())
surfaceTypeProp.floatValue = surfaceTypeValue;
if((SurfaceType)surfaceTypeValue == SurfaceType.Transparent)
{
int blendModeValue = (int)blendModeProp.floatValue;
EditorGUI.BeginChangeCheck();
blendModeValue = EditorGUILayout.Popup(Styles.blendingModeLabel, blendModeValue, Styles.blendNames);
if (EditorGUI.EndChangeCheck())
blendModeProp.floatValue = blendModeValue;
}
EditorGUI.BeginChangeCheck();
bool twoSidedEnabled = EditorGUILayout.Toggle(Styles.twoSidedLabel, culling.floatValue == 0);
if (EditorGUI.EndChangeCheck())
culling.floatValue = twoSidedEnabled ? 0 : 2;
EditorGUI.BeginChangeCheck();
bool alphaClipEnabled = EditorGUILayout.Toggle(Styles.alphaClipLabel, alphaClip.floatValue == 1);
if (EditorGUI.EndChangeCheck())
alphaClip.floatValue = alphaClipEnabled ? 1 : 0;
int surfaceTypeValue = (int)surfaceTypeProp.floatValue;
if ((SurfaceType)surfaceTypeValue == SurfaceType.Opaque)
{
int glossSource = (int)glossinessSourceProp.floatValue;

{
m_MaterialEditor.TexturePropertySingleLine(Styles.albedoAlphaLabel, albedoMapProp, albedoColorProp);
}
if (alphaClipEnabled)
m_MaterialEditor.ShaderProperty(alphaThresholdProp, Styles.clipThresholdLabel, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
}
private void DoSpecular()

117
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/ShaderGUI/LightweightUnlitGUI.cs


using System;
using UnityEditor;
using UnityEngine;
using UnityEditor.Experimental.Rendering.LightweightPipeline;
public enum UnlitBlendMode
{
Alpha, // Old school alpha-blending mode, fresnel does not affect amount of transparency
Additive,
Multiply
}
private MaterialProperty surfaceTypeProp;
private MaterialProperty blendModeProp;
private MaterialProperty culling;
private MaterialProperty alphaClip;
private MaterialProperty alphaCutoffProp;
public static GUIContent twoSidedLabel = new GUIContent("Two Sided", "Render front and back faces");
public static GUIContent alphaClipLabel = new GUIContent("Alpha Clip", "Enable Alpha Clip");
public static GUIContent[] mainTexLabels =
{
new GUIContent("MainTex (RGB)", "Base Color"),

public static string surfaceProperties = "Surface Properties";
public static readonly string[] surfaceNames = Enum.GetNames(typeof(SurfaceType));
public static readonly string[] blendNames = Enum.GetNames(typeof(UnlitBlendMode));
public static string surfaceTypeLabel = "Surface Type";
public static string blendingModeLabel = "Blending Mode";
public static string clipThresholdLabel = "Clip Threshold";
surfaceTypeProp = FindProperty("_Surface", properties);
blendModeProp = FindProperty("_Blend", properties);
culling = FindProperty("_Cull", properties);
alphaClip = FindProperty("_AlphaClip", properties);
base.FindProperties(properties);
alphaCutoffProp = FindProperty("_Cutoff", properties);
sampleGIProp = FindProperty("_SampleGI", properties, false);
bumpMap = FindProperty("_BumpMap", properties, false);
}

EditorGUI.BeginChangeCheck();
{
DoPopup(Styles.surfaceTypeLabel, surfaceTypeProp, Styles.surfaceNames);
base.ShaderPropertiesGUI(material);
GUILayout.Label(Styles.surfaceProperties, EditorStyles.boldLabel);
if((SurfaceType)surfaceTypeValue == SurfaceType.Transparent)
DoPopup(Styles.blendingModeLabel, blendModeProp, Styles.blendNames);
EditorGUI.BeginChangeCheck();
bool twoSidedEnabled = EditorGUILayout.Toggle(Styles.twoSidedLabel, culling.floatValue == 0);
if (EditorGUI.EndChangeCheck())
culling.floatValue = twoSidedEnabled ? 0 : 2;
EditorGUI.BeginChangeCheck();
bool alphaClipEnabled = EditorGUILayout.Toggle(Styles.alphaClipLabel, alphaClip.floatValue == 1);
if (EditorGUI.EndChangeCheck())
alphaClip.floatValue = alphaClipEnabled ? 1 : 0;
if (alphaClipProp.floatValue >= 1.0f)
surfaceTypeValue = 1;
if (alphaClipEnabled)
m_MaterialEditor.ShaderProperty(alphaCutoffProp, Styles.clipThresholdLabel, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
m_MaterialEditor.TextureScaleOffsetProperty(mainTexProp);
EditorGUILayout.Space();
EditorGUILayout.Space();
m_MaterialEditor.TextureScaleOffsetProperty(mainTexProp);
}
if (EditorGUI.EndChangeCheck())
{

EditorGUILayout.Space();
EditorGUILayout.Space();
DoMaterialRenderingOptions();
SetupMaterialBlendMode(material);
SetMaterialKeywords(material);
}
static void SetMaterialKeywords(Material material)
{
bool alphaClip = material.GetFloat("_AlphaClip") == 1;
if(alphaClip)
material.EnableKeyword("_ALPHATEST_ON");
else
material.DisableKeyword("_ALPHATEST_ON");
SurfaceType surfaceType = (SurfaceType)material.GetFloat("_Surface");
if(surfaceType == SurfaceType.Opaque)
{
material.SetOverrideTag("RenderType", "");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 1);
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = -1;
material.SetShaderPassEnabled("ShadowCaster", true);
}
else
{
UnlitBlendMode blendMode = (UnlitBlendMode)material.GetFloat("_Blend");
switch (blendMode)
{
case UnlitBlendMode.Alpha:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
material.SetShaderPassEnabled("ShadowCaster", false);
break;
case UnlitBlendMode.Additive:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.One);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
material.SetShaderPassEnabled("ShadowCaster", false);
break;
case UnlitBlendMode.Multiply:
material.SetOverrideTag("RenderType", "Transparent");
material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.DstColor);
material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
material.SetInt("_ZWrite", 0);
material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
material.SetShaderPassEnabled("ShadowCaster", false);
break;
}
}
}
}

6
ScriptableRenderPipeline/LightweightPipeline/LWRP/Materials/Lightweight-Default.mat


m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0

- _SpecSource: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.5, g: 0.5, b: 0.5, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/Materials/Lightweight-StandardSimpleLighting.mat


m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AlphaClip: 0
- _Blend: 0
- _Cull: 2
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0

- _SpecSource: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Surface: 0
- _UVSec: 0
- _ZWrite: 1
m_Colors:

13
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl


// If lightmap: sampleData.xy = lightmapUV
// If probe: sampleData.xyz = L2 SH terms
#ifdef LIGHTMAP_ON
#define SAMPLE_GI(lmName, shName, normalWSName) SampleGI(lmName, normalWSName)
half3 SampleGI(float2 sampleData, half3 normalWS)
{
return SampleLightmap(sampleData, normalWS);
}
#define SAMPLE_GI(lmName, shName, normalWSName) SampleLightmap(lmName, normalWSName)
#define SAMPLE_GI(lmName, shName, normalWSName) SampleGI(shName, normalWSName)
half3 SampleGI(half3 sampleData, half3 normalWS)
{
// If lightmap is not enabled we sample GI from SH
return SampleSHPixel(sampleData, normalWS);
}
#define SAMPLE_GI(lmName, shName, normalWSName) SampleSHPixel(shName, normalWSName)
#endif
half3 GlossyEnvironmentReflection(half3 reflectVector, half perceptualRoughness, half occlusion)

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Particles.hlsl


half4 SampleAlbedo(VertexOutputLit IN, TEXTURE2D_ARGS(albedoMap, sampler_albedoMap))
{
half4 albedo = readTexture(TEXTURE2D_PARAM(albedoMap, sampler_albedoMap), IN) * IN.color;
half4 albedo = readTexture(TEXTURE2D_PARAM(albedoMap, sampler_albedoMap), IN) * _Color;
// No distortion Support
fragColorMode(IN);

#else
half result = 1.0h;
#endif
AlphaDiscard(result, cutoff, 0.0001h);
AlphaDiscard(alpha, cutoff, 0.0001h);
return result;
}

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/ParticlesPBR.hlsl


surfaceData.smoothness = metallicGloss.g;
surfaceData.occlusion = 1.0;
surfaceData.albedo = AlphaModulate(surfaceData.albedo, albedo.a);
surfaceData.albedo = AlphaModulate(surfaceData.albedo, surfaceData.alpha);
}
#endif // LIGHTWEIGHT_PARTICLES_PBR_INCLUDED

5
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardParticles.shader


VertexOutputLit o;
OUTPUT_NORMAL(v, o);
o.color = v.color * _Color;
o.color = v.color;
// TODO: Instancing
// vertColor(v.color);
vertTexcoord(v, o);
vertFading(o, o.posWS, o.clipPos);
return o;

7
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardParticlesSimpleLighting.shader


OUTPUT_NORMAL(v, o);
o.color = v.color * _Color;
o.color = v.color;
// TODO: Instancing
// vertColor(o.color);
vertTexcoord(v, o);
vertFading(o, o.posWS, o.clipPos);
return o;

{
half4 albedo = SampleAlbedo(IN, TEXTURE2D_PARAM(_MainTex, sampler_MainTex));
half3 diffuse = AlphaModulate(albedo.rgb, albedo.a);
half3 diffuse = AlphaModulate(albedo.rgb, alpha);
half3 normalTS = SampleNormalTS(IN, TEXTURE2D_PARAM(_BumpMap, sampler_BumpMap));
half3 emission = SampleEmission(IN, _EmissionColor.rgb, TEXTURE2D_PARAM(_EmissionMap, sampler_EmissionMap));
half4 specularGloss = SampleSpecularGloss(IN, albedo.a, _SpecColor, TEXTURE2D_PARAM(_SpecGlossMap, sampler_SpecGlossMap));

10
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardParticlesUnlit.shader


o.posWS.xyz = TransformObjectToWorld(v.vertex.xyz);
o.posWS.w = ComputeFogFactor(o.clipPos.z);
o.clipPos = TransformWorldToHClip(o.posWS.xyz);
o.color = v.color * _Color;
o.color = v.color;
vertColor(o.color);
// TODO: Instancing
//vertColor(o.color);
vertTexcoord(v, o);
vertFading(o, o.posWS, o.clipPos);

half4 fragParticleUnlit(VertexOutputLit IN) : SV_Target
{
half4 albedo = SampleAlbedo(IN, TEXTURE2D_PARAM(_MainTex, sampler_MainTex));
half3 diffuse = AlphaModulate(albedo.rgb, albedo.a);
half3 diffuse = AlphaModulate(albedo.rgb, alpha);
half fogFactor = IN.posWS.w;
ApplyFogColor(result, half3(0, 0, 0), fogFactor);
return half4(result, alpha);

20
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardUnlit.shader


}
SubShader
{
Tags { "RenderType" = "Opaque" "IgnoreProjectors" = "True" "RenderPipeline" = "LightweightPipeline" "IgnoreProjector" = "True"}
Tags { "RenderType" = "Opaque" "IgnoreProjectors" = "True" "RenderPipeline" = "LightweightPipeline" }
LOD 100
Blend [_SrcBlend][_DstBlend]

#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma shader_feature _ALPHAPREMULTIPLY_ON
#pragma multi_compile_fog
#pragma multi_compile_instancing
// Lighting include is needed because of GI
#include "LWRP/ShaderLibrary/Lighting.hlsl"

{
float3 uv0AndFogCoord : TEXCOORD0; // xy: uv0, z: fogCoord
#if _SAMPLE_GI
float4 lightmapOrVertexSH : TEXCOORD1;
DECLARE_LIGHTMAP_OR_SH(lightmapUV, vertexSH, 1);
half3 normal : TEXCOORD2;
#if _NORMALMAP
half3 tangent : TEXCOORD3;

#if _SAMPLE_GI
OUTPUT_NORMAL(v, o);
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapOrVertexSH.xy);
OUTPUT_SH(o.normal, o.lightmapOrVertexSH);
OUTPUT_LIGHTMAP_UV(v.lightmapUV, unity_LightmapST, o.lightmapUV);
OUTPUT_SH(o.normal, o.vertexSH);
#endif
return o;
}

half alpha = texColor.a * _Color.a;
AlphaDiscard(alpha, _Cutoff);
#ifdef _ALPHAPREMULTIPLY_ON
color *= alpha;
#endif
#if _SAMPLE_GI
#if _NORMALMAP
half3 normalWS = TangentToWorldNormal(surfaceData.normalTS, IN.tangent, IN.binormal, IN.normal);

color *= SampleGI(IN.lightmapOrVertexSH, normalWS);
color += SAMPLE_GI(IN.lightmapUV, IN.vertexSH, normalWS);
#endif
ApplyFog(color, IN.uv0AndFogCoord.z);

正在加载...
取消
保存