Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed issue where using DOF at the same time as Dynamic Scaling, the depth buffer was sampled with incorrect UVs. [case 1225467](https://issuetracker.unity3d.com/product/unity/issues/guid/1225467/)
- Fixed an issue where URP Simple Lit shader had attributes swapped incorrectly for BaseMap and BaseColor properties.
- Fixed an issue where camera stacking with MSAA on OpenGL resulted in a black screen. [case 1250602](https://issuetracker.unity3d.com/issues/urp-camera-stacking-results-in-black-screen-when-msaa-and-opengl-graphics-api-are-used)
- Fixed issue with Model Importer materials using the Legacy standard shader instead of URP's Lit shader when import happens at Editor startup.

## [8.1.0] - 2020-04-21

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using UnityEditor.AssetImporters;
using UnityEngine;
using UnityEngine.Rendering.Universal;

namespace UnityEditor.Rendering.Universal
{
Expand All @@ -23,8 +24,9 @@ public void OnPreprocessMaterialDescription(MaterialDescription description, Mat
var lowerCaseExtension = Path.GetExtension(assetPath).ToLower();
if (lowerCaseExtension != ".fbx" && lowerCaseExtension != ".obj" && lowerCaseExtension != ".blend" && lowerCaseExtension != ".mb" && lowerCaseExtension != ".ma" && lowerCaseExtension != ".max")
return;

var shader = Shader.Find("Universal Render Pipeline/Lit");

string path = AssetDatabase.GUIDToAssetPath(ShaderUtils.GetShaderGUID(ShaderPathID.Lit));
var shader = AssetDatabase.LoadAssetAtPath<Shader>(path);
if (shader == null)
return;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.IO;
using UnityEngine;
using UnityEditor.AssetImporters;
using UnityEngine.Rendering.Universal;

namespace UnityEditor.Rendering.Universal
{
Expand All @@ -25,7 +26,8 @@ public void OnPreprocessMaterialDescription(MaterialDescription description, Mat
if (lowerCasePath != ".skp")
return;

var shader = Shader.Find("Universal Render Pipeline/Lit");
string path = AssetDatabase.GUIDToAssetPath(ShaderUtils.GetShaderGUID(ShaderPathID.Lit));
var shader = AssetDatabase.LoadAssetAtPath<Shader>(path);
if (shader == null)
return;
material.shader = shader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using UnityEngine;
using UnityEditor.AssetImporters;
using UnityEngine.Rendering.Universal;

namespace UnityEditor.Rendering.Universal
{
Expand All @@ -26,7 +27,8 @@ public void OnPreprocessMaterialDescription(MaterialDescription description, Mat
if (lowerCasePath != ".3ds")
return;

var shader = Shader.Find("Universal Render Pipeline/Lit");
string path = AssetDatabase.GUIDToAssetPath(ShaderUtils.GetShaderGUID(ShaderPathID.Lit));
var shader = AssetDatabase.LoadAssetAtPath<Shader>(path);
if (shader == null)
return;
material.shader = shader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using UnityEditor;
using UnityEditor.ProjectWindowCallback;
using System.IO;
using UnityEditorInternal;
#endif
using System.ComponentModel;
using System.Linq;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use Linq? How does that perform in practice?


namespace UnityEngine.Rendering.LWRP
{
Expand Down Expand Up @@ -258,9 +260,10 @@ UniversalRenderPipelineEditorResources editorResources
{
if (m_EditorResourcesAsset != null && !m_EditorResourcesAsset.Equals(null))
return m_EditorResourcesAsset;

string resourcePath = AssetDatabase.GUIDToAssetPath(editorResourcesGUID);
m_EditorResourcesAsset = AssetDatabase.LoadAssetAtPath<UniversalRenderPipelineEditorResources>(resourcePath);
var objs = InternalEditorUtility.LoadSerializedFileAndForget(resourcePath);
m_EditorResourcesAsset = objs != null && objs.Length > 0 ? objs.First() as UniversalRenderPipelineEditorResources : null;
return m_EditorResourcesAsset;
}
}
Expand Down Expand Up @@ -687,6 +690,12 @@ public override Shader defaultShader
if (defaultShader != null)
return defaultShader;
}

if (m_DefaultShader == null)
{
string path = AssetDatabase.GUIDToAssetPath(ShaderUtils.GetShaderGUID(ShaderPathID.Lit));
m_DefaultShader = AssetDatabase.LoadAssetAtPath<Shader>(path);
}
#endif

if (m_DefaultShader == null)
Expand Down
26 changes: 26 additions & 0 deletions com.unity.render-pipelines.universal/Runtime/ShaderUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,31 @@ public static bool IsLWShader(Shader shader)
{
return s_ShaderPaths.Contains(shader.name);
}

#if UNITY_EDITOR
static readonly string[] s_ShaderGUIDs =
{
"933532a4fcc9baf4fa0491de14d08ed7",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very manual and therefore brittle. Could we have symbolic constants or generate this automatically?

"8d2bb70cbf9db8d4da26e15b26e74248",
"650dd9526735d5b46b79224bc6e94025",
"69c1f799e772cb6438f56c23efccb782",
"b7839dad95683814aa64166edc107ae2",
"8516d7a69675844a7a0b7095af7c46af",
"0406db5a14f94604a8c57ccfbc9f3b46",
"0ca6dca7396eb48e5849247ffd444914",
};

internal static string GetShaderGUID(ShaderPathID id)
{
int index = (int)id;
if (index < 0 && index >= (int)ShaderPathID.Count)
{
Debug.LogError("Trying to access universal shader path out of bounds");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should print params 'index' and 'count', so there's no need to debug to see what they were.

return "";
}

return s_ShaderGUIDs[index];
}
#endif
}
}
18 changes: 18 additions & 0 deletions com.unity.render-pipelines.universal/Tests/Editor/EditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ public void ValidateBuiltinResourceFiles()
Assert.IsFalse(string.IsNullOrEmpty(editorResourcesPath));
}

// Validate that ShaderUtils.GetShaderGUID results are valid and that ShaderUtils.GetShaderPath match shader names.
[TestCase(ShaderPathID.Lit)]
[TestCase(ShaderPathID.SimpleLit)]
[TestCase(ShaderPathID.Unlit)]
[TestCase(ShaderPathID.TerrainLit)]
[TestCase(ShaderPathID.ParticlesLit)]
[TestCase(ShaderPathID.ParticlesSimpleLit)]
[TestCase(ShaderPathID.ParticlesUnlit)]
[TestCase(ShaderPathID.BakedLit)]
public void ValidateShaderResources(ShaderPathID shaderPathID)
{
string path = AssetDatabase.GUIDToAssetPath(ShaderUtils.GetShaderGUID(shaderPathID));
Assert.IsFalse(string.IsNullOrEmpty(path));

var shader = AssetDatabase.LoadAssetAtPath<Shader>(path);
Assert.AreEqual(shader.name, ShaderUtils.GetShaderPath(shaderPathID));
}

// When creating URP all required resources should be initialized.
[Test]
public void ValidateNewAssetResources()
Expand Down