Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal/master #8053

Merged
merged 34 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
aca18c8
Add Render Graph Viewer editor analytics
arttu-peltonen Mar 26, 2024
819f479
Add doc for 'Screen Space - Overlay' in Graphics Compositor.
YohannVaastUnity Mar 26, 2024
64c342c
Update buginfo and codeowners for Environment Effect bug area
adrien-de-tocqueville Mar 26, 2024
3c1501d
[content automatically redacted] touching PlatformDependent folder
brendan-duncan Mar 27, 2024
7f43545
Fix HDRP DXR tests.
IonutNedelcuUnity Mar 27, 2024
69fda8e
Update codeowners and buginfo for PostProcessing
BenGraterUnity Mar 27, 2024
516b6c9
Fix scene dirtiness issue with the HDRP compositor
pmavridis Mar 27, 2024
2dd5cec
[HDRP] Fix realloc of history buffer when XR is enabled
adrien-de-tocqueville Mar 27, 2024
9b29d8f
[HDRP] Support water in custom passes
adrien-de-tocqueville Mar 27, 2024
2423578
Fixed Unity-specific #pragma directives being reported in #include files
zoe-bare-unity3d Mar 28, 2024
610510f
Graphics/urp/bugfix/taa api
eh-unity Mar 28, 2024
cf7e34c
Use half instead of float on mobile for octahedral normal packing fun…
pema99 Mar 28, 2024
672a923
shader_feature_local
adrien-de-tocqueville Mar 28, 2024
c2c10d8
Add missing LightCookies keyword to screenspace decal projector pass
pema99 Mar 28, 2024
9a0f850
[VFX] Fix ConstructMatrix serialization issue + add symetrical SplitM…
julienf-unity Mar 28, 2024
990b81f
Fix for viewport distortion when using dynamic resolution
lpledouxUnity Mar 28, 2024
e71c6aa
[RPW] Switch to default and current render pipeline
kirill-titov-u Mar 29, 2024
21fc624
[VFX] Add Template Validation Test
PaulDemeulenaere Mar 29, 2024
76c98c1
Improve post process message when creating mismatching shader
alelievr Mar 29, 2024
5e3c342
[VFX] Fix Position Box with Zero Scale
PaulDemeulenaere Mar 29, 2024
f8b3cb2
[Yamato] Fix & re-enable unstable IsAssetPreviewCorrect test
arttu-peltonen Mar 29, 2024
0a12d40
UUM-65454 MaxSubpass discrepancy with RenderPassSetup and NativePassC…
RoseHirigoyen Mar 29, 2024
9ccd98c
[VFX] CustomHLSL Operator Includes
PaulDemeulenaere Mar 29, 2024
dafc36b
Fix Render Graph Viewer displaying incorrect store reasoning for MSAA…
arttu-peltonen Mar 29, 2024
ed973f4
[HDRP] Fix missing xr index
adrien-de-tocqueville Mar 29, 2024
1800f2b
BugFix: RTHandle doesn't try to destroy persistent object in editor (…
Mar 30, 2024
da9a1e3
Support 4bytes per pixel in texture importer
adrien-de-tocqueville Mar 30, 2024
e9bf069
[HDRP] Move water specific global shader variables to separate file
adrien-de-tocqueville Mar 30, 2024
a957d70
Fixed XR shader stripping for non-XR project
thomas-zeng Mar 30, 2024
657ddb6
[HDRP] Fix flickering when using baked gi node and TAA
adrien-de-tocqueville Mar 30, 2024
6bd5c88
Fixed the recorder output to render target
alelievr Mar 30, 2024
8911a42
Fixed _ScreenParams after upscaling and update screen node doc
alelievr Mar 30, 2024
aa47869
[HDRP] Fix cinematic eye shader lighting with directionals
adrien-de-tocqueville Mar 30, 2024
5e10a43
[HDRP] update graphics compositor limitation for VR
sebastienlagarde Mar 30, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEngine;
using UnityEngine.Analytics;

namespace UnityEditor.Rendering.Analytics
{
// schema = com.unity3d.data.schemas.editor.analytics.uRenderGraphViewerLifetimeAnalytic_v1
// taxonomy = editor.analytics.uRenderGraphViewerLifetimeAnalytic.v1
internal class RenderGraphViewerLifetimeAnalytic
{
static bool IsInternalAssembly(Type type)
{
var assemblyName = type.Assembly.FullName;
if (assemblyName.StartsWith("UnityEditor.", StringComparison.InvariantCultureIgnoreCase) ||
assemblyName.StartsWith("Unity.", StringComparison.InvariantCultureIgnoreCase))
return true;
return false;
}

static List<string> GatherCurrentlyOpenWindowNames()
{
var openWindows = Resources.FindObjectsOfTypeAll(typeof(EditorWindow));
var openWindowNames = new List<string>(openWindows.Length);
foreach (var w in openWindows)
{
if (IsInternalAssembly(w.GetType()) && w is not RenderGraphViewer)
{
openWindowNames.Add((w as EditorWindow).titleContent.text);
}
}
return openWindowNames;
}

static string[] UnionWithoutLinq(List<string> a, List<string> b)
{
HashSet<string> aAndB = new HashSet<string>(a);
aAndB.UnionWith(b);
String[] aAndBArray = new String[aAndB.Count];
aAndB.CopyTo(aAndBArray);
return aAndBArray;
}

[AnalyticInfo(eventName: "uRenderGraphViewerLifetimeAnalytic", vendorKey: "unity.srp", maxEventsPerHour: 100, maxNumberOfElements: 1000)]
internal class Analytic : IAnalytic
{
public Analytic(WindowOpenedMetadata windowOpenedMetadata)
{
List<string> currentlyOpenEditorWindows = GatherCurrentlyOpenWindowNames();
var elapsed = DateTime.Now - windowOpenedMetadata.openedTime;
using (UnityEngine.Pool.GenericPool<Data>.Get(out var data))
{
data.seconds_opened = elapsed.Seconds;
data.other_open_windows = UnionWithoutLinq(currentlyOpenEditorWindows, windowOpenedMetadata.openEditorWindows);

m_Data = data;
}
}

[DebuggerDisplay("{seconds_opened} - {other_open_windows.Length}")]
[Serializable]
class Data : IAnalytic.IData
{
// Naming convention for analytics data
public int seconds_opened;
public string[] other_open_windows;
}

public bool TryGatherData(out IAnalytic.IData data, out Exception error)
{
data = m_Data;
error = null;
return true;
}

Data m_Data;
}

internal struct WindowOpenedMetadata
{
public List<string> openEditorWindows;
public DateTime openedTime;
}

static WindowOpenedMetadata? s_WindowOpenedMetadata = null;

public static void WindowOpened()
{
s_WindowOpenedMetadata = new WindowOpenedMetadata
{
openEditorWindows = GatherCurrentlyOpenWindowNames(),
openedTime = DateTime.Now
};
}

public static void WindowClosed()
{
if (s_WindowOpenedMetadata.HasValue)
{
Analytic analytic = new Analytic(s_WindowOpenedMetadata.Value);
EditorAnalytics.SendAnalytic(analytic);
s_WindowOpenedMetadata = null;
}
}
}
}

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

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using UnityEditor;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
Expand Down Expand Up @@ -118,7 +119,7 @@ public string GetPhotometricType()
int width = 2 * textureSize;
int height = 2 * textureSize;

NativeArray<Color32> colorBuffer;
NativeArray<Color> colorBuffer;

switch (m_iesReader.PhotometricType)
{
Expand Down Expand Up @@ -148,7 +149,7 @@ public string GetPhotometricType()
/// <returns>A Generated 2D texture doing the projection of the IES using the Gnomonic projection of the bottom half hemisphere with the given 'cone angle'</returns>
public (string, Texture) Generate2DCookie(TextureImporterCompression compression, float coneAngle, int textureSize, bool applyLightAttenuation)
{
NativeArray<Color32> colorBuffer;
NativeArray<Color> colorBuffer;

switch (m_iesReader.PhotometricType)
{
Expand All @@ -171,7 +172,7 @@ public string GetPhotometricType()
int width = 2 * textureSize;
int height = textureSize;

NativeArray<Color32> colorBuffer;
NativeArray<Color> colorBuffer;

switch (m_iesReader.PhotometricType)
{
Expand All @@ -189,7 +190,7 @@ public string GetPhotometricType()
return GenerateTexture(TextureImporterType.Default, TextureImporterShape.Texture2D, compression, width, height, colorBuffer);
}

(string, Texture) GenerateTexture(TextureImporterType type, TextureImporterShape shape, TextureImporterCompression compression, int width, int height, NativeArray<Color32> colorBuffer)
(string, Texture) GenerateTexture(TextureImporterType type, TextureImporterShape shape, TextureImporterCompression compression, int width, int height, NativeArray<Color> colorBuffer)
{
// Default values set by the TextureGenerationSettings constructor can be found in this file on GitHub:
// https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/AssetPipeline/TextureGenerator.bindings.cs
Expand Down Expand Up @@ -218,6 +219,7 @@ public string GetPhotometricType()
platformSettings.maxTextureSize = 2048;
platformSettings.resizeAlgorithm = TextureResizeAlgorithm.Bilinear;
platformSettings.textureCompression = compression;
platformSettings.format = TextureImporterFormat.RGB9E5;

TextureGenerationOutput output = TextureGenerator.GenerateTexture(settings, colorBuffer);

Expand All @@ -229,21 +231,22 @@ public string GetPhotometricType()
return (output.importInspectorWarnings, output.output);
}

private static byte PackIESValue(float value)
Color ComputePixelColor(float horizontalAnglePosition, float verticalAnglePosition, float attenuation = 1.0f)
{
return (byte)Math.Clamp(value * 255, 0, 255);
float value = m_iesReader.InterpolateBilinear(horizontalAnglePosition, verticalAnglePosition) / (m_iesReader.MaxCandelas * attenuation);
return new Color(value, value, value, value);
}

NativeArray<Color32> BuildTypeACylindricalTexture(int width, int height)
NativeArray<Color> BuildTypeACylindricalTexture(int width, int height)
{
float stepU = 360f / (width - 1);
float stepV = 180f / (height - 1);

var textureBuffer = new NativeArray<Color32>(width * height, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
var textureBuffer = new NativeArray<Color>(width * height, Allocator.Temp, NativeArrayOptions.UninitializedMemory);

for (int y = 0; y < height; y++)
{
var slice = new NativeSlice<Color32>(textureBuffer, y * width, width);
var slice = new NativeSlice<Color>(textureBuffer, y * width, width);

float latitude = y * stepV - 90f; // in range [-90..+90] degrees

Expand All @@ -255,24 +258,23 @@ NativeArray<Color32> BuildTypeACylindricalTexture(int width, int height)

float horizontalAnglePosition = m_iesReader.ComputeTypeAorBHorizontalAnglePosition(longitude);

byte value = PackIESValue(m_iesReader.InterpolateBilinear(horizontalAnglePosition, verticalAnglePosition) / m_iesReader.MaxCandelas);
slice[x] = new Color32(value, value, value, value);
slice[x] = ComputePixelColor(horizontalAnglePosition, verticalAnglePosition);
}
}

return textureBuffer;
}

NativeArray<Color32> BuildTypeBCylindricalTexture(int width, int height)
NativeArray<Color> BuildTypeBCylindricalTexture(int width, int height)
{
float stepU = k_TwoPi / (width - 1);
float stepV = Mathf.PI / (height - 1);

var textureBuffer = new NativeArray<Color32>(width * height, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
var textureBuffer = new NativeArray<Color>(width * height, Allocator.Temp, NativeArrayOptions.UninitializedMemory);

for (int y = 0; y < height; y++)
{
var slice = new NativeSlice<Color32>(textureBuffer, y * width, width);
var slice = new NativeSlice<Color>(textureBuffer, y * width, width);

float v = y * stepV - k_HalfPi; // in range [-90..+90] degrees

Expand All @@ -293,24 +295,23 @@ NativeArray<Color32> BuildTypeBCylindricalTexture(int width, int height)
float horizontalAnglePosition = m_iesReader.ComputeTypeAorBHorizontalAnglePosition(longitude);
float verticalAnglePosition = m_iesReader.ComputeVerticalAnglePosition(latitude);

byte value = PackIESValue(m_iesReader.InterpolateBilinear(horizontalAnglePosition, verticalAnglePosition) / m_iesReader.MaxCandelas);
slice[x] = new Color32(value, value, value, value);
slice[x] = ComputePixelColor(horizontalAnglePosition, verticalAnglePosition);
}
}

return textureBuffer;
}

NativeArray<Color32> BuildTypeCCylindricalTexture(int width, int height)
NativeArray<Color> BuildTypeCCylindricalTexture(int width, int height)
{
float stepU = k_TwoPi / (width - 1);
float stepV = Mathf.PI / (height - 1);

var textureBuffer = new NativeArray<Color32>(width * height, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
var textureBuffer = new NativeArray<Color>(width * height, Allocator.Temp, NativeArrayOptions.UninitializedMemory);

for (int y = 0; y < height; y++)
{
var slice = new NativeSlice<Color32>(textureBuffer, y * width, width);
var slice = new NativeSlice<Color>(textureBuffer, y * width, width);

float v = y * stepV - k_HalfPi; // in range [-90..+90] degrees

Expand All @@ -331,25 +332,24 @@ NativeArray<Color32> BuildTypeCCylindricalTexture(int width, int height)
float horizontalAnglePosition = m_iesReader.ComputeTypeCHorizontalAnglePosition(longitude);
float verticalAnglePosition = m_iesReader.ComputeVerticalAnglePosition(latitude);

byte value = PackIESValue(m_iesReader.InterpolateBilinear(horizontalAnglePosition, verticalAnglePosition) / m_iesReader.MaxCandelas);
slice[x] = new Color32(value, value, value, value);
slice[x] = ComputePixelColor(horizontalAnglePosition, verticalAnglePosition);
}
}

return textureBuffer;
}

NativeArray<Color32> BuildTypeAGnomonicTexture(float coneAngle, int size, bool applyLightAttenuation)
NativeArray<Color> BuildTypeAGnomonicTexture(float coneAngle, int size, bool applyLightAttenuation)
{
float limitUV = Mathf.Tan(0.5f * coneAngle * Mathf.Deg2Rad);
float stepUV = (2 * limitUV) / (size - 3);

var textureBuffer = new NativeArray<Color32>(size * size, Allocator.Temp, NativeArrayOptions.ClearMemory);
var textureBuffer = new NativeArray<Color>(size * size, Allocator.Temp, NativeArrayOptions.ClearMemory);

// Leave a one-pixel black border around the texture to avoid cookie spilling.
for (int y = 1; y < size - 1; y++)
{
var slice = new NativeSlice<Color32>(textureBuffer, y * size, size);
var slice = new NativeSlice<Color>(textureBuffer, y * size, size);

float v = (y - 1) * stepUV - limitUV;

Expand All @@ -368,25 +368,24 @@ NativeArray<Color32> BuildTypeAGnomonicTexture(float coneAngle, int size, bool a
// Factor in the light attenuation further from the texture center.
float lightAttenuation = applyLightAttenuation ? rayLengthSquared : 1f;

byte value = PackIESValue(m_iesReader.InterpolateBilinear(horizontalAnglePosition, verticalAnglePosition) / (m_iesReader.MaxCandelas * lightAttenuation));
slice[x] = new Color32(value, value, value, value);
slice[x] = ComputePixelColor(horizontalAnglePosition, verticalAnglePosition, lightAttenuation);
}
}

return textureBuffer;
}

NativeArray<Color32> BuildTypeBGnomonicTexture(float coneAngle, int size, bool applyLightAttenuation)
NativeArray<Color> BuildTypeBGnomonicTexture(float coneAngle, int size, bool applyLightAttenuation)
{
float limitUV = Mathf.Tan(0.5f * coneAngle * Mathf.Deg2Rad);
float stepUV = (2 * limitUV) / (size - 3);

var textureBuffer = new NativeArray<Color32>(size * size, Allocator.Temp, NativeArrayOptions.ClearMemory);
var textureBuffer = new NativeArray<Color>(size * size, Allocator.Temp, NativeArrayOptions.ClearMemory);

// Leave a one-pixel black border around the texture to avoid cookie spilling.
for (int y = 1; y < size - 1; y++)
{
var slice = new NativeSlice<Color32>(textureBuffer, y * size, size);
var slice = new NativeSlice<Color>(textureBuffer, y * size, size);

float v = (y - 1) * stepUV - limitUV;

Expand All @@ -406,25 +405,24 @@ NativeArray<Color32> BuildTypeBGnomonicTexture(float coneAngle, int size, bool a
// Factor in the light attenuation further from the texture center.
float lightAttenuation = applyLightAttenuation ? rayLengthSquared : 1f;

byte value = PackIESValue(m_iesReader.InterpolateBilinear(horizontalAnglePosition, verticalAnglePosition) / (m_iesReader.MaxCandelas * lightAttenuation));
slice[x] = new Color32(value, value, value, value);
slice[x] = ComputePixelColor(horizontalAnglePosition, verticalAnglePosition, lightAttenuation);
}
}

return textureBuffer;
}

NativeArray<Color32> BuildTypeCGnomonicTexture(float coneAngle, int size, bool applyLightAttenuation)
NativeArray<Color> BuildTypeCGnomonicTexture(float coneAngle, int size, bool applyLightAttenuation)
{
float limitUV = Mathf.Tan(0.5f * coneAngle * Mathf.Deg2Rad);
float stepUV = (2 * limitUV) / (size - 3);

var textureBuffer = new NativeArray<Color32>(size * size, Allocator.Temp, NativeArrayOptions.ClearMemory);
var textureBuffer = new NativeArray<Color>(size * size, Allocator.Temp, NativeArrayOptions.ClearMemory);

// Leave a one-pixel black border around the texture to avoid cookie spilling.
for (int y = 1; y < size - 1; y++)
{
var slice = new NativeSlice<Color32>(textureBuffer, y * size, size);
var slice = new NativeSlice<Color>(textureBuffer, y * size, size);

float v = (y - 1) * stepUV - limitUV;

Expand All @@ -443,8 +441,7 @@ NativeArray<Color32> BuildTypeCGnomonicTexture(float coneAngle, int size, bool a
// Factor in the light attenuation further from the texture center.
float lightAttenuation = applyLightAttenuation ? (uvLength * uvLength + 1) : 1f;

byte value = PackIESValue(m_iesReader.InterpolateBilinear(horizontalAnglePosition, verticalAnglePosition) / (m_iesReader.MaxCandelas * lightAttenuation));
slice[x] = new Color32(value, value, value, value);
slice[x] = ComputePixelColor(horizontalAnglePosition, verticalAnglePosition, lightAttenuation);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
area: Post-processing and UI Features
Loading
Loading