Skip to content

Commit

Permalink
com.unity.render-pipelines.core@10.6.0
Browse files Browse the repository at this point in the history
## [10.6.0] - 2021-04-29

### Fixed
- Fixed ACES filter artefact due to half floating point error on some mobile platforms.
- Fixed Explicit half precision not working even when Unified Shader Precision Model is enabled.
- Fixed memory leak when changing SRP pipeline settings, and having the player in pause mode.
- Skip wind calculations for Speed Tree 8 when wind vector is zero (case 1343002)
  • Loading branch information
Unity Technologies committed Apr 29, 2021
1 parent abfc08d commit 8c5ce6c
Show file tree
Hide file tree
Showing 17 changed files with 365 additions and 69 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [10.5.1] - 2021-05-28
## [10.6.0] - 2021-04-29

Version Updated
The version number for this package has increased due to a version update of a related graphics package.
### Fixed
- Fixed ACES filter artefact due to half floating point error on some mobile platforms.
- Fixed Explicit half precision not working even when Unified Shader Precision Model is enabled.
- Fixed memory leak when changing SRP pipeline settings, and having the player in pause mode.
- Skip wind calculations for Speed Tree 8 when wind vector is zero (case 1343002)

## [10.5.0] - 2021-04-19

Expand All @@ -20,6 +23,7 @@ The version number for this package has increased due to a version update of a r
- Support for the XboxSeries platform has been added.
- New API in DynamicResolutionHandler to handle multicamera rendering for hardware mode. Changing cameras and resetting scaling per camera should be safe.
- New API functions with no side effects in DynamicResolutionHandler, to retrieve resolved drs scale and to apply DRS on a size.
- Added SpeedTree8MaterialUpgrader, which provides utilities for upgrading and importing SpeedTree 8 assets to scriptable render pipelines.

### Fixed
- Fixed parameters order on inspectors for Volume Components without custom editor
Expand Down
1 change: 1 addition & 0 deletions Editor/LookDev/DisplayWindow.uss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#viewContainer
{
min-width: 50px;
flex-shrink: 0;
}

Expand Down
186 changes: 186 additions & 0 deletions Editor/SpeedTree8MaterialUpgrader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
using System.Collections.Generic;
using UnityEngine;
using System;

namespace UnityEditor.Rendering
{
/// <summary>
/// Material upgrader and relevant utilities for SpeedTree 8.
/// </summary>
public class SpeedTree8MaterialUpgrader : MaterialUpgrader
{
private enum WindQuality
{
None = 0,
Fastest,
Fast,
Better,
Best,
Palm,
Count
}

private static string[] WindQualityString =
{
"_WINDQUALITY_NONE",
"_WINDQUALITY_FASTEST",
"_WINDQUALITY_FAST",
"_WINDQUALITY_BETTER",
"_WINDQUALITY_BEST",
"_WINDQUALITY_PALM"
};

/// <summary>
/// Creates a material upgrader that handles the property renames that HD and Universal have in common when upgrading
/// from the built-in SpeedTree 8 shader.
/// </summary>
/// <param name="sourceShaderName">Original SpeedTree8 shader name.</param>
/// <param name="destShaderName">New SpeedTree 8 shader name.</param>
/// <param name="finalizer">A delegate that postprocesses the material for the render pipeline in use.</param>
public SpeedTree8MaterialUpgrader(string sourceShaderName, string destShaderName, MaterialFinalizer finalizer = null)
{
RenameShader(sourceShaderName, destShaderName, finalizer);
RenameFloat("_WindQuality", "_WINDQUALITY");
RenameFloat("_TwoSided", "_CullMode"); // Currently only used in HD. Update this once URP per-material cullmode is enabled via shadergraph.
}

private static void ImportNewSpeedTree8Material(Material mat, int windQuality, bool isBillboard)
{
int cullmode = 0;
mat.SetFloat("_WINDQUALITY", windQuality);
if (isBillboard)
{
mat.EnableKeyword("EFFECT_BILLBOARD");
cullmode = 2;
}
if (mat.HasProperty("_CullMode"))
mat.SetFloat("_CullMode", cullmode);
}

/// <summary>
/// Postprocesses materials while you are importing a SpeedTree 8 asset. Call from OnPostprocessSpeedTree in a MaterialPostprocessor.
/// </summary>
/// <param name="speedtree">The GameObject Unity creates from this imported SpeedTree.</param>
/// <param name="stImporter">The asset importer used to import this SpeedTree asset.</param>
/// <param name="finalizer">Render pipeline-specific material finalizer.</param>
public static void PostprocessSpeedTree8Materials(GameObject speedtree, SpeedTreeImporter stImporter, MaterialFinalizer finalizer = null)
{
LODGroup lg = speedtree.GetComponent<LODGroup>();
LOD[] lods = lg.GetLODs();
for (int l = 0; l < lods.Length; l++)
{
LOD lod = lods[l];
bool isBillboard = stImporter.hasBillboard && (l == lods.Length - 1);
int wq = Mathf.Min(stImporter.windQualities[l], stImporter.bestWindQuality);
foreach (Renderer r in lod.renderers)
{
// Override default motion vector generation mode pending
// proper motion vector integration in SRPs.
r.motionVectorGenerationMode = MotionVectorGenerationMode.Camera;
foreach (Material m in r.sharedMaterials)
{
ImportNewSpeedTree8Material(m, wq, isBillboard);
if (finalizer != null)
finalizer(m);
}
}
}
}

/// <summary>
/// Preserves wind quality and billboard settings while you are upgrading a SpeedTree 8 material from previous versions of SpeedTree 8.
/// To determine which WindQuality to use, Unity checks the keywords first and then the _WindQuality float value.
/// See SpeedTree in the Unity Manual for the values associated with different WindQuality settings.
/// Should work for upgrading versions within a pipeline and from standard to current pipeline.
/// </summary>
/// <param name="material">SpeedTree 8 material to upgrade.</param>
public static void SpeedTree8MaterialFinalizer(Material material)
{
if (material.HasProperty("_TwoSided") && material.HasProperty("_CullMode"))
material.SetFloat("_CullMode", material.GetFloat("_TwoSided"));

if (material.IsKeywordEnabled("EFFECT_EXTRA_TEX"))
material.SetFloat("EFFECT_EXTRA_TEX", 1.0f);

bool isBillboard = material.IsKeywordEnabled("EFFECT_BILLBOARD");
if (material.HasProperty("EFFECT_BILLBOARD"))
material.SetFloat("EFFECT_BILLBOARD", isBillboard ? 1.0f : 0.0f);

UpgradeWindQuality(material);
}

private static void UpgradeWindQuality(Material material, int windQuality = -1)
{
int wq = GetWindQuality(material, windQuality);
SetWindQuality(material, wq);
}

private static int GetWindQuality(Material material, int windQuality = -1)
{
// Conservative wind quality priority:
// input WindQuality > enabled keyword > _WindQuality float value
if (!WindIntValid(windQuality))
{
windQuality = GetWindQualityFromKeywords(material.shaderKeywords);
if (!WindIntValid(windQuality))
{
windQuality = material.HasProperty("_WindQuality") ? (int)material.GetFloat("_WindQuality") : 0;

if (!WindIntValid(windQuality))
windQuality = 0;
}
}
return windQuality;
}

private static void ClearWindKeywords(Material material)
{
if (material == null)
return;

for (int i = 0; i < (int)WindQuality.Count; i++)
{
material.DisableKeyword(WindQualityString[i]);
}
}

private static void SetWindQuality(Material material, int windQuality)
{
Debug.Assert(WindIntValid(windQuality), "Attempting to set invalid wind quality on material " + material.name);

if (material == null)
return;

if (windQuality != GetWindQualityFromKeywords(material.shaderKeywords))
{
ClearWindKeywords(material);
}

material.EnableKeyword(WindQualityString[windQuality]);
material.SetFloat("_WindQuality", windQuality); // A legacy float used in native code to apply wind data
if (material.HasProperty("_WINDQUALITY"))
material.SetFloat("_WINDQUALITY", windQuality); // The actual name of the keyword enum for the shadergraph
}

private static int GetWindQualityFromKeywords(string[] matKws)
{
foreach (string kw in matKws)
{
if (kw.StartsWith("_WINDQUALITY_"))
{
for (int i = 0; i < (int)WindQuality.Count; i++)
{
if (kw.EndsWith(WindQualityString[i]))
return i;
}
}
}
return -1;
}

private static bool WindIntValid(int windInt)
{
return ((int)WindQuality.None <= windInt) && (windInt < (int)WindQuality.Count);
}
}
}
11 changes: 11 additions & 0 deletions Editor/SpeedTree8MaterialUpgrader.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Runtime/Debugging/DebugManager.Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ internal float GetAction(DebugAction action)

void RegisterInputs()
{
#if UNITY_EDITOR
#if UNITY_EDITOR && !USE_INPUT_SYSTEM
var inputEntries = new List<InputManagerEntry>
{
new InputManagerEntry { name = kEnableDebugBtn1, kind = InputManagerEntry.Kind.KeyOrButton, btnPositive = "left ctrl", altBtnPositive = "joystick button 8" },
Expand Down
6 changes: 4 additions & 2 deletions Runtime/Debugging/Prefabs/Scripts/DebugUIHandlerBitField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace UnityEngine.Rendering.UI
{
/// <summary>
/// DebugUIHandler for Bitfield widget. Require the enum to have a None field set to 0 in it's values.
/// DebugUIHandler for Bitfield widget. Require the enum to have a None field set to 0 in its values.
/// </summary>
public class DebugUIHandlerBitField : DebugUIHandlerWidget
{
Expand Down Expand Up @@ -44,9 +44,11 @@ internal override void SetWidget(DebugUI.Widget widget)
toggleIndex++;
};

// Destroy the remaining toggles outside of the range of the displayed enum.
for (; toggleIndex < toggles.Count; ++toggleIndex)
{
toggles[toggleIndex].transform.SetParent(null);
CoreUtils.Destroy(toggles[toggleIndex].gameObject);
toggles[toggleIndex] = null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/Documentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class DocumentationInfo
/// <summary>
/// Current version of the documentation.
/// </summary>
public const string version = "10.5";
public const string version = "10.6";
}

//Need to live in Runtime as Attribute of documentation is on Runtime classes \o/
Expand Down
Loading

0 comments on commit 8c5ce6c

Please sign in to comment.