浏览代码

Merge pull request #884 from Unity-Technologies/Update-Menu-location-and-label

Update menu item location and label
/main
GitHub 7 年前
当前提交
22cb3935
共有 12 个文件被更改,包括 61 次插入56 次删除
  1. 1
      ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs
  2. 2
      ScriptableRenderPipeline/Core/CoreRP/Editor/Debugging/DebugMenuEditor.cs
  3. 2
      ScriptableRenderPipeline/Core/CoreRP/Editor/ShaderGenerator/ShaderGeneratorMenu.cs
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Decal/DecalMenuItems.cs
  5. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs
  6. 13
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineMenuItems.cs
  7. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/UpgradeStandardShaderMaterials.cs
  8. 10
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs
  9. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightMaterialUpgrader.cs
  10. 2
      TestbedPipelines/BasicRenderPipeline/BasicRenderPipeline.cs
  11. 3
      TestbedPipelines/Fptl/FptlLighting.cs
  12. 68
      TestbedPipelines/OnTileDeferredPipeline/OnTileDeferredRenderPipeline.cs

1
ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs


public const int editMenuPriority1 = 320;
public const int editMenuPriority2 = 331;
public const int editMenuPriority3 = 342;
public const int assetCreateMenuPriority1 = 230;
public const int assetCreateMenuPriority2 = 241;
public const int gameObjectMenuPriority = 10;

2
ScriptableRenderPipeline/Core/CoreRP/Editor/Debugging/DebugMenuEditor.cs


[SerializeField]
private DebugMenuState m_DebugMenuState;
[MenuItem("Edit/Render Pipeline/Tools/High Definition/Debug Window", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Window/Render Pipeline/Debug Window", priority = CoreUtils.editMenuPriority2)]
static void DisplayDebugMenu()
{
var window = EditorWindow.GetWindow<DebugMenuEditor>("Debug Window");

2
ScriptableRenderPipeline/Core/CoreRP/Editor/ShaderGenerator/ShaderGeneratorMenu.cs


{
public class ShaderGeneratorMenu
{
[UnityEditor.MenuItem("Edit/Render Pipeline/Tools/Generate Shader Includes", priority = CoreUtils.editMenuPriority1)]
[UnityEditor.MenuItem("Edit/Render Pipeline/Generate Shader Includes", priority = CoreUtils.editMenuPriority1)]
static void GenerateShaderIncludes()
{
CSharpToHLSL.GenerateAll();

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Decal/DecalMenuItems.cs


{
public class DecalMenuItems
{
[MenuItem("GameObject/Render Pipeline/High Definition/DecalProjector", priority = CoreUtils.gameObjectMenuPriority)]
[MenuItem("GameObject/Graphics/DecalProjector", priority = CoreUtils.gameObjectMenuPriority)]
static void CreateDecal(MenuCommand menuCommand)
{
// Create a custom game object

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDAssetFactory.cs


}
}
[MenuItem("Assets/Create/Render Pipeline/High Definition/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
[MenuItem("Assets/Create/Graphics/High Definition Render Pipeline Asset", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateHDRenderPipeline()
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");

}
}
[MenuItem("Assets/Create/Render Pipeline/High Definition/Render Pipeline Resources", priority = CoreUtils.assetCreateMenuPriority1)]
[MenuItem("Assets/Create/Graphics/High Definition Render Pipeline Resources", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateRenderPipelineResources()
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");

13
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/HDRenderPipelineMenuItems.cs


// In case the shader code have change and the inspector have been update with new kind of keywords we need to regenerate the set of keywords use by the material.
// This script will remove all keyword of a material and trigger the inspector that will re-setup all the used keywords.
// It require that the inspector of the material have a static function call that update all keyword based on material properties.
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Reset All Materials Keywords (Loaded Materials)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Reset All Loaded High Definition Materials Keywords", priority = CoreUtils.editMenuPriority3)]
static void ResetAllMaterialKeywords()
{
try

}
}
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Reset All Material Asset's Keywords (Materials in Project)", priority = CoreUtils.editMenuPriority2)]
// Don't expose, ResetAllMaterialKeywordsInProjectAndScenes include it anyway
//[MenuItem("Edit/Render Pipeline/Reset All Material Asset's Keywords (Materials in Project)", priority = CoreUtils.editMenuPriority3)]
static void ResetAllMaterialAssetsKeywords()
{
try

}
}
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Reset All Materials Keywords (Materials in Project and scenes)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Reset All Project and Scene High Definition Materials Keywords", priority = CoreUtils.editMenuPriority3)]
static void ResetAllMaterialKeywordsInProjectAndScenes()
{
var openedScenes = new string[EditorSceneManager.loadedSceneCount];

}
}
[MenuItem("Edit/Render Pipeline/Tools/High Definition/Export Sky to Image", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Export Sky to Image", priority = CoreUtils.editMenuPriority3)]
static void ExportSkyToImage()
{
var renderpipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;

}
}
[MenuItem("GameObject/Render Pipeline/High Definition/Scene Settings", priority = CoreUtils.gameObjectMenuPriority)]
[MenuItem("GameObject/Graphics/Scene Settings", priority = CoreUtils.gameObjectMenuPriority)]
static void CreateCustomGameObject(MenuCommand menuCommand)
{
var sceneSettings = new GameObject("Scene Settings");

class DoCreateNewAssetDiffusionProfileSettings : DoCreateNewAsset<DiffusionProfileSettings> {}
[MenuItem("Assets/Create/Render Pipeline/High Definition/Diffusion profile Settings", priority = CoreUtils.assetCreateMenuPriority2)]
[MenuItem("Assets/Create/Graphics/Diffusion profile Settings", priority = CoreUtils.assetCreateMenuPriority2)]
static void MenuCreateDiffusionProfile()
{
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");

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


return upgraders;
}
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Upgrade Standard Materials to Lit Materials (Project)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Project Materials to High Definition Materials", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Upgrade Standard Materials to Lit Materials (Selection)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Selected Standard Materials to High Definition Materials", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade/High Definition/Modify Light Intensity for Upgrade (Scene Only)", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Scene Light Intensity for High Definition", priority = CoreUtils.editMenuPriority2)]
static void UpgradeLights()
{
Light[] lights = Light.GetLights(LightType.Directional, 0);

10
ScriptableRenderPipeline/LightweightPipeline/LWRP/Data/LightweightPipelineAsset.cs


[SerializeField] private ShadowCascades m_ShadowCascades = ShadowCascades.FOUR_CASCADES;
[SerializeField] private float m_Cascade2Split = 0.25f;
[SerializeField] private Vector3 m_Cascade4Split = new Vector3(0.067f, 0.2f, 0.467f);
[SerializeField]
private LightweightPipelineResources m_ResourcesAsset;

[MenuItem("Assets/Create/Render Pipeline/Lightweight/Pipeline Asset", priority = CoreUtils.assetCreateMenuPriority1)]
[MenuItem("Assets/Create/Graphics/Lightweight Pipeline Asset", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateLightweightPipeline()
{
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreateLightweightPipelineAsset>(),

//[MenuItem("Assets/Create/Render Pipeline/Lightweight/Pipeline Resources", priority = CoreUtils.assetCreateMenuPriority1)]
//[MenuItem("Assets/Create/Graphics/Lightweight Pipeline Resources", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateLightweightPipelineResources()
{
var instance = CreateInstance<LightweightPipelineResources>();

//[MenuItem("Assets/Create/Render Pipeline/Lightweight/Pipeline Editor Resources", priority = CoreUtils.assetCreateMenuPriority1)]
//[MenuItem("Assets/Create/Graphics/Lightweight Pipeline Editor Resources", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateLightweightPipelineEditorResources()
{
var instance = CreateInstance<LightweightPipelineEditorResources>();

private Material GetMaterial(DefaultMaterialType materialType)
{
#if UNITY_EDITOR
switch (materialType)
{
case DefaultMaterialType.Standard:

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/Editor/LightweightMaterialUpgrader.cs


{
public class LightweightMaterialUpgrader
{
[MenuItem("Edit/Render Pipeline/Upgrade/Lightweight/Upgrade Project Materials", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Project Materials to LightWeight Materials", priority = CoreUtils.editMenuPriority2)]
private static void UpgradeProjectMaterials()
{
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>();

}
[MenuItem("Edit/Render Pipeline/Upgrade/Lightweight/Upgrade Selected Materials", priority = CoreUtils.editMenuPriority2)]
[MenuItem("Edit/Render Pipeline/Upgrade Selected Materials to LightWeight Materials", priority = CoreUtils.editMenuPriority2)]
private static void UpgradeSelectedMaterials()
{
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>();

2
TestbedPipelines/BasicRenderPipeline/BasicRenderPipeline.cs


public bool UseIntermediateRenderTargetBlit;
#if UNITY_EDITOR
[UnityEditor.MenuItem("Assets/Create/Render Pipeline/Basic/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
[UnityEditor.MenuItem("Assets/Create/Graphics/Basic Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateBasicRenderPipeline()
{
var instance = ScriptableObject.CreateInstance<BasicRenderPipeline>();

3
TestbedPipelines/Fptl/FptlLighting.cs


public class FptlLighting : RenderPipelineAsset
{
#if UNITY_EDITOR
[UnityEditor.MenuItem("Assets/Create/Render Pipeline/FPTL/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
// Hide as not an official pipeline
// [UnityEditor.MenuItem("Assets/Create/Render Pipeline/FPTL/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateRenderLoopFPTL()
{
var instance = ScriptableObject.CreateInstance<FptlLighting>();

68
TestbedPipelines/OnTileDeferredPipeline/OnTileDeferredRenderPipeline.cs


[ExecuteInEditMode]
public class OnTileDeferredRenderPipeline : RenderPipelineAsset {
#if UNITY_EDITOR
[UnityEditor.MenuItem("Assets/Create/Render Pipeline/On Tile Deferred/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
#if UNITY_EDITOR
// Hide as not an official pipeline
// [UnityEditor.MenuItem("Assets/Create/Render Pipeline/On Tile Deferred/Render Pipeline", priority = CoreUtils.assetCreateMenuPriority1)]
static void CreateDeferredRenderPipeline()
{
var instance = ScriptableObject.CreateInstance<OnTileDeferredRenderPipeline> ();

[UnityEditor.MenuItem("Edit/Render Pipeline/Upgrade/On Tile Deferred/Upgrade Standard Shader Materials", priority = CoreUtils.editMenuPriority2)]
// Hide as not an official pipeline
//[UnityEditor.MenuItem("Edit/Render Pipeline/Upgrade/On Tile Deferred/Upgrade Standard Shader Materials", priority = CoreUtils.editMenuPriority2)]
static void SetupDeferredRenderPipelineMaterials()
{
Renderer[] _renderers = Component.FindObjectsOfType<Renderer> ();

if (_material == null)
continue;
if (_material.shader.name.Contains ("Standard (Specular setup)")) {
_material.shader = Shader.Find("Standard-SRP (Specular setup)");
} else if (_material.shader.name.Contains ("Standard")) {

{
return new OnTileDeferredRenderPipelineInstance(this);
}
[SerializeField] ShadowSettings m_ShadowSettings = new ShadowSettings();
ShadowSetup m_ShadowSetup;

// TODO: When graphics/renderpass lands, replace code that uses boolean below with SystemInfo.supportsReadOnlyDepth
#if UNITY_EDITOR || UNITY_STANDALONE
static bool s_SupportsReadOnlyDepth = true;
#else
#else
static bool s_SupportsReadOnlyDepth = false;
#endif

s_GBufferEmission = new RenderPassAttachment(RenderTextureFormat.ARGBHalf) { hideFlags = HideFlags.HideAndDontSave };
s_Depth = new RenderPassAttachment(RenderTextureFormat.Depth) { hideFlags = HideFlags.HideAndDontSave };
s_CameraTarget = s_GBufferAlbedo;
s_GBufferEmission.Clear(new Color(0.0f, 0.0f, 0.0f, 0.0f), 1.0f, 0);
s_Depth.Clear(new Color(), 1.0f, 0);

m_ReflectionNearAndFarClipMaterial.SetInt("_DstABlend", (int)BlendMode.Zero);
m_ReflectionNearAndFarClipMaterial.SetInt("_CullMode", (int)CullMode.Off);
m_ReflectionNearAndFarClipMaterial.SetInt("_CompareFunc", (int)CompareFunction.Always);
m_CookieTexArray = new TextureCache2D();
m_CubeCookieTexArray = new TextureCacheCubemap();
m_CubeReflTexArray = new TextureCacheCubemap();

void ExecuteRenderLoop(Camera camera, CullResults cullResults, ScriptableRenderContext loop)
{
using (RenderPass rp = new RenderPass (loop, camera.pixelWidth, camera.pixelHeight, 1, s_SupportsReadOnlyDepth ?
using (RenderPass rp = new RenderPass (loop, camera.pixelWidth, camera.pixelHeight, 1, s_SupportsReadOnlyDepth ?
using (new RenderPass.SubPass (rp, s_SupportsReadOnlyDepth ?
using (new RenderPass.SubPass (rp, s_SupportsReadOnlyDepth ?
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission } :
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_GBufferEmission, s_GBufferRedF32 }, null)) {
using (var cmd = new CommandBuffer { name = "Create G-Buffer" }) {

loop.ExecuteCommandBuffer (cmd);
// render opaque objects using Deferred pass
var drawSettings = new DrawRendererSettings (camera, new ShaderPassName ("Deferred")) {
sorting = { flags = SortFlags.CommonOpaque },

}
//Lighting Pass
using (new RenderPass.SubPass(rp, new[] { s_GBufferEmission },
using (new RenderPass.SubPass(rp, new[] { s_GBufferEmission },
new[] { s_GBufferAlbedo, s_GBufferSpecRough, s_GBufferNormal, s_SupportsReadOnlyDepth ? s_Depth : s_GBufferRedF32 }, true))
{
using (var cmd = new CommandBuffer { name = "Deferred Lighting and Reflections Pass"} )

}
}
}
// Utilites
static Matrix4x4 GetFlipMatrix()
{

{
return camera.projectionMatrix * GetFlipMatrix();
}
Matrix4x4 PerspectiveCotanMatrix(float cotangent, float zNear, float zFar )
{
float deltaZ = zNear - zFar;

Matrix4x4 scaled = Matrix4x4.Scale (combinedExtent * 2.0f);
mat = mat * Matrix4x4.Translate (boxOffset) * scaled;
var probeRadius = combinedExtent.magnitude;
var viewDistance = eyePlane.GetDistanceToPoint(boxOffset);
bool intersectsNear = viewDistance - probeRadius <= nearDistanceFudged;

// draw the base probe
// TODO: (cleanup) dont use builtins like unity_SpecCube0
{
{
var props = new MaterialPropertyBlock ();
props.SetFloat ("_LightAsQuad", 1.0f);

Matrix4x4 temp3 = PerspectiveCotanMatrix (chsa, 0.0f, range);
return temp2 * temp1 * temp3 * worldToLight;
}
void RenderSpotlight(VisibleLight light, CommandBuffer cmd, MaterialPropertyBlock properties, bool renderAsQuad, bool intersectsNear, bool deferred)
{
float range = light.range;

// Setup Spot Rendering mesh matrix
float sideLength = range / chsa;
// scalingFactor corrosoponds to the scale factor setting (and wether file scale is used) of mesh in Unity mesh inspector.
// A scale factor setting in Unity of 0.01 would require this to be set to 100. A scale factor setting of 1, is just 1 here.
// scalingFactor corrosoponds to the scale factor setting (and wether file scale is used) of mesh in Unity mesh inspector.
// A scale factor setting in Unity of 0.01 would require this to be set to 100. A scale factor setting of 1, is just 1 here.
lightToWorld = lightToWorld * Matrix4x4.Scale (new Vector3(sideLength*SpotLightMeshScaleFactor, sideLength*SpotLightMeshScaleFactor, range*SpotLightMeshScaleFactor));
//set default cookie for spot light if there wasnt one added to the light manually

Vector3 lightPos = light.localToWorld.GetColumn (3); //position
float range = light.range;
// scalingFactor corrosoponds to the scale factor setting (and wether file scale is used) of mesh in Unity mesh inspector.
// A scale factor setting in Unity of 0.01 would require this to be set to 100. A scale factor setting of 1, is just 1 here.
// scalingFactor corrosoponds to the scale factor setting (and wether file scale is used) of mesh in Unity mesh inspector.
// A scale factor setting in Unity of 0.01 would require this to be set to 100. A scale factor setting of 1, is just 1 here.
if (cookie != null)
if (cookie != null)
else
else
if (renderAsQuad)
if (renderAsQuad)
else if (intersectsNear)
else if (intersectsNear)
else
else
cmd.DrawMesh (m_PointLightMesh, matrix, m_FiniteDeferredLightingMaterial, 0, 0, properties);
}

void RenderLightsDeferred (Camera camera, CullResults inputs, CommandBuffer cmd, ScriptableRenderContext loop)
{
int lightCount = inputs.visibleLights.Count;
for (int lightNum = 0; lightNum < lightCount; lightNum++)
for (int lightNum = 0; lightNum < lightCount; lightNum++)
{
VisibleLight light = inputs.visibleLights[lightNum];

Vector3 lightPos = light.localToWorld.GetColumn (3); //position
Vector3 lightDir = light.localToWorld.GetColumn (2); //z axis
float range = light.range;

float chsa = GetCotanHalfSpotAngle (light.spotAngle);
// Setup Light Matrix
m_LightMatrix[i] = SpotlightMatrix (light, worldToLight, range, chsa);
m_LightMatrix[i] = SpotlightMatrix (light, worldToLight, range, chsa);
} else if (light.lightType == LightType.Directional) {
m_LightData[i].x = LightDefinitions.DIRECTIONAL_LIGHT;

var decodeVals = rl.hdr;
// C is reflection volume center in world space (NOT same as cube map capture point)
var e = bnds.extents;
var C = mat.MultiplyPoint(boxOffset);
var e = bnds.extents;
var C = mat.MultiplyPoint(boxOffset);
var combinedExtent = e + new Vector3(blendDistance, blendDistance, blendDistance);
Vector3 vx = mat.GetColumn(0);

cmd.SetGlobalFloat ("_useLegacyCookies", UseLegacyCookies?1.0f:0.0f);
cmd.SetGlobalFloat ("_transparencyShadows", TransparencyShadows ? 1.0f : 0.0f);
}
}
}
正在加载...
取消
保存