maint: added htrace ssgi

This commit is contained in:
Chris
2025-12-31 12:44:11 -05:00
parent 91ce080f51
commit 54f2d5a85f
203 changed files with 17634 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
//pipelinedefine
#define H_URP
#if UNITY_EDITOR
using System;
using System.IO;
using System.Linq;
using UnityEngine;
namespace HTraceSSGI.Scripts.PipelelinesConfigurator
{
public static class ConfiguratorUtils
{
public static string GetFullHdrpPath()
{
string targetPathStandart = Path.Combine(Directory.GetCurrentDirectory(), "Library", "PackageCache");
string hdrpPathStandart = Directory.GetDirectories(targetPathStandart)
.FirstOrDefault(name => name.Contains("high-definition") && !name.Contains("config"));
string targetPathCustom = Path.Combine(Directory.GetCurrentDirectory(), "Packages");
string hdrpPathCustom = Directory.GetDirectories(targetPathCustom)
.FirstOrDefault(name => name.Contains("high-definition") && !name.Contains("config"));
if (string.IsNullOrEmpty(hdrpPathStandart) && string.IsNullOrEmpty(hdrpPathCustom))
{
Debug.LogError($"HDRP path was not found there: {hdrpPathStandart}\n and there:\n{hdrpPathCustom}");
}
return string.IsNullOrEmpty(hdrpPathStandart) ? hdrpPathCustom : hdrpPathStandart;
}
public static string GetHTraceFolderPath()
{
//string filePath = AssetDatabase.GetAssetPath(MonoScript.FromMonoBehaviour(this));
string filePath = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
string htraceFolder = Directory.GetParent(Directory.GetParent(Path.GetDirectoryName(filePath)).FullName).FullName;
return htraceFolder;
}
public static string GetUnityAndHdrpVersion()
{
return $"Unity {Application.unityVersion}, HDRP version {GetHdrpVersion()}";
}
public static string GetHdrpVersion()
{
string fullHdrpPath = GetFullHdrpPath();
string pathPackageJson = Path.Combine(fullHdrpPath, "package.json");
string[] packageJson = File.ReadAllLines(pathPackageJson);
string hdrpVersion = string.Empty;
foreach (string line in packageJson)
{
if (line.Contains("version"))
{
hdrpVersion = line.Replace("version", "").Replace(" ", "").Replace(":", "").Replace(",", "").Replace("\"", "");
break;
}
}
return hdrpVersion;
}
public static int GetMajorHdrpVersion()
{
string hdrpVersion = GetHdrpVersion();
string[] split = hdrpVersion.Split('.');
return Convert.ToInt32(split[0]);
}
public static int GetMinorHdrpVersion()
{
string hdrpVersion = GetHdrpVersion();
string[] split = hdrpVersion.Split('.');
return Convert.ToInt32(split[1]);
}
public static int GetPatchHdrpVersion()
{
string hdrpVersion = GetHdrpVersion();
string[] split = hdrpVersion.Split('.');
return Convert.ToInt32(split[2]);
}
}
}
#endif

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 47b546814df5cef4797c41e297dc66d6
timeCreated: 1729006593
AssetOrigin:
serializedVersion: 1
productId: 336896
packageName: 'HTrace: Screen Space Global Illumination URP'
packageVersion: 1.2.0
assetPath: Assets/HTraceSSGI/Scripts/PipelelinesConfigurator/ConfiguratorUtiles.cs
uploadId: 840002

View File

@@ -0,0 +1,101 @@
#if UNITY_EDITOR
using System.IO;
using System.Linq;
using HTraceSSGI.Scripts.Globals;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
namespace HTraceSSGI.Scripts.PipelelinesConfigurator
{
internal class HPipelinesConfigurator
{
public static void UpdateDefines(HRenderPipeline hRenderPipeline)
{
string firstLine = "//pipelinedefine";
var hTraceFolderPath = ConfiguratorUtils.GetHTraceFolderPath();
string supportedExtensions = "*.cs,*.hlsl,*.compute,*.glsl,*.shader";
var filesPaths = Directory.GetFiles(hTraceFolderPath, "*.*", SearchOption.AllDirectories).Where(s => supportedExtensions.Contains(Path.GetExtension(s).ToLower()));
foreach (string filePath in filesPaths)
{
string[] allLinesFile = File.ReadAllLines(filePath);
if (allLinesFile[0] == firstLine)
{
switch (hRenderPipeline)
{
case HRenderPipeline.None:
allLinesFile[1] = "#define NONE";
break;
case HRenderPipeline.BIRP:
if (allLinesFile[1] == "#define H_BIRP")
continue;
allLinesFile[1] = "#define H_BIRP";
break;
case HRenderPipeline.URP:
if (allLinesFile[1] == "#define H_URP")
continue;
allLinesFile[1] = "#define H_URP";
break;
case HRenderPipeline.HDRP:
if (allLinesFile[1] == "#define H_HDRP")
continue;
allLinesFile[1] = "#define H_HDRP";
break;
}
}
else
{
continue;
}
File.WriteAllLines(filePath, allLinesFile);
}
Debug.Log($"Defines updated successfully {hRenderPipeline}!");
}
public static void AlwaysIncludedShaders()
{
AddShaderToGraphicsSettings("Hidden/HTraceSSGI/MotionVectorsURP");
AddShaderToGraphicsSettings("Hidden/HTraceSSGI/ColorComposeURP");
}
public static void AddShaderToGraphicsSettings(string shaderName)
{
var shader = Shader.Find(shaderName);
if (shader == null)
return;
var graphicsSettings = AssetDatabase.LoadAssetAtPath<GraphicsSettings>("ProjectSettings/GraphicsSettings.asset");
var serializedObject = new SerializedObject(graphicsSettings);
var arrayProp = serializedObject.FindProperty("m_AlwaysIncludedShaders");
bool hasShader = false;
for (int i = 0; i < arrayProp.arraySize; ++i)
{
var arrayElem = arrayProp.GetArrayElementAtIndex(i);
if (shader == arrayElem.objectReferenceValue)
{
hasShader = true;
break;
}
}
if (!hasShader)
{
int arrayIndex = arrayProp.arraySize;
arrayProp.InsertArrayElementAtIndex(arrayIndex);
var arrayElem = arrayProp.GetArrayElementAtIndex(arrayIndex);
arrayElem.objectReferenceValue = shader;
serializedObject.ApplyModifiedProperties();
AssetDatabase.SaveAssets();
}
}
}
}
#endif

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 78d7385774d0ece4ab24703dc44d4f4f
timeCreated: 1729006583
AssetOrigin:
serializedVersion: 1
productId: 336896
packageName: 'HTrace: Screen Space Global Illumination URP'
packageVersion: 1.2.0
assetPath: Assets/HTraceSSGI/Scripts/PipelelinesConfigurator/HPipelinesConfigurator.cs
uploadId: 840002