浏览代码

Updated inspectors to 2018.1 and remove pipeline warnings.

/main
Felipe Lira 7 年前
当前提交
f8a9d47a
共有 8 个文件被更改,包括 157 次插入544 次删除
  1. 258
      ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightCameraEditor.cs
  2. 262
      ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightLightEditor.cs
  3. 64
      ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardGUI.cs
  4. 47
      ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardParticlesShaderGUI.cs
  5. 30
      ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardSimpleLightingGUI.cs
  6. 5
      ScriptableRenderPipeline/LightweightPipeline/Editor/StandardToLightweightMaterialUpgrader.cs.meta
  7. 2
      ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs
  8. 33
      ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandard.shader

258
ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightCameraEditor.cs


using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Scripting;
using UnityEditor.Modules;
using UnityEngine.Rendering.PostProcessing;
public class LightweightameraEditor : Editor
public class LightweightameraEditor : CameraEditor
{
public class Styles
{

public readonly GUIContent clipingPlanesLabel = new GUIContent("Clipping Planes", "Distances from the camera to start and stop rendering.");
public readonly GUIContent nearPlaneLabel = new GUIContent("Near", "The closest point relative to the camera that drawing will occur.");
public readonly GUIContent farPlaneLabel = new GUIContent("Far", "The furthest point relative to the camera that drawing will occur.");
public readonly string mssaDisabledWarning = "Anti Aliasing is disabled in Lightweight Pipeline settings.";
};
private static readonly int[] kRenderingPathValues = {0};

public SerializedProperty clearFlags { get; private set; }
public SerializedProperty backgroundColor { get; private set; }
public SerializedProperty normalizedViewPortRect { get; private set; }
public SerializedProperty fieldOfView { get; private set; }
public SerializedProperty orthographic { get; private set; }
public SerializedProperty orthographicSize { get; private set; }
public SerializedProperty depth { get; private set; }
public SerializedProperty cullingMask { get; private set; }
public SerializedProperty renderingPath { get; private set; }
public SerializedProperty occlusionCulling { get; private set; }
public SerializedProperty targetTexture { get; private set; }
public SerializedProperty HDR { get; private set; }
public SerializedProperty allowMSAA { get; private set; }
public SerializedProperty allowDynamicResolution { get; private set; }
public SerializedProperty stereoConvergence { get; private set; }
public SerializedProperty stereoSeparation { get; private set; }
public SerializedProperty nearClippingPlane { get; private set; }
public SerializedProperty farClippingPlane { get; private set; }
#if ENABLE_MULTIPLE_DISPLAYS
public SerializedProperty targetDisplay { get; private set; }
#endif
public SerializedProperty targetEye { get; private set; }
private bool IsSameClearFlags { get { return !clearFlags.hasMultipleDifferentValues; } }
private bool IsSameOrthographic { get { return !orthographic.hasMultipleDifferentValues; } }
private bool IsSameClearFlags { get { return !settings.clearFlags.hasMultipleDifferentValues; } }
private bool IsSameOrthographic { get { return !settings.orthographic.hasMultipleDifferentValues; } }
readonly AnimBool showBGColorAnim = new AnimBool();
readonly AnimBool showOrthoAnim = new AnimBool();

{
SetAnimationTarget(showBGColorAnim, initialize, IsSameClearFlags && (camera.clearFlags == CameraClearFlags.SolidColor || camera.clearFlags == CameraClearFlags.Skybox));
SetAnimationTarget(showOrthoAnim, initialize, IsSameOrthographic && camera.orthographic);
SetAnimationTarget(showTargetEyeAnim, initialize, targetEye.intValue != (int)StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported);
SetAnimationTarget(showTargetEyeAnim, initialize, settings.targetEye.intValue != (int)StereoTargetEyeMask.Both || PlayerSettings.virtualRealitySupported);
private static readonly GUIContent[] kTargetEyes =
{
new GUIContent("Both"),
new GUIContent("Left"),
new GUIContent("Right"),
new GUIContent("None (Main Display)"),
};
private static readonly int[] kTargetEyeValues =
{
(int) StereoTargetEyeMask.Both, (int) StereoTargetEyeMask.Left,
(int) StereoTargetEyeMask.Right, (int) StereoTargetEyeMask.None
};
void OnEnable()
public new void OnEnable()
clearFlags = serializedObject.FindProperty("m_ClearFlags");
backgroundColor = serializedObject.FindProperty("m_BackGroundColor");
normalizedViewPortRect = serializedObject.FindProperty("m_NormalizedViewPortRect");
nearClippingPlane = serializedObject.FindProperty("near clip plane");
farClippingPlane = serializedObject.FindProperty("far clip plane");
fieldOfView = serializedObject.FindProperty("field of view");
orthographic = serializedObject.FindProperty("orthographic");
orthographicSize = serializedObject.FindProperty("orthographic size");
depth = serializedObject.FindProperty("m_Depth");
cullingMask = serializedObject.FindProperty("m_CullingMask");
occlusionCulling = serializedObject.FindProperty("m_OcclusionCulling");
targetTexture = serializedObject.FindProperty("m_TargetTexture");
HDR = serializedObject.FindProperty("m_HDR");
allowMSAA = serializedObject.FindProperty("m_AllowMSAA");
allowDynamicResolution = serializedObject.FindProperty("m_AllowDynamicResolution");
stereoConvergence = serializedObject.FindProperty("m_StereoConvergence");
stereoSeparation = serializedObject.FindProperty("m_StereoSeparation");
#if ENABLE_MULTIPLE_DISPLAYS
targetDisplay = serializedObject.FindProperty("m_TargetDisplay");
#endif
targetEye = serializedObject.FindProperty("m_TargetEye");
settings.OnEnable();
void OnDisable()
public void OnDisable()
{
showBGColorAnim.valueChanged.RemoveListener(Repaint);
showOrthoAnim.valueChanged.RemoveListener(Repaint);

}
public void DrawClearFlags()
{
EditorGUILayout.PropertyField(clearFlags,
new GUIContent(
"Clear Flags","What to display in empty areas of this Camera's view.\n\nChoose Skybox to display a skybox in empty areas, defaulting to a background color if no skybox is found.\n\nChoose Solid Color to display a background color in empty areas.\n\nChoose Depth Only to display nothing in empty areas.\n\nChoose Don't Clear to display whatever was displayed in the previous frame in empty areas."));
}
public void DrawBackgroundColor()
{
EditorGUILayout.PropertyField(backgroundColor,
new GUIContent("Background", "The Camera clears the screen to this color before rendering."));
}
public void DrawCullingMask()
{
EditorGUILayout.PropertyField(cullingMask);
}
public void DrawProjection()
{
ProjectionType projectionType = orthographic.boolValue
? ProjectionType.Orthographic
: ProjectionType.Perspective;
EditorGUI.BeginChangeCheck();
EditorGUI.showMixedValue = orthographic.hasMultipleDifferentValues;
projectionType =
(ProjectionType)
EditorGUILayout.EnumPopup(
new GUIContent(
"Projection", "How the Camera renders perspective.\n\nChoose Perspective to render objects with perspective.\n\nChoose Orthographic to render objects uniformly, with no sense of perspective."),
projectionType);
EditorGUI.showMixedValue = false;
if (EditorGUI.EndChangeCheck())
orthographic.boolValue = (projectionType == ProjectionType.Orthographic);
if (!orthographic.hasMultipleDifferentValues)
{
if (projectionType == ProjectionType.Orthographic)
EditorGUILayout.PropertyField(orthographicSize, new GUIContent("Size"));
else
EditorGUILayout.Slider(fieldOfView, 1f, 179f,
new GUIContent(
"Field of View", "The width of the Camera’s view angle, measured in degrees along the local Y axis."));
}
}
public void DrawClippingPlanes()
{
EditorGUILayout.LabelField(s_Styles.clipingPlanesLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(nearClippingPlane, s_Styles.nearPlaneLabel);
EditorGUILayout.PropertyField(farClippingPlane, s_Styles.farPlaneLabel);
EditorGUI.indentLevel--;
}
public void DrawNormalizedViewPorts()
{
EditorGUILayout.PropertyField(normalizedViewPortRect,
new GUIContent("Viewport Rect", "Four values that indicate where on the screen this camera view will be drawn. Measured in Viewport Coordinates (values 0–1)."));
}
public void DrawDepth()
{
EditorGUILayout.PropertyField(depth);
}
public void DrawRenderingPath()
private void DrawRenderingPath()
{
using (new EditorGUI.DisabledScope(true))
{

EditorGUILayout.HelpBox(s_Styles.renderingPathInfo.text, MessageType.Info);
}
public void DrawTargetTexture()
private void DrawTargetTexture()
EditorGUILayout.PropertyField(targetTexture);
// show warning if we have deferred but manual MSAA set
// only do this if the m_TargetTexture has the same values across all target cameras
EditorGUILayout.PropertyField(settings.targetTexture);
// TODO: Add fix to change target texture msaa
if (!targetTexture.hasMultipleDifferentValues)
if (!settings.targetTexture.hasMultipleDifferentValues)
var texture = targetTexture.objectReferenceValue as RenderTexture;
var texture = settings.targetTexture.objectReferenceValue as RenderTexture;
int pipelineSamplesCount = lightweightPipeline.MSAASampleCount;
if (texture && texture.antiAliasing > pipelineSamplesCount)

: "has MSAA disabled";
pipelineMSAACaps += " due to Soft Particles being enabled in the pipeline asset";
if (GUILayout.Button(s_Styles.fixNow))
lightweightPipeline.MSAASampleCount = texture.antiAliasing;
public void DrawOcclusionCulling()
{
EditorGUILayout.PropertyField(occlusionCulling);
}
public void DrawHDR()
{
EditorGUILayout.PropertyField(HDR, new GUIContent("Allow HDR"));
}
public void DrawMSAA()
{
EditorGUILayout.PropertyField(allowMSAA);
}
public void DrawDynamicResolution()
private void DrawMSAA()
EditorGUILayout.PropertyField(allowDynamicResolution);
}
public void DrawVR()
{
if (PlayerSettings.virtualRealitySupported)
EditorGUILayout.PropertyField(settings.allowMSAA);
if (settings.allowMSAA.boolValue && lightweightPipeline.MSAASampleCount <= 1)
EditorGUILayout.PropertyField(stereoSeparation);
EditorGUILayout.PropertyField(stereoConvergence);
EditorGUILayout.HelpBox(s_Styles.mssaDisabledWarning, MessageType.Warning);
if (GUILayout.Button(s_Styles.fixNow))
lightweightPipeline.MSAASampleCount = 4;
// Not supported ATM
// public void DrawMultiDisplay()
// {
//#if ENABLE_MULTIPLE_DISPLAYS
// if (ModuleManager.ShouldShowMultiDisplayOption())
// {
// int prevDisplay = targetDisplay.intValue;
// EditorGUILayout.Space();
// EditorGUILayout.IntPopup(targetDisplay, DisplayUtility.GetDisplayNames(),
// DisplayUtility.GetDisplayIndices(), EditorGUIUtility.TempContent("Target Display"));
// if (prevDisplay != targetDisplay.intValue)
// GameView.RepaintAll();
// }
//#endif
// }
public void DrawTargetEye()
{
EditorGUILayout.IntPopup(targetEye, kTargetEyes, kTargetEyeValues, new GUIContent("Target Eye"));
}
enum ProjectionType
{
Perspective,
Orthographic
};
serializedObject.Update();
settings.Update();
DrawClearFlags();
settings.DrawClearFlags();
if (group.visible) DrawBackgroundColor();
if (group.visible) settings.DrawBackgroundColor();
DrawCullingMask();
settings.DrawCullingMask();
DrawProjection();
DrawClippingPlanes();
DrawNormalizedViewPorts();
settings.DrawProjection();
settings.DrawClippingPlanes();
settings.DrawNormalizedViewPort();
DrawDepth();
settings.DrawDepth();
DrawOcclusionCulling();
DrawHDR();
DrawVR();
settings.DrawOcclusionCulling();
settings.DrawHDR();
DrawMSAA();
settings.DrawVR();
settings.DrawMultiDisplay();
if (group.visible) DrawTargetEye();
if (group.visible) settings.DrawTargetEye();
serializedObject.ApplyModifiedProperties();
settings.ApplyModifiedProperties();
}
}
}

262
ScriptableRenderPipeline/LightweightPipeline/Editor/LightweightLightEditor.cs


using UnityEngine;
using UnityEngine.Experimental.Rendering.LightweightPipeline;
// TODO: Once we can target 2018.1 we can remove many duplicated properties in this class
namespace UnityEditor.Experimental.Rendering.LightweightPipeline
{
[CanEditMultipleObjects]

SerializedProperty typeProp;
SerializedProperty rangeProp;
SerializedProperty spotAngleProp;
SerializedProperty cookieSizeProp;
SerializedProperty colorProp;
SerializedProperty intensityProp;
SerializedProperty bounceIntensityProp;
SerializedProperty cookieProp;
SerializedProperty shadowsTypeProp;
SerializedProperty shadowsStrengthProp;
SerializedProperty shadowsResolutionProp;
SerializedProperty shadowsBiasProp;
SerializedProperty shadowsNormalBiasProp;
SerializedProperty shadowsNearPlaneProp;
SerializedProperty renderModeProp;
SerializedProperty cullingMaskProp;
SerializedProperty lightmappingProp;
SerializedProperty areaSizeXProp;
SerializedProperty areaSizeYProp;
SerializedProperty bakedShadowRadiusProp;
SerializedProperty bakedShadowAngleProp;
AnimBool animShowSpotOptions = new AnimBool();
AnimBool animShowPointOptions = new AnimBool();
AnimBool animShowDirOptions = new AnimBool();

class Styles
{
public readonly GUIContent Type = new GUIContent("Type", "Specifies the current type of light. Possible types are Directional, Spot, Point, and Area lights.");
public readonly GUIContent Range = new GUIContent("Range", "Controls how far the light is emitted from the center of the object.");
public readonly GUIContent Color = new GUIContent("Color", "Controls the color being emitted by the light.");
public readonly GUIContent Intensity = new GUIContent("Intensity", "Controls the brightness of the light. Light color is multiplied by this value.");
public readonly GUIContent LightmappingMode = new GUIContent("Mode", "Specifies the light mode used to determine if and how a light will be baked. Possible modes are Baked, Mixed, and Realtime.");
public readonly GUIContent LightBounceIntensity = new GUIContent("Indirect Multiplier", "Controls the intensity of indirect light being contributed to the scene. A value of 0 will cause Realtime lights to be removed from realtime global illumination and Baked and Mixed lights to no longer emit indirect lighting. Has no effect when both Realtime and Baked Global Illumination are disabled.");
public readonly GUIContent ShadowType = new GUIContent("Shadow Type", "Specifies whether Hard Shadows, Soft Shadows, or No Shadows will be cast by the light.");
//realtime
public readonly GUIContent ShadowRealtimeSettings = new GUIContent("Realtime Shadows", "Settings for realtime direct shadows.");
public readonly GUIContent ShadowStrength = new GUIContent("Strength", "Controls how dark the shadows cast by the light will be.");
public readonly GUIContent ShadowResolution = new GUIContent("Resolution", "Controls the rendered resolution of the shadow maps. A higher resolution will increase the fidelity of shadows at the cost of GPU performance and memory usage.");
public readonly GUIContent ShadowBias = new GUIContent("Bias", "Controls the distance at which the shadows will be pushed away from the light. Useful for avoiding false self-shadowing artifacts.");
public readonly GUIContent ShadowNormalBias = new GUIContent("Normal Bias", "Controls distance at which the shadow casting surfaces will be shrunk along the surface normal. Useful for avoiding false self-shadowing artifacts.");
public readonly GUIContent ShadowNearPlane = new GUIContent("Near Plane", "Controls the value for the near clip plane when rendering shadows. Currently clamped to 0.1 units or 1% of the lights range property, whichever is lower.");
//baked
public readonly GUIContent BakedShadowRadius = new GUIContent("Baked Shadow Radius", "Controls the amount of artificial softening applied to the edges of shadows cast by the Point or Spot light.");
public readonly GUIContent BakedShadowAngle = new GUIContent("Baked Shadow Angle", "Controls the amount of artificial softening applied to the edges of shadows cast by directional lights.");
public readonly GUIContent RenderMode = new GUIContent("Render Mode", "Specifies the importance of the light which impacts lighting fidelity and performance. Options are Auto, Important, and Not Important. This only affects Forward Rendering");
public readonly GUIContent CullingMask = new GUIContent("Culling Mask", "Specifies which layers will be affected or excluded from the light's effect on objects in the scene.");
public readonly GUIContent AreaWidth = new GUIContent("Width", "Controls the width in units of the area light.");
public readonly GUIContent AreaHeight = new GUIContent("Height", "Controls the height in units of the area light.");
public readonly GUIContent IndirectBounceShadowWarning = new GUIContent("Realtime indirect bounce shadowing is not supported for Spot and Point lights.");
public readonly GUIContent[] LightmapBakeTypeTitles = { new GUIContent("Realtime"), new GUIContent("Mixed"), new GUIContent("Baked") };
public readonly int[] LightmapBakeTypeValues = { (int)LightmapBakeType.Realtime, (int)LightmapBakeType.Mixed, (int)LightmapBakeType.Baked };
private bool TypeIsSame { get { return !typeProp.hasMultipleDifferentValues; } }
private bool ShadowTypeIsSame { get { return !shadowsTypeProp.hasMultipleDifferentValues; } }
private bool LightmappingTypeIsSame { get { return !lightmappingProp.hasMultipleDifferentValues; } }
private bool TypeIsSame { get { return !settings.lightType.hasMultipleDifferentValues; } }
private bool ShadowTypeIsSame { get { return !settings.shadowsType.hasMultipleDifferentValues; } }
private bool LightmappingTypeIsSame { get { return !settings.lightmapping.hasMultipleDifferentValues; } }
private bool IsRealtime { get { return lightmappingProp.intValue == 4; } }
private bool IsCompletelyBaked { get { return lightmappingProp.intValue == 2; } }
private bool IsBakedOrMixed { get { return !IsRealtime; } }
private Texture Cookie { get { return cookieProp.objectReferenceValue as Texture; } }
private bool SpotOptionsValue { get { return TypeIsSame && LightProperty.type == LightType.Spot; } }
private bool PointOptionsValue { get { return TypeIsSame && LightProperty.type == LightType.Point; } }

// Point light realtime shadows not supported
private bool RuntimeOptionsValue { get { return TypeIsSame && (LightProperty.type != LightType.Area && LightProperty.type != LightType.Point && !IsCompletelyBaked); } }
private bool BakedShadowRadius { get { return TypeIsSame && (LightProperty.type == LightType.Point || LightProperty.type == LightType.Spot) && IsBakedOrMixed; } }
private bool BakedShadowAngle { get { return TypeIsSame && LightProperty.type == LightType.Directional && IsBakedOrMixed; } }
private bool RuntimeOptionsValue { get { return TypeIsSame && (LightProperty.type != LightType.Area && LightProperty.type != LightType.Point && !settings.isCompletelyBaked); } }
private bool BakedShadowRadius { get { return TypeIsSame && (LightProperty.type == LightType.Point || LightProperty.type == LightType.Spot) && settings.isBakedOrMixed; } }
private bool BakedShadowAngle { get { return TypeIsSame && LightProperty.type == LightType.Directional && settings.isBakedOrMixed; } }
private bool BounceWarningValue
{
get
{
return TypeIsSame && (LightProperty.type == LightType.Point || LightProperty.type == LightType.Spot) &&
LightmappingTypeIsSame && IsRealtime && !bounceIntensityProp.hasMultipleDifferentValues && bounceIntensityProp.floatValue > 0.0F;
}
}
private bool BakingWarningValue { get { return !UnityEditor.Lightmapping.bakedGI && LightmappingTypeIsSame && IsBakedOrMixed; } }
private bool BakingWarningValue { get { return !UnityEditor.Lightmapping.bakedGI && LightmappingTypeIsSame && settings.isBakedOrMixed; } }
private bool ShowLightBounceIntensity { get { return true; } }
private bool CookieWarningValue
{

!cookieProp.hasMultipleDifferentValues && Cookie && Cookie.wrapMode != TextureWrapMode.Clamp;
!settings.cookieProp.hasMultipleDifferentValues && settings.cookie && settings.cookie.wrapMode != TextureWrapMode.Clamp;
private bool IsShadowEnabled { get { return shadowsTypeProp.intValue != 0; } }
private bool IsShadowEnabled { get { return settings.shadowsType.intValue != 0; } }
private bool RealtimeShadowsWarningValue
{

ShadowTypeIsSame && IsShadowEnabled &&
LightmappingTypeIsSame && !IsCompletelyBaked;
LightmappingTypeIsSame && !settings.isCompletelyBaked;
}
}

SetOptions(animShowLightBounceIntensity, initialize, ShowLightBounceIntensity);
}
void OnEnable()
protected override void OnEnable()
typeProp = serializedObject.FindProperty("m_Type");
rangeProp = serializedObject.FindProperty("m_Range");
spotAngleProp = serializedObject.FindProperty("m_SpotAngle");
cookieSizeProp = serializedObject.FindProperty("m_CookieSize");
colorProp = serializedObject.FindProperty("m_Color");
intensityProp = serializedObject.FindProperty("m_Intensity");
bounceIntensityProp = serializedObject.FindProperty("m_BounceIntensity");
cookieProp = serializedObject.FindProperty("m_Cookie");
shadowsTypeProp = serializedObject.FindProperty("m_Shadows.m_Type");
shadowsStrengthProp = serializedObject.FindProperty("m_Shadows.m_Strength");
shadowsResolutionProp = serializedObject.FindProperty("m_Shadows.m_Resolution");
shadowsBiasProp = serializedObject.FindProperty("m_Shadows.m_Bias");
shadowsNormalBiasProp = serializedObject.FindProperty("m_Shadows.m_NormalBias");
shadowsNearPlaneProp = serializedObject.FindProperty("m_Shadows.m_NearPlane");
renderModeProp = serializedObject.FindProperty("m_RenderMode");
cullingMaskProp = serializedObject.FindProperty("m_CullingMask");
lightmappingProp = serializedObject.FindProperty("m_Lightmapping");
areaSizeXProp = serializedObject.FindProperty("m_AreaSize.x");
areaSizeYProp = serializedObject.FindProperty("m_AreaSize.y");
bakedShadowRadiusProp = serializedObject.FindProperty("m_ShadowRadius");
bakedShadowAngleProp = serializedObject.FindProperty("m_ShadowAngle");
settings.OnEnable();
public void DrawLightType()
{
EditorGUILayout.PropertyField(typeProp, s_Styles.Type);
}
public void DrawRange(bool showAreaOptions)
{
// If the light is an area light, the range is determined by other parameters.
// Therefore, disable area light's range for editing, but just update the editor field.
if (showAreaOptions)
{
GUI.enabled = false;
string areaLightToolTip = "For area lights " + rangeProp.displayName + " is computed from Width, Height and Intensity";
GUIContent areaRangeWithToolTip = new GUIContent(rangeProp.displayName, areaLightToolTip);
EditorGUILayout.FloatField(areaRangeWithToolTip, LightProperty.range);
GUI.enabled = true;
}
else
EditorGUILayout.PropertyField(rangeProp, s_Styles.Range);
}
EditorGUILayout.Slider(spotAngleProp, 1f, 179f, s_Styles.SpotAngle);
}
public void DrawArea()
{
EditorGUILayout.PropertyField(areaSizeXProp, s_Styles.AreaWidth);
EditorGUILayout.PropertyField(areaSizeYProp, s_Styles.AreaHeight);
}
public void DrawColor()
{
EditorGUILayout.PropertyField(colorProp, s_Styles.Color);
}
public void DrawLightmapping()
{
EditorGUILayout.IntPopup(lightmappingProp, s_Styles.LightmapBakeTypeTitles, s_Styles.LightmapBakeTypeValues, s_Styles.LightmappingMode);
// Warning if GI Baking disabled and m_Lightmapping isn't realtime
if (BakingWarningValue)
{
EditorGUILayout.HelpBox(s_Styles.BakingWarning.text, MessageType.Info);
}
}
public void DrawIntensity()
{
EditorGUILayout.PropertyField(intensityProp, s_Styles.Intensity);
}
public void DrawBounceIntensity()
{
EditorGUILayout.PropertyField(bounceIntensityProp, s_Styles.LightBounceIntensity);
// Indirect shadows warning (Should be removed when we support realtime indirect shadows)
if (BounceWarningValue)
{
EditorGUILayout.HelpBox(s_Styles.IndirectBounceShadowWarning.text, MessageType.Info);
}
EditorGUILayout.Slider(settings.spotAngle, 1f, 179f, s_Styles.SpotAngle);
EditorGUILayout.PropertyField(cookieProp, s_Styles.Cookie);
EditorGUILayout.PropertyField(settings.cookieProp, s_Styles.Cookie);
if (CookieWarningValue)
{

public void DrawCookieSize()
{
EditorGUILayout.PropertyField(cookieSizeProp, s_Styles.CookieSize);
}
public void DrawRenderMode()
{
EditorGUILayout.PropertyField(renderModeProp, s_Styles.RenderMode);
}
public void DrawCullingMask()
{
EditorGUILayout.PropertyField(cullingMaskProp, s_Styles.CullingMask);
}
public void DrawShadowsType()
{
EditorGUILayout.Space();
EditorGUILayout.PropertyField(shadowsTypeProp, s_Styles.ShadowType);
}
public void DrawBakedShadowRadius()
{
using (new EditorGUI.DisabledScope(shadowsTypeProp.intValue != (int)LightShadows.Soft))
{
EditorGUILayout.PropertyField(bakedShadowRadiusProp, s_Styles.BakedShadowRadius);
}
}
public void DrawBakedShadowAngle()
{
using (new EditorGUI.DisabledScope(shadowsTypeProp.intValue != (int)LightShadows.Soft))
{
EditorGUILayout.Slider(bakedShadowAngleProp, 0.0F, 90.0F, s_Styles.BakedShadowAngle);
}
}
public void DrawRuntimeShadow()
{
EditorGUILayout.LabelField(s_Styles.ShadowRealtimeSettings);
EditorGUI.indentLevel += 1;
EditorGUILayout.Slider(shadowsStrengthProp, 0f, 1f, s_Styles.ShadowStrength);
EditorGUILayout.PropertyField(shadowsResolutionProp, s_Styles.ShadowResolution);
EditorGUILayout.Slider(shadowsBiasProp, 0.0f, 2.0f, s_Styles.ShadowBias);
EditorGUILayout.Slider(shadowsNormalBiasProp, 0.0f, 3.0f, s_Styles.ShadowNormalBias);
// this min bound should match the calculation in SharedLightData::GetNearPlaneMinBound()
float nearPlaneMinBound = Mathf.Min(0.01f*rangeProp.floatValue, 0.1f);
EditorGUILayout.Slider(shadowsNearPlaneProp, nearPlaneMinBound, 10.0f, s_Styles.ShadowNearPlane);
EditorGUI.indentLevel -= 1;
EditorGUILayout.PropertyField(settings.cookieSize, s_Styles.CookieSize);
}
public override void OnInspectorGUI()

serializedObject.Update();
settings.Update();
DrawLightType();
settings.DrawLightType();
EditorGUILayout.Space();

if (group.visible) DrawRange(animShowAreaOptions.target);
if (group.visible)
settings.DrawRange(animShowAreaOptions.target);
if (group.visible) DrawSpotAngle();
if (group.visible)
DrawSpotAngle();
if (group.visible) DrawArea();
if (group.visible)
settings.DrawArea();
DrawColor();
settings.DrawColor();
if (group.visible) DrawLightmapping();
if (group.visible)
settings.DrawLightmapping();
DrawIntensity();
settings.DrawIntensity();
if (group.visible) DrawBounceIntensity();
if (group.visible)
settings.DrawBounceIntensity();
if (group.visible) DrawCookie();
if (group.visible)
DrawCookie();
if (group.visible) DrawCookieSize();
if (group.visible)
DrawCookieSize();
DrawRenderMode();
DrawCullingMask();
settings.DrawRenderMode();
settings.DrawCullingMask();
EditorGUILayout.Space();

// Shadows drop-down. Area lights can only be baked and always have shadows.
float show = 1.0f - animShowAreaOptions.faded;
using (new EditorGUILayout.FadeGroupScope(show))
DrawShadowsType();
settings.DrawShadowsType();
if (group.visible) DrawBakedShadowRadius();
if (group.visible)
settings.DrawBakedShadowRadius();
if (group.visible) DrawBakedShadowAngle();
if (group.visible)
settings.DrawBakedShadowAngle();
if (group.visible) DrawRuntimeShadow();
if (group.visible)
settings.DrawRuntimeShadow();
EditorGUI.indentLevel -= 1;
if (BakingWarningValue)

64
ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardGUI.cs


private static class Styles
{
public static GUIContent uvSetLabel = new GUIContent("UV Set");
public static GUIContent albedoText = new GUIContent("Albedo", "Albedo (RGB) and Transparency (A)");
public static GUIContent alphaCutoffText = new GUIContent("Alpha Cutoff", "Threshold for alpha cutoff");
public static GUIContent specularMapText = new GUIContent("Specular", "Specular (RGB) and Smoothness (A)");

public static GUIContent highlightsText = new GUIContent("Specular Highlights", "Specular Highlights");
public static GUIContent reflectionsText = new GUIContent("Reflections", "Glossy Reflections");
public static GUIContent normalMapText = new GUIContent("Normal Map", "Normal Map");
public static GUIContent heightMapText = new GUIContent("Height Map", "Height Map (G)");
public static GUIContent detailMaskText = new GUIContent("Detail Mask", "Mask for Secondary Maps (A)");
public static GUIContent detailAlbedoText = new GUIContent("Detail Albedo x2", "Albedo (RGB) multiplied by 2");
public static GUIContent detailNormalMapText = new GUIContent("Normal Map", "Normal Map");
public static GUIContent bumpScaleNotSupported = new GUIContent("Bump scale is not supported on mobile platforms");
public static GUIContent fixNow = new GUIContent("Fix now");

}
#pragma warning disable 0414
private MaterialProperty workflowMode = null;
private MaterialProperty blendMode = null;
private MaterialProperty workflowMode;
private MaterialProperty blendMode;
private MaterialProperty albedoColor = null;
private MaterialProperty albedoMap = null;
private MaterialProperty alphaCutoff = null;
private MaterialProperty albedoColor;
private MaterialProperty albedoMap;
private MaterialProperty alphaCutoff;
private MaterialProperty smoothness = null;
private MaterialProperty smoothnessScale = null;
private MaterialProperty smoothnessMapChannel = null;
private MaterialProperty smoothness;
private MaterialProperty smoothnessScale;
private MaterialProperty smoothnessMapChannel;
private MaterialProperty metallic = null;
private MaterialProperty specColor = null;
private MaterialProperty metallicGlossMap = null;
private MaterialProperty specGlossMap = null;
private MaterialProperty highlights = null;
private MaterialProperty reflections = null;
private MaterialProperty metallic;
private MaterialProperty specColor;
private MaterialProperty metallicGlossMap;
private MaterialProperty specGlossMap;
private MaterialProperty highlights;
private MaterialProperty reflections;
private MaterialProperty bumpScale = null;
private MaterialProperty bumpMap = null;
private MaterialProperty occlusionStrength = null;
private MaterialProperty occlusionMap = null;
private MaterialProperty heigtMapScale = null;
private MaterialProperty heightMap = null;
private MaterialProperty emissionColorForRendering = null;
private MaterialProperty emissionMap = null;
private MaterialProperty detailMask = null;
private MaterialProperty detailAlbedoMap = null;
private MaterialProperty detailNormalMapScale = null;
private MaterialProperty detailNormalMap = null;
private MaterialProperty uvSetSecondary = null;
private MaterialProperty bumpScale;
private MaterialProperty bumpMap;
private MaterialProperty occlusionStrength;
private MaterialProperty occlusionMap;
private MaterialProperty emissionColorForRendering;
private MaterialProperty emissionMap;
private const float kMaxfp16 = 65536f; // Clamp to a value that fits into fp16.
private ColorPickerHDRConfig m_ColorPickerHDRConfig = new ColorPickerHDRConfig(0f, kMaxfp16, 1 / kMaxfp16, 3f);
private bool m_FirstTimeApply = true;
#pragma warning restore 0414

bumpScale = FindProperty("_BumpScale", props);
bumpMap = FindProperty("_BumpMap", props);
heigtMapScale = FindProperty("_Parallax", props);
heightMap = FindProperty("_ParallaxMap", props);
detailMask = FindProperty("_DetailMask", props);
detailAlbedoMap = FindProperty("_DetailAlbedoMap", props);
detailNormalMapScale = FindProperty("_DetailNormalMapScale", props);
detailNormalMap = FindProperty("_DetailNormalMap", props);
uvSetSecondary = FindProperty("_UVSec", props);
}
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] props)

bool hadEmissionTexture = emissionMap.textureValue != null;
// Texture and HDR color controls
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false);
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false);
// If texture was assigned and color was black set color to white
float brightness = emissionColorForRendering.colorValue.maxColorComponent;

47
ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardParticlesShaderGUI.cs


public static GUIContent streamApplyToAllSystemsText = new GUIContent("Apply to Systems", "Apply the vertex stream layout to all Particle Systems using this material");
}
MaterialProperty blendMode = null;
MaterialProperty colorMode = null;
MaterialProperty flipbookMode = null;
MaterialProperty cullMode = null;
MaterialProperty albedoMap = null;
MaterialProperty albedoColor = null;
MaterialProperty alphaCutoff = null;
MaterialProperty metallicMap = null;
MaterialProperty metallic = null;
MaterialProperty smoothness = null;
MaterialProperty bumpScale = null;
MaterialProperty bumpMap = null;
MaterialProperty emissionEnabled = null;
MaterialProperty emissionColorForRendering = null;
MaterialProperty emissionMap = null;
MaterialProperty softParticlesEnabled = null;
MaterialProperty cameraFadingEnabled = null;
MaterialProperty softParticlesNearFadeDistance = null;
MaterialProperty softParticlesFarFadeDistance = null;
MaterialProperty cameraNearFadeDistance = null;
MaterialProperty cameraFarFadeDistance = null;
MaterialProperty blendMode;
MaterialProperty colorMode;
MaterialProperty flipbookMode;
MaterialProperty cullMode;
MaterialProperty albedoMap;
MaterialProperty albedoColor;
MaterialProperty alphaCutoff;
MaterialProperty metallicMap;
MaterialProperty metallic;
MaterialProperty smoothness;
MaterialProperty bumpScale;
MaterialProperty bumpMap;
MaterialProperty emissionEnabled;
MaterialProperty emissionColorForRendering;
MaterialProperty emissionMap;
MaterialProperty softParticlesEnabled;
MaterialProperty cameraFadingEnabled;
MaterialProperty softParticlesNearFadeDistance;
MaterialProperty softParticlesFarFadeDistance;
MaterialProperty cameraNearFadeDistance;
MaterialProperty cameraFarFadeDistance;
ColorPickerHDRConfig m_ColorPickerHDRConfig = new ColorPickerHDRConfig(0f, 99f, 1 / 99f, 3f);
List<ParticleSystemRenderer> m_RenderersUsingThisMaterial = new List<ParticleSystemRenderer>();
bool m_FirstTimeApply = true;

void DoAlbedoArea(Material material)
{
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.albedoText, albedoMap, albedoColor, m_ColorPickerHDRConfig, true);
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.albedoText, albedoMap, albedoColor, true);
if (((BlendMode)material.GetFloat("_Mode") == BlendMode.Cutout))
{
m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText, MaterialEditor.kMiniTextureFieldLabelIndentLevel);

bool hadEmissionTexture = emissionMap.textureValue != null;
// Texture and HDR color controls
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, m_ColorPickerHDRConfig, false);
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionText, emissionMap, emissionColorForRendering, false);
// If texture was assigned and color was black set color to white
float brightness = emissionColorForRendering.colorValue.maxColorComponent;

30
ScriptableRenderPipeline/LightweightPipeline/Editor/ShaderGUI/LightweightStandardSimpleLightingGUI.cs


public class LightweightStandardSimpleLightingGUI : ShaderGUI
{
private const float kMinShininessValue = 0.01f;
private MaterialProperty blendModeProp = null;
private MaterialProperty albedoMapProp = null;
private MaterialProperty albedoColorProp = null;
private MaterialProperty alphaCutoffProp = null;
private MaterialProperty specularSourceProp = null;
private MaterialProperty glossinessSourceProp = null;
private MaterialProperty specularGlossMapProp = null;
private MaterialProperty specularColorProp = null;
private MaterialProperty shininessProp = null;
private MaterialProperty bumpMapProp = null;
private MaterialProperty emissionMapProp = null;
private MaterialProperty emissionColorProp = null;
private MaterialProperty blendModeProp;
private MaterialProperty albedoMapProp;
private MaterialProperty albedoColorProp;
private MaterialProperty alphaCutoffProp;
private MaterialProperty specularSourceProp;
private MaterialProperty glossinessSourceProp;
private MaterialProperty specularGlossMapProp;
private MaterialProperty specularColorProp;
private MaterialProperty shininessProp;
private MaterialProperty bumpMapProp;
private MaterialProperty emissionMapProp;
private MaterialProperty emissionColorProp;
private MaterialEditor m_MaterialEditor = null;
private const float kMaxfp16 = 65536f; // Clamp to a value that fits into fp16.
private ColorPickerHDRConfig m_ColorPickerHDRConfig = new ColorPickerHDRConfig(0f, kMaxfp16, 1 / kMaxfp16, 3f);
private MaterialEditor m_MaterialEditor;
private static class Styles
{

bool hadEmissionTexture = emissionMapProp.textureValue != null;
// Texture and HDR color controls
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionMapLabel, emissionMapProp, emissionColorProp, m_ColorPickerHDRConfig, false);
m_MaterialEditor.TexturePropertyWithHDRColor(Styles.emissionMapLabel, emissionMapProp, emissionColorProp, false);
// If texture was assigned and color was black set color to white
float brightness = emissionColorProp.colorValue.maxColorComponent;

5
ScriptableRenderPipeline/LightweightPipeline/Editor/StandardToLightweightMaterialUpgrader.cs.meta


fileFormatVersion: 2
guid: aec5479bdc442cb4d96b1de3f5e5c818
timeCreated: 1484641774
licenseType: Pro
guid: d639cdbf740deb94687e01a181ea790a
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0

2
ScriptableRenderPipeline/LightweightPipeline/LightweightPipeline.cs


m_RequiredDepth = false;
m_CameraPostProcessLayer = m_CurrCamera.GetComponent<PostProcessLayer>();
bool msaaEnabled = m_Asset.MSAASampleCount > 1 && (m_CurrCamera.targetTexture == null || m_CurrCamera.targetTexture.antiAliasing > 1);
bool msaaEnabled = m_CurrCamera.allowMSAA && m_Asset.MSAASampleCount > 1 && (m_CurrCamera.targetTexture == null || m_CurrCamera.targetTexture.antiAliasing > 1);
// TODO: PostProcessing and SoftParticles are currently not support for VR
bool postProcessEnabled = m_CameraPostProcessLayer != null && m_CameraPostProcessLayer.enabled && !stereoEnabled;

33
ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightStandard.shader


ENDCG
}
// This pass it not used during regular rendering, only for lightmap baking.
Pass
{
Tags{"LightMode" = "Meta"}
// This pass it not used during regular rendering, only for lightmap baking.
Pass
{
Tags{"LightMode" = "Meta"}
Cull Off
Cull Off
CGPROGRAM
#pragma vertex LightweightVertexMeta
#pragma fragment LightweightFragmentMeta
CGPROGRAM
#pragma vertex LightweightVertexMeta
#pragma fragment LightweightFragmentMeta
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature EDITOR_VISUALIZATION
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature EDITOR_VISUALIZATION
#pragma shader_feature _EMISSION
#pragma shader_feature _SPECGLOSSMAP
#pragma shader_feature _SPECGLOSSMAP
#include "LightweightPassMeta.cginc"
ENDCG
}
#include "LightweightPassMeta.cginc"
ENDCG
}
}
FallBack "Hidden/InternalErrorShader"
CustomEditor "LightweightStandardGUI"
正在加载...
取消
保存