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.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Implemented ray traced reflections for transparent objects.
- Add a new parameter to control reflections in recursive rendering.
- Added an initial version of SSGI.
- Added back-compatibility with builtin stereo matrices.

### Fixed
- Fix when rescale probe all direction below zero (1219246)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd)

ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal);

hdCamera.xr.UpdateBuiltinStereoMatrices(cmd);
hdCamera.UpdateShaderVariablesXRCB(ref m_ShaderVariablesXRCB);
ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesXRCB, HDShaderIDs._ShaderVariablesXR);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ internal void AddViewInternal(XRView xrView)
{
Debug.LogWarning("If you're trying to enable XR single-pass after the first frame, you need to set TextureXR.maxViews to 2 before the render pipeline is created (typically in a script with Awake()).");
}

throw new NotImplementedException($"Invalid XR setup for single-pass, trying to add too many views! Max supported: {maxSupportedViews}");
}
}
Expand Down Expand Up @@ -274,5 +274,30 @@ internal void RenderOcclusionMeshes(CommandBuffer cmd, RTHandle depthBuffer)
}
}
}

static readonly int _unity_StereoMatrixV = Shader.PropertyToID("unity_StereoMatrixV");
static readonly int _unity_StereoMatrixP = Shader.PropertyToID("unity_StereoMatrixP");
static readonly int _unity_StereoMatrixVP = Shader.PropertyToID("unity_StereoMatrixVP");
Matrix4x4[] builtinViewMatrix = new Matrix4x4[2];
Matrix4x4[] builtinProjMatrix = new Matrix4x4[2];
Matrix4x4[] builtinViewProjMatrix = new Matrix4x4[2];

// Maintain compatibility with builtin renderer
internal void UpdateBuiltinStereoMatrices(CommandBuffer cmd)
{
if (singlePassEnabled)
{
for (int viewIndex = 0; viewIndex < 2; ++viewIndex)
{
builtinViewMatrix[viewIndex] = GetViewMatrix(viewIndex);
builtinProjMatrix[viewIndex] = GL.GetGPUProjectionMatrix(GetProjMatrix(viewIndex), true);
builtinViewProjMatrix[viewIndex] = builtinProjMatrix[viewIndex] * builtinViewMatrix[viewIndex];
}

cmd.SetGlobalMatrixArray(_unity_StereoMatrixV, builtinViewMatrix);
cmd.SetGlobalMatrixArray(_unity_StereoMatrixP, builtinProjMatrix);
cmd.SetGlobalMatrixArray(_unity_StereoMatrixVP, builtinViewProjMatrix);
}
}
}
}
31 changes: 0 additions & 31 deletions com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public class HDRP_TestSettings : GraphicsTestSettings

void Awake()
{
// Built-in font shaders are incompatible with XR, replace them with a ShaderGraph version
if (XRSystem.testModeEnabled && xrCompatible)
doBeforeTest.AddListener(ReplaceBuiltinFontShaders);

if (renderPipelineAsset == null)
{
Debug.LogWarning("No RenderPipelineAsset has been assigned in the test settings. This may result in a wrong test.");
Expand All @@ -60,31 +56,4 @@ void OnApplicationQuit()

quitDebug.Clear();
}

void ReplaceBuiltinFontShaders()
{
#if UNITY_EDITOR
var fontMaterialSG = AssetDatabase.LoadAssetAtPath<Material>("Packages/com.unity.testing.hdrp/Fonts/Font Material SG.mat");
if (fontMaterialSG != null)
{
foreach (var textMesh in GameObject.FindObjectsOfType<TextMesh>())
{
var textMeshRenderer = textMesh.gameObject.GetComponent<MeshRenderer>();

if (!textMeshRenderer.material.shader.name.StartsWith("Shader Graphs"))
{
// From Unity source: Runtime\Resources\Assets\DefaultResources\Font.shader
var fontTexture = textMeshRenderer.material.GetTexture("_MainTex");
var fontColor = textMeshRenderer.material.GetColor("_Color");

textMeshRenderer.material = fontMaterialSG;
textMeshRenderer.material.SetTexture("_MainTex", fontTexture);
textMeshRenderer.material.SetColor("_Color", fontColor);

textMeshRenderer.shadowCastingMode = ShadowCastingMode.Off;
}
}
}
#endif
}
}