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 @@ -188,6 +188,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed GLES shaders compilation failing on Windows platform (not a mobile platform) due to uniform count limit.
- Fixed an issue that caused the inverse view and projection matrix to output wrong values in some platforms. [case 1243990](https://issuetracker.unity3d.com/issues/urp-8-dot-1-breaks-unity-matrix-i-vp)
- Fixed an issue with not being able to remove Light Mode Tags [case 1240895](https://issuetracker.unity3d.com/issues/urp-unable-to-remove-added-lightmode-tags-of-filters-property-in-render-object)
- Fixed issue with Model Importer materials using the Legacy standard shader instead of URP's Lit shader when import happens at Editor startup.

## [7.1.1] - 2019-09-05
### Upgrade Guide
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;

namespace UnityEngine.Rendering.LWRP
{
Expand Down Expand Up @@ -256,9 +258,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 @@ -675,6 +678,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.

We should add test automation to validate we don't break these GUIDs for some reason. Maybe we should check all s_ShaderGUIDs return valid paths in here: https://github.com/Unity-Technologies/Graphics/blob/master/com.unity.render-pipelines.universal/Tests/Editor/EditorTests.cs#L57-L65

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a test in the latest commit, how do you proceed to run them locally ? I ended up copying that folder in a sandbox project and managed to run them, not ideal..

Copy link
Contributor

Choose a reason for hiding this comment

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

You can run them locally by opening the test runner window and running editor mode tests

"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");
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