diff --git a/Assets/Plugins/HTraceSSGI.meta b/Assets/Plugins/HTraceSSGI.meta new file mode 100644 index 0000000..69e574b --- /dev/null +++ b/Assets/Plugins/HTraceSSGI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 772a801e4d7875842bc2f6e62abe5777 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/HTraceSSGI Quick-Start Manual.pdf b/Assets/Plugins/HTraceSSGI/HTraceSSGI Quick-Start Manual.pdf new file mode 100644 index 0000000..db668f2 Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/HTraceSSGI Quick-Start Manual.pdf differ diff --git a/Assets/Plugins/HTraceSSGI/HTraceSSGI Quick-Start Manual.pdf.meta b/Assets/Plugins/HTraceSSGI/HTraceSSGI Quick-Start Manual.pdf.meta new file mode 100644 index 0000000..61ea39f --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/HTraceSSGI Quick-Start Manual.pdf.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: dbec97f308251d742b13d987ef881cbc +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/HTraceSSGI Quick-Start Manual.pdf + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/HTraceSSGI.asmdef b/Assets/Plugins/HTraceSSGI/HTraceSSGI.asmdef new file mode 100644 index 0000000..63e1898 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/HTraceSSGI.asmdef @@ -0,0 +1,24 @@ +{ + "name": "HTraceSSGI", + "rootNamespace": "", + "references": [ + "GUID:3eae0364be2026648bf74846acb8a731", + "GUID:78bd2ddd6e276394a9615c203e574844", + "GUID:c579267770062bf448e75eb160330b7f", + "GUID:df380645f10b7bc4b97d4f5eb6303d95", + "GUID:457756d89b35d2941b3e7b37b4ece6f1", + "GUID:15fc0a57446b3144c949da3e2b9737a9", + "GUID:b4517ec124862cb4bb3b8b27d72843a6", + "GUID:ab67fb10353d84448ac887a7367cbda8", + "GUID:75469ad4d38634e559750d17036d5f7c" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/HTraceSSGI.asmdef.meta b/Assets/Plugins/HTraceSSGI/HTraceSSGI.asmdef.meta new file mode 100644 index 0000000..b40bf0b --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/HTraceSSGI.asmdef.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c83bdcd2d30ce80428fffd5ed2cb670f +timeCreated: 1674796741 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/HTraceSSGI.asmdef + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Icons.meta b/Assets/Plugins/HTraceSSGI/Icons.meta new file mode 100644 index 0000000..d416f1a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Icons.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e68f1575a717afb4f9f5b0a24029a1ae +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Icons/HTrace SSGI Icon.png b/Assets/Plugins/HTraceSSGI/Icons/HTrace SSGI Icon.png new file mode 100644 index 0000000..4af2d32 Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Icons/HTrace SSGI Icon.png differ diff --git a/Assets/Plugins/HTraceSSGI/Icons/HTrace SSGI Icon.png.meta b/Assets/Plugins/HTraceSSGI/Icons/HTrace SSGI Icon.png.meta new file mode 100644 index 0000000..52a01fb --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Icons/HTrace SSGI Icon.png.meta @@ -0,0 +1,124 @@ +fileFormatVersion: 2 +guid: 72a9ca4a910cb6e478e3b0b89afa0b3c +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 128 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Icons/HTrace SSGI Icon.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Icons/Resources.meta b/Assets/Plugins/HTraceSSGI/Icons/Resources.meta new file mode 100644 index 0000000..125d720 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Icons/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 079947b8551f06a49aefeee0ac313b52 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Icons/Resources/SSGI UI Card.png b/Assets/Plugins/HTraceSSGI/Icons/Resources/SSGI UI Card.png new file mode 100644 index 0000000..127f341 Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Icons/Resources/SSGI UI Card.png differ diff --git a/Assets/Plugins/HTraceSSGI/Icons/Resources/SSGI UI Card.png.meta b/Assets/Plugins/HTraceSSGI/Icons/Resources/SSGI UI Card.png.meta new file mode 100644 index 0000000..540f701 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Icons/Resources/SSGI UI Card.png.meta @@ -0,0 +1,124 @@ +fileFormatVersion: 2 +guid: 794f3cf37bffa5b489c41a10a9f65492 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 1 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Icons/Resources/SSGI UI Card.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources.meta b/Assets/Plugins/HTraceSSGI/Resources.meta new file mode 100644 index 0000000..ee47674 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd0d146c752f0f7489f7995e5e5499c9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI.meta new file mode 100644 index 0000000..07eda17 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 263aa0d227a83dc4ca6c2fc4192f02d2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise.meta new file mode 100644 index 0000000..d70bae2 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4ee20b6f611369444acf19533acf34bb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise256.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise256.png new file mode 100644 index 0000000..ee6c446 Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise256.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise256.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise256.png.meta new file mode 100644 index 0000000..61a3d99 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise256.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: d136d460c5b2faa48b1da6098c1362ca +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise256.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise4.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise4.png new file mode 100644 index 0000000..70d66c6 Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise4.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise4.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise4.png.meta new file mode 100644 index 0000000..94ad024 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise4.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 7708504b58552e441af54534c7810c94 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/OwenScrambledNoise4.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile1SPP.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile1SPP.png new file mode 100644 index 0000000..3d16339 Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile1SPP.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile1SPP.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile1SPP.png.meta new file mode 100644 index 0000000..a1e1b9b --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile1SPP.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 93b82a938a7bec34687ba2936e9c867c +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile1SPP.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile256SPP.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile256SPP.png new file mode 100644 index 0000000..d117179 Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile256SPP.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile256SPP.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile256SPP.png.meta new file mode 100644 index 0000000..ad90e7f --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile256SPP.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 2d193765922195249804503e5bf21bde +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile256SPP.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile8SPP.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile8SPP.png new file mode 100644 index 0000000..521166d Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile8SPP.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile8SPP.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile8SPP.png.meta new file mode 100644 index 0000000..51136b1 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile8SPP.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 4cf78bccf8ab83042806476d7947fd9a +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/RankingTile8SPP.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScrambleNoise.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScrambleNoise.png new file mode 100644 index 0000000..82493df Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScrambleNoise.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScrambleNoise.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScrambleNoise.png.meta new file mode 100644 index 0000000..39b1dae --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScrambleNoise.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 95d6a0e569139f84fbe6573d9a4909f7 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 8192 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScrambleNoise.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile1SPP.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile1SPP.png new file mode 100644 index 0000000..231f11a Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile1SPP.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile1SPP.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile1SPP.png.meta new file mode 100644 index 0000000..8f2d281 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile1SPP.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 4e89ef6da80edf7408080313796a85df +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile1SPP.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile256SPP.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile256SPP.png new file mode 100644 index 0000000..cb69c8a Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile256SPP.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile256SPP.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile256SPP.png.meta new file mode 100644 index 0000000..95872f2 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile256SPP.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 21a227d96560f5e4eba8df75749c0d41 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile256SPP.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile8SPP.png b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile8SPP.png new file mode 100644 index 0000000..39c517d Binary files /dev/null and b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile8SPP.png differ diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile8SPP.png.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile8SPP.png.meta new file mode 100644 index 0000000..6f6e754 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile8SPP.png.meta @@ -0,0 +1,137 @@ +fileFormatVersion: 2 +guid: 447e554854bca1d4e822e506707c9f40 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 0 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 0 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 0 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/BlueNoise/ScramblingTile8SPP.png + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes.meta new file mode 100644 index 0000000..9d9c9c5 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 41620bce39125404eae8bf1b7d1dd7d9 +timeCreated: 1724756783 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HCheckerboardingSSGI.compute b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HCheckerboardingSSGI.compute new file mode 100644 index 0000000..459e61b --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HCheckerboardingSSGI.compute @@ -0,0 +1,85 @@ +#pragma kernel CheckerboardClassification +#pragma kernel IndirectArguments + +#include "../Includes/HCommonSSGI.hlsl" +#pragma multi_compile _ _GBUFFER_NORMALS_OCT + +H_TEXTURE(_SampleCount); + +RWStructuredBuffer _RayCounter; +RWStructuredBuffer _RayCounter_Output; +RWStructuredBuffer _IndirectCoords_Output; +RWStructuredBuffer _IndirectArguments_Output; + +uint _RayTracedCounter; + +groupshared uint SharedRayAllocator; +groupshared uint SharedAllocationStartOffset; +groupshared uint2 SharedAllocatedRays[8 * 8]; + + +// ------------------------ CHECKERBOARD CLASSIFICATION ------------------------- +[numthreads(8, 8, 1)] +void CheckerboardClassification(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint groupIndex : SV_GroupIndex, uint2 groupID : SV_GroupID) +{ + + if (groupIndex == 0) SharedRayAllocator = 0; + GroupMemoryBarrierWithGroupSync(); + + uint IndirectCoordOffsetVR = _ScreenSize.x * _ScreenSize.y * pixCoord.z / _HScaleFactorSSGI; + uint RayCounterOffsetVR = 2 * pixCoord.z; + + float Samplecount = H_LOAD(_SampleCount, pixCoord.xy).x; + + bool CullCheckerboard = false; + if (((pixCoord.x + pixCoord.y) % 2 == 0 && uint(_FrameCount) % 2 == 0) || Samplecount <= 1) + CullCheckerboard = true; + if (((pixCoord.x + pixCoord.y) % 2 != 0 && uint(_FrameCount) % 2 != 0) || Samplecount <= 1) + CullCheckerboard = true; + + if (CullCheckerboard) + { + // uint Index = 0; + // InterlockedAdd(_RayCounter_Output[0 + RayCounterOffsetVR], 1, Index); + // _IndirectCoords_Output[Index + IndirectCoordOffsetVR] = pixCoord.xy; + + uint SharedTexelOffset; + InterlockedAdd(SharedRayAllocator, 1, SharedTexelOffset); + SharedAllocatedRays[SharedTexelOffset] = pixCoord.xy; + } + + GroupMemoryBarrierWithGroupSync(); + + uint ThreadIndex = groupThreadID.y * 8 + groupThreadID.x; + + if (ThreadIndex == 0) + { + InterlockedAdd(_RayCounter_Output[0 + RayCounterOffsetVR], SharedRayAllocator, SharedAllocationStartOffset); + } + + GroupMemoryBarrierWithGroupSync(); + + if (ThreadIndex < SharedRayAllocator) + { + _IndirectCoords_Output[SharedAllocationStartOffset + ThreadIndex + IndirectCoordOffsetVR] = SharedAllocatedRays[ThreadIndex]; + } +} + + +// ------------------------ INDIRECT ARGUMENTS GENERATION ------------------------- +[numthreads(1, 1, 1)] +void IndirectArguments(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID, uint2 groupID : SV_GroupID) +{ + + uint IndirectArgumentsOffsetVR = 3 * pixCoord.z; + uint RayCounterOffsetVR = 2 * pixCoord.z; + + uint RayCounterBuffer = _RayCounter[0 + RayCounterOffsetVR]; + + _IndirectArguments_Output[0 + IndirectArgumentsOffsetVR] = (RayCounterBuffer + 63) / 64; + _IndirectArguments_Output[1 + IndirectArgumentsOffsetVR] = 1; + _IndirectArguments_Output[2 + IndirectArgumentsOffsetVR] = 1; + + _RayCounter[0 + RayCounterOffsetVR] = 0; + _RayCounter[1 + RayCounterOffsetVR] = RayCounterBuffer; +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HCheckerboardingSSGI.compute.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HCheckerboardingSSGI.compute.meta new file mode 100644 index 0000000..7fde4e9 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HCheckerboardingSSGI.compute.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 412aeb9af3abb33439c8084a878f56c2 +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Computes/HCheckerboardingSSGI.compute + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDebugSSGI.compute b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDebugSSGI.compute new file mode 100644 index 0000000..ae7038c --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDebugSSGI.compute @@ -0,0 +1,116 @@ +#pragma kernel Debug + +#include "../Includes/HCommonSSGI.hlsl" +#include "../Includes/HFallbackSSGI.hlsl" +#pragma multi_compile _ _GBUFFER_NORMALS_OCT + +H_TEXTURE(_SampleCountSSGI); +H_TEXTURE(_HTraceBufferGI); + +H_RW_TEXTURE(float4, _Debug_Output); + +uint _DebugSwitch; +uint _BuffersSwitch; +float _IndirectLightingIntensity; + +void DebugFinal(uint3 pixCoord) +{ + if (_DebugSwitch == 1) + { + if (_BuffersSwitch == 0) // Multi + { + uint2 AuadSize = _ScreenSize.xy / 2; + uint2 AuadIndex = pixCoord.xy / AuadSize; // (0,0), (1,0), (0,1), (1,1) + uint2 LocalCoord = pixCoord.xy % AuadSize; + uint2 SampleCoord = LocalCoord * 2; + + float4 Output = float4(0, 0, 0, 1); + + if (HBUFFER_DEPTH(SampleCoord.xy) <= UNITY_RAW_FAR_CLIP_VALUE) + { + _Debug_Output[H_COORD(pixCoord.xy)] = Output; + return; + } + + if (AuadIndex.x == 0 && AuadIndex.y == 0) // Bottom Left + { + Output = float4(HBUFFER_NORMAL_WS(SampleCoord).xyz, 1); + } + else if (AuadIndex.x == 1 && AuadIndex.y == 0) // Bottom Right + { + float2 motionVector = HBUFFER_MOTION_VECTOR(SampleCoord).xy; + float motionMask = HBUFFER_MOTION_MASK(SampleCoord).x; + Output = float4(motionVector * 5, motionMask * 0.05, 1); + } + else if (AuadIndex.x == 0 && AuadIndex.y == 1) // Top Left + { + Output = float4(H_LINEAR_EYE_DEPTH(H_LOAD(g_HTraceDepthPyramidSSGI, SampleCoord).x).xxx / 20.0f, 1); + } + else if (AuadIndex.x == 1 && AuadIndex.y == 1) // Top Right + { + Output = float4(HBUFFER_DIFFUSE(SampleCoord).xyz, 1); + } + + _Debug_Output[H_COORD(pixCoord.xy)] = Output; + return; + } + + if (HBUFFER_DEPTH(pixCoord.xy) <= UNITY_RAW_FAR_CLIP_VALUE) + { + _Debug_Output[H_COORD(pixCoord.xy)] = 0; + return; + } + + if (_BuffersSwitch == 1) // Depth + { + _Debug_Output[H_COORD(pixCoord.xy)] = float4(H_LINEAR_EYE_DEPTH(H_LOAD(g_HTraceDepthPyramidSSGI, pixCoord.xy).x).xxx / 20.0f, 1); + } + if (_BuffersSwitch == 2) // Diffuse + { + _Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_DIFFUSE(pixCoord.xy).xyz, 1); + } + if (_BuffersSwitch == 3) // Normal + { + _Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_NORMAL_WS(pixCoord.xy).xyz, 1); + } + if (_BuffersSwitch == 4) // Motion Mask + { + _Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_MOTION_MASK(pixCoord.xy).xxx, 1); + } + if (_BuffersSwitch == 5) // Motion Vectors + { + _Debug_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_MOTION_VECTOR(pixCoord.xy).xy * 5, 0, 1); + } + } + + if (HBUFFER_DEPTH(pixCoord.xy) <= UNITY_RAW_FAR_CLIP_VALUE) + { + float3 Sky = 0; + if (_DebugSwitch == 2) + Sky = EvaluateFallbackSky(H_GET_VIEW_VECTOR_WS((pixCoord.xy + 0.5f) * _ScreenSize.zw)); + + _Debug_Output[H_COORD(pixCoord.xy)] = float4(Sky, 1); + return; + } + if (_DebugSwitch == 2) + { + _Debug_Output[H_COORD(pixCoord.xy)] = HBUFFER_COLOR(pixCoord.xy); + } + if (_DebugSwitch == 3) + { + _Debug_Output[H_COORD(pixCoord.xy)] = H_LOAD(_HTraceBufferGI, pixCoord.xy) * _IndirectLightingIntensity; + } + if (_DebugSwitch == 4) + { + float Samplecount = H_LOAD(_SampleCountSSGI, pixCoord.xy / _HScaleFactorSSGI).x; + float3 Output = Samplecount < 1 ? float3(1,0,0) : Samplecount.xxx / 16.0f; + _Debug_Output[H_COORD(pixCoord.xy)] = float4(Output, 1); + } +} + +[numthreads(8, 8, 1)] +void Debug(uint3 pixCoord : SV_DispatchThreadID) +{ + + DebugFinal(pixCoord); +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDebugSSGI.compute.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDebugSSGI.compute.meta new file mode 100644 index 0000000..1cf1945 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDebugSSGI.compute.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 163108b35413d864fa7afffcb87d9861 +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Computes/HDebugSSGI.compute + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDenoiserSSGI.compute b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDenoiserSSGI.compute new file mode 100644 index 0000000..e6ca9d0 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDenoiserSSGI.compute @@ -0,0 +1,343 @@ +#pragma kernel TemporalAccumulation +#pragma kernel TemporalStabilization +#pragma kernel PointDistributionFill +#pragma kernel SpatialFilter + +#pragma kernel SpatialFilter1 SpatialFilter = SpatialFilter1 +#pragma kernel SpatialFilter2 SpatialFilter = SpatialFilter2 SECOND_PASS + +#include "../Includes/HReservoirSSGI.hlsl" +#pragma multi_compile _ _GBUFFER_NORMALS_OCT +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderVariablesFunctions.hlsl" + +#pragma multi_compile _ USE_SPATIAL_OCCLUSION +#pragma multi_compile _ USE_TEMPORAL_INVALIDITY +#pragma multi_compile _ INTERPOLATION_OUTPUT + +#define TEMPORAL_DENOISING_SAMPLECOUNT 16 +#define TEMPORAL_STABILIZATION_SAMPLECOUNT 16 + +H_TEXTURE(_Radiance); +H_TEXTURE(_NormalDepth); +H_TEXTURE(_AmbientOcclusion); +H_TEXTURE(_SpatialGuidance); +H_TEXTURE(_RadianceReprojected); +H_TEXTURE(_TemporalInvalidity); +H_TEXTURE(_SamplecountReprojected); +H_TEXTURE(_SpatialOcclusion); + +H_RW_TEXTURE(float4, _Radiance_TemporalOutput); +H_RW_TEXTURE(float3, _Radiance_SpatialOutput); +H_RW_TEXTURE(float3, _Radiance_Output); +H_RW_TEXTURE(float, _Samplecount_Output); +H_RW_TEXTURE(uint2, _RadianceNormalDepth_Output); + +StructuredBuffer _PointDistribution; +RWStructuredBuffer _PointDistribution_Output; + +float _FilterRadius; +float _FilterAdaptivity; + + +// ------------------------ TEMPORAL FUNCTIONS ------------------------- +float3 DirectClipToAABB(float3 History, float3 Min, float3 Max) +{ + float3 Center = 0.5 * (Max + Min); + float3 Extents = 0.5 * (Max - Min); + + float3 Offset = History - Center; + float3 Vunit = Offset.xyz / Extents.xyz; + float3 AbsUnit = abs(Vunit); + float MaxUnit = max(max(AbsUnit.x, AbsUnit.y), AbsUnit.z); + + if (MaxUnit > 1.0) return Center + (Offset / MaxUnit); + else return History; +} + + +// ------------------------ POINT DISTRIBUTION BUFFER -------------------- +[numthreads(128, 1, 1)] +void PointDistributionFill(uint pixCoord : SV_DispatchThreadID) +{ + // _PointDistribution_Output[pixCoord.x] = HSampleDiskCubic(GetLDSequenceSampleFloat(pixCoord.x, 0), GetLDSequenceSampleFloat(pixCoord.x, 1)); + + static const float3 k_PoissonDiskSamples[8] = + { + // https://www.desmos.com/calculator/abaqyvswem + float3( -1.00 , 0.00 , 1.0 ), + float3( 0.00 , 1.00 , 1.0 ), + float3( 1.00 , 0.00 , 1.0 ), + float3( 0.00 , -1.00 , 1.0 ), + float3( -0.25 * sqrt(2.0) , 0.25 * sqrt(2.0) , 0.5 ), + float3( 0.25 * sqrt(2.0) , 0.25 * sqrt(2.0) , 0.5 ), + float3( 0.25 * sqrt(2.0) , -0.25 * sqrt(2.0) , 0.5 ), + float3( -0.25 * sqrt(2.0) , -0.25 * sqrt(2.0) , 0.5 ) + }; + + int i = pixCoord; + uint JitterIndex = (uint(_FrameCount) % 8) + i; + float2 SampleJitter = SampleUnitDisk(JitterIndex) * 0.15; + + // 8 offsets with jitter + if (pixCoord.x < 8) + { + float3 Sample = k_PoissonDiskSamples[i]; + Sample.xy += SampleJitter; + + _PointDistribution_Output[i] = Sample; + } + + // 8 offsets without jitter + if (pixCoord.x >= 8 && pixCoord.x < 16) + { + _PointDistribution_Output[i] = k_PoissonDiskSamples[i - 8]; + } +} + + +// ------------------------ TEMPORAL ACCUMULATION ------------------------ +[numthreads(8, 8, 1)] +void TemporalAccumulation(uint3 pixCoord : SV_DispatchThreadID) +{ + + float3 Radiance = H_LOAD(_Radiance, pixCoord.xy).xyz; + float3 RadianceHistory = H_LOAD(_RadianceReprojected, pixCoord.xy).xyz; + + float3 Moment1 = Radiance; + float3 Moment2 = Radiance * Radiance; + float WeightTotal = 1.0; + + float CenterLuminance = Luminance(Radiance); + float MaxLuma = -9999; float MinLuma = 9999; + float3 MaxLumaSample, MinLumaSample; + + const static int2 SampleOffsets[8] = {int2(1, 0), int2(0, 1), int2(-1, 0), int2(0, -1), int2(1, -1), int2(-1, 1), int2(-1, -1), int2(1, 1)}; + + for (int i = 0; i < 8; i++) + { + int2 Offset = SampleOffsets[i]; + + float Weight = exp(-3.0 * float(Offset.x * Offset.x + Offset.y * Offset.y) / 4.0f); + float3 Sample = H_LOAD(_Radiance, pixCoord.xy + Offset * 1).xyz; + Moment1 += Sample * Weight; + Moment2 += Sample * Sample * Weight; + WeightTotal += Weight; + + float SampleLuma = Luminance(Sample); + if (MaxLuma < SampleLuma) { MaxLuma = SampleLuma; MaxLumaSample = Sample; } + if (MinLuma > SampleLuma) { MinLuma = SampleLuma; MinLumaSample = Sample; } + } + + Moment1 /= WeightTotal; + Moment2 /= WeightTotal; + float3 StdDev = sqrt(max(0.0, Moment2 - Moment1 * Moment1)); + + float2 TemporalInvalidity = 1; + if (USE_TEMPORAL_INVALIDITY) + { + TemporalInvalidity = H_LOAD(_TemporalInvalidity, pixCoord.xy).xy; + TemporalInvalidity.x = pow(TemporalInvalidity.x, 5); + TemporalInvalidity.y = TemporalInvalidity.y < 0.95f ? 0 : TemporalInvalidity.y; + } + + float ClampBoxSize = 0.5; + float ClampBoxMultiplier = lerp(1, 5, TemporalInvalidity.x); + float3 Min = lerp(Radiance, Moment1, ClampBoxSize * ClampBoxSize) - StdDev * ClampBoxSize * ClampBoxMultiplier; + float3 Max = lerp(Radiance, Moment1, ClampBoxSize * ClampBoxSize) + StdDev * ClampBoxSize * ClampBoxMultiplier; + + RadianceHistory = DirectClipToAABB(RadianceHistory, Min, Max); + + float SamplecountReprojected = H_LOAD(_SamplecountReprojected, pixCoord.xy).x; + float Samplecount = min(TEMPORAL_DENOISING_SAMPLECOUNT, SamplecountReprojected + 1); + float TemporalWeight = 1.0f - (1.0f / float(Samplecount)); + + if (ENABLE_RCRS_FILTER) + { + if (CenterLuminance >= MinLuma && CenterLuminance <= MaxLuma) { Radiance = Radiance;} + else if (CenterLuminance > MaxLuma) { Radiance = MaxLumaSample; } + else { Radiance = MinLumaSample; } + } + + if (ENABLE_EXPOSURE_CONTROL) + { + float ExposurePrevious = HGetPreviousExposureMultiplier; + float ExposureCurrent = HGetCurrentExposureMultiplier; + + float ExposureRatio = (ExposurePrevious * ExposureCurrent) != 0.0 ? ExposureCurrent / ExposurePrevious : 100.0; + + if (max(ExposureRatio, 1.0 / ExposureRatio) > 2.0) + TemporalWeight = 0; + } + + Radiance = lerp(Radiance, RadianceHistory, TemporalWeight * TemporalInvalidity.y * ENABLE_TEMPORAL_DENOISING); + + _Radiance_TemporalOutput[H_COORD(pixCoord.xy)] = float4(Radiance, 0); + _Radiance_SpatialOutput[H_COORD(pixCoord.xy)] = Radiance; + _Samplecount_Output[H_COORD(pixCoord.xy)] = Samplecount; +} + + +// ------------------------ TEMPORAL STABILIZATION ------------------------ +[numthreads(8, 8, 1)] +void TemporalStabilization(uint3 pixCoord : SV_DispatchThreadID) +{ + + float3 Radiance = H_LOAD(_Radiance, pixCoord.xy).xyz; + float4 RadianceSamplecountHistory = H_LOAD(_RadianceReprojected, pixCoord.xy); + + float3 Moment1 = Radiance; + float3 Moment2 = Radiance * Radiance; + float WeightTotal = 1.0; + + const static int2 SampleOffsets[8] = {int2(1, 0), int2(0, 1), int2(-1, 0), int2(0, -1), int2(1, -1), int2(-1, 1), int2(-1, -1), int2(1, 1)}; + + for (int i = 0; i < 8; i++) + { + int2 Offset = SampleOffsets[i]; + + float Weight = exp(-3.0 * float(Offset.x * Offset.x + Offset.y * Offset.y) / 4.0f); + float3 Sample = H_LOAD(_Radiance, pixCoord.xy + Offset * 1).xyz; + Moment1 += Sample * Weight; + Moment2 += Sample * Sample * Weight; + WeightTotal += Weight; + } + + Moment1 /= WeightTotal; + Moment2 /= WeightTotal; + float3 StdDev = sqrt(max(0.0, Moment2 - Moment1 * Moment1)); + + float2 TemporalInvalidity = 1; + if (USE_TEMPORAL_INVALIDITY) + { + TemporalInvalidity = H_LOAD(_TemporalInvalidity, pixCoord.xy / _HScaleFactorSSGI).xy; + TemporalInvalidity.x = pow(TemporalInvalidity.x, 5); + TemporalInvalidity.y = TemporalInvalidity.y < 0.95f ? 0 : TemporalInvalidity.y; + } + + float ClampBoxSize = 0.5; + float ClampBoxMultiplier = lerp(3, 6, TemporalInvalidity.x * 2); + float3 Min = lerp(Radiance, Moment1, ClampBoxSize * ClampBoxSize) - StdDev * ClampBoxSize * ClampBoxMultiplier; + float3 Max = lerp(Radiance, Moment1, ClampBoxSize * ClampBoxSize) + StdDev * ClampBoxSize * ClampBoxMultiplier; + + RadianceSamplecountHistory.xyz = DirectClipToAABB(RadianceSamplecountHistory.xyz, Min, Max); + + float Samplecount = min(TEMPORAL_STABILIZATION_SAMPLECOUNT, RadianceSamplecountHistory.w + 1); + float TemporalWeight = 1.0f - (1.0f / float(Samplecount)); + + if (ENABLE_EXPOSURE_CONTROL) + { + float ExposurePrevious = HGetPreviousExposureMultiplier; + float ExposureCurrent = HGetCurrentExposureMultiplier; + + float ExposureRatio = (ExposurePrevious * ExposureCurrent) != 0.0 ? ExposureCurrent / ExposurePrevious : 100.0; + + if (max(ExposureRatio, 1.0 / ExposureRatio) > 2.0) + TemporalWeight = 0; + } + + Radiance = lerp(Radiance, RadianceSamplecountHistory.xyz, TemporalWeight * TemporalInvalidity.y * ENABLE_TEMPORAL_STABILIZATION); + + _Radiance_TemporalOutput[H_COORD(pixCoord.xy)] = float4(Radiance.xyz, Samplecount.x); +} + + +// ------------------------ SPATIAL FILTER ------------------------ +[numthreads(8, 8, 1)] +void SpatialFilter(uint3 pixCoord : SV_DispatchThreadID) +{ + + uint2 pixCoordUnscaled = GetUnscaledCoords(pixCoord.xy); + int2 pixCoordMax = _ScreenSize.xy / _HScaleFactorSSGI.xx - 1; + float2 pixCoordNDC = (float2(pixCoordUnscaled) + 0.5f) * _ScreenSize.zw; + + uint NormalDepthPacked = asuint(H_LOAD(_NormalDepth, pixCoord.xy).x); + float4 NormalDepth = UnpackNormalDepth(NormalDepthPacked); + + if (NormalDepth.w <= UNITY_RAW_FAR_CLIP_VALUE) { return; } + + float3 Radiance = H_LOAD(_Radiance, pixCoord.xy).xyz; + Radiance = SpatialDenoisingTonemap(Radiance); + + float DepthCetnerLinear = H_LINEAR_EYE_DEPTH(NormalDepth.w); + float3 NormalCenterVS = H_TRANSFORM_WORLD_TO_VIEW_NORMAL(NormalDepth.xyz); + float3 PositionCenterWS = H_COMPUTE_POSITION_WS(pixCoordNDC, NormalDepth.w, H_MATRIX_I_VP); + float3 PositionCenterVS = ComputeFastViewSpacePosition(pixCoordNDC, NormalDepth.w, DepthCetnerLinear); + float4 NormalPlaneVS = float4(NormalCenterVS.xyz, dot(PositionCenterVS, NormalCenterVS.xyz)); + float SpatialOcclusionCenter = H_LOAD(_SpatialOcclusion, pixCoord.xy).x; + + uint2 SpatialGuidancePacked = asuint(H_LOAD(_SpatialGuidance, pixCoord.xy).xy); + float AdaptiveFilterScale = UnpackAmbientOcclusion(SpatialGuidancePacked.y); + float AdaptivePlaneWeight = lerp(500.0f, 100.0f, AdaptiveFilterScale); + uint SpatialGuidance = SpatialGuidancePacked.x; + + float FilterRadius = _FilterRadius / 2.0f; + #ifdef SECOND_PASS + FilterRadius = _FilterRadius; + #endif + + float MinFilterRadius = lerp(0.01f, 0.1f, H_LOAD(_AmbientOcclusion, pixCoord.xy).x); + FilterRadius = max(MinFilterRadius, lerp(FilterRadius, FilterRadius * AdaptiveFilterScale, _FilterAdaptivity)); + + float DistanceToPoint = length(H_GET_ABSOLUTE_POSITION_WS(PositionCenterWS) - H_GET_CAMERA_POSITION_WS()); + float3x3 OrthoBasis = HGetLocalFrame(NormalDepth.xyz); + float RadiusScale = lerp(5.0f, 50.0f, saturate(DistanceToPoint / 500.0f)); + float Radius = DistanceToPoint * FilterRadius / RadiusScale; + float Sigma = 0.9f * Radius; + + float WeightAccumulated = 1; + + float2 PerPixelJitter; + PerPixelJitter.x = HInterleavedGradientNoise(pixCoord.xy, 0); + PerPixelJitter.y = HInterleavedGradientNoise(pixCoord.yx, 1); + PerPixelJitter = (PerPixelJitter * 2 - 1) * 0.15; + + UNITY_UNROLL + for (int i = 0; i < 8; i++) + { + float GuidanceAdaptivity = 1 - (0.75 * ((SpatialGuidance >> i) & 0x1)); + float2 Point = (_PointDistribution[i + 8].xy + PerPixelJitter) * Radius * GuidanceAdaptivity; + + float3 PositionPointWS = PositionCenterWS + OrthoBasis[0] * Point.x + OrthoBasis[1] * Point.y; + float2 SampleCoordNDC = H_COMPUTE_NDC_Z(PositionPointWS, H_MATRIX_VP).xy; + int2 SampleCoord = SampleCoordNDC * _ScreenSize.xy / _HScaleFactorSSGI; + + int2 Overshoot = max(SampleCoord - pixCoordMax, 0); + SampleCoord -= 2 * Overshoot; + + uint NormalDepthPacked = asuint(H_LOAD(_NormalDepth, SampleCoord).x); + float4 NormalDepthSample = UnpackNormalDepth(NormalDepthPacked); + float SpatialOcclusionSample = H_LOAD(_SpatialOcclusion, SampleCoord).x; + + float3 PositionSampleVS = ComputeFastViewSpacePosition(SampleCoordNDC, NormalDepthSample.w, H_LINEAR_EYE_DEPTH(NormalDepthSample.w)); + float PlaneWeight = ProbePlaneWeighting(NormalPlaneVS, PositionSampleVS, DepthCetnerLinear, AdaptivePlaneWeight); + + float NormalWeight = saturate(dot(NormalDepth.xyz, NormalDepthSample.xyz)); + float GaussianWeight = GaussianWeighting(length(Point), Sigma); + float OcclusionWeight = 1.0f; + + if (USE_SPATIAL_OCCLUSION) + { OcclusionWeight = exp2(-max(5, 10 * (1 - SpatialOcclusionCenter)) * abs(SpatialOcclusionCenter - SpatialOcclusionSample)); } + + float SampleWeight = NormalWeight * PlaneWeight * OcclusionWeight * GaussianWeight * ENABLE_SPATIAL_DENOISING; + WeightAccumulated += SampleWeight; + + float3 RadianceSample = H_LOAD(_Radiance, SampleCoord).xyz; + RadianceSample = SpatialDenoisingTonemap(RadianceSample); + Radiance += RadianceSample * SampleWeight; + } + + Radiance /= WeightAccumulated; + Radiance = SpatialDenoisingTonemapInverse(Radiance); + + if (AnyIsNaN(Radiance) || AnyIsInf(Radiance)) + Radiance = 0; + + // Radiance = AdaptiveFilterScale; + + #if SECOND_PASS + if (INTERPOLATION_OUTPUT) _RadianceNormalDepth_Output[H_COORD(pixCoord.xy)] = uint2(PackToR11G11B10f(Radiance), PackNormalDepth(NormalDepth.xyz, NormalDepth.w)); + else _Radiance_Output[H_COORD(pixCoord.xy)] = Radiance; + #else + _Radiance_Output[H_COORD(pixCoord.xy)] = Radiance; + #endif +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDenoiserSSGI.compute.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDenoiserSSGI.compute.meta new file mode 100644 index 0000000..fb6da3d --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDenoiserSSGI.compute.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 4e9dcd36d21eeca4a93de42f47c188ce +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Computes/HDenoiserSSGI.compute + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDepthPyramid.compute b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDepthPyramid.compute new file mode 100644 index 0000000..be6a6bc --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDepthPyramid.compute @@ -0,0 +1,115 @@ +#pragma kernel GenerateDepthPyramid + +#include "../Includes/HCommonSSGI.hlsl" + +H_RW_TEXTURE(float, _DepthPyramid_OutputMIP0); +H_RW_TEXTURE(float, _DepthPyramid_OutputMIP1); +H_RW_TEXTURE(float, _DepthPyramid_OutputMIP2); +H_RW_TEXTURE(float, _DepthPyramid_OutputMIP3); +H_RW_TEXTURE(float, _DepthPyramid_OutputMIP4); + +groupshared float MipDepthLDS[8][8]; + +float DepthFilter(float4 DepthSamples) +{ + float DepthFiltered = 0; + + // Change filtering to max near sky pixels, to grab more skylight + if (any(DepthSamples <= 0)) + DepthFiltered = max(max(DepthSamples.x, DepthSamples.y), max(DepthSamples.z, DepthSamples.w)); + + DepthFiltered = min(min(DepthSamples.x, DepthSamples.y), min(DepthSamples.z, DepthSamples.w)); + + return DepthFiltered; +} + + +// ------------------------ MIP LEVEL 0-4 GENERATIONS ------------------------ +[numthreads(8, 8, 1)] +void GenerateDepthPyramid(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID) +{ + + const uint2 originalCoord = pixCoord.xy; + pixCoord *= 2; + + float4 Depth; + Depth.x = any(pixCoord.xy + uint2(0,0) >= uint2(_ScreenSize.xy)) ? 0 : HBUFFER_DEPTH(pixCoord.xy + uint2(0,0)).x; + Depth.y = any(pixCoord.xy + uint2(1,0) >= uint2(_ScreenSize.xy)) ? 0 : HBUFFER_DEPTH(pixCoord.xy + uint2(1,0)).x; + Depth.z = any(pixCoord.xy + uint2(0,1) >= uint2(_ScreenSize.xy)) ? 0 : HBUFFER_DEPTH(pixCoord.xy + uint2(0,1)).x; + Depth.w = any(pixCoord.xy + uint2(1,1) >= uint2(_ScreenSize.xy)) ? 0 : HBUFFER_DEPTH(pixCoord.xy + uint2(1,1)).x; + + Depth.x = Depth.x >= 0.9999f ? 0 : Depth.x; + Depth.y = Depth.y >= 0.9999f ? 0 : Depth.y; + Depth.z = Depth.z >= 0.9999f ? 0 : Depth.z; + Depth.w = Depth.w >= 0.9999f ? 0 : Depth.w; + + if (HBUFFER_RENDER_LAYER_MASK(pixCoord.xy + uint2(0,0)) & _ExcludeCastingLayerMaskSSGI) Depth.x = -1; + if (HBUFFER_RENDER_LAYER_MASK(pixCoord.xy + uint2(1,0)) & _ExcludeCastingLayerMaskSSGI) Depth.y = -1; + if (HBUFFER_RENDER_LAYER_MASK(pixCoord.xy + uint2(0,1)) & _ExcludeCastingLayerMaskSSGI) Depth.z = -1; + if (HBUFFER_RENDER_LAYER_MASK(pixCoord.xy + uint2(1,1)) & _ExcludeCastingLayerMaskSSGI) Depth.w = -1; + + // Write to MIP0 + _DepthPyramid_OutputMIP0[H_COORD(pixCoord.xy + uint2(0, 0))] = Depth.x; + _DepthPyramid_OutputMIP0[H_COORD(pixCoord.xy + uint2(1, 0))] = Depth.y; + _DepthPyramid_OutputMIP0[H_COORD(pixCoord.xy + uint2(0, 1))] = Depth.z; + _DepthPyramid_OutputMIP0[H_COORD(pixCoord.xy + uint2(1, 1))] = Depth.w; + + float DepthMIP1 = DepthFilter(Depth.xyzw); + + // Write to MIP1 + _DepthPyramid_OutputMIP1[H_COORD(originalCoord)] = DepthMIP1; + + MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP1; + GroupMemoryBarrierWithGroupSync(); + + // Write to MIP2 + [branch] + if (all((groupThreadID.xy % int2(2, 2)) == 0)) + { + float4 Depth; + Depth.x = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0]; + Depth.y = MipDepthLDS[groupThreadID.x + 1][groupThreadID.y + 0]; + Depth.z = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 1]; + Depth.w = MipDepthLDS[groupThreadID.x + 1][groupThreadID.y + 1]; + + float DepthMIP2 = DepthFilter(Depth.xyzw); + + _DepthPyramid_OutputMIP2[H_COORD(originalCoord / 2)] = DepthMIP2; + MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP2; + } + + GroupMemoryBarrierWithGroupSync(); + + // Write to MIP3 + [branch] + if (all((groupThreadID.xy % int2(4, 4)) == 0)) + { + float4 Depth; + Depth.x = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0]; + Depth.y = MipDepthLDS[groupThreadID.x + 2][groupThreadID.y + 0]; + Depth.z = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 2]; + Depth.w = MipDepthLDS[groupThreadID.x + 2][groupThreadID.y + 2]; + + float DepthMIP3 = DepthFilter(Depth.xyzw); + + _DepthPyramid_OutputMIP3[H_COORD(originalCoord / 4)] = DepthMIP3; + MipDepthLDS[groupThreadID.x][groupThreadID.y] = DepthMIP3; + } + + GroupMemoryBarrierWithGroupSync(); + + // Write to MIP4 + [branch] + if (all((groupThreadID.xy % int2(8, 8)) == 0)) + { + float4 Depth; + Depth.x = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 0]; + Depth.y = MipDepthLDS[groupThreadID.x + 4][groupThreadID.y + 0]; + Depth.z = MipDepthLDS[groupThreadID.x + 0][groupThreadID.y + 4]; + Depth.w = MipDepthLDS[groupThreadID.x + 4][groupThreadID.y + 4]; + + float DepthMIP4 = DepthFilter(Depth.xyzw); + + _DepthPyramid_OutputMIP4[H_COORD(originalCoord / 8)] = DepthMIP4; + } +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDepthPyramid.compute.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDepthPyramid.compute.meta new file mode 100644 index 0000000..5595945 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HDepthPyramid.compute.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 902b874ab8f513d4cbe65d1bfb2e9d24 +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Computes/HDepthPyramid.compute + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HInterpolationSSGI.compute b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HInterpolationSSGI.compute new file mode 100644 index 0000000..9f94465 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HInterpolationSSGI.compute @@ -0,0 +1,215 @@ +#pragma kernel Interpolation + +#include "../Includes/HReservoirSSGI.hlsl" +#pragma multi_compile _ _GBUFFER_NORMALS_OCT + +#define INTERPOLATION_LANCZOS 0 +#define INTERPOLATION_SAMPLECOUNT 5 +#define NORMAL_REJECTION 1 + +H_TEXTURE(_RadianceNormalDepth); + +H_RW_TEXTURE(float3, _Radiance_Output); +H_RW_TEXTURE(uint, _NormalDepth_HistoryOutput); + + +// ------------------------ INTERPOLATION STRUCTS ----------------------- +struct CenterPixelData +{ + float4 Plane; + float3 Normal; + float DepthLinear; +}; + + +// ------------------------ LANCZOS-SPECIFIC FUNCTIONS ------------------------- +float4 ProcessSample(float2 Offset, float4 DirectionLength, float2 LobeClip, float4 RadianceSample) +{ + float2 RotatedOffset = float2(dot(Offset, DirectionLength.xy), dot(Offset, float2(-DirectionLength.y, DirectionLength.x))) * DirectionLength.zw; + float DistanceDouble = min(dot(RotatedOffset, RotatedOffset), LobeClip.y); + + float Window = 0.4 * DistanceDouble - 1.0; + float Base = LobeClip.x * DistanceDouble - 1.0; + Window *= Window; + Base *= Base; + Window = 1.5625 * Window - 0.5625; + float Weight = Window * Base * RadianceSample.w; + + float4 AccumulatedData; + AccumulatedData.xyz = RadianceSample.xyz * Weight; + AccumulatedData.w = Weight; + + return AccumulatedData; +} + + +void GatherData(inout float2 Direction, inout float Length, float Weight, float SampleA, float SampleB, float SampleC, float SampleD, float SampleE) +{ + float LengthX = max(abs(SampleD.x - SampleC.x), abs(SampleC.x - SampleB.x)); + float DirectionX = SampleD.x - SampleB.x; + Direction.x += DirectionX * Weight; + LengthX = clamp(abs(DirectionX)/ LengthX, 0.0, 1.0); + LengthX *= LengthX; + Length += LengthX * Weight; + + float LengthY = max(abs(SampleE.x - SampleC.x), abs(SampleC.x - SampleA.x)); + float DirectionY = SampleE.x - SampleA.x; + Direction.y += DirectionY * Weight; + LengthY = clamp(abs(DirectionY) / LengthY, 0.0, 1.0); + LengthY *= LengthY; + Length += LengthY * Weight; +} + + +void AdaptiveLanczosData(float Samples[12], float2 PixelCoord, inout float4 DirLength, inout float2 LobeClip) +{ + float Length = 0; + float2 Direction = 0; + GatherData(Direction, Length, (1.0 -PixelCoord.x) * (1.0 -PixelCoord.y), Samples[0], Samples[5], Samples[4], Samples[9], Samples[3]); + GatherData(Direction, Length, PixelCoord.x * (1.0 -PixelCoord.y), Samples[1], Samples[4], Samples[9], Samples[8], Samples[6]); + GatherData(Direction, Length, (1.0 -PixelCoord.x) * PixelCoord.y, Samples[4], Samples[2], Samples[3], Samples[6], Samples[11]); + GatherData(Direction, Length, PixelCoord.x * PixelCoord.y, Samples[9], Samples[3], Samples[6], Samples[7], Samples[10]); + + float2 DirectionDouble = Direction * Direction; + float DirectionRadial = DirectionDouble.x + DirectionDouble.y; + bool IsNearZero = DirectionRadial < (1.0 / 32768.0); + DirectionRadial = rsqrt(DirectionRadial); + DirectionRadial = IsNearZero ? 1.0 : DirectionRadial; + Direction.x = IsNearZero ? 1.0 : Direction.x; + Direction *= float2(DirectionRadial, DirectionRadial); + Length = Length * 0.5; + Length *= Length; + + float Stretch = dot(Direction,Direction) / (max(abs(Direction.x), abs(Direction.y))); + float2 LengthDouble = float2(1.0 + (Stretch -1.0) * Length, 1.0 - 0.5 * Length); + float NegativeLobe = 0.5 - 0.29 * Length; + float Clip = 1.0 / NegativeLobe; + + DirLength = float4(Direction.xy, LengthDouble.xy); + LobeClip = float2(NegativeLobe, Clip); +} + + +float4 InterpolationSample(CenterPixelData CenterData, int2 SampleCoord, inout float LumaSample) +{ + uint2 RadianceNormalDepthPacked = asuint(H_LOAD(_RadianceNormalDepth, SampleCoord).xy); + float3 RadianceSample = UnpackFromR11G11B10f(RadianceNormalDepthPacked.x); + float4 NormalDepthSample = UnpackNormalDepth(RadianceNormalDepthPacked.y); + + float3 WorldPos = ComputeFastViewSpacePosition((SampleCoord * _HScaleFactorSSGI + 0.5) / _ScreenSize.xy, NormalDepthSample.w, H_LINEAR_EYE_DEPTH(NormalDepthSample.w)); + float PlaneWeight = ProbePlaneWeighting(CenterData.Plane, WorldPos, CenterData.DepthLinear, 5000); + float NormalWeight = 1; + + if (NORMAL_REJECTION) + NormalWeight = saturate(dot(CenterData.Normal, NormalDepthSample.xyz)); + + LumaSample = Luminance(RadianceSample) * PlaneWeight * NormalWeight; + return float4(RadianceSample, PlaneWeight * NormalWeight); +} + + +// ------------------------ INTERPOLATION ----------------------- +[numthreads(8, 8, 1)] +void Interpolation(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID) +{ + + const float DepthCenter = HBUFFER_DEPTH(pixCoord.xy).x; + if (DepthCenter <= 1e-7) { return; } + + const uint RadiancePacked = asuint(H_LOAD(_RadianceNormalDepth, floor(pixCoord.xy / _HScaleFactorSSGI)).x); + float3 RadianceCenter = UnpackFromR11G11B10f(RadiancePacked); + + const float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoord.xy).xyz; + const float3 NormalCenterVS = H_TRANSFORM_WORLD_TO_VIEW_NORMAL(NormalCenterWS); + const float3 WorldPosCenter = ComputeFastViewSpacePosition((pixCoord.xy + 0.5f) * _ScreenSize.zw, DepthCenter, H_LINEAR_EYE_DEPTH(DepthCenter)); + const int2 SampleOffsets[9] = {int2(0, 0), int2(1, 0), int2(0, 1), int2(-1, 0), int2(0, -1), int2(1, -1), int2(-1, 1), int2(-1, -1), int2(1, 1)}; + + CenterPixelData CenterData; + CenterData.Normal = NormalCenterWS; + CenterData.Plane = float4(NormalCenterVS, dot(WorldPosCenter, NormalCenterVS)); + CenterData.DepthLinear = H_LINEAR_EYE_DEPTH(DepthCenter); + + float3 InterpolatedRadiance = 0; + uint Count = 0; + + if (INTERPOLATION_LANCZOS) + { + float2 LanczosOffset = float2(pixCoord.xy) / _HScaleFactorSSGI; LanczosOffset -= floor(LanczosOffset); + int2 LanczosOffsetRounded = -floor(LanczosOffset ); + int2 DownscaledRes = floor(pixCoord.xy / _HScaleFactorSSGI); + + float4 Samples[12]; + float LumaSamples[12]; + + Samples[0] = InterpolationSample(CenterData, DownscaledRes + int2( 0,-1) + LanczosOffsetRounded, LumaSamples[0] ); + Samples[1] = InterpolationSample(CenterData, DownscaledRes + int2( 1,-1) + LanczosOffsetRounded, LumaSamples[1] ); + Samples[2] = InterpolationSample(CenterData, DownscaledRes + int2(-1, 1) + LanczosOffsetRounded, LumaSamples[2] ); + Samples[3] = InterpolationSample(CenterData, DownscaledRes + int2( 0, 1) + LanczosOffsetRounded, LumaSamples[3] ); + Samples[4] = InterpolationSample(CenterData, DownscaledRes + int2( 0, 0) + LanczosOffsetRounded, LumaSamples[4] ); + Samples[5] = InterpolationSample(CenterData, DownscaledRes + int2(-1, 0) + LanczosOffsetRounded, LumaSamples[5] ); + Samples[6] = InterpolationSample(CenterData, DownscaledRes + int2( 1, 1) + LanczosOffsetRounded, LumaSamples[6] ); + Samples[7] = InterpolationSample(CenterData, DownscaledRes + int2( 2, 1) + LanczosOffsetRounded, LumaSamples[7] ); + Samples[8] = InterpolationSample(CenterData, DownscaledRes + int2( 2, 0) + LanczosOffsetRounded, LumaSamples[8] ); + Samples[9] = InterpolationSample(CenterData, DownscaledRes + int2( 1, 0) + LanczosOffsetRounded, LumaSamples[9] ); + Samples[10] = InterpolationSample(CenterData, DownscaledRes + int2( 1, 2) + LanczosOffsetRounded, LumaSamples[10]); + Samples[11] = InterpolationSample(CenterData, DownscaledRes + int2( 0, 2) + LanczosOffsetRounded, LumaSamples[11]); + + float4 DirLength; float2 LobeClip; + AdaptiveLanczosData(LumaSamples, LanczosOffset, DirLength, LobeClip); + + float3 MinNeighbourhood = min(min(Samples[4].xyz, Samples[9].xyz), min(Samples[3].xyz, Samples[6].xyz)); + float3 MaxNeighbourhood = max(max(Samples[4].xyz, Samples[9].xyz), max(Samples[3].xyz, Samples[6].xyz)); + + float4 AccumulatedData = 0; + AccumulatedData += ProcessSample(float2( 0,-1) -LanczosOffset, DirLength, LobeClip, Samples[0]); + AccumulatedData += ProcessSample(float2( 1,-1) -LanczosOffset, DirLength, LobeClip, Samples[1]); + AccumulatedData += ProcessSample(float2(-1, 1) -LanczosOffset, DirLength, LobeClip, Samples[2]); + AccumulatedData += ProcessSample(float2( 0, 1) -LanczosOffset, DirLength, LobeClip, Samples[3]); + AccumulatedData += ProcessSample(float2( 0, 0) -LanczosOffset, DirLength, LobeClip, Samples[4]); + AccumulatedData += ProcessSample(float2(-1, 0) -LanczosOffset, DirLength, LobeClip, Samples[5]); + AccumulatedData += ProcessSample(float2( 1, 1) -LanczosOffset, DirLength, LobeClip, Samples[6]); + AccumulatedData += ProcessSample(float2( 2, 1) -LanczosOffset, DirLength, LobeClip, Samples[7]); + AccumulatedData += ProcessSample(float2( 2, 0) -LanczosOffset, DirLength, LobeClip, Samples[8]); + AccumulatedData += ProcessSample(float2( 1, 0) -LanczosOffset, DirLength, LobeClip, Samples[9]); + AccumulatedData += ProcessSample(float2( 1, 2) -LanczosOffset, DirLength, LobeClip, Samples[10]); + AccumulatedData += ProcessSample(float2( 0, 2) -LanczosOffset, DirLength, LobeClip, Samples[11]); + + AccumulatedData.w = max(AccumulatedData.w, 0.1f); + AccumulatedData.xyz = AccumulatedData.w > 0 ? AccumulatedData.xyz / AccumulatedData.w : RadianceCenter; + InterpolatedRadiance = min(MaxNeighbourhood, max(MinNeighbourhood, AccumulatedData.xyz )); + } + else + { + static const int2 SampleOffsets[9] = {int2(0, 0), int2(1, 0), int2(0, 1), int2(-1, 0), int2(0, -1), int2(1, -1), int2(-1, 1), int2(-1, -1), int2(1, 1)}; + + float2 pixCoordDownscaled = float2(pixCoord.xy) / _HScaleFactorSSGI; + float2 pixCoordDownscaledSnapped = floor(pixCoordDownscaled + 0.5 / _HScaleFactorSSGI); // or round(pixCoordDownscaled) ? + + float SigmaScale = pow(abs(_HScaleFactorSSGI - 1.0), 0.2); + float Sigma = lerp(0.3, 0.65, SigmaScale); + float AccumulatedWeight = 0; + + for (int i = 0; i < 9; i++) + { + float2 SampleCoord = pixCoordDownscaledSnapped + SampleOffsets[i]; + int2 SampleCoordSnapped = clamp(SampleCoord, 0 , _ScreenSize.xy / _HScaleFactorSSGI - 1); + + float Unused; + float4 Sample = InterpolationSample(CenterData, SampleCoordSnapped, Unused); + Sample.xyz = SpatialDenoisingTonemap(Sample.xyz); + + float2 Delta = (pixCoordDownscaled - SampleCoord); + float DistanceSq = dot(Delta, Delta); + float Weight = exp(-DistanceSq / (2.0 * Sigma * Sigma)); + + Sample.w *= Weight; + InterpolatedRadiance += Sample.xyz * Sample.w; + AccumulatedWeight += Sample.w; + } + + InterpolatedRadiance = AccumulatedWeight > 0 ? SpatialDenoisingTonemapInverse((InterpolatedRadiance) / AccumulatedWeight) : RadianceCenter; + } + + _Radiance_Output[H_COORD(pixCoord.xy)] = InterpolatedRadiance; + _NormalDepth_HistoryOutput[H_COORD(pixCoord.xy)] = PackNormalDepth(NormalCenterWS, DepthCenter); +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HInterpolationSSGI.compute.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HInterpolationSSGI.compute.meta new file mode 100644 index 0000000..0449987 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HInterpolationSSGI.compute.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: d9e32df3caf2788448cd612608bce346 +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Computes/HInterpolationSSGI.compute + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRenderSSGI.compute b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRenderSSGI.compute new file mode 100644 index 0000000..99dc7f0 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRenderSSGI.compute @@ -0,0 +1,231 @@ +#pragma kernel TraceSSGI +#pragma kernel MaskExclude + +#pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 +#pragma multi_compile _ FALLBACK_SKY FALLBACK_APV +#pragma multi_compile _ CHECKERBOARDING + +// Tracing keywords +#pragma multi_compile _ REFINE_INTERSECTION +#pragma multi_compile _ HALF_STEP_VALIDATION +#pragma multi_compile _ FULL_RESOLUTION_DEPTH +#pragma multi_compile LINEAR_THICKNESS UNIFORM_THICKNESS + +#define FALLBACK_STAGE 1 + +#include "../Includes/HRayMarchingSSGI.hlsl" +#include "../Includes/HFallbackSSGI.hlsl" +#include "../Headers/HDRP files/RaytracingSampling.hlsl" +#pragma multi_compile _ _GBUFFER_NORMALS_OCT + + +int _IndexXR; +int _RayCount; +float _SkyFallbackIntensity; + +H_TEXTURE(_SampleCount); + +H_RW_TEXTURE(float3, _Radiance_Output); +H_RW_TEXTURE(float, _AmbientOcclusion_Output); + +RWStructuredBuffer _TracingCoords; +RWStructuredBuffer _RayCounter; + + +// ------------------------ SSGI RENDER ------------------------- +[numthreads(8, 8, 1)] +void TraceSSGI(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID) +{ + if (CHECKERBOARDING) + { + uint RayCounterOffsetVR = 0; + uint IndirectCoordOffsetVR = 0; + + + uint RayIndex = groupID * 64 + groupIndex; + if (RayIndex >= _RayCounter[1 + RayCounterOffsetVR]) + return; + + pixCoord.xy = _TracingCoords[RayIndex + IndirectCoordOffsetVR]; + } + else + { + } + + uint2 pixCoordUnscaled = GetUnscaledCoords(pixCoord.xy); + float2 pixCoordNDC = (float2(pixCoordUnscaled) + 0.5f) * _ScreenSize.zw; + + float DepthCenter = HBUFFER_DEPTH(pixCoordUnscaled); + float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoordUnscaled); + float3 PositionCenterWS = H_COMPUTE_POSITION_WS(pixCoordNDC, DepthCenter, H_MATRIX_I_VP); + + float3 ViewDir = normalize(_WorldSpaceCameraPos - H_GET_ABSOLUTE_POSITION_WS(PositionCenterWS) ); + + if (DepthCenter <= UNITY_RAW_FAR_CLIP_VALUE) + { + _Reservoir_Output[H_COORD(pixCoord.xy)] = 0; + _AmbientOcclusion_Output[H_COORD(pixCoord.xy)] = 0; + return; + } + + float3 Diffuse = GetReservoirDiffuse(pixCoordUnscaled); + uint ReservoirUpdateRandom = Hash3(uint3(pixCoord.xy, _FrameCount)); + TemporalReservoir RadianceRes = (TemporalReservoir)0; + OcclusionReservoir OcclusionRes = (OcclusionReservoir)0; + + const float StepJitter = Jitter((pixCoord.xy) * 2 - 1); + int FrameStep = 1; if (CHECKERBOARDING) { FrameStep = 2;} + + float AmbientOcclusion = 0, AmbientOcclusionInvalidity = 0; + float3 DirectionsAccumulated = 0, BentNormal = 0, Radiance = 0; + + // Tracing + for (int i = 0; i < _RayCount; i++) + { + int SampleIndex = ((floor(uint(_FrameCount) / FrameStep) % 16) * _RayCount + i); + + float2 SampleRandom; + SampleRandom.x = GetBNDSequenceSample(pixCoord.xy, SampleIndex, 0); + SampleRandom.y = GetBNDSequenceSample(pixCoord.xy, SampleIndex, 1); + float3 RayDirectionWS = HSampleHemisphereCosine(SampleRandom.x, SampleRandom.y, NormalCenterWS); + + DirectionsAccumulated += RayDirectionWS; + + float3 RayOriginBiasedWS, RayStartPositionNDC, RayEndPositionNDC; + GetRayOriginAndDirectionNDC(_RayLength, DepthCenter, pixCoordNDC, PositionCenterWS, RayDirectionWS, NormalCenterWS, RayOriginBiasedWS, RayStartPositionNDC, RayEndPositionNDC); + + float4 HitData = RayMarch(RayStartPositionNDC, RayEndPositionNDC, StepJitter); + + float3 HitRadiance = 0; + float OcclusionDistance = 0, HitOcclusion = 0, HitDistance = 0; + + if (HitData.w) + { + bool MovingHitPoint; + HitRadiance = UnpackColorHit(asuint(H_LOAD(_Color, HitData.xy * _ScreenSize.xy).x), MovingHitPoint); + + float3 HitPosition = H_COMPUTE_POSITION_WS(HitData.xy, HitData.z, H_MATRIX_I_VP); + HitDistance = distance(PositionCenterWS, HitPosition); + //RayDirectionWS = normalize(HitPosition - PositionCenterWS); + + float HitSurface = H_LOAD(g_HTraceDepthPyramidSSGI, HitData.xy * _ScreenSize.xy).x; + float HitSurfaceLinear = H_LINEAR_EYE_DEPTH(HitSurface); + float HitDepthLinear = H_LINEAR_EYE_DEPTH(HitData.z); + + // Don't run hit validation on skybox hits + if (HitSurface > UNITY_RAW_FAR_CLIP_VALUE) + { + if (abs(HitDepthLinear - HitSurfaceLinear) > HitDistance + 0.05f * max(HitSurfaceLinear, 0.25f)) + HitRadiance = 0; + + if (dot(HBUFFER_NORMAL_WS(HitData.xy * _ScreenSize.xy), RayDirectionWS) > _BackfaceLighting) + HitRadiance = 0; + } + + HitRadiance *= ExponentialFalloff(HitDistance, _RayLength); + + if (HitDistance < 0.5) + AmbientOcclusion++; + + float HitSamplecount = H_LOAD(_SampleCount, HitData.xy * _ScreenSize.xy / _HScaleFactorSSGI).x; + if (HitSamplecount < 2) + AmbientOcclusionInvalidity++; + + if (HitDistance < 1.0) + { + OcclusionDistance = HitDistance; + HitOcclusion = MovingHitPoint ? 1 : 0; + } + } + + Radiance += HitRadiance; + BentNormal += RayDirectionWS * (1 - HitData.w); + + ReservoirUpdate(HitRadiance, RayDirectionWS, NormalCenterWS, HitDistance, HitData.w, Luminance(HitRadiance * Diffuse), 1, RadianceRes, ReservoirUpdateRandom); + ReservoirUpdate(HitOcclusion, RayDirectionWS, OcclusionDistance, HitOcclusion, 1, OcclusionRes, ReservoirUpdateRandom); + } + + // Fallback + if (FALLBACK_APV || FALLBACK_SKY) + { + float3 FallbackRadiance = 0; + + if (length(DirectionsAccumulated) > 0) + BentNormal /= length(DirectionsAccumulated); + + float BentNormalOcclusion = length(BentNormal); + BentNormal = BentNormalOcclusion > 0 ? BentNormal / BentNormalOcclusion : NormalCenterWS; + + // APV Fallback + #ifdef FALLBACK_APV + if (_EnableProbeVolumes) + { + if (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2) + { + float3 BakedAPV = EvaluateFallbackAPV(_APVParams, PositionCenterWS, BentNormal, H_GET_VIEW_DIRECTION_WS(PositionCenterWS), pixCoord.xy); + FallbackRadiance = BakedAPV * RadianceRes.M * BentNormalOcclusion; + } + } + #endif + + // Sky Fallback + if (FALLBACK_SKY) + { + float3 Sky = EvaluateFallbackSky(BentNormal); + FallbackRadiance = Sky * RadianceRes.M * BentNormalOcclusion * _SkyFallbackIntensity; + } + + FallbackRadiance = max(FallbackRadiance, 0); + ReservoirUpdate(FallbackRadiance, NormalCenterWS, false, Luminance(FallbackRadiance * Diffuse), 1 / float(_RayCount), RadianceRes, ReservoirUpdateRandom); + } + + RadianceRes.W = RadianceRes.Wsum / max(RadianceRes.M * Luminance(RadianceRes.Color * Diffuse), 1e-7); + OcclusionRes.W = OcclusionRes.Wsum / max(OcclusionRes.M * OcclusionRes.Occlusion, 1e-7); + RadianceRes.OriginNormal = NormalCenterWS; + + if (RadianceRes.HitFound == false) // && OcclusionRes.Distance > 0 && OcclusionRes.Occlusion > 0) + { + RadianceRes.Direction = OcclusionRes.Direction; + RadianceRes.Distance = OcclusionRes.Distance; + } + + float InvalidityEncodingSign = AmbientOcclusionInvalidity > 0 ? -1 : 1; + _AmbientOcclusion_Output[H_COORD(pixCoord.xy)] = (1 - (AmbientOcclusion / float(_RayCount))) * InvalidityEncodingSign; + _Reservoir_Output[H_COORD(pixCoord.xy)] = PackTemporalReservoir(RadianceRes); + + bool MovingHitPoint; + float3 HitRadiance = UnpackColorHit(asuint(H_LOAD(_Color, pixCoord.xy).x), MovingHitPoint); + + //_Radiance_Output[H_COORD(pixCoord.xy)] =RadianceRes.Color * RadianceRes.W; +} + + +// ------------------------ MASK EXCLUDE [HDRP ONLY] ----------------------- +[numthreads(8, 8, 1)] +void MaskExclude(uint3 pixCoord : SV_DispatchThreadID) +{ + + if (HBUFFER_RENDER_LAYER_MASK(pixCoord.xy) & _ExcludeReceivingLayerMaskSSGI) + { + float3 Radiance = 0; + + #ifdef FALLBACK_APV + if (_EnableProbeVolumes) + { + if (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2) + { + float DepthCenter = HBUFFER_DEPTH(pixCoord.xy); + float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoord.xy); + float3 PositionCenterWS = H_COMPUTE_POSITION_WS((pixCoord.xy + 0.5f) * _ScreenSize.zw, DepthCenter, H_MATRIX_I_VP); + + Radiance = EvaluateFallbackAPV(_APVParams, PositionCenterWS, NormalCenterWS, H_GET_VIEW_DIRECTION_WS(PositionCenterWS), pixCoord.xy); + } + } + #elif FALLBACK_SKY + float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoord.xy); + Radiance = EvaluateFallbackSky(NormalCenterWS); + #endif + + _Radiance_Output[H_COORD(pixCoord.xy)] = Radiance; + } +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRenderSSGI.compute.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRenderSSGI.compute.meta new file mode 100644 index 0000000..5935199 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRenderSSGI.compute.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: a19906341f84b914a88dd6966db40d78 +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Computes/HRenderSSGI.compute + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRestirSSGI.compute b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRestirSSGI.compute new file mode 100644 index 0000000..1814de8 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRestirSSGI.compute @@ -0,0 +1,498 @@ +#pragma kernel TemporalResampling +#pragma kernel FireflySuppression +#pragma kernel SpatialResampling SpatialResamplingValidation = SpatialResampling +#pragma kernel SpatialValidation SpatialResamplingValidation = SpatialValidation VALIDATION_STAGE + +#include "../Includes/HRayMarchingSSGI.hlsl" +#include "../Headers/HSpaceTransforms.hlsl" +#include "../Headers/HDRP files/RaytracingSampling.hlsl" + +#pragma multi_compile _ _GBUFFER_NORMALS_OCT + +#pragma multi_compile _ CHECKERBOARDING +#pragma multi_compile _ VALIDATE_SPATIAL_OCCLUSION +#pragma multi_compile _ VALIDATE_TEMPORAL_LIGHTING +#pragma multi_compile _ VALIDATE_TEMPORAL_OCCLUSION + +// Tracing keywords +#pragma multi_compile _ REFINE_INTERSECTION +#pragma multi_compile _ HALF_STEP_VALIDATION +#pragma multi_compile _ FULL_RESOLUTION_DEPTH +#pragma multi_compile LINEAR_THICKNESS UNIFORM_THICKNESS + +#ifdef VALIDATION_STAGE +#define SECOND_SPATIAL_PASS 1 +#else +#define SECOND_SPATIAL_PASS 0 +#endif + +#ifdef CHECKERBOARDING +#define RESTIR_HISTORY_MAX_LENGTH 32 +#define RESTIR_HISTORY_MIN_LENGTH 1 +#else +#define RESTIR_HISTORY_MAX_LENGTH 32 +#define RESTIR_HISTORY_MIN_LENGTH 0 +#endif + +H_TEXTURE(_SpatialGuidance); +H_TEXTURE(_SampleCount); +H_TEXTURE (_AmbientOcclusion); +H_TEXTURE(_AmbientOcclusionReprojected); +H_TEXTURE(_SpatialOcclusion); +H_TEXTURE(_TemporalInvalidity); + +H_RW_TEXTURE(float3, _Radiance_Output); +H_RW_TEXTURE(float2, _TemporalInvalidity_Output); +H_RW_TEXTURE(float, _AmbientOcclusion_Output); +H_RW_TEXTURE(float, _SpatialOcclusion_Output); +H_RW_TEXTURE(uint2, _SpatialGuidance_Output); +H_RW_TEXTURE(uint, _NormalDepth_HistoryOutput); + +StructuredBuffer _PointDistribution; + +float _FilterRadius; +float _FilterAdaptivity; +int _DenoiseFallback; +int _RayCount; + + +// ------------------------ TEMPORAL RESAMPLING + VALIDATION ------------------------- +[numthreads(8, 8, 1)] +void TemporalResampling(uint3 pixCoord : SV_DispatchThreadID) +{ + + uint2 pixCoordUnscaled = GetUnscaledCoords(pixCoord.xy); + float DepthCenter = HBUFFER_DEPTH(pixCoordUnscaled); + + if (DepthCenter <= UNITY_RAW_FAR_CLIP_VALUE) + { + _ReservoirLuminance_Output[H_COORD(pixCoord.xy)] = -1; + _NormalDepth_HistoryOutput[H_COORD(pixCoord.xy)] = 0; + _ReservoirSpatial_Output[H_COORD(pixCoord.xy)] = 0; + _ReservoirTemporal_Output[H_COORD(pixCoord.xy)] = 0; + _AmbientOcclusion_Output[H_COORD(pixCoord.xy)] = 0; + _TemporalInvalidity_Output[H_COORD(pixCoord.xy)] = 0; + return; + } + + float3 Diffuse = GetReservoirDiffuse(pixCoordUnscaled); + uint ReservoirUpdateRandom = Hash3(uint3(pixCoord.xy, _FrameCount)); + + // Load and unpack current and reprojected reservoirs + TemporalReservoir TemporalRes = (TemporalReservoir)0; + TemporalReservoir TemporalReprojectedRes = (TemporalReservoir)0; + UnpackTemporalReservoir(asuint(H_LOAD(_Reservoir, pixCoord.xy)), Diffuse, TemporalRes); + UnpackTemporalReservoir(asuint(H_LOAD(_ReservoirReprojected, pixCoord.xy)), Diffuse, TemporalReprojectedRes); + + float MaxHistoryClamp = RESTIR_HISTORY_MAX_LENGTH * max((uint(_RayCount) / 4), 1); + MaxHistoryClamp = clamp(MaxHistoryClamp, 0, 100); + + // Backup current Color and W for replacement + float4 OriginalColorW = float4(TemporalRes.Color, TemporalRes.W); + float SamplecountReprojected = H_LOAD(_SampleCount, pixCoord.xy).x; + bool CullCheckerboard = true; + + float AmbientOcclusion = H_LOAD(_AmbientOcclusion, pixCoord.xy).x; + float AmbientOcclusionInvalidity = sign(AmbientOcclusion) < 0 ? 0 : 1; + + // Checkerboarding logic + if (ENABLE_TEMPORAL_RESTIR) + { + if (CHECKERBOARDING) + { + CullCheckerboard = false; + if (((pixCoord.x + pixCoord.y) % 2 == 0 && uint(_FrameCount) % 2 == 0) || SamplecountReprojected <= 1) CullCheckerboard = true; + if (((pixCoord.x + pixCoord.y) % 2 != 0 && uint(_FrameCount) % 2 != 0) || SamplecountReprojected <= 1) CullCheckerboard = true; + + if (CullCheckerboard == false) + { + TemporalRes.Color = TemporalReprojectedRes.Color; + TemporalRes.Wsum = TemporalReprojectedRes.Wsum; + TemporalRes.W = TemporalReprojectedRes.W; + TemporalRes.M = TemporalReprojectedRes.M; + TemporalRes.OriginNormal = TemporalReprojectedRes.OriginNormal; + TemporalRes.Direction = TemporalReprojectedRes.Direction; + TemporalRes.Distance = TemporalReprojectedRes.Distance; + TemporalRes.HitFound = TemporalReprojectedRes.HitFound; + } + else + { ReservoirUpdate(TemporalReprojectedRes, TemporalRes, ReservoirUpdateRandom); } + } + else + { ReservoirUpdate(TemporalReprojectedRes, TemporalRes, ReservoirUpdateRandom); } + } + + bool HitIsMoving = false; + float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoordUnscaled); + float2 pixCoordNDC = (float2(pixCoordUnscaled) + 0.5f) / _ScreenSize.xy; + float3 PositionCenterWS = H_COMPUTE_POSITION_WS(pixCoordNDC, DepthCenter, H_MATRIX_I_VP); + + bool IsOcclusionValidation = false; + if (!TemporalRes.HitFound && TemporalRes.Distance > 0 && TemporalRes.Distance < 1) + IsOcclusionValidation = true; + + bool ReplaceRadiance = false; + if (VALIDATE_TEMPORAL_OCCLUSION) + { + // If the distance is in [0,1] and a hit wasn't found then we store occlusion data + bool IsOcclusionValidation = false; + if (!TemporalRes.HitFound && TemporalRes.Distance > 0 && TemporalRes.Distance < 1) + IsOcclusionValidation = true; + + float StepJitter = Jitter((pixCoord.xy) * 2 - 1); + float3 RayOriginBiasedWS, RayStartPositionNDC, RayEndPositionNDC; + GetRayOriginAndDirectionNDC(_RayLength, DepthCenter, pixCoordNDC, PositionCenterWS, TemporalRes.Direction, NormalCenterWS, RayOriginBiasedWS, RayStartPositionNDC, RayEndPositionNDC); + float4 HitData = RayMarchValidation(RayStartPositionNDC, RayEndPositionNDC, StepJitter); + + if (HitData.w) + { + float3 HitPosition = H_COMPUTE_POSITION_WS(HitData.xy, HitData.z, H_MATRIX_I_VP); + float HitDistance = distance(PositionCenterWS, HitPosition); + HitIsMoving = HBUFFER_MOTION_MASK(HitData.xy * _ScreenSize.xy); + + // We did hit something, but it was the wrong spot + if (abs(HitDistance - TemporalRes.Distance) / (TemporalRes.Distance + TemporalRes.Distance) > 0.2f) + { + // Clamp history (smoother reaction) + if (TemporalRes.HitFound && HitDistance < TemporalRes.Distance ) // && HitDistance > 0 && TemporalRes.Distance > 0) + MaxHistoryClamp = 0; + + // Replace radiance (faster reaction) if it was occlusion validation + if (IsOcclusionValidation && HitDistance < 1) // && dot(normalize(PositionCenterWS - HitPosition), TemporalRes.Direction) < 0) + ReplaceRadiance = true; + } + } + else if (IsOcclusionValidation) + { + // If we didn't hit anything but should have (because it was occlusion validation). + ReplaceRadiance = true; + } + } + + bool SampleIsOffscreen = false; + if (VALIDATE_TEMPORAL_LIGHTING && TemporalRes.HitFound) + { + float LightingInvalidity = 1.0f; + for (int x = -1; x <= 1; x++) + { + for (int y = -1; y <= 1; y++) + { + bool MovingHitPoint; + float2 HitCoordNDC = H_COMPUTE_NDC_Z(PositionCenterWS + TemporalRes.Direction * TemporalRes.Distance, H_MATRIX_VP).xy; + float3 HitRadiance = UnpackColorHit(asuint(H_LOAD(_Color, floor(HitCoordNDC * _ScreenSize.xy) + int2(x,y)).x), MovingHitPoint); + + HitRadiance *= ExponentialFalloff(TemporalRes.Distance, _RayLength); + + if (any(HitCoordNDC < 0) || any(HitCoordNDC > 1)) + SampleIsOffscreen = true; + + float3 LuminanceCurrent = (HitRadiance); + float3 LuminanceHistory = (TemporalRes.Color); + + float LightingDifference = length(abs(LuminanceHistory - LuminanceCurrent) / max(1e-3, LuminanceHistory + LuminanceCurrent)); + LightingInvalidity = min(LightingInvalidity, LightingDifference); + } + } + + if (!SampleIsOffscreen) + MaxHistoryClamp *= (1.0f - LightingInvalidity); + } + + if (ENABLE_EXPOSURE_CONTROL) + { + float ExposurePrevious = HGetPreviousExposureMultiplier; + float ExposureCurrent = HGetCurrentExposureMultiplier; + + float ExposureRatio = (ExposurePrevious * ExposureCurrent) != 0.0 ? ExposureCurrent / ExposurePrevious : 100.0; + + if (max(ExposureRatio, 1.0 / ExposureRatio) > 2.0) + MaxHistoryClamp = MaxHistoryClamp * HGetInversePreviousExposureMultiplier * ExposureCurrent; + } + + TemporalRes.W = TemporalRes.Wsum / max(TemporalRes.M * Luminance(TemporalRes.Color * Diffuse), 1e-8); + TemporalRes.M = clamp(TemporalRes.M, RESTIR_HISTORY_MIN_LENGTH, max(RESTIR_HISTORY_MIN_LENGTH, MaxHistoryClamp)); + + if (ReplaceRadiance || SampleIsOffscreen || (AmbientOcclusionInvalidity == 0 && !TemporalRes.HitFound)) + { + MaxHistoryClamp = 0; + if (CullCheckerboard == true) + { + // Tried setting W and Color to 0, looks similar in certain cases, but worse in others + TemporalRes.W = OriginalColorW.w; + TemporalRes.Color = OriginalColorW.xyz; + } + } + + float Samplecount = min(8, SamplecountReprojected + 1); + float TemporalWeight = 1.0f - (1.0f / float(Samplecount)); + + float2 TemporalInvalidity = float2(1,1); + if (VALIDATE_TEMPORAL_OCCLUSION || VALIDATE_TEMPORAL_LIGHTING) + { + TemporalInvalidity.x = MaxHistoryClamp / RESTIR_HISTORY_MAX_LENGTH; + TemporalInvalidity.y = MaxHistoryClamp < (RESTIR_HISTORY_MAX_LENGTH && HitIsMoving) ? 0 : 1; + + if (TemporalRes.HitFound == false) + { TemporalInvalidity.x *= AmbientOcclusionInvalidity; } + + float2 TemporalInvalidityReprojected = H_LOAD(_TemporalInvalidity, pixCoord.xy).xy; + TemporalInvalidity = lerp(TemporalInvalidity, TemporalInvalidityReprojected, CullCheckerboard ? TemporalWeight : 1); + + _TemporalInvalidity_Output[H_COORD(pixCoord.xy)] = TemporalInvalidity; + } + + float AmbientOcclusionReprojected = H_LOAD(_AmbientOcclusionReprojected, pixCoord.xy).x; + AmbientOcclusion = lerp(abs(AmbientOcclusion), AmbientOcclusionReprojected, CullCheckerboard ? TemporalWeight * pow(TemporalInvalidity.y, 2) * AmbientOcclusionInvalidity : 1); + + // Transfer data from temporal to spatial reservoir + SpatialReservoir SpatialRes; + SpatialRes.Color = TemporalRes.Color; + SpatialRes.W = TemporalRes.W; + SpatialRes.M = TemporalRes.M; + SpatialRes.HitFound = TemporalRes.HitFound; + SpatialRes.Occlusion = H_LOAD(_SpatialOcclusion, pixCoord.xy).x; + SpatialRes.Direction = TemporalRes.Direction; + SpatialRes.Distance = TemporalRes.Distance; + SpatialRes.Normal = NormalCenterWS; + SpatialRes.Depth = DepthCenter; + + _ReservoirSpatial_Output[H_COORD(pixCoord.xy)] = PackSpatialReservoir(SpatialRes); + _ReservoirTemporal_Output[H_COORD(pixCoord.xy)] = PackTemporalReservoir(TemporalRes); + _ReservoirLuminance_Output[H_COORD(pixCoord.xy)] = Luminance(TemporalRes.Color * TemporalRes.W); + + _AmbientOcclusion_Output[H_COORD(pixCoord.xy)] = AmbientOcclusion; + _NormalDepth_HistoryOutput[H_COORD(pixCoord.xy)] = PackNormalDepth(NormalCenterWS, DepthCenter); + + // _Radiance_Output[H_COORD(pixCoord.xy)] = TemporalRes.Color * TemporalRes.W; + // if (Luminance(TemporalRes.Color * TemporalRes.W) > 0.01) + // _Radiance_Output[H_COORD(pixCoord.xy)] = lerp(float3(1,0,0), TemporalRes.Color * TemporalRes.W, saturate(MaxHistoryClamp / RESTIR_HISTORY_MAX_LENGTH)); +} + + +// ------------------------ FIREFLY SUPPRESSION ------------------------- +[numthreads(8, 8, 1)] +void FireflySuppression(uint3 pixCoord : SV_DispatchThreadID) +{ + + float LumaCenter = H_LOAD(_ReservoirLuminance, pixCoord.xy).x; + + float2 Moments; + Moments.x = 0; + Moments.y = 0; + + float TotalWeight = 0; + + UNITY_UNROLL + for (int x = -3; x <= 3; x++) + { + UNITY_UNROLL + for (int y = -3; y <= 3; y++) + { + int2 SampleCoord = pixCoord.xy + int2(x, y); + SampleCoord = clamp(SampleCoord, 0, _ScreenSize.xy / _HScaleFactorSSGI - 1); + + float LumaSample = H_LOAD(_ReservoirLuminance, pixCoord.xy + int2(x, y)).x; + + // Sky pixels are marked as -1 + if (LumaSample < 0) + continue; + + Moments.x += LumaSample; + Moments.y += LumaSample * LumaSample; + + TotalWeight += 1; + } + } + + Moments.x /= TotalWeight; + Moments.y /= TotalWeight; + + float Variance = (max(0.0, Moments.y - Moments.x * Moments.x)); + float StdDev = sqrt(Variance); + + float SamplecountReprojected = H_LOAD(_SampleCount, pixCoord.xy).x; + + // Avoid applying firefly suppression for the first 4 frames of temporal accumulation + float SamplecountScale = clamp(4 - SamplecountReprojected, 1, 2); + float LumaThreshold = Moments.x + SamplecountScale * StdDev; + + // If Luma is above threshold - unpack the reservoir, clamp W and pack it back + if (LumaCenter > LumaThreshold) + { + uint4 ReservoirMW = _ReservoirSpatial_Output[H_COORD(pixCoord.xy)]; + + float W = f16tof32(ReservoirMW.y >> 16); + W *= (LumaThreshold / max(LumaCenter, 1e-5)); + + uint PackedW = f32tof16(W); + PackedW = PackedW << 16; + + ReservoirMW.y &= 0x0000FFFF; + ReservoirMW.y |= PackedW; + _ReservoirSpatial_Output[H_COORD(pixCoord.xy)] = ReservoirMW; + } +} + + + +// ------------------------ SPATIAL RESAMPLING + VALIDATION ------------------------- +[numthreads(8, 8, 1)] +void SpatialResamplingValidation(uint3 pixCoord : SV_DispatchThreadID) +{ + + uint2 pixCoordUnscaled = GetUnscaledCoords(pixCoord.xy); + int2 pixCoordMax = _ScreenSize.xy / _HScaleFactorSSGI.xx - 1; + float2 pixCoordNDC = (float2(pixCoordUnscaled) + 0.5f) * _ScreenSize.zw; + + float3 Diffuse = GetReservoirDiffuse(pixCoordUnscaled); + uint ReservoirUpdateRandom = Hash3(uint3(pixCoord.xy, _FrameCount)); + SpatialReservoir Reservoir = (SpatialReservoir)0; + UnpackSpatialReservoir(asuint(H_LOAD(_Reservoir, pixCoord.xy)), Diffuse, Reservoir); + + if (Reservoir.Depth <= UNITY_RAW_FAR_CLIP_VALUE) { return; } + + float DepthCetnerLinear = H_LINEAR_EYE_DEPTH(Reservoir.Depth); + float3 NormalCenterVS = H_TRANSFORM_WORLD_TO_VIEW_NORMAL(Reservoir.Normal); + float3 PositionCenterWS = H_COMPUTE_POSITION_WS(pixCoordNDC, Reservoir.Depth, H_MATRIX_I_VP); + float3 PositionCenterVS = ComputeFastViewSpacePosition(pixCoordNDC, Reservoir.Depth, DepthCetnerLinear); + float4 NormalPlaneVS = float4(NormalCenterVS.xyz, dot(PositionCenterVS, NormalCenterVS.xyz)); + + float SamplecountReprojected = H_LOAD(_SampleCount, pixCoord.xy).x; + float AmbientOcclusion = H_LOAD(_AmbientOcclusion, pixCoord.xy).x; + + #if SECOND_SPATIAL_PASS + uint2 SpatialGuidancePacked = asuint(H_LOAD(_SpatialGuidance, pixCoord.xy).xy); + float AmbientOcclusionFilterScale = UnpackAmbientOcclusion(SpatialGuidancePacked.y); + uint SpatialGuidance = SpatialGuidancePacked.x; + float FilterRadius = _FilterRadius; + uint BufferOffset = 0; + #else + float AmbientOcclusionFilterScale = H_LOAD(_AmbientOcclusion, pixCoord.xy).x; + + if (Luminance(Reservoir.Color * Reservoir.W) < 0.001) + AmbientOcclusionFilterScale = AmbientOcclusionFilterScale > 0.4 ? 1 : AmbientOcclusionFilterScale; + + float FilterRadius = _FilterRadius / 2.0f; + uint SpatialGuidance = 0; + uint BufferOffset = 8; + #endif + + float AdaptiveFilterScale; + if (_DenoiseFallback) AdaptiveFilterScale = min(saturate(Reservoir.Distance / 2 + !Reservoir.HitFound), AmbientOcclusionFilterScale); + else AdaptiveFilterScale = min(saturate(Reservoir.Distance / 2), AmbientOcclusionFilterScale); + + float MinFilterRadius = lerp(0.01f, 0.1f, AmbientOcclusion); + float AdaptivePlaneWeight = lerp(500.0f, 100.0f, AdaptiveFilterScale); + + FilterRadius = max(MinFilterRadius, lerp(FilterRadius, FilterRadius * AdaptiveFilterScale, _FilterAdaptivity)); + + float3x3 OrthoBasis = HGetLocalFrame(Reservoir.Normal); + float DistanceToPoint = length(H_GET_ABSOLUTE_POSITION_WS(PositionCenterWS) - H_GET_CAMERA_POSITION_WS()); + float RadiusScale = lerp(5.0f, 50.0f, saturate(DistanceToPoint / 500.0f)); + float Radius = DistanceToPoint * FilterRadius / RadiusScale; + float Sigma = 0.9f * Radius; + + float WeightTotal = 1; + float2 TemporalInvalidity = 1, TemporalInvalidityAccumulated = 1; + + if (VALIDATE_TEMPORAL_OCCLUSION || VALIDATE_TEMPORAL_LIGHTING) + { TemporalInvalidity = H_LOAD(_TemporalInvalidity, pixCoord.xy).xy; TemporalInvalidityAccumulated = TemporalInvalidity; } + + UNITY_UNROLL + for (int i = 0; i < 8; i++) + { + float GuidanceAdaptivity = 1 - (0.75 * ((SpatialGuidance >> i) & 0x1)); + float2 Point = _PointDistribution[i + BufferOffset].xy * Radius * GuidanceAdaptivity; + + float3 PositionPointWS = PositionCenterWS + OrthoBasis[0] * Point.x + OrthoBasis[1] * Point.y; + float2 SampleCoordNDC = H_COMPUTE_NDC_Z(PositionPointWS, H_MATRIX_VP).xy; + int2 SampleCoord = SampleCoordNDC * _ScreenSize.xy / _HScaleFactorSSGI; + + int2 Overshoot = max(SampleCoord - pixCoordMax, 0); + SampleCoord = SampleCoord - 2 * Overshoot; + + SpatialReservoir SampleReservoir = (SpatialReservoir)0; + uint4 SampleReservoirPacked = asuint(H_LOAD(_Reservoir, SampleCoord)); + UnpackSpatialReservoir(SampleReservoirPacked, Diffuse, SampleReservoir); + + float3 PositionSampleVS = ComputeFastViewSpacePosition(SampleCoordNDC, SampleReservoir.Depth, H_LINEAR_EYE_DEPTH(SampleReservoir.Depth)); + float PlaneWeight = ProbePlaneWeighting(NormalPlaneVS, PositionSampleVS, DepthCetnerLinear, AdaptivePlaneWeight); + float NormalWeight = saturate(dot(Reservoir.Normal, SampleReservoir.Normal)); + float GaussianWeight = GaussianWeighting(length(Point), Sigma); + float OcclusionWeight = 1.0f; + + if (VALIDATE_SPATIAL_OCCLUSION) + { OcclusionWeight = exp2(-10 * abs(Reservoir.Occlusion - SampleReservoir.Occlusion)); } + + float SampleWeight = PlaneWeight * NormalWeight * OcclusionWeight; + SpatialGuidance |= (uint(round(1 - SampleWeight)) << i); + + SampleWeight *= GaussianWeight * ENABLE_SPATIAL_RESTIR; + + SampleReservoir.Wsum *= SampleWeight; + SampleReservoir.M *= SampleWeight; + ReservoirUpdate(SampleReservoir, Reservoir, ReservoirUpdateRandom); + + WeightTotal += NormalWeight * PlaneWeight * GaussianWeight; + + if (VALIDATE_TEMPORAL_OCCLUSION || VALIDATE_TEMPORAL_LIGHTING) + { TemporalInvalidityAccumulated += H_LOAD(_TemporalInvalidity, SampleCoord).xy * NormalWeight * PlaneWeight * GaussianWeight; } + } + + Reservoir.W = Reservoir.Wsum / max(Reservoir.M * Luminance(Reservoir.Color * Diffuse), 1e-8); + float3 FinalColor = Reservoir.Color * Reservoir.W; + + if (SECOND_SPATIAL_PASS) + { + if (VALIDATE_SPATIAL_OCCLUSION) // && Reservoir.HitFound) + { + float SpatialOcclusion = 1; + const float3 RayDirectionWS = Reservoir.Direction; + float StepJitter = Jitter((pixCoord.xy) * 2 - 1); + + float3 RayOriginBiasedWS, RayStartPositionNDC, RayEndPositionNDC; + GetRayOriginAndDirectionNDC(min(3, Reservoir.Distance), Reservoir.Depth, pixCoordNDC, PositionCenterWS, RayDirectionWS, Reservoir.Normal, RayOriginBiasedWS, RayStartPositionNDC, RayEndPositionNDC); + + float4 HitData = RayMarchValidation(RayStartPositionNDC, RayEndPositionNDC, StepJitter); + + if (HitData.w) + { + float3 HitPosition = H_COMPUTE_POSITION_WS(HitData.xy, HitData.z, H_MATRIX_I_VP); + float HitDistance = distance(PositionCenterWS, HitPosition); + + if (abs(HitDistance - Reservoir.Distance) / (Reservoir.Distance + Reservoir.Distance) > 0.2) + { + if (HitDistance < Reservoir.Distance) + { + SpatialOcclusion = saturate(HitDistance / 3.0f); + + if (Reservoir.HitFound) + { + if (dot(HBUFFER_NORMAL_WS(HitData.xy * _ScreenSize.xy), RayDirectionWS) > _BackfaceLighting) + { + FinalColor *= saturate(HitDistance / 1.0f); + } + } + } + } + } + + float Samplecount = min(16, SamplecountReprojected + 1); + float TemporalWeight = 1.0f - (1.0f / float(Samplecount)); + + float SpatialOcclusionReprojected = H_LOAD(_SpatialOcclusion, pixCoord.xy).x; + SpatialOcclusion = lerp(SpatialOcclusion, SpatialOcclusionReprojected, TemporalWeight * pow(TemporalInvalidity.y, 2)); + _SpatialOcclusion_Output[H_COORD(pixCoord.xy)] = SpatialOcclusion; + } + + _Radiance_Output[H_COORD(pixCoord.xy)] = FinalColor; + } + else + { + _SpatialGuidance_Output[H_COORD(pixCoord.xy)] = uint2(SpatialGuidance, PackAmbientOcclusion(AdaptiveFilterScale)); + _Reservoir_Output[H_COORD(pixCoord.xy)] = PackSpatialReservoir(Reservoir); + } + + if (VALIDATE_TEMPORAL_OCCLUSION || VALIDATE_TEMPORAL_LIGHTING) + { _TemporalInvalidity_Output[H_COORD(pixCoord.xy)] = TemporalInvalidityAccumulated / WeightTotal; } +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRestirSSGI.compute.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRestirSSGI.compute.meta new file mode 100644 index 0000000..1e565a6 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HRestirSSGI.compute.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 97f6e36d045d93d4ea8ed934f8bc4a03 +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Computes/HRestirSSGI.compute + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HTemporalReprojectionSSGI.compute b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HTemporalReprojectionSSGI.compute new file mode 100644 index 0000000..4b30d9a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HTemporalReprojectionSSGI.compute @@ -0,0 +1,438 @@ +#pragma kernel TemporalReprojection +#pragma kernel ColorReprojection +#pragma kernel CopyHistory +#pragma kernel LuminanceMomentsGeneration +#pragma kernel LuminanceMomentsClear + +#include "../Includes/HReservoirSSGI.hlsl" +#include "../Includes/HFallbackSSGI.hlsl" +#pragma multi_compile _ _GBUFFER_NORMALS_OCT + +#pragma multi_compile _ REPROJECT_COLOR +#pragma multi_compile _ AUTOMATIC_BRIGHTNESS_CLAMP +#pragma multi_compile _ REPROJECT_TEMPORAL_INVALIDITY +#pragma multi_compile _ REPROJECT_SPATIAL_OCCLUSION +#pragma multi_compile _ FULL_RESOLUTION_REPROJECTION + +H_TEXTURE(_HTraceBufferGI); +H_TEXTURE(_Color_History); +H_TEXTURE(_NormalDepth_History); +H_TEXTURE(_Radiance_History); +H_TEXTURE(_Samplecount_History); +H_TEXTURE(_SpatialOcclusion_History); +H_TEXTURE(_TemporalInvalidity_History); +H_TEXTURE(_AmbientOcclusion_History); + +H_RW_TEXTURE(float, _AmbientOcclusion_Output); +H_RW_TEXTURE(float2, _TemporalInvalidity_Output); +H_RW_TEXTURE(float, _Samplecount_Output); +H_RW_TEXTURE(float, _SpatialOcclusion_Output); +H_RW_TEXTURE(float4, _Radiance_Output); +H_RW_TEXTURE(uint, _ReprojectedColor_Output); + +groupshared uint GroupMoment1; +groupshared uint GroupMoment2; +RWStructuredBuffer _LuminanceMoments; + +float _BrightnessClamp; +float _MaxDeviation; + + +// ------------------------ REPROJECTION STRUCTS ----------------------- +struct CurrentFrameData +{ + float3 Normal; + float3 WorldPos; + float DepthRaw; + float DepthLinear; + float2 RejectionPower; +}; + +struct PreviousFrameData +{ + float3 Normal; + float3 WorldPos; + float DepthLinear; +}; + + +// ------------------------ REPROJECTION STRUCTS ----------------------- +float Disocclusion(CurrentFrameData CurrentData, PreviousFrameData PreviousData) +{ + float Diosocclusion = 1; + + float PlaneDistance = abs(dot(PreviousData.WorldPos - CurrentData.WorldPos, CurrentData.Normal)); + float RelativeDepthDifference = PlaneDistance / CurrentData.DepthLinear; + if (exp2(-CurrentData.RejectionPower.x * (RelativeDepthDifference * RelativeDepthDifference)) < 0.1f) + Diosocclusion = 0.0f; + + if (abs((PreviousData.DepthLinear - CurrentData.DepthLinear) / CurrentData.DepthLinear) >= CurrentData.RejectionPower.y) + Diosocclusion = 0.0f; + + if (dot(PreviousData.Normal, CurrentData.Normal) < 0.5) + Diosocclusion = 0.0f; + + return Diosocclusion; +} + + +// ------------------------ COLOR REPROJECTION ----------------------- +[numthreads(8, 8, 1)] +void ColorReprojection(uint3 pixCoord : SV_DispatchThreadID) +{ + + bool MovingPixel = HBUFFER_MOTION_MASK(pixCoord.xy); + float2 pixCoordNDC = (pixCoord.xy + 0.5f) / _ScreenSize.xy; + + float3 Sky = EvaluateFallbackSky(H_GET_VIEW_VECTOR_WS(pixCoordNDC)); + + float LumaThreshold = _BrightnessClamp; + + if (AUTOMATIC_BRIGHTNESS_CLAMP) + { + uint2 MomentsPacked; + MomentsPacked.x = _LuminanceMoments[0]; + MomentsPacked.y = _LuminanceMoments[1]; + + float2 Moments; + float Scale = 4294967295.0f / (30.0f * 30.0f); + Moments.x = float(MomentsPacked.x) / Scale; + Moments.y = float(MomentsPacked.y) / Scale; + + float Variance = (max(0.0, Moments.y - Moments.x * Moments.x)); + float StdDev = sqrt(Variance); + LumaThreshold = Moments.x + _MaxDeviation * StdDev; + } + + CurrentFrameData CurrentData; + CurrentData.DepthRaw = HBUFFER_DEPTH(pixCoord.xy); + CurrentData.Normal = HBUFFER_NORMAL_WS(pixCoord.xy); + CurrentData.DepthLinear = H_LINEAR_EYE_DEPTH(CurrentData.DepthRaw); + CurrentData.WorldPos = H_COMPUTE_POSITION_WS(pixCoordNDC, CurrentData.DepthRaw, H_MATRIX_I_VP); + + const float DepthAligment = 1.0f - dot(-normalize(H_GET_ABSOLUTE_POSITION_WS((CurrentData.WorldPos)) - _WorldSpaceCameraPos), CurrentData.Normal); + CurrentData.RejectionPower.x = 100000.0f * (MovingPixel ? 0.0001 * CurrentData.DepthLinear * CurrentData.DepthLinear : 1); + CurrentData.RejectionPower.y = lerp(1e-2f, 1e-1f, pow(DepthAligment, 8)) * (MovingPixel ? 50 / CurrentData.DepthLinear : 1); + + if (!REPROJECT_COLOR) + { + float3 ReprojectedColor = CurrentData.DepthRaw <= UNITY_RAW_FAR_CLIP_VALUE ? Sky : HBUFFER_COLOR(pixCoord.xy).xyz; + + float ReprojectedColorLuma = Luminance(ReprojectedColor); + if (ReprojectedColorLuma > LumaThreshold) + ReprojectedColor *= (LumaThreshold / ReprojectedColorLuma); + + _ReprojectedColor_Output[H_COORD(pixCoord.xy)] = PackColorHit(ReprojectedColor, MovingPixel); + //return; + } + + float2 ReprojectionCoord = float2(pixCoord.xy) - HBUFFER_MOTION_VECTOR(pixCoord.xy) * floor(_ScreenSize.xy); + ReprojectionCoord /= (HRenderScale.xy / HRenderScalePrevious.xy); + + float UVx = frac(ReprojectionCoord.x); + float UVy = frac(ReprojectionCoord.y); + + float4 ReprojectionWeights; + ReprojectionWeights.x = (1.0f - UVx) * (1.0f - UVy); + ReprojectionWeights.y = (UVx) * (1.0f - UVy); + ReprojectionWeights.z = (1.0f - UVx) * (UVy); + ReprojectionWeights.w = (UVx) * (UVy); + + const uint2 ReprojectionOffsets[4] = {uint2(0, 0), uint2(1, 0), uint2(0, 1), uint2(1, 1)}; + + UNITY_UNROLL + for (int i = 0; i < 4; i++) + { + int2 SampleCoord = ReprojectionCoord + ReprojectionOffsets[i]; + uint HistoryNormalDepthPacked = asuint(H_LOAD(_NormalDepth_History, SampleCoord).x); + float4 HistoryNormalDepth = UnpackNormalDepth(HistoryNormalDepthPacked); + + SampleCoord /= (HRenderScalePrevious.xy / HRenderScale.xy); + + PreviousFrameData PreviousData; + PreviousData.Normal = HistoryNormalDepth.xyz; + PreviousData.WorldPos = H_COMPUTE_POSITION_WS((SampleCoord + 0.5f) * _ScreenSize.zw, HistoryNormalDepth.w, H_MATRIX_PREV_I_VP); + PreviousData.DepthLinear = H_LINEAR_EYE_DEPTH(PreviousData.WorldPos, UNITY_MATRIX_V); + + ReprojectionWeights[i] *= Disocclusion(CurrentData, PreviousData); + + if (CurrentData.DepthRaw <= UNITY_RAW_FAR_CLIP_VALUE) + ReprojectionWeights[i] = 1; + + if (any(SampleCoord.xy >= _ScreenSize.xy)) + ReprojectionWeights[i] = 0; + } + + float WeightsTotal = ReprojectionWeights.x + ReprojectionWeights.y + ReprojectionWeights.z + ReprojectionWeights.w; + + float ReprojectedSamplecount = 0; + float3 ReprojectedRadiance = 0; + float3 ReprojectedColor = 0; + + if (WeightsTotal > 0.15f) + { + ReprojectionWeights = WeightsTotal > 0 ? ReprojectionWeights / WeightsTotal : 0; + + float BestWeight = 0; + uint2 BestOffset = 0; + + UNITY_UNROLL + for (int i = 0; i < 4; i++) + { + float4 RadianceSamplecountHistory = H_LOAD(_Radiance_History, ReprojectionCoord + ReprojectionOffsets[i]) * ReprojectionWeights[i]; + ReprojectedSamplecount += RadianceSamplecountHistory.w; + ReprojectedRadiance += RadianceSamplecountHistory.xyz; + + // Select best reprojection for color + if (ReprojectionWeights[i] > BestWeight) + { + BestWeight = ReprojectionWeights[i]; + BestOffset = ReprojectionOffsets[i]; + } + } + + if (REPROJECT_COLOR) + { + ReprojectedColor = CurrentData.DepthRaw <= UNITY_RAW_FAR_CLIP_VALUE ? Sky : H_LOAD(_Color_History, ReprojectionCoord + BestOffset).xyz; + + float ReprojectedColorLuma = Luminance(ReprojectedColor); + if (ReprojectedColorLuma > LumaThreshold) + ReprojectedColor *= (LumaThreshold / ReprojectedColorLuma); + } + } + + _Radiance_Output[H_COORD(pixCoord.xy)] = float4(ReprojectedRadiance.xyz, ReprojectedSamplecount.x); + _ReprojectedColor_Output[H_COORD(pixCoord.xy)] = PackColorHit(ReprojectedColor, MovingPixel); +} + + +// ------------------------ TEMPORAL REPROJECTION ----------------------- +[numthreads(8, 8, 1)] +void TemporalReprojection(uint3 pixCoord : SV_DispatchThreadID) +{ + + uint2 pixCoordUnscaled = GetUnscaledCoords(pixCoord.xy); + float2 pixCoordNDC = (float2(pixCoordUnscaled) + 0.5f) / _ScreenSize.xy; + + float3 Sky = EvaluateFallbackSky(H_GET_VIEW_VECTOR_WS(pixCoordNDC)); + + float LumaThreshold = _BrightnessClamp; + + if (AUTOMATIC_BRIGHTNESS_CLAMP) + { + uint2 MomentsPacked; + MomentsPacked.x = _LuminanceMoments[0]; + MomentsPacked.y = _LuminanceMoments[1]; + + float2 Moments; + float Scale = 4294967295.0f / (30.0f * 30.0f); + Moments.x = float(MomentsPacked.x) / Scale; + Moments.y = float(MomentsPacked.y) / Scale; + + float Variance = (max(0.0, Moments.y - Moments.x * Moments.x)); + float StdDev = sqrt(Variance); + LumaThreshold = Moments.x + _MaxDeviation * StdDev; + } + + CurrentFrameData CurrentData; + CurrentData.DepthRaw = HBUFFER_DEPTH(pixCoordUnscaled); + CurrentData.Normal = HBUFFER_NORMAL_WS(pixCoordUnscaled); + CurrentData.DepthLinear = H_LINEAR_EYE_DEPTH(CurrentData.DepthRaw); + CurrentData.WorldPos = H_COMPUTE_POSITION_WS(pixCoordNDC, CurrentData.DepthRaw, H_MATRIX_I_VP); + + bool MovingPixel = HBUFFER_MOTION_MASK(pixCoordUnscaled); + float DepthAligment = 1.0f - dot(-normalize(H_GET_ABSOLUTE_POSITION_WS((CurrentData.WorldPos)) - _WorldSpaceCameraPos), CurrentData.Normal); + CurrentData.RejectionPower.x = 100000.0f * (MovingPixel ? 0.0001 * CurrentData.DepthLinear * CurrentData.DepthLinear : 1); + CurrentData.RejectionPower.y = lerp(1e-2f, 1e-1f, pow(DepthAligment, 8)) * (MovingPixel ? 50 / CurrentData.DepthLinear : 1); + + float2 MotionVectors = HBUFFER_MOTION_VECTOR(pixCoordUnscaled); + float2 ReprojectionCoord = float2(pixCoord.xy) - MotionVectors * floor(_ScreenSize.xy / _HScaleFactorSSGI); + ReprojectionCoord /= (_HPreviousScaleFactorSSGI.xx / _HScaleFactorSSGI.xx); + ReprojectionCoord /= (HRenderScale.xy / HRenderScalePrevious.xy); + + float UVx = frac(ReprojectionCoord.x); + float UVy = frac(ReprojectionCoord.y); + + float4 ReprojectionWeights; + ReprojectionWeights.x = (1.0f - UVx) * (1.0f - UVy); + ReprojectionWeights.y = (UVx) * (1.0f - UVy); + ReprojectionWeights.z = (1.0f - UVx) * (UVy); + ReprojectionWeights.w = (UVx) * (UVy); + + const uint2 ReprojectionOffsets[4] = {uint2(0, 0), uint2(1, 0), uint2(0, 1), uint2(1, 1)}; + + UNITY_UNROLL + for (int i = 0; i < 4; i++) + { + int2 SampleCoord = ReprojectionCoord + ReprojectionOffsets[i]; + + uint HistoryNormalDepthPacked = asuint(H_LOAD(_NormalDepth_History, SampleCoord).x); + float4 HistoryNormalDepth = UnpackNormalDepth(HistoryNormalDepthPacked); + + SampleCoord /= (HRenderScalePrevious.xy / HRenderScale.xy); + + PreviousFrameData PreviousData; + PreviousData.Normal = HistoryNormalDepth.xyz; + PreviousData.WorldPos = H_COMPUTE_POSITION_WS((SampleCoord * _HPreviousScaleFactorSSGI + 0.5f) * _ScreenSize.zw, HistoryNormalDepth.w, H_MATRIX_PREV_I_VP); + PreviousData.DepthLinear = H_LINEAR_EYE_DEPTH(PreviousData.WorldPos, UNITY_MATRIX_V); + + ReprojectionWeights[i] *= Disocclusion(CurrentData, PreviousData); + + if (CurrentData.DepthRaw <= UNITY_RAW_FAR_CLIP_VALUE) + ReprojectionWeights[i] = 1; + + if (any(SampleCoord.xy >= _ScreenSize.xy / _HPreviousScaleFactorSSGI)) + ReprojectionWeights[i] = 0; + } + + float WeightsTotal = ReprojectionWeights.x + ReprojectionWeights.y + ReprojectionWeights.z + ReprojectionWeights.w; + + TemporalReservoir Reservoir = (TemporalReservoir)0; + float3 Diffuse = GetReservoirDiffuse(pixCoordUnscaled); + + float Samplecount = 0; + float ReprojectedAmbientOcclusion = 1; + float ReprojectedSpatialOcclusion = 1; + float2 ReprojectedTemporalInvalidity = 1; + float3 ReprojectedColor = 0; + float3 ReprojectedRadiance = 0; + + if (WeightsTotal > 0.15f) + { + ReprojectionWeights /= WeightsTotal; + + float BestWeight = 0; + uint2 BestOffset = 0; + ReprojectedSpatialOcclusion = 0; + ReprojectedTemporalInvalidity = 0; + ReprojectedAmbientOcclusion = 0; + + uint ReservoirUpdateRandom = Hash3(uint3(pixCoord.xy, _FrameCount)); + + UNITY_UNROLL + for (int i = 0; i < 4; i++) + { + // Reproject Spatial Occlusion + if (REPROJECT_TEMPORAL_INVALIDITY) { ReprojectedTemporalInvalidity += H_LOAD(_TemporalInvalidity_History, ReprojectionCoord + ReprojectionOffsets[i]).xy * ReprojectionWeights[i]; } + if (REPROJECT_SPATIAL_OCCLUSION) { ReprojectedSpatialOcclusion += H_LOAD(_SpatialOcclusion_History, ReprojectionCoord + ReprojectionOffsets[i]).x * ReprojectionWeights[i]; } + ReprojectedAmbientOcclusion += H_LOAD(_AmbientOcclusion_History, ReprojectionCoord + ReprojectionOffsets[i]).x * ReprojectionWeights[i]; + ReprojectedRadiance += H_LOAD(_Radiance_History, ReprojectionCoord + ReprojectionOffsets[i]).xyz * ReprojectionWeights[i]; + Samplecount += H_LOAD(_Samplecount_History, ReprojectionCoord + ReprojectionOffsets[i]).x * ReprojectionWeights[i]; + + // Reproject ReSTIR reservoir + TemporalReservoir HistoryReservoir = (TemporalReservoir)0; + UnpackTemporalReservoir(asuint(H_LOAD(_Reservoir, ReprojectionCoord + ReprojectionOffsets[i])), Diffuse, HistoryReservoir); + + HistoryReservoir.Wsum *= ReprojectionWeights[i]; + HistoryReservoir.M *= ReprojectionWeights[i]; + + ReservoirUpdate(HistoryReservoir, Reservoir, ReservoirUpdateRandom); + + // Select best reprojection for color + if (ReprojectionWeights[i] > BestWeight) + { + BestWeight = ReprojectionWeights[i]; + BestOffset = ReprojectionOffsets[i]; + } + } + + // Reproject Color + if (FULL_RESOLUTION_REPROJECTION && REPROJECT_COLOR) + { + // Use original reprojection coord to avoid reading Color buffer in wrong location (scaled by _HScaleFactorSSGI / _HPreviousScaleFactorSSGI) + float2 ReprojectionCoord = float2(pixCoord.xy) - MotionVectors * floor(_ScreenSize.xy / _HScaleFactorSSGI); + ReprojectionCoord /= (HRenderScale.xy / HRenderScalePrevious.xy); + + ReprojectedColor = CurrentData.DepthRaw <= UNITY_RAW_FAR_CLIP_VALUE ? Sky : H_LOAD(_Color_History, ReprojectionCoord + BestOffset).xyz; + + float ReprojectedColorLuma = Luminance(ReprojectedColor); + if (ReprojectedColorLuma > LumaThreshold) + ReprojectedColor *= (LumaThreshold / ReprojectedColorLuma); + + } + } + + Reservoir.W = Reservoir.Wsum / max(Reservoir.M * Luminance(Reservoir.Color * Diffuse), 1e-8); + + _Samplecount_Output[H_COORD(pixCoord.xy)] = Samplecount; + _Radiance_Output[H_COORD(pixCoord.xy)] = float4(ReprojectedRadiance.xyz, 0); + _Reservoir_Output[H_COORD(pixCoord.xy)] = PackTemporalReservoir(Reservoir); + _AmbientOcclusion_Output[H_COORD(pixCoord.xy)] = ReprojectedAmbientOcclusion; + + if (!REPROJECT_COLOR) + { + ReprojectedColor = CurrentData.DepthRaw <= UNITY_RAW_FAR_CLIP_VALUE ? Sky : HBUFFER_COLOR(pixCoord.xy).xyz; + + float ReprojectedColorLuma = Luminance(ReprojectedColor); + if (ReprojectedColorLuma > LumaThreshold) + ReprojectedColor *= (LumaThreshold / ReprojectedColorLuma); + } + + if (FULL_RESOLUTION_REPROJECTION) { _ReprojectedColor_Output[H_COORD(pixCoordUnscaled)] = PackColorHit(ReprojectedColor, MovingPixel); } + if (REPROJECT_SPATIAL_OCCLUSION) { _SpatialOcclusion_Output[H_COORD(pixCoord.xy)] = ReprojectedSpatialOcclusion; } + if (REPROJECT_TEMPORAL_INVALIDITY) { _TemporalInvalidity_Output[H_COORD(pixCoord.xy)] = ReprojectedTemporalInvalidity; } +} + + +// ------------------------ HISTORY COPYING ----------------------- +[numthreads(8, 8, 1)] +void CopyHistory(uint3 pixCoord : SV_DispatchThreadID) +{ + + float3 IndirectLighting = H_LOAD(_HTraceBufferGI, pixCoord.xy).xyz; + float3 DiffuseColor = HBUFFER_DIFFUSE(pixCoord.xy).xyz; + float Metallic = H_LOAD(g_HTraceGBuffer1, pixCoord.xy).x; + + // No Indirect Intensity multiplier here to avoid overblown lighting through the temporal loop + float3 FinalIndirectLighting = IndirectLighting * DiffuseColor * (1 - Metallic); + + _Radiance_Output[H_COORD(pixCoord.xy)] = float4(HBUFFER_COLOR(pixCoord.xy).xyz + FinalIndirectLighting, 0); +} + + +// ------------------------ LUMINANCE MOMENTS GENERATION ------------------------ +[numthreads(8, 8, 1)] +void LuminanceMomentsGeneration(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex) +{ + if (groupIndex == 0) + { GroupMoment1 = 0; GroupMoment2 = 0;} + GroupMemoryBarrierWithGroupSync(); + + // We don't reproject this buffer even if it's from the prev. frame because it's fine for this operation + float2 pixCoordNDC = float2(pixCoord.xy + 0.5) * _ScreenSize.zw; + float3 Color = HBUFFER_DEPTH(pixCoord.xy).x <= UNITY_RAW_FAR_CLIP_VALUE ? EvaluateFallbackSky(H_GET_VIEW_VECTOR_WS(pixCoordNDC)) : H_LOAD(_Color_History, pixCoord.xy).xyz; + float Luma = Luminance(Color); + Luma = clamp(Luma, 0.0, 30); + + float Scale = 4294967295.0f / (30.0f * 30.0f); + uint Moment1 = uint(Luma * Scale / 64.0f); + uint Moment2 = uint(Luma * Luma * Scale / 64.0f); + + InterlockedAdd(GroupMoment1, Moment1); + InterlockedAdd(GroupMoment2, Moment2); + GroupMemoryBarrierWithGroupSync(); + + UNITY_BRANCH + if (groupIndex == 0) + { + float2 Moments = 0; + Moments.x = float(GroupMoment1); + Moments.y = float(GroupMoment2); + + GroupMoment1 = uint(Moments.x / (_ScreenSize.x * _ScreenSize.y / 64)); + GroupMoment2 = uint(Moments.y / (_ScreenSize.x * _ScreenSize.y / 64)); + + uint Index = 0; + InterlockedAdd(_LuminanceMoments[0], GroupMoment1, Index); + InterlockedAdd(_LuminanceMoments[1], GroupMoment2, Index); + } +} + + +// ------------------------ LUMINANCE MOMENTS CLEAR ------------------------ +[numthreads(1, 1, 1)] +void LuminanceMomentsClear(uint3 pixCoord : SV_DispatchThreadID, uint2 groupThreadID : SV_GroupThreadID) +{ + _LuminanceMoments[0] = 0; + _LuminanceMoments[1] = 0; +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HTemporalReprojectionSSGI.compute.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HTemporalReprojectionSSGI.compute.meta new file mode 100644 index 0000000..c04d8ef --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Computes/HTemporalReprojectionSSGI.compute.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: c91b570672b56b14ca13f188b77120ab +ComputeShaderImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Computes/HTemporalReprojectionSSGI.compute + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/HTraceSSGI Volume Profile URP.asset b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/HTraceSSGI Volume Profile URP.asset new file mode 100644 index 0000000..f413057 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/HTraceSSGI Volume Profile URP.asset @@ -0,0 +1,62 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-7993483843299501905 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6bd486065ce11414fa40e631affc4900, type: 3} + m_Name: ProbeVolumesOptions + m_EditorClassIdentifier: + active: 0 + normalBias: + m_OverrideState: 1 + m_Value: 0 + viewBias: + m_OverrideState: 1 + m_Value: 0 + scaleBiasWithMinProbeDistance: + m_OverrideState: 0 + m_Value: 0 + samplingNoise: + m_OverrideState: 1 + m_Value: 0 + animateSamplingNoise: + m_OverrideState: 0 + m_Value: 0 + leakReductionMode: + m_OverrideState: 0 + m_Value: 2 + minValidDotProductValue: + m_OverrideState: 0 + m_Value: 0.1 + occlusionOnlyReflectionNormalization: + m_OverrideState: 0 + m_Value: 1 + intensityMultiplier: + m_OverrideState: 0 + m_Value: 1 + skyOcclusionIntensityMultiplier: + m_OverrideState: 0 + m_Value: 1 + worldOffset: + m_OverrideState: 0 + m_Value: {x: 0, y: 0, z: 0} +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3} + m_Name: HTraceSSGI Volume Profile URP + m_EditorClassIdentifier: + components: + - {fileID: -7993483843299501905} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/HTraceSSGI Volume Profile URP.asset.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/HTraceSSGI Volume Profile URP.asset.meta new file mode 100644 index 0000000..7b02ba7 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/HTraceSSGI Volume Profile URP.asset.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: ace954f626dae2f42bd7ce088bf3a88f +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/HTraceSSGI Volume Profile URP.asset + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers.meta new file mode 100644 index 0000000..d9527b9 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6d45cf09bd8aeb74da02a17745b1a2fb +timeCreated: 1659620468 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files.meta new file mode 100644 index 0000000..44647ae --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6fd27422052b4b24fa14bee0cd9faf8f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/Color.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/Color.hlsl new file mode 100644 index 0000000..0cedd1a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/Color.hlsl @@ -0,0 +1,21 @@ +// Hue, Saturation, Value +// Ranges: +// Hue [0.0, 1.0] +// Sat [0.0, 1.0] +// Lum [0.0, HALF_MAX] +float3 RgbToHsv(float3 c) +{ + const float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g)); + float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r)); + float d = q.x - min(q.w, q.y); + const float e = 1.0e-4; + return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); +} + +float3 HsvToRgb(float3 c) +{ + const float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www); + return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y); +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/Color.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/Color.hlsl.meta new file mode 100644 index 0000000..7e4e0b3 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/Color.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 4f691d60f06346958b6ee703007d2346 +timeCreated: 1747411471 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/Color.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/RaytracingSampling.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/RaytracingSampling.hlsl new file mode 100644 index 0000000..746ac43 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/RaytracingSampling.hlsl @@ -0,0 +1,77 @@ +#pragma once + +Texture2D g_OwenScrambledTexture; +Texture2D g_ScramblingTileXSPP; +Texture2D g_RankingTileXSPP; +Texture2D g_ScramblingTexture; + +float ScramblingValueFloat(uint2 pixelCoord) +{ + pixelCoord = pixelCoord & 255; + return g_ScramblingTexture[uint2(pixelCoord.x, pixelCoord.y)].x; +} + +float2 ScramblingValueFloat2(uint2 pixelCoord) +{ + pixelCoord = pixelCoord & 255; + return g_ScramblingTexture[uint2(pixelCoord.x, pixelCoord.y)].xy; +} + +uint ScramblingValueUInt(uint2 pixelCoord) +{ + pixelCoord = pixelCoord & 255; + return clamp((uint)(g_ScramblingTexture[uint2(pixelCoord.x, pixelCoord.y)].x * 256.0), 0, 255); +} + +uint2 ScramblingValueUInt2(uint2 pixelCoord) +{ + pixelCoord = pixelCoord & 255; + return clamp((uint2)(g_ScramblingTexture[uint2(pixelCoord.x, pixelCoord.y)] * 256.0), uint2(0,0), uint2(255, 255)); +} + +// Wrapper to sample the scrambled low Low-Discrepancy sequence (returns a float) +float GetLDSequenceSampleFloat(uint sampleIndex, uint sampleDimension) +{ + // Make sure arguments are in the right range + sampleIndex = sampleIndex & 255; + // sampleDimension = sampleDimension & 255; + + // Fetch the sequence value and return it + return g_OwenScrambledTexture[uint2(sampleDimension, sampleIndex)]; +} + +// Wrapper to sample the scrambled low Low-Discrepancy sequence (returns an unsigned int) +uint GetLDSequenceSampleUInt(uint sampleIndex, uint sampleDimension) +{ + // Make sure arguments are in the right range + sampleIndex = sampleIndex & 255; + // sampleDimension = sampleDimension & 255; + + // Fetch the sequence value and return it + return clamp((uint)(g_OwenScrambledTexture[uint2(sampleDimension, sampleIndex)] * 256.0), 0, 255); +} + +// This is an implementation of the method from the paper +// "A Low-Discrepancy Sampler that Distributes Monte Carlo Errors as a Blue Noise in Screen Space" by Heitz et al. +float GetBNDSequenceSample(uint2 pixelCoord, uint sampleIndex, uint sampleDimension) +{ + // wrap arguments + pixelCoord = pixelCoord & 127; + sampleIndex = sampleIndex & 255; + sampleDimension = sampleDimension & 255; + + // xor index based on optimized ranking + uint rankingIndex = (pixelCoord.x + pixelCoord.y * 128) * 8 + (sampleDimension & 7); + uint rankedSampleIndex = sampleIndex ^ clamp((uint)(g_RankingTileXSPP[uint2(rankingIndex & 127, rankingIndex / 128)] * 256.0), 0, 255); + + // fetch value in sequence + uint value = clamp((uint)(g_OwenScrambledTexture[uint2(sampleDimension, rankedSampleIndex.x)] * 256.0), 0, 255); + + // If the dimension is optimized, xor sequence value based on optimized scrambling + uint scramblingIndex = (pixelCoord.x + pixelCoord.y * 128) * 8 + (sampleDimension & 7); + float scramblingValue = min(g_ScramblingTileXSPP[uint2(scramblingIndex & 127, scramblingIndex / 128)], 0.999); + value = value ^ uint(scramblingValue * 256.0); + + // Convert to float (to avoid the same 1/256th quantization everywhere, we jitter by the pixel scramblingValue) + return (scramblingValue + value) / 256.0; +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/RaytracingSampling.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/RaytracingSampling.hlsl.meta new file mode 100644 index 0000000..e6e1811 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/RaytracingSampling.hlsl.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 65e6e8fcb728c8c4c84222455e57dc80 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Headers/HDRP files/RaytracingSampling.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMain.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMain.hlsl new file mode 100644 index 0000000..9dcd8ea --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMain.hlsl @@ -0,0 +1,219 @@ +//pipelinedefine +#define H_URP + +#ifndef HMAIN_INCLUDED +#define HMAIN_INCLUDED + +// TODO: check if we need all these includes or some can be removed? +// --------------------------------- INCLUDE FILES ----------------------------- // + + + +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareNormalsTexture.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareOpaqueTexture.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Sampling/Sampling.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" + + +// --------------------------------- VALUES ----------------------------- // + +float4 _HRenderScale; +float4 _HRenderScalePrevious; + +#define HRenderScale _HRenderScale +#define HRenderScalePrevious _HRenderScalePrevious + + +uint _FrameCount; + + +// --------------------------------- CONSTANTS ----------------------------- // +#define H_TWO_PI (6.28318530718f) +#define H_PI (3.1415926535897932384626433832795) +#define H_PI_HALF (1.5707963267948966192313216916398) + + +// --------------------------------- TEXTURE SAMPLERS ----------------------------- // + + +SamplerState sampler_point_clamp; +SamplerState sampler_linear_clamp; +SamplerState sampler_point_repeat; +SamplerState sampler_point_mirror; +SamplerState sampler_linear_repeat; +SamplerState sampler_trilinear_clamp; + +#define H_SAMPLER_POINT_CLAMP sampler_point_clamp +#define H_SAMPLER_LINEAR_CLAMP sampler_linear_clamp +#define H_SAMPLER_LINEAR_REPEAT sampler_linear_repeat +#define H_SAMPLER_TRILINEAR_CLAMP sampler_trilinear_clamp + + +// --------------------------------- TEXTURE READ / WRITE HELPERS ----------------------------- // + + +#define H_COORD(pixelCoord) uint2(pixelCoord) //todo: do we need defines for VR? +#define H_INDEX_ARRAY(slot) (slot) + + +// ----------------------------- TEXTURE PROPERTY DECLARATIONS ----------------------------- // + + +#define H_TEXTURE(textureName) TEXTURE2D(textureName) +#define H_TEXTURE_ARRAY(textureName) TEXTURE2D_ARRAY(textureName) + +#define H_RW_TEXTURE(type, textureName) RW_TEXTURE2D(type, textureName) +#define H_RW_TEXTURE_ARRAY(type, textureName) RW_TEXTURE2D_ARRAY(type, textureName) + + +// ----------------------------- TEXTURE FETCH ----------------------------- // + + +#define H_LOAD(textureName, unCoord2) LOAD_TEXTURE2D(textureName, unCoord2) +#define H_LOAD_LOD(textureName, unCoord2, lod) LOAD_TEXTURE2D_LOD(textureName, unCoord2, lod) +#define H_LOAD_ARRAY(textureName, unCoord2, index) LOAD_TEXTURE2D_ARRAY(textureName, unCoord2, index) +#define H_LOAD_ARRAY_LOD(textureName, unCoord2, index, lod) LOAD_TEXTURE2D_ARRAY_LOD(textureName, unCoord2, index, lod) + +#define H_SAMPLE(textureName, samplerName, coord2) SAMPLE_TEXTURE2D(textureName, samplerName, coord2) +#define H_SAMPLE_LOD(textureName, samplerName, coord2, lod) SAMPLE_TEXTURE2D_LOD(textureName, samplerName, coord2, lod) +#define H_SAMPLE_ARRAY(textureName, samplerName, coord2, index) SAMPLE_TEXTURE2D_ARRAY(textureName, samplerName, coord2, index) +#define H_SAMPLE_ARRAY_LOD(textureName, samplerName, coord2, index, lod) SAMPLE_TEXTURE2D_ARRAY_LOD(textureName, samplerName, coord2, index, lod) + +#define H_GATHER_RED(textureName, samplerName, coord2, offset) GATHER_RED_TEXTURE2D(textureName, samplerName, coord2) +#define H_GATHER_BLUE(textureName, samplerName, coord2, offset) GATHER_BLUE_TEXTURE2D(textureName, samplerName, coord2) +#define H_GATHER_GREEN(textureName, samplerName, coord2, offset) GATHER_GREEN_TEXTURE2D(textureName, samplerName, coord2) +#define H_GATHER_ALPHA(textureName, samplerName, coord2, offset) GATHER_ALPHA_TEXTURE2D(textureName, samplerName, coord2) + + +// ---------------------------------- MATRICES ----------------------------- // + + +float4x4 _H_MATRIX_I_P; +float4x4 _H_MATRIX_PREV_VP; +float4x4 _H_MATRIX_PREV_I_VP; + +#define H_MATRIX_PREV_VP _H_MATRIX_PREV_VP +#define H_MATRIX_PREV_I_VP _H_MATRIX_PREV_I_VP +#define H_MATRIX_I_VP UNITY_MATRIX_I_VP +#define H_MATRIX_I_P UNITY_MATRIX_I_P +#define H_MATRIX_VP UNITY_MATRIX_VP +#define H_MATRIX_V UNITY_MATRIX_V +#define H_MATRIX_I_V UNITY_MATRIX_I_V + + +// ------------------------------------- GBUFFER RESOURCES ----------------------------- // + +float4 H_SHAr; +float4 H_SHAg; +float4 H_SHAb; +float4 H_SHBr; +float4 H_SHBg; +float4 H_SHBb; +float4 H_SHC; + +H_TEXTURE(g_HTraceGBuffer0); +H_TEXTURE(g_HTraceGBuffer1); +H_TEXTURE(g_HTraceGBuffer2); +H_TEXTURE(g_HTraceGBuffer3); + +H_TEXTURE(g_HTraceDepth); +H_TEXTURE(g_HTraceDepthPyramidSSGI); +H_TEXTURE(g_HTraceColor); +H_TEXTURE(g_HTraceMotionMask); +H_TEXTURE(g_HTraceMotionVectors); +H_TEXTURE(g_HTraceRenderLayerMask); + +H_TEXTURE(g_HTraceSSAO); + + + +// --------------------------------- GBUFFER FETCH ----------------------------- // +#define HBUFFER_NORMAL_WS(pixCoord) GetNormalWS(pixCoord) +#define HBUFFER_ROUGHNESS(pixCoord) GetRoughness(pixCoord) +#define HBUFFER_DEPTH(pixCoord) GetDepth(pixCoord) +#define HBUFFER_COLOR(pixCoord) GetColor(pixCoord) +#define HBUFFER_DIFFUSE(pixCoord) GetDiffuse(pixCoord) +#define HBUFFER_MOTION_VECTOR(pixCoord) GetMotionVectors(pixCoord) +#define HBUFFER_MOTION_MASK(pixCoord) GetMotionMask(pixCoord) +#define HBUFFER_RENDER_LAYER_MASK(pixCoord) GetRenderLayerMask(pixCoord) + +float3 GetNormalWS(uint2 pixCoord) +{ + + + float3 Normal = H_LOAD(g_HTraceGBuffer2, pixCoord).xyz; + #if defined(_GBUFFER_NORMALS_OCT) + float2 RemappedOctNormalWS = Unpack888ToFloat2(Normal); + float2 OctNormalWS = RemappedOctNormalWS.xy * 2.0 - 1.0; + Normal = UnpackNormalOctQuadEncode(OctNormalWS); + #endif + return Normal; +} + +float GetDepth(uint2 pixCoord) +{ + + + return H_LOAD(g_HTraceDepth, pixCoord).x; +} + +float4 GetColor(uint2 pixCoord) +{ + + + return H_LOAD(g_HTraceColor, pixCoord); +} + +float4 GetDiffuse(uint2 pixCoord) +{ + + + return H_LOAD(g_HTraceGBuffer0, pixCoord).xyzw; +} + + +float2 GetMotionVectors(uint2 pixCoord) +{ + + + return H_LOAD(g_HTraceMotionVectors, pixCoord).xy; +} + + +float GetMotionMask(uint2 pixCoord) +{ + + + return any(H_LOAD(g_HTraceMotionMask, pixCoord).xy != 0); +} + +uint GetRenderLayerMask(uint2 pixCoord) +{ + #if UNITY_VERSION >= 600000 + + + + #if UNITY_VERSION >= 60020000 + return asuint(H_LOAD(g_HTraceRenderLayerMask, pixCoord.xy).x); + #else + float4 RenderLayers = H_LOAD(g_HTraceRenderLayerMask, pixCoord.xy); + return DecodeMeshRenderingLayer(RenderLayers.x); + #endif + + #else + return 0; + #endif +} + +// ---------------------------------- OTHER ----------------------------------------- + + + +#define HGetInversePreviousExposureMultiplier 1 +#define HGetInverseCurrentExposureMultiplier 1 +#define HGetCurrentExposureMultiplier 1 +#define HGetPreviousExposureMultiplier 1 + +#endif // HMAIN_INCLUDED diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMain.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMain.hlsl.meta new file mode 100644 index 0000000..1363454 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMain.hlsl.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: a4c2fc6c03cd9d5449598ccc2642ba20 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Headers/HMain.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMath.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMath.hlsl new file mode 100644 index 0000000..368f484 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMath.hlsl @@ -0,0 +1,154 @@ +#pragma once + +#define FLT_MIN 1.175494351e-38 +#define FLT_MAX 3.402823466e+38 + +float3 HSafeNormalize(float3 inVec) +{ + float dp3 = max(FLT_MIN, dot(inVec, inVec)); + return inVec * rsqrt(dp3); +} + +float HSinFromCos(float cosX) +{ + return sqrt(saturate(1 - cosX * cosX)); +} + +float HFastSqrt(float x) +{ + return (asfloat(0x1fbd1df5 + (asint(x) >> 1))); +} + +float HFastACos( float inX ) +{ + float pi = 3.141593; + float half_pi = 1.570796; + float x = abs(inX); + float res = -0.156583 * x + half_pi; + res *= HFastSqrt(1.0 - x); + return (inX >= 0) ? res : pi - res; +} + +float3x3 HGetLocalFrame(float3 localZ) +{ + float x = localZ.x; + float y = localZ.y; + float z = localZ.z; + + + float sz = FastSign(z); + float a = 1 / (sz + z); + float ya = y * a; + float b = x * ya; + float c = x * sz; + + float3 localX = float3(c * x * a - 1, sz * b, c); + float3 localY = float3(b, y * ya - sz, y); + + return float3x3(localX, localY, localZ); +} + +float2 HSampleDiskCubic(float u1, float u2) +{ + float r = u1; + float phi = 6.28318530718f * u2; + + float sinPhi, cosPhi; + sincos(phi, sinPhi, cosPhi); + + return r * float2(cosPhi, sinPhi); +} + +float3 HSphericalToCartesian(float cosPhi, float sinPhi, float cosTheta) +{ + float sinTheta = HSinFromCos(cosTheta); + return float3(float2(cosPhi, sinPhi) * sinTheta, cosTheta); +} + +float3 HSphericalToCartesian(float phi, float cosTheta) +{ + float sinPhi, cosPhi; + sincos(phi, sinPhi, cosPhi); + return HSphericalToCartesian(cosPhi, sinPhi, cosTheta); +} + +float3 HSampleSphereUniform(float u1, float u2) +{ + float phi = 6.28318530718f * u2; + float cosTheta = 1.0 - 2.0 * u1; + return HSphericalToCartesian(phi, cosTheta); +} + +float3 HSampleHemisphereCosine(float u1, float u2, float3 normal) +{ + float3 pointOnSphere = HSampleSphereUniform(u1, u2); + return HSafeNormalize(normal + pointOnSphere); +} + + +float2 HLineBoxIntersect(float3 RayOrigin, float3 RayEnd, float3 BoxMin, float3 BoxMax) +{ + float3 InvRayDir = 1.0f / (RayEnd - RayOrigin); + + float3 FirstPlaneIntersections = (BoxMin - RayOrigin) * InvRayDir; + float3 SecondPlaneIntersections = (BoxMax - RayOrigin) * InvRayDir; + float3 ClosestPlaneIntersections = min(FirstPlaneIntersections, SecondPlaneIntersections); + float3 FurthestPlaneIntersections = max(FirstPlaneIntersections, SecondPlaneIntersections); + + float2 BoxIntersections; + BoxIntersections.x = max(ClosestPlaneIntersections.x, max(ClosestPlaneIntersections.y, ClosestPlaneIntersections.z)); + BoxIntersections.y = min(FurthestPlaneIntersections.x, min(FurthestPlaneIntersections.y, FurthestPlaneIntersections.z)); + return saturate(BoxIntersections); +} + +float HUintToFloat01(uint h) +{ + static const uint MantissaMask = 0x007FFFFFu; + static const uint One = 0x3F800000u; + + h &= MantissaMask; + h |= One; + + float r2 = asfloat(h); + return r2 - 1.0; +} + +uint Hash_Combine(uint x, uint y) +{ + static const uint M = 1664525u, C = 1013904223u; + uint seed = (x * M + y + C) * M; + + seed ^= (seed >> 11u); + seed ^= (seed << 7u) & 0x9d2c5680u; + seed ^= (seed << 15u) & 0xefc60000u; + seed ^= (seed >> 18u); + return seed; +} + +uint Hash1(uint x) +{ + x += (x << 10u); + x ^= (x >> 6u); + x += (x << 3u); + x ^= (x >> 11u); + x += (x << 15u); + return x; +} + +uint Hash2(uint2 v) +{ + return Hash_Combine(v.x, Hash1(v.y)); +} + +uint Hash3(uint3 v) +{ + return Hash_Combine(v.x, Hash2(v.yz)); +} + +uint Hash1Mutate(inout uint h) +{ + uint Res = h; + h = Hash1(h); + return Res; +} + diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMath.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMath.hlsl.meta new file mode 100644 index 0000000..15c617c --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HMath.hlsl.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: 9742473896537694a88a5b10866e1a9c +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Headers/HMath.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HSpaceTransforms.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HSpaceTransforms.hlsl new file mode 100644 index 0000000..cce234c --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HSpaceTransforms.hlsl @@ -0,0 +1,144 @@ +#pragma once + + + + +// --------------------------------- GET CAMERA POSITION +float3 H_GET_CAMERA_POSITION_WS() +{ + + + return _WorldSpaceCameraPos; +} + + +// --------------------------------- GET ABSOLUTE WS POSITION +float3 H_GET_ABSOLUTE_POSITION_WS(float3 PositionWS) +{ + + + return PositionWS; +} + + +// --------------------------------- GET RELATIVE WS POSITION +float3 H_GET_RELATIVE_POSITION_WS(float3 PositionWS) +{ + + + return GetCameraRelativePositionWS(PositionWS); +} + + +// --------------------------------- GET NORMALIZED WS VIEW DIRECTION +float3 H_GET_VIEW_DIRECTION_WS(float3 PositionWS) +{ + float3 ViewDirectionWS = H_GET_CAMERA_POSITION_WS() - H_GET_ABSOLUTE_POSITION_WS(PositionWS); + return normalize(ViewDirectionWS); +} + + +// --------------------------------- GET NORMALIZED WS VIEW VECTOR +float3 H_GET_VIEW_VECTOR_WS(float2 pixCoordNDC) +{ + float4 PositionVS = mul(H_MATRIX_I_P, float4(pixCoordNDC * 2.0 - 1.0, 1.0, 1.0)); + float3 DirectionVS = normalize(float3(PositionVS.x, -PositionVS.y, PositionVS.z)); + return normalize(mul((float3x3)H_MATRIX_I_V, DirectionVS)); +} + + +// --------------------------------- COMPUTE CLIP SPACE POSITION +float4 H_COMPUTE_POSITION_CS(float2 pixCoordNDC, float Depth) +{ + float4 PositionCS = float4(pixCoordNDC * 2.0 - 1.0, Depth, 1.0); + + #if UNITY_UV_STARTS_AT_TOP + PositionCS.y = -PositionCS.y; + #endif + + return PositionCS; +} + + +// --------------------------------- COMPUTE CLIP SPACE POSITION +float3 H_COMPUTE_NDC_Z(float3 Position, float4x4 InvViewProjMatrix) +{ + + return ComputeNormalizedDeviceCoordinatesWithZ(Position, InvViewProjMatrix); + +} + + +// --------------------------------- COMPUTE WORLD SPACE POSITION +float3 H_COMPUTE_POSITION_WS(float2 pixCoordNDC, float Depth, float4x4 InvViewProjMatrix) +{ + + return ComputeWorldSpacePosition(pixCoordNDC, Depth, InvViewProjMatrix); + +} + + +// --------------------------------- WORLD TO VIEW DIRECTION +float3 H_TRANSFORM_WORLD_TO_VIEW_DIR(float3 DirectionWS, bool Normalize = false) +{ + float3 DirectionVS = mul((float3x3)H_MATRIX_V, DirectionWS).xyz; + if (Normalize) return normalize(DirectionVS); + + return DirectionVS; +} + + +// --------------------------------- VIEW TO WORLD DIRECTION +float3 H_TRANSFORM_VIEW_TO_WORLD_DIR(float3 DirectionVS, bool Normalize = false) +{ + float3 DirectionWS = mul((float3x3)H_MATRIX_I_V, DirectionVS).xyz; + if (Normalize) return normalize(Normalize); + + return DirectionWS; +} + + +// --------------------------------- WORLD TO VIEW NOWMAL +float3 H_TRANSFORM_WORLD_TO_VIEW_NORMAL(float3 NormalWS, bool Normalize = false) +{ + + return TransformWorldToViewNormal(NormalWS); + +} + + + +// --------------------------------- VIEW TO WORLD NOWMAL +float3 H_TRANSFORM_VIEW_TO_WORLD_NORMAL(float3 NormalVS, bool Normalize = false) +{ + + return TransformViewToWorldNormal(NormalVS); + +} + + + +// --------------------------------- RAW TO 01 LINEAR DEPTH +float H_LINEAR_01_DEPTH(float Depth) +{ + + + return Linear01Depth(Depth, _ZBufferParams); +} + + +// --------------------------------- RAW TO EYE LINEAR DEPTH +float H_LINEAR_EYE_DEPTH(float3 PositionWS, float4x4 ViewMatrix) +{ + + + return LinearEyeDepth(PositionWS, ViewMatrix); +} + + +float H_LINEAR_EYE_DEPTH(float Depth) +{ + + + return LinearEyeDepth(Depth, _ZBufferParams); +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HSpaceTransforms.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HSpaceTransforms.hlsl.meta new file mode 100644 index 0000000..8032941 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Headers/HSpaceTransforms.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 60126f3b2f7939246ab1d0c0e26f670f +timeCreated: 1727882853 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Headers/HSpaceTransforms.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes.meta new file mode 100644 index 0000000..086a44d --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc41ad21f8ea07c458acca5c5c52c745 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HCommonSSGI.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HCommonSSGI.hlsl new file mode 100644 index 0000000..6cd7b48 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HCommonSSGI.hlsl @@ -0,0 +1,237 @@ +#include "../Headers/HMain.hlsl" +#include "../Headers/HMath.hlsl" +#include "../Headers/HSpaceTransforms.hlsl" + +#define ENABLE_RCRS_FILTER 1 +#define ENABLE_EXPOSURE_CONTROL 1 + +#define ENABLE_SPATIAL_RESTIR 1 +#define ENABLE_TEMPORAL_RESTIR 1 + +#define ENABLE_SPATIAL_DENOISING 1 +#define ENABLE_TEMPORAL_DENOISING 1 +#define ENABLE_TEMPORAL_STABILIZATION 1 + + +// ------------------------ COMMON PROPERTIES ------------------------- +float _HScaleFactorSSGI; +float _HPreviousScaleFactorSSGI; + +float _Falloff; +float4 _APVParams; +float4 _DepthToViewParams; + +uint _ExcludeCastingLayerMaskSSGI; +uint _ExcludeReceivingLayerMaskSSGI; + + +// ------------------------ SCALING FUNCTIONS ------------------------- +uint2 GetUnscaledCoords(uint2 pixCoord) +{ + return round(pixCoord.xy * _HScaleFactorSSGI.xx); +} + + +// ------------------------ SAMPLING FUNCTIONS ------------------------- +float ProbePlaneWeighting(float4 Plane, float3 WorldPosSample, float DepthLinearCenter, float Multiplier) +{ + float PlaneDistance = abs(dot(float4(WorldPosSample, -1), Plane)); + float DepthDifference = PlaneDistance / DepthLinearCenter; + float PlaneWeight = exp2(-100.0f * Multiplier * (DepthDifference * DepthDifference)); + return PlaneWeight; +} + +float3 ComputeFastViewSpacePosition(float2 pixCoordNDC, float Depth, float DepthLinear) +{ + #ifdef VR_COMPATIBILITY + return ComputeViewSpacePosition(pixCoordNDC, Depth, UNITY_MATRIX_I_P) * float3(1, -1, 1); + #endif + + float3 PositionVS = float3((pixCoordNDC * _DepthToViewParams.xy + _DepthToViewParams.zw) * DepthLinear.xx, DepthLinear); + return float3(PositionVS.x, PositionVS.y, -PositionVS.z); +} + +float ExponentialFalloff(float HitDistance, float MaxDistance) +{ + float Falloff = 0; + + float Threshold = 0.35 * MaxDistance; + if (HitDistance <= Threshold) + Falloff = 1.0; + + float NormalizedDistance = saturate((HitDistance - Threshold) / (MaxDistance - Threshold)); + Falloff = exp2(-(_Falloff * 3) * NormalizedDistance); + + return Falloff; +} + +float RadicalInverseVdC(uint bits) +{ + bits = (bits << 16) | (bits >> 16); + bits = ((bits & 0x55555555) << 1) | ((bits & 0xAAAAAAAA) >> 1); + bits = ((bits & 0x33333333) << 2) | ((bits & 0xCCCCCCCC) >> 2); + bits = ((bits & 0x0F0F0F0F) << 4) | ((bits & 0xF0F0F0F0) >> 4); + bits = ((bits & 0x00FF00FF) << 8) | ((bits & 0xFF00FF00) >> 8); + return float(bits) * 2.3283064365386963e-10; +} + +float2 SampleUnitDisk(uint Index) +{ + float Angle = RadicalInverseVdC(Index) * 2.0 * H_PI; + float Radius = sqrt(frac(float(Index) * 0.61803398875)); // Golden ratio for decorrelation + return float2(cos(Angle), sin(Angle)) * Radius; +} + +inline float Jitter(float2 Coord) +{ + float a = 12.9898; + float b = 78.233; + float c = 43758.5453; + float dt = dot(Coord.xy, float2(a, b)); + float sn = fmod(dt, 3.14); + return frac(sin(sn) * c); +} + +float sqr(float value) +{ + return value * value; +} + +float GaussianWeighting(float Radius, float Sigma) +{ + return exp2(-sqr(Radius / Sigma)); +} + +float3 SpatialDenoisingTonemap(float3 Color) +{ + return Color * rcp(max(max(Color.r, Color.g), Color.b) + 1.0); +} + +float3 SpatialDenoisingTonemapInverse(float3 Color) +{ + return Color * rcp(1.0 - max(max(Color.r, Color.g), Color.b)); +} + +// ------------------------ Color.hlsl in HDRP ------------------------- + +float HInterleavedGradientNoise(float2 pixCoord, int frameCount) +{ + const float3 magic = float3(0.06711056f, 0.00583715f, 52.9829189f); + float2 frameMagicScale = float2(2.083f, 4.867f); + pixCoord += frameCount * frameMagicScale; + return frac(magic.z * frac(dot(pixCoord, magic.xy))); +} + +// ------------------------ PACKING FUNCTIONS ------------------------- + +uint PackDirection32Bit(float3 Direction) +{ + float2 DirectionOctahedral = PackNormalOctQuadEncode(Direction); + DirectionOctahedral = DirectionOctahedral * 0.5f + 0.5f; + + uint DirectionX = uint(DirectionOctahedral.x * 65534.0f + 0.5f); + uint DirectionY = uint(DirectionOctahedral.y * 65534.0f + 0.5f); + return (DirectionX << 16) | (DirectionY << 0); +} + +float3 UnpackDirection32Bit(uint PackedDirection) +{ + float3 Direction; + Direction.x = float((PackedDirection >> 16) & 0xFFFF) / 65534.0f; + Direction.y = float((PackedDirection >> 0) & 0xFFFF) / 65534.0f; + Direction = UnpackNormalOctQuadEncode(Direction.xy * 2.0f - 1.0f); + return Direction; +} + +uint PackDirection24Bit(float3 Direction) +{ + float2 DirectionOctahedral = PackNormalOctQuadEncode(Direction); + DirectionOctahedral = DirectionOctahedral * 0.5f + 0.5f; + + uint DirectionX = uint(DirectionOctahedral.x * 4095.0f + 0.5f); + uint DirectionY = uint(DirectionOctahedral.y * 4095.0f + 0.5f); + return (DirectionX << 12) | (DirectionY << 0); +} + +float3 UnpackDirection24Bit(uint PackedDirection) +{ + float3 Direction; + Direction.x = float((PackedDirection >> 12) & 0xFFF) / 4095.0f; + Direction.y = float((PackedDirection >> 0) & 0xFFF) / 4095.0f; + Direction = UnpackNormalOctQuadEncode(Direction.xy * 2.0f - 1.0f); + return Direction; +} + +uint PackDirection16Bit(float3 Direction) +{ + float2 DirectionOctahedral = PackNormalOctQuadEncode(Direction); + DirectionOctahedral = DirectionOctahedral * 0.5f + 0.5f; + + uint DirectionX = uint(DirectionOctahedral.x * 255.0f + 0.5f); + uint DirectionY = uint(DirectionOctahedral.y * 255.0f + 0.5f); + return (DirectionX << 8) | (DirectionY << 0); +} + +float3 UnpackDirection16Bit(uint PackedDirection) +{ + float3 Direction; + Direction.x = float((PackedDirection >> 8) & 0xFF) / 255.0f; + Direction.y = float((PackedDirection >> 0) & 0xFF) / 255.0f; + Direction = UnpackNormalOctQuadEncode(Direction.xy * 2.0f - 1.0f); + return Direction; +} + +uint PackAmbientOcclusion(float AmbientOcclusion) +{ + uint AmbientOcclusionPacked = AmbientOcclusion * 255.0f + 0.5f; + return AmbientOcclusionPacked; +} + +float UnpackAmbientOcclusion(uint AmbientOcclusionPacked) +{ + float AmbientOcclusion = float(AmbientOcclusionPacked) / 255.0f; + return AmbientOcclusion; +} + +uint PackColorHit(float3 Color, bool Hit) +{ + uint R = (f32tof16(Color.r) << 17) & 0xFFE00000; + uint G = (f32tof16(Color.g) << 6) & 0x001FF800; + uint B = (f32tof16(Color.b) >> 4) & 0x000007FE; + uint A = Hit ? 0x00000001 : 0x00000000; + return R | G | B | A; +} + +float3 UnpackColorHit(uint ColorHitPacked, inout bool Hit) +{ + float3 Color; + Color.r = f16tof32((ColorHitPacked >> 17) & 0x7FF0); + Color.g = f16tof32((ColorHitPacked >> 6) & 0x7FF0); + Color.b = f16tof32((ColorHitPacked << 4) & 0x7FE0); + Hit = (ColorHitPacked & 0x00000001) == 0x00000001 ? true : false; + return Color; +} + +uint PackNormalDepth(float3 Normal, float Depth) +{ + float2 NormalOctahedral = PackNormalOctQuadEncode(Normal); + NormalOctahedral = NormalOctahedral * 0.5f + 0.5f; + uint NormalX = uint(NormalOctahedral.x * 255.0f + 0.5f); + uint NormalY = uint(NormalOctahedral.y * 255.0f + 0.5f); + + uint DepthPacked = f32tof16(Depth); + return (DepthPacked << 16) | (NormalX << 8) | (NormalY << 0); +} + +float4 UnpackNormalDepth(uint NormalDepthPacked) +{ + float2 Normal; + float4 NormalDepth; + Normal.x = float((NormalDepthPacked >> 8) & 0xFF) / 255.0f; + Normal.y = float((NormalDepthPacked >> 0) & 0xFF) / 255.0f; + NormalDepth.xyz = UnpackNormalOctQuadEncode(Normal * 2.0f - 1.0f); + + NormalDepth.w = f16tof32(NormalDepthPacked >> 16); + + return NormalDepth.xyzw; +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HCommonSSGI.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HCommonSSGI.hlsl.meta new file mode 100644 index 0000000..9e4a2a3 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HCommonSSGI.hlsl.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: da57d648cbc5caf44837dabea199a907 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Includes/HCommonSSGI.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HFallbackSSGI.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HFallbackSSGI.hlsl new file mode 100644 index 0000000..d308fe5 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HFallbackSSGI.hlsl @@ -0,0 +1,66 @@ +//pipelinedefine +#define H_URP + + +#if UNITY_VERSION >= 600000 +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/AmbientProbe.hlsl" +#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl" + +float3 EvaluateFallbackSky(float3 Direction) +{ + unity_SHAr = H_SHAr; + unity_SHAg = H_SHAg; + unity_SHAb = H_SHAb; + unity_SHBr = H_SHBr; + unity_SHBg = H_SHBg; + unity_SHBb = H_SHBb; + unity_SHC = H_SHC; + + return EvaluateAmbientProbe(Direction); +} + +float3 EvaluateFallbackAPV(float4 APVParams, float3 PositionWS, float3 NormalWS, float3 ViewDirection, float2 pixCoord) +{ + float3 BakedAPV = 0; + float3 Unused = 0; + + _APVSamplingNoise = APVParams.z; + PositionWS = AddNoiseToSamplingPosition(PositionWS, pixCoord, ViewDirection); + PositionWS = (PositionWS + NormalWS * APVParams.x) + ViewDirection * APVParams.y; + + unity_SHAr = H_SHAr; + unity_SHAg = H_SHAg; + unity_SHAb = H_SHAb; + unity_SHBr = H_SHBr; + unity_SHBg = H_SHBg; + unity_SHBb = H_SHBb; + unity_SHC = H_SHC; + + EvaluateAdaptiveProbeVolume(PositionWS, NormalWS, -NormalWS, ViewDirection, pixCoord, BakedAPV, Unused); + + #ifdef FALLBACK_STAGE + BakedAPV *= APVParams.w; + #endif + + return BakedAPV; +} +#else +#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBlendStates.hlsl" +#include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolume.hlsl" + +float3 EvaluateFallbackAPV(float4 APVParams, float3 PositionWS, float3 NormalWS, float3 ViewDirection, int2 pixCoord) +{ + return 0; +} + +float3 EvaluateFallbackSky(float3 Direction) +{ + float3 Sky = SHEvalLinearL0L1(Direction, H_SHAr, H_SHAg, H_SHAb); + Sky += SHEvalLinearL2(Direction, H_SHBr, H_SHBg, H_SHBb, H_SHC); + + return max(Sky, 0); +} +#endif + + + diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HFallbackSSGI.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HFallbackSSGI.hlsl.meta new file mode 100644 index 0000000..29b00bf --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HFallbackSSGI.hlsl.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: ad1d271555f9ba343b68747597d2cae6 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Includes/HFallbackSSGI.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HRayMarchingSSGI.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HRayMarchingSSGI.hlsl new file mode 100644 index 0000000..4218b74 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HRayMarchingSSGI.hlsl @@ -0,0 +1,195 @@ +#ifdef FULL_RESOLUTION_DEPTH +#define MAX_DEPTH_MIP_LEVEL 0 +#else +#define MAX_DEPTH_MIP_LEVEL 1 +#endif + +#include "HReservoirSSGI.hlsl" + +uint _StepCount; +float _RayLength; +float _BackfaceLighting; +float4 _ThicknessParams; + +H_TEXTURE(_Color); + + +float GetRayOriginAndDirectionNDC(float MaxLength, float Depth, float2 pixCoordNDC, float3 PositionWS, float3 RayDirectionWS, float3 NormalWS, inout float3 RayOriginBiasedWS, inout float3 RayStartPositionNDC, inout float3 RayEndPositionNDC) +{ + // Bias ray origin in world space + { + RayOriginBiasedWS = PositionWS; + float3 NormalForBias = dot(NormalWS, RayDirectionWS) < 0 ? -NormalWS : NormalWS; + + // Calculate normal bias + float2 CornerCoordNDC = pixCoordNDC + 0.5f * _ScreenSize.zw; + float3 CornerPositionWS = H_COMPUTE_POSITION_WS(CornerCoordNDC.xy, Depth, H_MATRIX_I_VP); + float NormalBias = abs(dot(CornerPositionWS - PositionWS, NormalForBias)) * 2.0f; + + // This can push the ray origin off-screen causing black pixels on the border + RayOriginBiasedWS += NormalForBias * max(NormalBias, 0.01f) + RayDirectionWS * 0.01f; + } + + // Calculate ray start position in screen space + RayStartPositionNDC = H_COMPUTE_NDC_Z(RayOriginBiasedWS, H_MATRIX_VP).xyz; + + // Calculate ray end clipped position in screen space + { + // Calculate clipped ray distance in world space + float MaxRayDistanceWS = MaxLength; + + float3 RayDirectionVS = H_TRANSFORM_WORLD_TO_VIEW_DIR(-RayDirectionWS, true); + float SceneDepth = H_LINEAR_EYE_DEPTH(RayOriginBiasedWS, H_MATRIX_V); + float RayClippedDistanceWS = RayDirectionVS.z < 0.0 ? min(-0.99f * SceneDepth / RayDirectionVS.z, MaxRayDistanceWS) : MaxRayDistanceWS; + + // Calculate ray end position in screen space + RayEndPositionNDC.xyz = H_COMPUTE_NDC_Z(RayOriginBiasedWS + RayDirectionWS * RayClippedDistanceWS, H_MATRIX_VP).xyz; + + // Recalculate ray end position where it leaves the screen + float2 ScreenEdgeIntersections = HLineBoxIntersect(RayStartPositionNDC, RayEndPositionNDC, 0, 1); + RayEndPositionNDC = RayStartPositionNDC + (RayEndPositionNDC - RayStartPositionNDC) * ScreenEdgeIntersections.y; + + return ScreenEdgeIntersections.y; + } +} + +float2 GetWorkingDepth(float SurfaceDepth, float RayDepth) +{ + #ifdef LINEAR_THICKNESS + return float2(SurfaceDepth, RayDepth); + #else + return float2(H_LINEAR_EYE_DEPTH(SurfaceDepth), H_LINEAR_EYE_DEPTH(RayDepth)); + #endif +} + +bool WorkingDepthCompare(float SurfaceDepth, float RayDepth, float2 ThicknessParams) +{ + #ifdef LINEAR_THICKNESS + return RayDepth > SurfaceDepth * ThicknessParams.x + ThicknessParams.y; + #else + return RayDepth < SurfaceDepth * ThicknessParams.x + ThicknessParams.y; + #endif +} + + +float4 RayMarch(float3 RayStartPositionNDC, float3 RayEndPositionNDC, float StepJitter) +{ + int StepCount = _StepCount; + + bool HitFound = false; + bool SkyPassed = false; + + float3 HitCoordNDC = 0; + float3 PreviousPositionNDC = RayStartPositionNDC; + + for (int i = 0; i < StepCount; i++) + { + float3 SamplePositionNDC = lerp(RayStartPositionNDC, RayEndPositionNDC, pow(float(min(float(StepCount), i + StepJitter * 1)) / float(StepCount), 2)); + + uint DepthLOD = lerp(MAX_DEPTH_MIP_LEVEL, 4, (float(i)) / StepCount); + float SurfaceDepth = H_SAMPLE_LOD(g_HTraceDepthPyramidSSGI, H_SAMPLER_POINT_CLAMP, SamplePositionNDC.xy * HRenderScale.xy, DepthLOD).x; + + if (SurfaceDepth <= 0) + { + SkyPassed = true; + } + + if (SamplePositionNDC.z < SurfaceDepth) + { + float2 WorkingDepth = GetWorkingDepth(SurfaceDepth, SamplePositionNDC.z); + + if (WorkingDepthCompare(WorkingDepth.x, WorkingDepth.y, _ThicknessParams.xy)) + { + HitCoordNDC = SamplePositionNDC.xyz; + HitFound = true; + break; + } + if (REFINE_INTERSECTION && WorkingDepthCompare(WorkingDepth.x, WorkingDepth.y, _ThicknessParams.zw)) + { + float3 MiddlePositionNDC = lerp(SamplePositionNDC, PreviousPositionNDC, 0.25f); + float MiddleSurfaceDepth = H_SAMPLE_LOD(g_HTraceDepthPyramidSSGI, H_SAMPLER_POINT_CLAMP, MiddlePositionNDC.xy * HRenderScale.xy, DepthLOD).x; + float2 MiddleWorkingDepth = GetWorkingDepth(MiddleSurfaceDepth, MiddlePositionNDC.z); + + if (WorkingDepthCompare(MiddleWorkingDepth.x, MiddleWorkingDepth.y, _ThicknessParams.xy)) // && SurfaceDepth > 0) + { + HitCoordNDC = MiddlePositionNDC.xyz; + HitFound = true; + break; + } + } + } + + PreviousPositionNDC = SamplePositionNDC; + } + + HitCoordNDC = SkyPassed ? PreviousPositionNDC : HitCoordNDC; + + return float4(HitCoordNDC.xyz, HitFound); +} + + +float4 RayMarchHalf(float3 RayStartPositionNDC, float3 RayEndPositionNDC, float StepJitter) +{ + int StepCount = _StepCount / 2; + uint FirstStep = _FrameCount % 2; + + bool HitFound = false; + bool SkyPassed = false; + + float3 HitCoordNDC = 0; + float3 PreviousPositionNDC = RayStartPositionNDC; + + for (int i = FirstStep; i < StepCount; i = i + 2) + { + float3 SamplePositionNDC = lerp(RayStartPositionNDC, RayEndPositionNDC, pow(float(min(StepCount, i + StepJitter * 1)) / StepCount, 2)); + + uint DepthLOD = lerp(MAX_DEPTH_MIP_LEVEL, 4, (float(i)) / StepCount); + float SurfaceDepth = H_SAMPLE_LOD(g_HTraceDepthPyramidSSGI, H_SAMPLER_POINT_CLAMP, SamplePositionNDC.xy * HRenderScale.xy, DepthLOD).x; + + if (SurfaceDepth <= 0) + { + SkyPassed = true; + } + + if (SamplePositionNDC.z < SurfaceDepth) + { + float2 WorkingDepth = GetWorkingDepth(SurfaceDepth, SamplePositionNDC.z); + + if (WorkingDepthCompare(WorkingDepth.x, WorkingDepth.y, _ThicknessParams.xy)) + { + HitCoordNDC = SamplePositionNDC.xyz; + HitFound = true; + break; + } + else if (REFINE_INTERSECTION && WorkingDepthCompare(WorkingDepth.x, WorkingDepth.y, _ThicknessParams.zw)) + { + float3 MiddlePositionNDC = lerp(SamplePositionNDC, PreviousPositionNDC, 0.25f); + float MiddleSurfaceDepth = H_SAMPLE_LOD(g_HTraceDepthPyramidSSGI, H_SAMPLER_POINT_CLAMP, MiddlePositionNDC.xy * HRenderScale.xy, DepthLOD).x; + float2 MiddleWorkingDepth = GetWorkingDepth(MiddleSurfaceDepth, MiddlePositionNDC.z); + + if (WorkingDepthCompare(MiddleWorkingDepth.x, MiddleWorkingDepth.y, _ThicknessParams.xy)) + { + HitCoordNDC = MiddlePositionNDC.xyz; + HitFound = true; + break; + } + } + } + + PreviousPositionNDC = SamplePositionNDC; + } + + HitCoordNDC = SkyPassed ? PreviousPositionNDC : HitCoordNDC; + + return float4(HitCoordNDC.xyz, HitFound); +} + + +float4 RayMarchValidation(float3 RayStartPositionNDC, float3 RayEndPositionNDC, float StepJitter) +{ + #ifdef HALF_STEP_VALIDATION + return RayMarchHalf(RayStartPositionNDC, RayEndPositionNDC, StepJitter); + #else + return RayMarch(RayStartPositionNDC, RayEndPositionNDC, StepJitter); + #endif +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HRayMarchingSSGI.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HRayMarchingSSGI.hlsl.meta new file mode 100644 index 0000000..68e2a49 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HRayMarchingSSGI.hlsl.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: d70f0a4fb67872c4eb21e7facb552b46 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Includes/HRayMarchingSSGI.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HReservoirSSGI.hlsl b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HReservoirSSGI.hlsl new file mode 100644 index 0000000..7ca0149 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HReservoirSSGI.hlsl @@ -0,0 +1,242 @@ +#include "HCommonSSGI.hlsl" + +H_TEXTURE(_Reservoir); +H_TEXTURE(_ReservoirReprojected); +H_TEXTURE(_ReservoirLuminance); + +H_RW_TEXTURE(uint4, _Reservoir_Output); +H_RW_TEXTURE(uint4, _ReservoirSpatial_Output); +H_RW_TEXTURE(uint4, _ReservoirTemporal_Output); +H_RW_TEXTURE(float, _ReservoirLuminance_Output); + +float _ReservoirDiffuseWeight; + +// ------------------------ RESERVOIR STRUCTS ----------------------- +struct OcclusionReservoir +{ + // Main + float Occlusion; + float Wsum; + float M; + float W; + + // Ray + float3 Direction; + float Distance; +}; + +struct TemporalReservoir +{ + // Main + float3 Color; + float Wsum; + float M; + float W; + + // Origin + float3 OriginNormal; + + // Ray + float3 Direction; + float Distance; + bool HitFound; +}; + +struct SpatialReservoir +{ + // Main + float3 Color; + float Wsum; + float M; + float W; + + // Denoiser + float3 Normal; + float Depth; + float Occlusion; + + // Ray + float3 Direction; + float Distance; + bool HitFound; +}; + + +// ------------------------ PACKING FUNCTIONS ----------------------- + +uint4 PackTemporalReservoir(TemporalReservoir Reservoir) +{ + uint W = f32tof16(Reservoir.W); + uint M = f32tof16(Reservoir.M); + uint PackedMW = (W << 16) | (M & 0xFFFE) | (Reservoir.HitFound & 0x1); + uint PackedColorHit = PackToR11G11B10f(Reservoir.Color); // PackColorHit(Reservoir.Color, Reservoir.HitFound); + uint PackedDistance = f32tof16(Reservoir.Distance); // uint(Reservoir.Distance * 65534.0f + 0.5f); + uint PackedDirection = PackDirection32Bit(Reservoir.Direction); + uint PackedOriginaNormal = PackDirection16Bit(Reservoir.OriginNormal); + uint PackedNormalDistance = (PackedDistance << 16) | (PackedOriginaNormal << 0); + + return uint4(PackedColorHit, PackedMW, PackedDirection, PackedNormalDistance); +} + +void UnpackTemporalReservoir(uint4 ReservoirPacked, float3 Diffuse, inout TemporalReservoir Reservoir) +{ + Reservoir.HitFound = ReservoirPacked.y & 0x1; + Reservoir.Color = UnpackFromR11G11B10f(ReservoirPacked.x); // UnpackColorHit(ReservoirPacked.x, Reservoir.HitFound); + Reservoir.W = f16tof32(ReservoirPacked.y >> 16); + Reservoir.M = f16tof32(ReservoirPacked.y & 0xFFFE); + Reservoir.Wsum = Reservoir.W * Reservoir.M * Luminance(Reservoir.Color * Diffuse); + Reservoir.Distance = f16tof32(ReservoirPacked.w >> 16); + Reservoir.Direction = UnpackDirection32Bit(ReservoirPacked.z); + Reservoir.OriginNormal = UnpackDirection16Bit(ReservoirPacked.w); +} + +uint4 PackSpatialReservoir(SpatialReservoir Reservoir) +{ + uint W = f32tof16(Reservoir.W); + uint M = f32tof16(Reservoir.M); + uint PackedMW = (W << 16) | (M & 0xFFFE) | (Reservoir.HitFound & 0x1); + uint PackedColor = PackToR11G11B10f(Reservoir.Color); + uint PackedDistance = (uint(f32tof16(Reservoir.Distance)) >> 6) & 0x3FF; + uint PackedDirection = PackDirection16Bit(Reservoir.Direction) & 0xFFFF; + uint PackedOcclusion = uint(Reservoir.Occlusion * 63.0f + 0.5f) & 0x3F; + uint PackedDirectionDistanceOcclusion = (PackedDirection << 16) | (PackedOcclusion << 10) | (PackedDistance << 0); + uint DepthPacked = f32tof16(Reservoir.Depth) & 0xFFFF; + uint NormalPacked = PackDirection16Bit(Reservoir.Normal) & 0xFFFF; + uint NormalDepthPacked = (NormalPacked << 16) | (DepthPacked << 0); + + return uint4(PackedColor, PackedMW, PackedDirectionDistanceOcclusion, NormalDepthPacked); +} + +void UnpackSpatialReservoir(uint4 ReservoirPacked, float3 Diffuse, inout SpatialReservoir Reservoir) +{ + Reservoir.HitFound = ReservoirPacked.y & 0x1; + Reservoir.Color = UnpackFromR11G11B10f(ReservoirPacked.x); + Reservoir.W = f16tof32(ReservoirPacked.y >> 16); + Reservoir.M = f16tof32(ReservoirPacked.y >> 0); + Reservoir.Wsum = Reservoir.W * Reservoir.M * Luminance(Reservoir.Color * Diffuse); + Reservoir.Distance = f16tof32((ReservoirPacked.z & 0x3FF) << 6); + Reservoir.Occlusion = float((ReservoirPacked.z >> 10) & 0x3F) / 63; + Reservoir.Direction = UnpackDirection16Bit((ReservoirPacked.z >> 16) & 0xFFFF); + Reservoir.Normal = UnpackDirection16Bit((ReservoirPacked.w >> 16) & 0xFFFF); + Reservoir.Depth = f16tof32(ReservoirPacked.w & 0xFFFF); +} + + +// ------------------------ RESERVOIR FUNCTIONS ----------------------- +float3 GetReservoirDiffuse(uint2 pixCoord) +{ + float3 DiffuseBuffer = HBUFFER_DIFFUSE(pixCoord).xyz * _ReservoirDiffuseWeight; + + if (DiffuseBuffer.x + DiffuseBuffer.y + DiffuseBuffer.z <= 0.05f) + DiffuseBuffer = float3(0.05f, 0.05f, 0.05f); + + return DiffuseBuffer; +} + +// Spatial reservoir exchange +bool ReservoirUpdate(SpatialReservoir SampleReservoir, inout SpatialReservoir MainReservoir, inout uint Random) +{ + float RandomValue = HUintToFloat01(Hash1Mutate(Random)); + + MainReservoir.Wsum += SampleReservoir.Wsum; + MainReservoir.M += SampleReservoir.M; + + if (RandomValue < SampleReservoir.Wsum / MainReservoir.Wsum) + { + MainReservoir.Color = SampleReservoir.Color; + MainReservoir.HitFound = SampleReservoir.HitFound; + MainReservoir.Distance = SampleReservoir.Distance; + MainReservoir.Direction = SampleReservoir.Direction; + + return true; + } + + return false; +} + +// Temporal reservoir exchange +bool ReservoirUpdate(TemporalReservoir SampleReservoir, inout TemporalReservoir MainReservoir, inout uint Random) +{ + float RandomValue = HUintToFloat01(Hash1Mutate(Random)); + + MainReservoir.Wsum += SampleReservoir.Wsum; + MainReservoir.M += SampleReservoir.M; + + if (RandomValue < SampleReservoir.Wsum / MainReservoir.Wsum) + { + MainReservoir.Color = SampleReservoir.Color; + MainReservoir.HitFound = SampleReservoir.HitFound; + MainReservoir.Distance = SampleReservoir.Distance; + MainReservoir.Direction = SampleReservoir.Direction; + MainReservoir.OriginNormal = SampleReservoir.OriginNormal; + + return true; + } + + return false; +} + + +// Radiance reservoir fill +bool ReservoirUpdate(float3 SampleColor, float3 SampleNormal, bool HitFound, float SampleW, float SampleM, inout TemporalReservoir Reservoir, inout uint Random) +{ + float RandomValue = HUintToFloat01(Hash1Mutate(Random)); + + Reservoir.Wsum += SampleW; + Reservoir.M += SampleM; + + if (RandomValue < SampleW / Reservoir.Wsum) + { + Reservoir.Color = SampleColor; + Reservoir.HitFound = HitFound; + Reservoir.OriginNormal = SampleNormal; + + return true; + } + + return false; +} + + +// Radiance reservoir fill +bool ReservoirUpdate(float3 SampleColor, float3 SampleDirection, float3 SampleNormal, float SampleDistance, bool HitFound, float SampleW, float SampleM, inout TemporalReservoir Reservoir, inout uint Random) +{ + float RandomValue = HUintToFloat01(Hash1Mutate(Random)); + + Reservoir.Wsum += SampleW; + Reservoir.M += SampleM; + + if (RandomValue < SampleW / Reservoir.Wsum) + { + Reservoir.Color = SampleColor; + Reservoir.HitFound = HitFound; + Reservoir.Distance = SampleDistance; + Reservoir.Direction = SampleDirection; + Reservoir.OriginNormal = SampleNormal; + + return true; + } + + return false; +} + + +// Occlusion reservoir fill +bool ReservoirUpdate(float SampleOcclusion, float3 SampleDirection, float SampleDistance, float SampleW, float SampleM, inout OcclusionReservoir Reservoir, inout uint Random) +{ + float RandomValue = HUintToFloat01(Hash1Mutate(Random)); + + Reservoir.Wsum += SampleW; + Reservoir.M += SampleM; + + if (RandomValue < SampleW / Reservoir.Wsum) + { + Reservoir.Distance = SampleDistance; + Reservoir.Direction = SampleDirection; + Reservoir.Occlusion = SampleOcclusion; + + return true; + } + + return false; +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HReservoirSSGI.hlsl.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HReservoirSSGI.hlsl.meta new file mode 100644 index 0000000..8b75a45 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Includes/HReservoirSSGI.hlsl.meta @@ -0,0 +1,14 @@ +fileFormatVersion: 2 +guid: d85ff336dd0f7d34c938a3c1920ae46a +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Includes/HReservoirSSGI.hlsl + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders.meta new file mode 100644 index 0000000..0b72dc7 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 34ae425a90532074bae6cd5dbd2aafe5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP.meta new file mode 100644 index 0000000..95a637d --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e08fec73177458e4186aa8fdc8e7961d +timeCreated: 1730137400 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/ColorComposeURP.shader b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/ColorComposeURP.shader new file mode 100644 index 0000000..8856a8e --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/ColorComposeURP.shader @@ -0,0 +1,210 @@ +Shader "Hidden/HTraceSSGI/ColorComposeURP" +{ + SubShader + { + HLSLINCLUDE + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" + + struct Attributes + { + uint VertexID : SV_VertexID; + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + + struct Varyings + { + float4 PositionCS : POSITION; + float2 TexCoord : TEXCOORD0; + UNITY_VERTEX_OUTPUT_STEREO + }; + + Varyings SharedVertexStage(Attributes input) + { + Varyings output; + UNITY_SETUP_INSTANCE_ID(input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + output.PositionCS = GetFullScreenTriangleVertexPosition(input.VertexID); + output.TexCoord = GetFullScreenTriangleTexCoord(input.VertexID); + + return output; + } + + ENDHLSL + + Pass + { + Name "Copy Color Buffer" + + Cull Off + ZWrite Off + + HLSLPROGRAM + + #pragma vertex SharedVertexStage + #pragma fragment FragmentStage + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl" + #include "../../Headers/HMain.hlsl" + + float4 FragmentStage(Varyings input) : SV_Target + { + return float4(HBUFFER_COLOR(input.TexCoord * _ScreenSize.xy).xyz, 1); + } + + ENDHLSL + } + + Pass + { + Name "Override Indirect Lighting" + + Cull Off + ZWrite Off + + // Doesn't seem to work for the R16G16A16B16 Color Buffer + // Blend One One + // BlendOp RevSub + + HLSLPROGRAM + + #pragma vertex SharedVertexStage + #pragma fragment FragmentStage + + #pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _ _GBUFFER_NORMALS_OCT + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + #include "../../Headers/HMain.hlsl" + #include "../../Headers/HSpaceTransforms.hlsl" + #include "../../Includes/HFallbackSSGI.hlsl" + + H_TEXTURE(_ColorCopy); + + #define kMaterialFlagSpecularSetup 8 + uint UnpackMaterialFlags(float packedMaterialFlags) + { return uint((packedMaterialFlags * 255.0h) + 0.5h); } + + float4 FragmentStage(Varyings input) : SV_Target + { + uint2 pixCoord = input.TexCoord * _ScreenSize.xy; + float3 ColorCopy = H_LOAD(_ColorCopy, pixCoord).xyz; + + float DepthCenter = HBUFFER_DEPTH(pixCoord); + float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoord); + float3 PositionCenterWS = H_COMPUTE_POSITION_WS(input.TexCoord, DepthCenter, H_MATRIX_I_VP); + + float4 GBuffer0 = H_LOAD(g_HTraceGBuffer0, pixCoord); + float4 Gbuffer1 = H_LOAD(g_HTraceGBuffer1, pixCoord); + + float3 IndirectLighting = 0; + float Metallic = Gbuffer1.r; + + // This seems to make everything worse. + // if ((UnpackMaterialFlags(GBuffer0.a) & kMaterialFlagSpecularSetup) != 0) + // Metallic = (ReflectivitySpecular(Gbuffer1.rgb)); + +#if UNITY_VERSION >= 600000 + if (_EnableProbeVolumes) + { + if (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2) + { IndirectLighting = EvaluateFallbackAPV(float4(0,0,0,0), PositionCenterWS, NormalCenterWS, H_GET_VIEW_DIRECTION_WS(PositionCenterWS), pixCoord); } + } + else +#endif + { IndirectLighting = EvaluateFallbackSky(NormalCenterWS); } + + // This works reliably only with Render Graph, so we'll use Unity's _ScreenSpaceOcclusionTexture texture directly here + // float SSAO = H_SAMPLE(g_HTraceSSAO, H_SAMPLER_POINT_CLAMP, input.TexCoord); + float SSAO = _AmbientOcclusionParam.x == 0 ? 1 : H_SAMPLE(_ScreenSpaceOcclusionTexture, H_SAMPLER_POINT_CLAMP, input.TexCoord).x; + float AmbientOcclusion = min(SSAO, Gbuffer1.a); + + IndirectLighting = IndirectLighting * GBuffer0.rgb * (1.0 - Metallic) * AmbientOcclusion; + + return float4(max(ColorCopy - IndirectLighting, 0), 1); + } + + ENDHLSL + } + + Pass + { + Name "Final Output" + + Cull Off + ZWrite Off + Blend One One + + HLSLPROGRAM + + #pragma vertex SharedVertexStage + #pragma fragment FragmentStage + + #pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 + #pragma multi_compile _ _GBUFFER_NORMALS_OCT + #pragma multi_compile _ USE_RECEIVE_LAYER_MASK + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" + + #include "../../Headers/HMain.hlsl" + #include "../../Headers/HSpaceTransforms.hlsl" + #include "../../Includes/HFallbackSSGI.hlsl" + + H_TEXTURE(_HTraceBufferGI); + + uint _MetallicIndirectFallback; + uint _ExcludeReceivingLayerMaskSSGI; + float _IndirectLightingIntensity; + float4 _APVParams; + + float4 FragmentStage(Varyings input) : SV_Target + { + uint2 pixCoord = input.TexCoord * _ScreenSize.xy; + + if (HBUFFER_DEPTH(pixCoord) <= 1e-7) return 0; + + float3 IndirectLighting = H_LOAD(_HTraceBufferGI, pixCoord).xyz; + +#if UNITY_VERSION >= 600000 + // Restore indirect lighting on masked out objects + if (USE_RECEIVE_LAYER_MASK) + { + if (HBUFFER_RENDER_LAYER_MASK(input.TexCoord * _ScreenSize.xy) & _ExcludeReceivingLayerMaskSSGI) + { + float3 NormalCenterWS = HBUFFER_NORMAL_WS(pixCoord); + if (_EnableProbeVolumes) + { + float DepthCenter = HBUFFER_DEPTH(pixCoord); + float3 PositionCenterWS = H_COMPUTE_POSITION_WS(input.TexCoord, DepthCenter, H_MATRIX_I_VP); + + if (PROBE_VOLUMES_L1 || PROBE_VOLUMES_L2) + { IndirectLighting = EvaluateFallbackAPV(_APVParams, PositionCenterWS, NormalCenterWS, H_GET_VIEW_DIRECTION_WS(PositionCenterWS), pixCoord); } + } + else + IndirectLighting = EvaluateFallbackSky(NormalCenterWS); + } + } +#endif + float4 GBuffer0 = H_LOAD(g_HTraceGBuffer0, pixCoord); + float4 Gbuffer1 = H_LOAD(g_HTraceGBuffer1, pixCoord); + + // This works reliably only with Render Graph, so we'll use Unity's _ScreenSpaceOcclusionTexture texture directly here + // float SSAO = H_SAMPLE(g_HTraceSSAO, H_SAMPLER_POINT_CLAMP, input.TexCoord); + float SSAO = _AmbientOcclusionParam.x == 0 ? 1 : H_SAMPLE(_ScreenSpaceOcclusionTexture, H_SAMPLER_POINT_CLAMP, input.TexCoord).x; + float AmbientOcclusion = min(SSAO, Gbuffer1.a); + + float Metallic = _MetallicIndirectFallback ? 0 : MetallicFromReflectivity(ReflectivitySpecular(Gbuffer1.rgb)); + + float3 FinalIndirectLighting = IndirectLighting * _IndirectLightingIntensity * GBuffer0.rgb * (1 - Metallic) * AmbientOcclusion; + + return float4(FinalIndirectLighting, 1); + } + + ENDHLSL + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/ColorComposeURP.shader.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/ColorComposeURP.shader.meta new file mode 100644 index 0000000..e09e725 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/ColorComposeURP.shader.meta @@ -0,0 +1,16 @@ +fileFormatVersion: 2 +guid: 2a65a40305a962f458eb23b936f45b2c +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/ColorComposeURP.shader + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/MotionVectorsURP.shader b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/MotionVectorsURP.shader new file mode 100644 index 0000000..bc0bd3a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/MotionVectorsURP.shader @@ -0,0 +1,231 @@ +Shader "Hidden/HTraceSSGI/MotionVectorsURP" +{ + SubShader + { + Pass + { + Name "Camera Motion Vectors" + + Cull Off + ZWrite Off + + HLSLPROGRAM + + #pragma vertex VertexStage + #pragma fragment FragmentStage + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRendering.hlsl" + #include "../../Headers/HMain.hlsl" + + H_TEXTURE(_ObjectMotionVectors); + H_TEXTURE(_ObjectMotionVectorsDepth); + + float _BiasOffset; + + struct Attributes + { + uint VertexID : SV_VertexID; + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + + struct Varyings + { + float4 PositionCS : SV_POSITION; + float2 TexCoord : TEXCOORD0; + UNITY_VERTEX_OUTPUT_STEREO + }; + + struct FragOutput + { + float2 MotionVectors : SV_Target0; + float Mask : SV_Target1; + }; + + Varyings VertexStage(Attributes Input) + { + Varyings Output; + UNITY_SETUP_INSTANCE_ID(Input); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); + + Output.PositionCS = GetFullScreenTriangleVertexPosition(Input.VertexID); + Output.TexCoord = GetFullScreenTriangleTexCoord(Input.VertexID); + + return Output; + } + + FragOutput FragmentStage(Varyings Input) + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + FragOutput Output = (FragOutput)0; + + float2 ObjectMotionVectorsColor = H_LOAD(_ObjectMotionVectors, Input.PositionCS.xy).xy; + float ObjectMotionVectorsDepth = H_LOAD(_ObjectMotionVectorsDepth, Input.PositionCS.xy).x; + float CameraDepth = LoadSceneDepth(Input.PositionCS.xy); + + #if !UNITY_REVERSED_Z + CameraDepth = lerp(UNITY_NEAR_CLIP_VALUE, 1, LoadSceneDepth(Input.PositionCS.xy).x); + #endif + + if (ObjectMotionVectorsDepth >= CameraDepth + _BiasOffset) + { + Output.MotionVectors = ObjectMotionVectorsColor; + Output.Mask = 1; + return Output; + } + + // Reconstruct world position + float3 PositionWS = ComputeWorldSpacePosition(Input.PositionCS.xy * _ScreenSize.zw, CameraDepth, UNITY_MATRIX_I_VP); + + // Multiply with current and previous non-jittered view projection + float4 PositionCS = mul(H_MATRIX_VP, float4(PositionWS.xyz, 1.0)); + float4 PreviousPositionCS = mul(H_MATRIX_PREV_VP, float4(PositionWS.xyz, 1.0)); + + // Non-uniform raster needs to keep the posNDC values in float to avoid additional conversions + // since uv remap functions use floats + float2 PositionNDC = PositionCS.xy * rcp(PositionCS.w); + float2 PreviousPositionNDC = PreviousPositionCS.xy * rcp(PreviousPositionCS.w); + + // Calculate forward velocity + float2 Velocity = (PositionNDC - PreviousPositionNDC); + + // TODO: test that velocity.y is correct + #if UNITY_UV_STARTS_AT_TOP + Velocity.y = -Velocity.y; + #endif + + // Convert velocity from NDC space (-1..1) to screen UV 0..1 space + // Note: It doesn't mean we don't have negative values, we store negative or positive offset in the UV space. + // Note: ((posNDC * 0.5 + 0.5) - (prevPosNDC * 0.5 + 0.5)) = (velocity * 0.5) + Velocity.xy *= 0.5; + + Output.MotionVectors = Velocity; + Output.Mask = 0; + + return Output; + } + + ENDHLSL + } + + + Pass + { + Name "Object Motion Vectors" + + Tags { "LightMode" = "MotionVectors" } + + HLSLPROGRAM + + #pragma vertex vert + #pragma fragment frag + #pragma multi_compile_instancing + + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl" + #include "../../Headers/HMain.hlsl" + + #ifndef HAVE_VFX_MODIFICATION + #pragma multi_compile _ DOTS_INSTANCING_ON + #if UNITY_PLATFORM_ANDROID || UNITY_PLATFORM_WEBGL || UNITY_PLATFORM_UWP + #pragma target 3.5 DOTS_INSTANCING_ON + #else + #pragma target 4.5 DOTS_INSTANCING_ON + #endif + #endif + + struct Attributes + { + float4 Position : POSITION; + float3 PositionOld : TEXCOORD4; + UNITY_VERTEX_INPUT_INSTANCE_ID + }; + + struct Varyings + { + float4 PositionCS : SV_POSITION; + float4 PositionCSNoJitter : TEXCOORD0; + float4 PreviousPositionCSNoJitter : TEXCOORD1; + float MotionMask : TEXCOORD2; + UNITY_VERTEX_INPUT_INSTANCE_ID + UNITY_VERTEX_OUTPUT_STEREO + }; + + Varyings vert(Attributes Input) + { + UNITY_SETUP_INSTANCE_ID(Input); + Varyings Output = (Varyings)0; + UNITY_TRANSFER_INSTANCE_ID(Input, Output); + UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(Output); + + VertexPositionInputs VertexInput = GetVertexPositionInputs(Input.Position.xyz); + + // Jittered. Match the frame. + Output.PositionCS = VertexInput.positionCS; + + // This is required to avoid artifacts ("gaps" in the _MotionVectorTexture) on some platforms + #if defined(UNITY_REVERSED_Z) + Output.PositionCS.z -= unity_MotionVectorsParams.z * Output.PositionCS.w; + #else + Output.PositionCS.z += unity_MotionVectorsParams.z * Output.PositionCS.w; + #endif + + const float4 PreviousPosition = (unity_MotionVectorsParams.x == 1) ? float4(Input.PositionOld, 1) : Input.Position; + const float4 PositionWS = mul(UNITY_MATRIX_M, Input.Position); + const float4 PreviousPositionWS = mul(UNITY_PREV_MATRIX_M, PreviousPosition); + + Output.PositionCSNoJitter = mul(H_MATRIX_VP, PositionWS); + Output.PreviousPositionCSNoJitter = mul(H_MATRIX_PREV_VP, PreviousPositionWS); + Output.MotionMask = length(PositionWS - PreviousPositionWS) > 0.0001 ? 1 : 0; + + return Output; + } + + struct FragOutput + { + float2 MotionVectors : SV_Target0; + float Mask : SV_Target1; + }; + + FragOutput frag(Varyings Input) + { + UNITY_SETUP_INSTANCE_ID(input); + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + FragOutput Output = (FragOutput)0; + + // Note: unity_MotionVectorsParams.y is 0 is forceNoMotion is enabled + bool ForceNoMotion = unity_MotionVectorsParams.y == 0.0; + if (ForceNoMotion) + { + Output.MotionVectors = 0; + Output.Mask = 0; + return Output; + } + + // Calculate positions + float4 PositionCS = Input.PositionCSNoJitter; + float4 PreviousPositionCS = Input.PreviousPositionCSNoJitter; + + float2 PositionNDC = PositionCS.xy * rcp(PositionCS.w); + float2 PreviousPositionNDC = PreviousPositionCS.xy * rcp(PreviousPositionCS.w); + + float2 Velocity = (PositionNDC.xy - PreviousPositionNDC.xy); + #if UNITY_UV_STARTS_AT_TOP + Velocity.y = -Velocity.y; + #endif + + // Convert velocity from NDC space (-1..1) to UV 0..1 space + // Note: It doesn't mean we don't have negative values, we store negative or positive offset in UV space. + // Note: ((posNDC * 0.5 + 0.5) - (prevPosNDC * 0.5 + 0.5)) = (velocity * 0.5) + Velocity.xy *= 0.5; + + Output.MotionVectors = Velocity; + Output.Mask = Input.MotionMask; + return Output; + } + ENDHLSL + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/MotionVectorsURP.shader.meta b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/MotionVectorsURP.shader.meta new file mode 100644 index 0000000..c49d4ed --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/MotionVectorsURP.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 6f27aac68f194270ad9353a4177fcf0a +timeCreated: 1745943152 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Resources/HTraceSSGI/Shaders/URP/MotionVectorsURP.shader + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene.meta b/Assets/Plugins/HTraceSSGI/Sample Scene.meta new file mode 100644 index 0000000..6a5a71c --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4c5d5b37adba1e741b0c5e491ae76235 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Default HTrace SSGI Profile.asset b/Assets/Plugins/HTraceSSGI/Sample Scene/Default HTrace SSGI Profile.asset new file mode 100644 index 0000000..b3b6784 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Default HTrace SSGI Profile.asset @@ -0,0 +1,65 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4cfa758cbcc84a509b4fbdd3a170a992, type: 3} + m_Name: Default HTrace SSGI Profile + m_EditorClassIdentifier: HTraceSSGI::HTraceSSGI.Scripts.Data.Private.HTraceSSGIProfile + GeneralSettings: + DebugMode: 0 + HBuffer: 0 + Multibounce: 1 + ExcludeCastingMask: + serializedVersion: 0 + m_Bits: 0 + ExcludeReceivingMask: + serializedVersion: 0 + m_Bits: 0 + FallbackType: 0 + _skyIntensity: 0.5 + _viewBias: 0 + _normalBias: 0.33 + _samplingNoise: 0.1 + _intensityMultiplier: 1 + DenoiseFallback: 1 + SSGISettings: + _backfaceLighting: 0 + _maxRayLength: 100 + ThicknessMode: 0 + _thickness: 0.35 + _falloff: 0 + _rayCount: 4 + _stepCount: 32 + RefineIntersection: 1 + FullResolutionDepth: 1 + Checkerboard: 0 + _renderScale: 1 + DenoisingSettings: + BrightnessClamp: 1 + _maxValueBrightnessClamp: 12 + _maxDeviationBrightnessClamp: 2 + HalfStepValidation: 0 + SpatialOcclusionValidation: 1 + TemporalLightingValidation: 1 + TemporalOcclusionValidation: 1 + _spatialRadius: 0.6 + _adaptivity: 0.9 + RecurrentBlur: 0 + FireflySuppression: 1 + DebugSettings: + ShowBowels: 0 + ShowFullDebugLog: 0 + HInjectionPoint: 1 + HTraceLayer: + serializedVersion: 2 + m_Bits: 4294967295 + TestCheckBox1: 0 + TestCheckBox2: 0 + TestCheckBox3: 0 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Default HTrace SSGI Profile.asset.meta b/Assets/Plugins/HTraceSSGI/Sample Scene/Default HTrace SSGI Profile.asset.meta new file mode 100644 index 0000000..dd9416b --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Default HTrace SSGI Profile.asset.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: 4b20d84daa4c7da478a5f7a10fead959 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Sample Scene/Default HTrace SSGI Profile.asset + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP.meta b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP.meta new file mode 100644 index 0000000..f7a15c3 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d6cfd446d4b049a4b848d41d5fef1fb3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP Volume Profile.asset b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP Volume Profile.asset new file mode 100644 index 0000000..2774ea7 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP Volume Profile.asset @@ -0,0 +1,1024 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-5470913452283579750 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f17acff6deb4f089d110375635d4e37, type: 3} + m_Name: HTraceSSGIVolume + m_EditorClassIdentifier: + active: 1 + Enable: + m_OverrideState: 1 + m_Value: 1 + DebugMode: + m_OverrideState: 1 + m_Value: 0 + HBuffer: + m_OverrideState: 1 + m_Value: 0 + ExcludeCastingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + ExcludeReceivingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + FallbackType: + m_OverrideState: 1 + m_Value: 0 + MetallicIndirectFallback: + m_OverrideState: 1 + m_Value: 0 + AmbientOverride: + m_OverrideState: 1 + m_Value: 0 + Multibounce: + m_OverrideState: 1 + m_Value: 1 + SkyIntensity: + m_OverrideState: 1 + m_Value: 0.5 + ViewBias: + m_OverrideState: 1 + m_Value: 0.1 + NormalBias: + m_OverrideState: 1 + m_Value: 0.25 + SamplingNoise: + m_OverrideState: 1 + m_Value: 0.1 + IntensityMultiplier: + m_OverrideState: 1 + m_Value: 1 + DenoiseFallback: + m_OverrideState: 1 + m_Value: 1 + BackfaceLighting: + m_OverrideState: 0 + m_Value: 0 + MaxRayLength: + m_OverrideState: 1 + m_Value: 100 + ThicknessMode: + m_OverrideState: 1 + m_Value: 0 + Thickness: + m_OverrideState: 1 + m_Value: 0.4 + Intensity: + m_OverrideState: 1 + m_Value: 1 + Falloff: + m_OverrideState: 1 + m_Value: 0 + RayCount: + m_OverrideState: 1 + m_Value: 4 + StepCount: + m_OverrideState: 1 + m_Value: 32 + RefineIntersection: + m_OverrideState: 1 + m_Value: 1 + FullResolutionDepth: + m_OverrideState: 1 + m_Value: 1 + Checkerboard: + m_OverrideState: 1 + m_Value: 0 + RenderScale: + m_OverrideState: 1 + m_Value: 1 + BrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxValueBrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxDeviationBrightnessClamp: + m_OverrideState: 1 + m_Value: 3 + HalfStepValidation: + m_OverrideState: 1 + m_Value: 0 + SpatialOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalLightingValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + SpatialRadius: + m_OverrideState: 1 + m_Value: 0.6 + Adaptivity: + m_OverrideState: 1 + m_Value: 0.9 + RecurrentBlur: + m_OverrideState: 1 + m_Value: 0 + FireflySuppression: + m_OverrideState: 1 + m_Value: 1 + ShowBowels: + m_OverrideState: 1 + m_Value: 1 +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3} + m_Name: HTrace SSGI Sample Scene URP Volume Profile + m_EditorClassIdentifier: + components: + - {fileID: 9108082675869322749} + - {fileID: 7058305194296896203} + - {fileID: 6804410375353511003} +--- !u!114 &184643366705782357 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f17acff6deb4f089d110375635d4e37, type: 3} + m_Name: HTraceSSGIVolume + m_EditorClassIdentifier: + active: 1 + Enable: + m_OverrideState: 1 + m_Value: 1 + DebugMode: + m_OverrideState: 1 + m_Value: 0 + HBuffer: + m_OverrideState: 1 + m_Value: 0 + ExcludeCastingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + ExcludeReceivingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + FallbackType: + m_OverrideState: 1 + m_Value: 0 + MetallicIndirectFallback: + m_OverrideState: 1 + m_Value: 0 + AmbientOverride: + m_OverrideState: 1 + m_Value: 0 + Multibounce: + m_OverrideState: 1 + m_Value: 1 + SkyIntensity: + m_OverrideState: 1 + m_Value: 0.5 + ViewBias: + m_OverrideState: 1 + m_Value: 0.1 + NormalBias: + m_OverrideState: 1 + m_Value: 0.25 + SamplingNoise: + m_OverrideState: 1 + m_Value: 0.1 + IntensityMultiplier: + m_OverrideState: 1 + m_Value: 1 + DenoiseFallback: + m_OverrideState: 1 + m_Value: 1 + BackfaceLighting: + m_OverrideState: 0 + m_Value: 0 + MaxRayLength: + m_OverrideState: 1 + m_Value: 100 + ThicknessMode: + m_OverrideState: 1 + m_Value: 0 + Thickness: + m_OverrideState: 1 + m_Value: 0.4 + Intensity: + m_OverrideState: 1 + m_Value: 1 + Falloff: + m_OverrideState: 1 + m_Value: 0 + RayCount: + m_OverrideState: 1 + m_Value: 4 + StepCount: + m_OverrideState: 1 + m_Value: 32 + RefineIntersection: + m_OverrideState: 1 + m_Value: 1 + FullResolutionDepth: + m_OverrideState: 1 + m_Value: 1 + Checkerboard: + m_OverrideState: 1 + m_Value: 0 + RenderScale: + m_OverrideState: 1 + m_Value: 1 + BrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxValueBrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxDeviationBrightnessClamp: + m_OverrideState: 1 + m_Value: 4 + HalfStepValidation: + m_OverrideState: 1 + m_Value: 0 + SpatialOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalLightingValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + SpatialRadius: + m_OverrideState: 1 + m_Value: 0.6 + Adaptivity: + m_OverrideState: 1 + m_Value: 0.9 + RecurrentBlur: + m_OverrideState: 1 + m_Value: 0 + FireflySuppression: + m_OverrideState: 1 + m_Value: 1 + ShowBowels: + m_OverrideState: 1 + m_Value: 1 +--- !u!114 &1174947720324204672 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f17acff6deb4f089d110375635d4e37, type: 3} + m_Name: HTraceSSGIVolume + m_EditorClassIdentifier: + active: 1 + Enable: + m_OverrideState: 1 + m_Value: 1 + DebugMode: + m_OverrideState: 1 + m_Value: 0 + HBuffer: + m_OverrideState: 1 + m_Value: 0 + ExcludeCastingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 4 + ExcludeReceivingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + FallbackType: + m_OverrideState: 1 + m_Value: 0 + MetallicIndirectFallback: + m_OverrideState: 1 + m_Value: 0 + AmbientOverride: + m_OverrideState: 1 + m_Value: 1 + Multibounce: + m_OverrideState: 1 + m_Value: 1 + SkyIntensity: + m_OverrideState: 1 + m_Value: 0.5 + ViewBias: + m_OverrideState: 1 + m_Value: 0.1 + NormalBias: + m_OverrideState: 1 + m_Value: 0.25 + SamplingNoise: + m_OverrideState: 1 + m_Value: 0.1 + IntensityMultiplier: + m_OverrideState: 1 + m_Value: 1 + DenoiseFallback: + m_OverrideState: 1 + m_Value: 1 + BackfaceLighting: + m_OverrideState: 1 + m_Value: 0 + MaxRayLength: + m_OverrideState: 1 + m_Value: 100 + ThicknessMode: + m_OverrideState: 1 + m_Value: 0 + Thickness: + m_OverrideState: 1 + m_Value: 0.35 + Intensity: + m_OverrideState: 1 + m_Value: 1 + Falloff: + m_OverrideState: 1 + m_Value: 0 + RayCount: + m_OverrideState: 1 + m_Value: 4 + StepCount: + m_OverrideState: 1 + m_Value: 32 + RefineIntersection: + m_OverrideState: 1 + m_Value: 1 + FullResolutionDepth: + m_OverrideState: 1 + m_Value: 1 + Checkerboard: + m_OverrideState: 1 + m_Value: 0 + RenderScale: + m_OverrideState: 1 + m_Value: 1 + BrightnessClamp: + m_OverrideState: 1 + m_Value: 0 + MaxValueBrightnessClamp: + m_OverrideState: 1 + m_Value: 30 + MaxDeviationBrightnessClamp: + m_OverrideState: 1 + m_Value: 5 + HalfStepValidation: + m_OverrideState: 1 + m_Value: 0 + SpatialOcclusionValidation: + m_OverrideState: 1 + m_Value: 0 + TemporalLightingValidation: + m_OverrideState: 1 + m_Value: 0 + TemporalOcclusionValidation: + m_OverrideState: 1 + m_Value: 0 + SpatialRadius: + m_OverrideState: 1 + m_Value: 0.6 + Adaptivity: + m_OverrideState: 1 + m_Value: 0.9 + RecurrentBlur: + m_OverrideState: 1 + m_Value: 0 + FireflySuppression: + m_OverrideState: 1 + m_Value: 1 + ShowBowels: + m_OverrideState: 1 + m_Value: 0 +--- !u!114 &2426405236594000685 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f17acff6deb4f089d110375635d4e37, type: 3} + m_Name: HTraceSSGIVolume + m_EditorClassIdentifier: + active: 1 + Enable: + m_OverrideState: 1 + m_Value: 1 + DebugMode: + m_OverrideState: 1 + m_Value: 0 + HBuffer: + m_OverrideState: 1 + m_Value: 0 + ExcludeCastingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + ExcludeReceivingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + FallbackType: + m_OverrideState: 1 + m_Value: 0 + MetallicIndirectFallback: + m_OverrideState: 1 + m_Value: 1 + AmbientOverride: + m_OverrideState: 1 + m_Value: 1 + Multibounce: + m_OverrideState: 1 + m_Value: 1 + SkyIntensity: + m_OverrideState: 1 + m_Value: 0.5 + ViewBias: + m_OverrideState: 1 + m_Value: 0.1 + NormalBias: + m_OverrideState: 1 + m_Value: 0.25 + SamplingNoise: + m_OverrideState: 1 + m_Value: 0.1 + IntensityMultiplier: + m_OverrideState: 1 + m_Value: 1 + DenoiseFallback: + m_OverrideState: 1 + m_Value: 1 + BackfaceLighting: + m_OverrideState: 1 + m_Value: 0 + MaxRayLength: + m_OverrideState: 1 + m_Value: 100 + ThicknessMode: + m_OverrideState: 1 + m_Value: 0 + Thickness: + m_OverrideState: 1 + m_Value: 0.4 + Intensity: + m_OverrideState: 1 + m_Value: 1 + Falloff: + m_OverrideState: 1 + m_Value: 0 + RayCount: + m_OverrideState: 1 + m_Value: 4 + StepCount: + m_OverrideState: 1 + m_Value: 32 + RefineIntersection: + m_OverrideState: 1 + m_Value: 1 + FullResolutionDepth: + m_OverrideState: 1 + m_Value: 1 + Checkerboard: + m_OverrideState: 1 + m_Value: 0 + RenderScale: + m_OverrideState: 1 + m_Value: 1 + BrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxValueBrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxDeviationBrightnessClamp: + m_OverrideState: 1 + m_Value: 3 + HalfStepValidation: + m_OverrideState: 1 + m_Value: 0 + SpatialOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalLightingValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + SpatialRadius: + m_OverrideState: 1 + m_Value: 0.6 + Adaptivity: + m_OverrideState: 1 + m_Value: 0.9 + RecurrentBlur: + m_OverrideState: 1 + m_Value: 0 + FireflySuppression: + m_OverrideState: 1 + m_Value: 1 + ShowBowels: + m_OverrideState: 1 + m_Value: 0 +--- !u!114 &5672950372258795113 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f17acff6deb4f089d110375635d4e37, type: 3} + m_Name: HTraceSSGIVolume + m_EditorClassIdentifier: + active: 1 + Enable: + m_OverrideState: 1 + m_Value: 1 + DebugMode: + m_OverrideState: 1 + m_Value: 1 + HBuffer: + m_OverrideState: 1 + m_Value: 0 + ExcludeCastingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 8 + ExcludeReceivingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + FallbackType: + m_OverrideState: 1 + m_Value: 0 + MetallicIndirectFallback: + m_OverrideState: 1 + m_Value: 1 + AmbientOverride: + m_OverrideState: 1 + m_Value: 1 + Multibounce: + m_OverrideState: 1 + m_Value: 1 + SkyIntensity: + m_OverrideState: 1 + m_Value: 0.5 + ViewBias: + m_OverrideState: 1 + m_Value: 0.1 + NormalBias: + m_OverrideState: 1 + m_Value: 0.25 + SamplingNoise: + m_OverrideState: 1 + m_Value: 0.1 + IntensityMultiplier: + m_OverrideState: 1 + m_Value: 1 + DenoiseFallback: + m_OverrideState: 1 + m_Value: 1 + BackfaceLighting: + m_OverrideState: 1 + m_Value: 0 + MaxRayLength: + m_OverrideState: 1 + m_Value: 100 + ThicknessMode: + m_OverrideState: 1 + m_Value: 0 + Thickness: + m_OverrideState: 1 + m_Value: 0.4 + Intensity: + m_OverrideState: 1 + m_Value: 1 + Falloff: + m_OverrideState: 1 + m_Value: 0 + RayCount: + m_OverrideState: 1 + m_Value: 4 + StepCount: + m_OverrideState: 1 + m_Value: 32 + RefineIntersection: + m_OverrideState: 1 + m_Value: 1 + FullResolutionDepth: + m_OverrideState: 1 + m_Value: 1 + Checkerboard: + m_OverrideState: 1 + m_Value: 0 + RenderScale: + m_OverrideState: 1 + m_Value: 1 + BrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxValueBrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxDeviationBrightnessClamp: + m_OverrideState: 1 + m_Value: 3 + HalfStepValidation: + m_OverrideState: 1 + m_Value: 0 + SpatialOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalLightingValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + SpatialRadius: + m_OverrideState: 1 + m_Value: 0.6 + Adaptivity: + m_OverrideState: 1 + m_Value: 0.86 + RecurrentBlur: + m_OverrideState: 1 + m_Value: 0 + FireflySuppression: + m_OverrideState: 1 + m_Value: 1 + ShowBowels: + m_OverrideState: 1 + m_Value: 0 +--- !u!114 &6804410375353511003 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f17acff6deb4f089d110375635d4e37, type: 3} + m_Name: HTraceSSGIVolume + m_EditorClassIdentifier: + active: 1 + Enable: + m_OverrideState: 1 + m_Value: 1 + DebugMode: + m_OverrideState: 1 + m_Value: 0 + HBuffer: + m_OverrideState: 1 + m_Value: 0 + ExcludeCastingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + ExcludeReceivingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + FallbackType: + m_OverrideState: 1 + m_Value: 0 + MetallicIndirectFallback: + m_OverrideState: 1 + m_Value: 1 + AmbientOverride: + m_OverrideState: 1 + m_Value: 1 + Multibounce: + m_OverrideState: 1 + m_Value: 1 + SkyIntensity: + m_OverrideState: 1 + m_Value: 0.5 + ViewBias: + m_OverrideState: 1 + m_Value: 0.1 + NormalBias: + m_OverrideState: 1 + m_Value: 0.25 + SamplingNoise: + m_OverrideState: 1 + m_Value: 0.1 + IntensityMultiplier: + m_OverrideState: 1 + m_Value: 1 + DenoiseFallback: + m_OverrideState: 1 + m_Value: 1 + BackfaceLighting: + m_OverrideState: 1 + m_Value: 0 + MaxRayLength: + m_OverrideState: 1 + m_Value: 100 + ThicknessMode: + m_OverrideState: 1 + m_Value: 0 + Thickness: + m_OverrideState: 1 + m_Value: 0.4 + Intensity: + m_OverrideState: 1 + m_Value: 1 + Falloff: + m_OverrideState: 1 + m_Value: 0 + RayCount: + m_OverrideState: 1 + m_Value: 4 + StepCount: + m_OverrideState: 1 + m_Value: 32 + RefineIntersection: + m_OverrideState: 1 + m_Value: 1 + FullResolutionDepth: + m_OverrideState: 1 + m_Value: 1 + Checkerboard: + m_OverrideState: 1 + m_Value: 0 + RenderScale: + m_OverrideState: 1 + m_Value: 1 + BrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxValueBrightnessClamp: + m_OverrideState: 1 + m_Value: 1 + MaxDeviationBrightnessClamp: + m_OverrideState: 1 + m_Value: 3 + HalfStepValidation: + m_OverrideState: 1 + m_Value: 0 + SpatialOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalLightingValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + SpatialRadius: + m_OverrideState: 1 + m_Value: 0.6 + Adaptivity: + m_OverrideState: 1 + m_Value: 0.9 + RecurrentBlur: + m_OverrideState: 1 + m_Value: 0 + FireflySuppression: + m_OverrideState: 1 + m_Value: 1 + ShowBowels: + m_OverrideState: 1 + m_Value: 0 +--- !u!114 &7058305194296896203 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3} + m_Name: ColorAdjustments + m_EditorClassIdentifier: + active: 1 + postExposure: + m_OverrideState: 1 + m_Value: 1 + contrast: + m_OverrideState: 1 + m_Value: 5 + colorFilter: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + hueShift: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &7310906143425567460 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f17acff6deb4f089d110375635d4e37, type: 3} + m_Name: HTraceSSGIVolume + m_EditorClassIdentifier: + active: 1 + Enable: + m_OverrideState: 1 + m_Value: 1 + DebugMode: + m_OverrideState: 1 + m_Value: 0 + HBuffer: + m_OverrideState: 1 + m_Value: 0 + ExcludeCastingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + ExcludeReceivingMask: + m_OverrideState: 1 + m_Value: + serializedVersion: 0 + m_Bits: 0 + FallbackType: + m_OverrideState: 1 + m_Value: 1 + MetallicIndirectFallback: + m_OverrideState: 1 + m_Value: 1 + AmbientOverride: + m_OverrideState: 1 + m_Value: 1 + Multibounce: + m_OverrideState: 1 + m_Value: 1 + SkyIntensity: + m_OverrideState: 1 + m_Value: 1 + ViewBias: + m_OverrideState: 1 + m_Value: 0.1 + NormalBias: + m_OverrideState: 1 + m_Value: 0.25 + SamplingNoise: + m_OverrideState: 1 + m_Value: 0.1 + IntensityMultiplier: + m_OverrideState: 1 + m_Value: 1 + DenoiseFallback: + m_OverrideState: 1 + m_Value: 1 + BackfaceLighting: + m_OverrideState: 0 + m_Value: 0 + MaxRayLength: + m_OverrideState: 1 + m_Value: 100 + ThicknessMode: + m_OverrideState: 1 + m_Value: 0 + Thickness: + m_OverrideState: 1 + m_Value: 0.4 + Intensity: + m_OverrideState: 1 + m_Value: 1 + Falloff: + m_OverrideState: 1 + m_Value: 0 + RayCount: + m_OverrideState: 1 + m_Value: 4 + StepCount: + m_OverrideState: 1 + m_Value: 32 + RefineIntersection: + m_OverrideState: 1 + m_Value: 1 + FullResolutionDepth: + m_OverrideState: 1 + m_Value: 1 + Checkerboard: + m_OverrideState: 1 + m_Value: 0 + RenderScale: + m_OverrideState: 1 + m_Value: 1 + BrightnessClamp: + m_OverrideState: 1 + m_Value: 0 + MaxValueBrightnessClamp: + m_OverrideState: 1 + m_Value: 2 + MaxDeviationBrightnessClamp: + m_OverrideState: 1 + m_Value: 3 + HalfStepValidation: + m_OverrideState: 1 + m_Value: 0 + SpatialOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalLightingValidation: + m_OverrideState: 1 + m_Value: 1 + TemporalOcclusionValidation: + m_OverrideState: 1 + m_Value: 1 + SpatialRadius: + m_OverrideState: 1 + m_Value: 0.6 + Adaptivity: + m_OverrideState: 1 + m_Value: 0.9 + RecurrentBlur: + m_OverrideState: 1 + m_Value: 0 + FireflySuppression: + m_OverrideState: 1 + m_Value: 1 + ShowBowels: + m_OverrideState: 1 + m_Value: 0 +--- !u!114 &9108082675869322749 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3} + m_Name: Tonemapping + m_EditorClassIdentifier: + active: 1 + mode: + m_OverrideState: 1 + m_Value: 2 + neutralHDRRangeReductionMode: + m_OverrideState: 0 + m_Value: 2 + acesPreset: + m_OverrideState: 0 + m_Value: 3 + hueShiftAmount: + m_OverrideState: 0 + m_Value: 0 + detectPaperWhite: + m_OverrideState: 0 + m_Value: 0 + paperWhite: + m_OverrideState: 0 + m_Value: 300 + detectBrightnessLimits: + m_OverrideState: 0 + m_Value: 1 + minNits: + m_OverrideState: 0 + m_Value: 0.005 + maxNits: + m_OverrideState: 0 + m_Value: 1000 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP Volume Profile.asset.meta b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP Volume Profile.asset.meta new file mode 100644 index 0000000..6142958 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP Volume Profile.asset.meta @@ -0,0 +1,16 @@ +fileFormatVersion: 2 +guid: 2b7b1942fa57e1a4cbcff6ea0d7d65f8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample + Scene URP Volume Profile.asset + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP.unity b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP.unity new file mode 100644 index 0000000..a8f3fa4 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP.unity @@ -0,0 +1,1359 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 10 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0, g: 0, b: 0, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 13 + m_BakeOnSceneLoad: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 112000000, guid: 366e5d9a3e206e041aa009d54e997a87, type: 2} + m_LightingSettings: {fileID: 4890085278179872738, guid: 590535ecc0f15f14199f779f7aa4c507, type: 2} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &196438145 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 196438146} + - component: {fileID: 196438149} + - component: {fileID: 196438148} + - component: {fileID: 196438147} + m_Layer: 0 + m_Name: Back Wall + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 2147483647 + m_IsActive: 1 +--- !u!4 &196438146 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 196438145} + serializedVersion: 2 + m_LocalRotation: {x: -0.49999973, y: 0.5000002, z: -0.50000024, w: 0.49999988} + m_LocalPosition: {x: -0.0143, y: 0.2082, z: 1.06} + m_LocalScale: {x: 2.9590182, y: 0.1, z: 2.9688} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1380110274} + m_LocalEulerAnglesHint: {x: 0, y: 90, z: -90} +--- !u!65 &196438147 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 196438145} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &196438148 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 196438145} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: d9153fcff3f6ea841adaf48d8126e8ef, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &196438149 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 196438145} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &280668584 +GameObject: + m_ObjectHideFlags: 19 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 280668586} + - component: {fileID: 280668585} + m_Layer: 0 + m_Name: SceneIDMap + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &280668585 +MonoBehaviour: + m_ObjectHideFlags: 19 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 280668584} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 370450657} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &280668586 +Transform: + m_ObjectHideFlags: 19 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 280668584} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &343207155 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 343207156} + - component: {fileID: 343207159} + - component: {fileID: 343207158} + - component: {fileID: 343207157} + m_Layer: 0 + m_Name: Big Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 2147483647 + m_IsActive: 1 +--- !u!4 &343207156 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 343207155} + serializedVersion: 2 + m_LocalRotation: {x: -0.68109804, y: -0.19001414, z: -0.19001412, w: 0.6810982} + m_LocalPosition: {x: -0.51, y: -0.39, z: -0.17919587} + m_LocalScale: {x: 0.7518184, y: 0.6488982, z: 1.4962934} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1380110274} + m_LocalEulerAnglesHint: {x: -90, y: 0, z: -31.176} +--- !u!65 &343207157 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 343207155} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &343207158 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 343207155} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: d9153fcff3f6ea841adaf48d8126e8ef, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &343207159 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 343207155} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!115 &370450657 +MonoScript: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + serializedVersion: 7 + m_DefaultReferences: {} + m_Icon: {fileID: 0} + m_Type: 2 + m_ExecutionOrder: 0 + m_ClassName: SceneObjectIDMapSceneAsset + m_Namespace: UnityEngine.Rendering.HighDefinition + m_AssemblyName: +--- !u!1 &661537973 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 661537974} + - component: {fileID: 661537977} + - component: {fileID: 661537976} + - component: {fileID: 661537975} + m_Layer: 0 + m_Name: Ceiling + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 2147483647 + m_IsActive: 1 +--- !u!4 &661537974 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 661537973} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.0121, y: 1.622, z: -0.3051} + m_LocalScale: {x: 2.982305, y: 0.1, z: 2.8895998} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1380110274} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &661537975 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 661537973} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &661537976 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 661537973} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: d9153fcff3f6ea841adaf48d8126e8ef, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &661537977 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 661537973} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &673803001 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 673803002} + - component: {fileID: 673803005} + - component: {fileID: 673803004} + - component: {fileID: 673803003} + m_Layer: 0 + m_Name: Floor + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 2147483647 + m_IsActive: 1 +--- !u!4 &673803002 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 673803001} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -0.0121, y: -1.188, z: -0.3168} + m_LocalScale: {x: 2.982305, y: 0.1, z: 2.913137} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1380110274} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &673803003 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 673803001} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &673803004 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 673803001} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: d9153fcff3f6ea841adaf48d8126e8ef, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &673803005 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 673803001} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1071973031 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1071973033} + - component: {fileID: 1071973032} + m_Layer: 0 + m_Name: HTrace Volume + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1071973032 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1071973031} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IsGlobal: 1 + priority: 0 + blendDistance: 0 + weight: 1 + sharedProfile: {fileID: 11400000, guid: 2b7b1942fa57e1a4cbcff6ea0d7d65f8, type: 2} +--- !u!4 &1071973033 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1071973031} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 3, y: 1.2, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1380110273 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1380110274} + m_Layer: 0 + m_Name: Geometry + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1380110274 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1380110273} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.03529141, y: 1.080143, z: 0.30615434} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1736322565} + - {fileID: 661537974} + - {fileID: 673803002} + - {fileID: 1580325724} + - {fileID: 196438146} + - {fileID: 343207156} + - {fileID: 1564718288} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1564718287 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1564718288} + - component: {fileID: 1564718291} + - component: {fileID: 1564718290} + - component: {fileID: 1564718289} + m_Layer: 0 + m_Name: Small Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 2147483647 + m_IsActive: 1 +--- !u!4 &1564718288 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1564718287} + serializedVersion: 2 + m_LocalRotation: {x: -0.60084724, y: -0.37280366, z: -0.3728037, w: 0.6008473} + m_LocalPosition: {x: 0.49, y: -0.779, z: -0.735} + m_LocalScale: {x: 0.6090482, y: 0.6488983, z: 0.7201619} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1380110274} + m_LocalEulerAnglesHint: {x: -90, y: 0, z: -63.636} +--- !u!65 &1564718289 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1564718287} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1564718290 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1564718287} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: d9153fcff3f6ea841adaf48d8126e8ef, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1564718291 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1564718287} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1580325723 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1580325724} + - component: {fileID: 1580325727} + - component: {fileID: 1580325726} + - component: {fileID: 1580325725} + m_Layer: 0 + m_Name: Green Wall + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 2147483647 + m_IsActive: 1 +--- !u!4 &1580325724 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1580325723} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0.70710707, w: 0.70710653} + m_LocalPosition: {x: 1.45, y: 0.2171, z: -0.30615434} + m_LocalScale: {x: 2.9659188, y: 0.1, z: 3} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1380110274} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90} +--- !u!65 &1580325725 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1580325723} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1580325726 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1580325723} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 425ea38ed8bedfa4aacf6f733eb2282d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1580325727 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1580325723} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1684564753 +GameObject: + m_ObjectHideFlags: 19 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1684564755} + - component: {fileID: 1684564754} + m_Layer: 0 + m_Name: SceneIDMap + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1684564754 +MonoBehaviour: + m_ObjectHideFlags: 19 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1684564753} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 2102043654} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1684564755 +Transform: + m_ObjectHideFlags: 19 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1684564753} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1736322564 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1736322565} + - component: {fileID: 1736322568} + - component: {fileID: 1736322567} + - component: {fileID: 1736322566} + m_Layer: 0 + m_Name: Red Wall + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 2147483647 + m_IsActive: 1 +--- !u!4 &1736322565 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1736322564} + serializedVersion: 2 + m_LocalRotation: {x: -0, y: -0, z: -0.70710707, w: 0.70710653} + m_LocalPosition: {x: -1.47, y: 0.2152, z: -0.30615434} + m_LocalScale: {x: 2.9659188, y: 0.1, z: 3} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1380110274} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90} +--- !u!65 &1736322566 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1736322564} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1736322567 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1736322564} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RayTracingAccelStructBuildFlagsOverride: 0 + m_RayTracingAccelStructBuildFlags: 1 + m_SmallMeshCulling: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 67fcf4336f6079b499741f9409bb9602, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1736322568 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1736322564} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1952662268 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1952662271} + - component: {fileID: 1952662273} + - component: {fileID: 1952662272} + m_Layer: 0 + m_Name: Spot Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1952662271 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1952662268} + serializedVersion: 2 + m_LocalRotation: {x: 0.6427876, y: 0, z: 0, w: 0.7660445} + m_LocalPosition: {x: 0.03, y: 2.5, z: -0.819} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 80, y: 0, z: 0} +--- !u!114 &1952662272 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1952662268} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 3 + m_UsePipelineSettings: 0 + m_AdditionalLightsShadowResolutionTier: 2 + m_LightLayerMask: 1 + m_RenderingLayers: 1 + m_CustomShadowLayers: 0 + m_ShadowLayerMask: 1 + m_ShadowRenderingLayers: 1 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} + m_SoftShadowQuality: 3 +--- !u!108 &1952662273 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1952662268} + m_Enabled: 1 + serializedVersion: 11 + m_Type: 0 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Intensity: 2.5 + m_Range: 10 + m_SpotAngle: 165 + m_InnerSpotAngle: 129.99837 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.01 + m_NormalBias: 0.1 + m_NearPlane: 0.1 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ForceVisible: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 + m_LightUnit: 1 + m_LuxAtDistance: 1 + m_EnableSpotReflector: 1 +--- !u!1 &2028365469 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2028365473} + - component: {fileID: 2028365478} + - component: {fileID: 2028365477} + - component: {fileID: 2028365479} + m_Layer: 0 + m_Name: Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2028365473 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2028365469} + serializedVersion: 2 + m_LocalRotation: {x: 0.012827826, y: 0, z: 0, w: 0.99991775} + m_LocalPosition: {x: 0, y: 1.4, z: -4.15} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 1.47, y: 0, z: 0} +--- !u!114 &2028365477 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2028365469} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_VolumeFrameworkUpdateModeOption: 2 + m_RenderPostProcessing: 1 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_AllowXRRendering: 1 + m_AllowHDROutput: 1 + m_UseScreenCoordOverride: 0 + m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} + m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_Version: 2 + m_TaaSettings: + m_Quality: 3 + m_FrameInfluence: 0.1 + m_JitterScale: 1 + m_MipBias: 0 + m_VarianceClampScale: 0.9 + m_ContrastAdaptiveSharpening: 0 +--- !u!20 &2028365478 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2028365469} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.14716971, g: 0.14716971, b: 0.14716971, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 0 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!114 &2028365479 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2028365469} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 618b0e3f6c65dd247a4a016150006c57, type: 3} + m_Name: + m_EditorClassIdentifier: + m_LookSpeedController: 80 + m_LookSpeedMouse: 2 + m_MoveSpeed: 5 + m_MoveSpeedIncrement: 1.8 + m_Turbo: 8 +--- !u!115 &2102043654 +MonoScript: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + serializedVersion: 7 + m_DefaultReferences: {} + m_Icon: {fileID: 0} + m_Type: 2 + m_ExecutionOrder: 0 + m_ClassName: SceneObjectIDMapSceneAsset + m_Namespace: UnityEngine.Rendering.HighDefinition + m_AssemblyName: +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 2028365473} + - {fileID: 1380110274} + - {fileID: 280668586} + - {fileID: 1684564755} + - {fileID: 1952662271} + - {fileID: 1071973033} diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP.unity.meta b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP.unity.meta new file mode 100644 index 0000000..ddcc815 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample Scene URP.unity.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: a2578560f514a8a488c151ed7db841fb +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/HTrace SSGI Sample + Scene URP.unity + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Green.mat b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Green.mat new file mode 100644 index 0000000..cc865fa --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Green.mat @@ -0,0 +1,356 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Material Green + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: + - TransparentDepthPrepass + - TransparentDepthPostpass + - TransparentBackface + - RayTracingPrepass + - MOTIONVECTORS + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _AnisotropyMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _CoatMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissiveColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _HeightMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecularColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SubsurfaceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmissionMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmittanceColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AORemapMax: 1 + - _AORemapMin: 0 + - _ATDistance: 1 + - _AddPrecomputedVelocity: 0 + - _AlbedoAffectEmissive: 0 + - _AlphaClip: 0 + - _AlphaCutoff: 0.5 + - _AlphaCutoffEnable: 0 + - _AlphaCutoffPostpass: 0.5 + - _AlphaCutoffPrepass: 0.5 + - _AlphaCutoffShadow: 0.5 + - _AlphaDstBlend: 0 + - _AlphaRemapMax: 1 + - _AlphaRemapMin: 0 + - _AlphaSrcBlend: 1 + - _AlphaToMask: 0 + - _Anisotropy: 0 + - _Blend: 0 + - _BlendMode: 0 + - _BlendModePreserveSpecular: 1 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _CoatMask: 0 + - _Cull: 2 + - _CullMode: 2 + - _CullModeForward: 2 + - _Cutoff: 0.5 + - _DepthOffsetEnable: 0 + - _DetailAlbedoMapScale: 1 + - _DetailAlbedoScale: 1 + - _DetailNormalMapScale: 1 + - _DetailNormalScale: 1 + - _DetailSmoothnessScale: 1 + - _DiffusionProfile: 0 + - _DiffusionProfileHash: 0 + - _DisplacementLockObjectScale: 1 + - _DisplacementLockTilingScale: 1 + - _DisplacementMode: 0 + - _DoubleSidedEnable: 0 + - _DoubleSidedGIMode: 0 + - _DoubleSidedNormalMode: 1 + - _DstBlend: 0 + - _DstBlend2: 0 + - _DstBlendAlpha: 0 + - _EmissiveColorMode: 1 + - _EmissiveExposureWeight: 1 + - _EmissiveIntensity: 1 + - _EmissiveIntensityUnit: 0 + - _EnableBlendModePreserveSpecularLighting: 1 + - _EnableFogOnTransparent: 1 + - _EnableGeometricSpecularAA: 0 + - _EnergyConservingSpecularColor: 1 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _HeightAmplitude: 0.02 + - _HeightCenter: 0.5 + - _HeightMapParametrization: 0 + - _HeightMax: 1 + - _HeightMin: -1 + - _HeightOffset: 0 + - _HeightPoMAmplitude: 2 + - _HeightTessAmplitude: 2 + - _HeightTessCenter: 0.5 + - _InvTilingScale: 1 + - _Ior: 1.5 + - _IridescenceMask: 1 + - _IridescenceThickness: 1 + - _LinkDetailsWithBase: 1 + - _MaterialID: 1 + - _Metallic: 0 + - _MetallicRemapMax: 1 + - _MetallicRemapMin: 0 + - _NormalMapSpace: 0 + - _NormalScale: 1 + - _ObjectSpaceUVMapping: 0 + - _ObjectSpaceUVMappingEmissive: 0 + - _OcclusionStrength: 1 + - _OpaqueCullMode: 2 + - _PPDLodThreshold: 5 + - _PPDMaxSamples: 15 + - _PPDMinSamples: 5 + - _PPDPrimitiveLength: 1 + - _PPDPrimitiveWidth: 1 + - _Parallax: 0.005 + - _PerPixelSorting: 0 + - _QueueOffset: 0 + - _RayTracing: 0 + - _ReceiveShadows: 1 + - _ReceivesSSR: 1 + - _ReceivesSSRTransparent: 0 + - _RefractionModel: 0 + - _Smoothness: 0 + - _SmoothnessRemapMax: 1 + - _SmoothnessRemapMin: 0 + - _SmoothnessTextureChannel: 0 + - _SpecularAAScreenSpaceVariance: 0.1 + - _SpecularAAThreshold: 0.2 + - _SpecularHighlights: 1 + - _SpecularOcclusionMode: 1 + - _SrcBlend: 1 + - _SrcBlendAlpha: 1 + - _StencilRef: 0 + - _StencilRefDepth: 8 + - _StencilRefGBuffer: 10 + - _StencilRefMV: 40 + - _StencilWriteMask: 6 + - _StencilWriteMaskDepth: 9 + - _StencilWriteMaskGBuffer: 15 + - _StencilWriteMaskMV: 41 + - _SubsurfaceMask: 1 + - _SupportDecals: 1 + - _Surface: 0 + - _SurfaceType: 0 + - _TexWorldScale: 1 + - _TexWorldScaleEmissive: 1 + - _Thickness: 1 + - _TransmissionEnable: 1 + - _TransmissionMask: 1 + - _TransparentBackfaceEnable: 0 + - _TransparentCullMode: 2 + - _TransparentDepthPostpassEnable: 0 + - _TransparentDepthPrepassEnable: 0 + - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 + - _TransparentZWrite: 0 + - _UVBase: 0 + - _UVDetail: 0 + - _UVEmissive: 0 + - _UseEmissiveIntensity: 0 + - _UseShadowThreshold: 0 + - _WorkflowMode: 1 + - _ZTestDepthEqualForOpaque: 3 + - _ZTestGBuffer: 4 + - _ZTestTransparent: 4 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 0, g: 1, b: 0, a: 1} + - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 0, g: 1, b: 0, a: 1} + - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} + - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} + - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} + - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} + - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} + - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} + - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} + - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} + - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} + m_BuildTextureStacks: [] + m_AllowLocking: 1 +--- !u!114 &1339670755895587704 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 10 +--- !u!114 &7733451441409226090 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 13 + hdPluginSubTargetMaterialVersions: + m_Keys: [] + m_Values: diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Green.mat.meta b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Green.mat.meta new file mode 100644 index 0000000..f25b020 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Green.mat.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: 425ea38ed8bedfa4aacf6f733eb2282d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Green.mat + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Red.mat b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Red.mat new file mode 100644 index 0000000..b8a7eb4 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Red.mat @@ -0,0 +1,356 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Material Red + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: + - TransparentDepthPrepass + - TransparentDepthPostpass + - TransparentBackface + - RayTracingPrepass + - MOTIONVECTORS + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _AnisotropyMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _CoatMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissiveColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _HeightMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecularColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SubsurfaceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmissionMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmittanceColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AORemapMax: 1 + - _AORemapMin: 0 + - _ATDistance: 1 + - _AddPrecomputedVelocity: 0 + - _AlbedoAffectEmissive: 0 + - _AlphaClip: 0 + - _AlphaCutoff: 0.5 + - _AlphaCutoffEnable: 0 + - _AlphaCutoffPostpass: 0.5 + - _AlphaCutoffPrepass: 0.5 + - _AlphaCutoffShadow: 0.5 + - _AlphaDstBlend: 0 + - _AlphaRemapMax: 1 + - _AlphaRemapMin: 0 + - _AlphaSrcBlend: 1 + - _AlphaToMask: 0 + - _Anisotropy: 0 + - _Blend: 0 + - _BlendMode: 0 + - _BlendModePreserveSpecular: 1 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _CoatMask: 0 + - _Cull: 2 + - _CullMode: 2 + - _CullModeForward: 2 + - _Cutoff: 0.5 + - _DepthOffsetEnable: 0 + - _DetailAlbedoMapScale: 1 + - _DetailAlbedoScale: 1 + - _DetailNormalMapScale: 1 + - _DetailNormalScale: 1 + - _DetailSmoothnessScale: 1 + - _DiffusionProfile: 0 + - _DiffusionProfileHash: 0 + - _DisplacementLockObjectScale: 1 + - _DisplacementLockTilingScale: 1 + - _DisplacementMode: 0 + - _DoubleSidedEnable: 0 + - _DoubleSidedGIMode: 0 + - _DoubleSidedNormalMode: 1 + - _DstBlend: 0 + - _DstBlend2: 0 + - _DstBlendAlpha: 0 + - _EmissiveColorMode: 1 + - _EmissiveExposureWeight: 1 + - _EmissiveIntensity: 1 + - _EmissiveIntensityUnit: 0 + - _EnableBlendModePreserveSpecularLighting: 1 + - _EnableFogOnTransparent: 1 + - _EnableGeometricSpecularAA: 0 + - _EnergyConservingSpecularColor: 1 + - _EnvironmentReflections: 1 + - _GlossMapScale: 0 + - _Glossiness: 0 + - _GlossyReflections: 0 + - _HeightAmplitude: 0.02 + - _HeightCenter: 0.5 + - _HeightMapParametrization: 0 + - _HeightMax: 1 + - _HeightMin: -1 + - _HeightOffset: 0 + - _HeightPoMAmplitude: 2 + - _HeightTessAmplitude: 2 + - _HeightTessCenter: 0.5 + - _InvTilingScale: 1 + - _Ior: 1.5 + - _IridescenceMask: 1 + - _IridescenceThickness: 1 + - _LinkDetailsWithBase: 1 + - _MaterialID: 1 + - _Metallic: 0 + - _MetallicRemapMax: 1 + - _MetallicRemapMin: 0 + - _NormalMapSpace: 0 + - _NormalScale: 1 + - _ObjectSpaceUVMapping: 0 + - _ObjectSpaceUVMappingEmissive: 0 + - _OcclusionStrength: 1 + - _OpaqueCullMode: 2 + - _PPDLodThreshold: 5 + - _PPDMaxSamples: 15 + - _PPDMinSamples: 5 + - _PPDPrimitiveLength: 1 + - _PPDPrimitiveWidth: 1 + - _Parallax: 0.005 + - _PerPixelSorting: 0 + - _QueueOffset: 0 + - _RayTracing: 0 + - _ReceiveShadows: 1 + - _ReceivesSSR: 1 + - _ReceivesSSRTransparent: 0 + - _RefractionModel: 0 + - _Smoothness: 0 + - _SmoothnessRemapMax: 1 + - _SmoothnessRemapMin: 0 + - _SmoothnessTextureChannel: 0 + - _SpecularAAScreenSpaceVariance: 0.1 + - _SpecularAAThreshold: 0.2 + - _SpecularHighlights: 1 + - _SpecularOcclusionMode: 1 + - _SrcBlend: 1 + - _SrcBlendAlpha: 1 + - _StencilRef: 0 + - _StencilRefDepth: 8 + - _StencilRefGBuffer: 10 + - _StencilRefMV: 40 + - _StencilWriteMask: 6 + - _StencilWriteMaskDepth: 9 + - _StencilWriteMaskGBuffer: 15 + - _StencilWriteMaskMV: 41 + - _SubsurfaceMask: 1 + - _SupportDecals: 1 + - _Surface: 0 + - _SurfaceType: 0 + - _TexWorldScale: 1 + - _TexWorldScaleEmissive: 1 + - _Thickness: 1 + - _TransmissionEnable: 1 + - _TransmissionMask: 1 + - _TransparentBackfaceEnable: 0 + - _TransparentCullMode: 2 + - _TransparentDepthPostpassEnable: 0 + - _TransparentDepthPrepassEnable: 0 + - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 + - _TransparentZWrite: 0 + - _UVBase: 0 + - _UVDetail: 0 + - _UVEmissive: 0 + - _UseEmissiveIntensity: 0 + - _UseShadowThreshold: 0 + - _WorkflowMode: 1 + - _ZTestDepthEqualForOpaque: 3 + - _ZTestGBuffer: 4 + - _ZTestTransparent: 4 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 0.05042496, b: 0, a: 1} + - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 0.050424933, b: 0, a: 1} + - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} + - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} + - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} + - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} + - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} + - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} + - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} + - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} + - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} + m_BuildTextureStacks: [] + m_AllowLocking: 1 +--- !u!114 &276577487753328058 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 13 + hdPluginSubTargetMaterialVersions: + m_Keys: [] + m_Values: +--- !u!114 &4019547435452770196 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 10 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Red.mat.meta b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Red.mat.meta new file mode 100644 index 0000000..99889d5 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Red.mat.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: 67fcf4336f6079b499741f9409bb9602 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material Red.mat + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material White.mat b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material White.mat new file mode 100644 index 0000000..b29b4af --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material White.mat @@ -0,0 +1,358 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-3222236429044804832 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 13 + hdPluginSubTargetMaterialVersions: + m_Keys: [] + m_Values: +--- !u!114 &-2805634088877745809 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 10 +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Material White + m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: + RenderType: Opaque + disabledShaderPasses: + - MOTIONVECTORS + - TransparentDepthPrepass + - TransparentDepthPostpass + - TransparentBackface + - RayTracingPrepass + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _AnisotropyMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _CoatMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissiveColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _HeightMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecularColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SubsurfaceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmissionMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmittanceColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_Lightmaps: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_LightmapsInd: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - unity_ShadowMasks: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _AORemapMax: 1 + - _AORemapMin: 0 + - _ATDistance: 1 + - _AddPrecomputedVelocity: 0 + - _AlbedoAffectEmissive: 0 + - _AlphaClip: 0 + - _AlphaCutoff: 0.5 + - _AlphaCutoffEnable: 0 + - _AlphaCutoffPostpass: 0.5 + - _AlphaCutoffPrepass: 0.5 + - _AlphaCutoffShadow: 0.5 + - _AlphaDstBlend: 0 + - _AlphaRemapMax: 1 + - _AlphaRemapMin: 0 + - _AlphaSrcBlend: 1 + - _AlphaToMask: 0 + - _Anisotropy: 0 + - _Blend: 0 + - _BlendMode: 0 + - _BlendModePreserveSpecular: 1 + - _BumpScale: 1 + - _ClearCoatMask: 0 + - _ClearCoatSmoothness: 0 + - _CoatMask: 0 + - _Cull: 2 + - _CullMode: 2 + - _CullModeForward: 2 + - _Cutoff: 0.5 + - _DepthOffsetEnable: 0 + - _DetailAlbedoMapScale: 1 + - _DetailAlbedoScale: 1 + - _DetailNormalMapScale: 1 + - _DetailNormalScale: 1 + - _DetailSmoothnessScale: 1 + - _DiffusionProfile: 0 + - _DiffusionProfileHash: 0 + - _DisplacementLockObjectScale: 1 + - _DisplacementLockTilingScale: 1 + - _DisplacementMode: 0 + - _DoubleSidedEnable: 0 + - _DoubleSidedGIMode: 0 + - _DoubleSidedNormalMode: 1 + - _DstBlend: 0 + - _DstBlend2: 0 + - _DstBlendAlpha: 0 + - _EmissiveColorMode: 1 + - _EmissiveExposureWeight: 1 + - _EmissiveIntensity: 1 + - _EmissiveIntensityUnit: 0 + - _EnableBlendModePreserveSpecularLighting: 1 + - _EnableFogOnTransparent: 1 + - _EnableGeometricSpecularAA: 0 + - _EnergyConservingSpecularColor: 1 + - _EnvironmentReflections: 1 + - _GlossMapScale: 1 + - _Glossiness: 0 + - _GlossyReflections: 1 + - _HeightAmplitude: 0.02 + - _HeightCenter: 0.5 + - _HeightMapParametrization: 0 + - _HeightMax: 1 + - _HeightMin: -1 + - _HeightOffset: 0 + - _HeightPoMAmplitude: 2 + - _HeightTessAmplitude: 2 + - _HeightTessCenter: 0.5 + - _InvTilingScale: 1 + - _Ior: 1.5 + - _IridescenceMask: 1 + - _IridescenceThickness: 1 + - _LinkDetailsWithBase: 1 + - _MaterialID: 1 + - _Metallic: 0 + - _MetallicRemapMax: 0 + - _MetallicRemapMin: 0 + - _Mode: 0 + - _NormalMapSpace: 0 + - _NormalScale: 1 + - _ObjectSpaceUVMapping: 0 + - _ObjectSpaceUVMappingEmissive: 0 + - _OcclusionStrength: 1 + - _OpaqueCullMode: 2 + - _PPDLodThreshold: 5 + - _PPDMaxSamples: 15 + - _PPDMinSamples: 5 + - _PPDPrimitiveLength: 1 + - _PPDPrimitiveWidth: 1 + - _Parallax: 0.02 + - _PerPixelSorting: 0 + - _QueueOffset: 0 + - _RayTracing: 0 + - _ReceiveShadows: 1 + - _ReceivesSSR: 1 + - _ReceivesSSRTransparent: 0 + - _RefractionModel: 0 + - _Smoothness: 0 + - _SmoothnessRemapMax: 1 + - _SmoothnessRemapMin: 0 + - _SmoothnessTextureChannel: 0 + - _SpecularAAScreenSpaceVariance: 0.1 + - _SpecularAAThreshold: 0.2 + - _SpecularHighlights: 1 + - _SpecularOcclusionMode: 1 + - _SrcBlend: 1 + - _SrcBlendAlpha: 1 + - _StencilRef: 0 + - _StencilRefDepth: 8 + - _StencilRefGBuffer: 10 + - _StencilRefMV: 40 + - _StencilWriteMask: 6 + - _StencilWriteMaskDepth: 9 + - _StencilWriteMaskGBuffer: 15 + - _StencilWriteMaskMV: 41 + - _SubsurfaceMask: 1 + - _SupportDecals: 1 + - _Surface: 0 + - _SurfaceType: 0 + - _TexWorldScale: 1 + - _TexWorldScaleEmissive: 1 + - _Thickness: 1 + - _TransmissionEnable: 1 + - _TransmissionMask: 1 + - _TransparentBackfaceEnable: 0 + - _TransparentCullMode: 2 + - _TransparentDepthPostpassEnable: 0 + - _TransparentDepthPrepassEnable: 0 + - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 + - _TransparentZWrite: 0 + - _UVBase: 0 + - _UVDetail: 0 + - _UVEmissive: 0 + - _UVSec: 0 + - _UseEmissiveIntensity: 0 + - _UseShadowThreshold: 0 + - _WorkflowMode: 1 + - _ZTestDepthEqualForOpaque: 3 + - _ZTestGBuffer: 4 + - _ZTestTransparent: 4 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 0.9622642, g: 0.9622642, b: 0.9622642, a: 1} + - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 0.9622641, g: 0.9622641, b: 0.9622641, a: 1} + - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} + - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} + - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} + - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} + - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} + - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} + - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1} + - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} + - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} + - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} + m_BuildTextureStacks: [] + m_AllowLocking: 1 diff --git a/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material White.mat.meta b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material White.mat.meta new file mode 100644 index 0000000..72e1be2 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material White.mat.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: d9153fcff3f6ea841adaf48d8126e8ef +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Sample Scene/Sample Scene SSGI URP/Material White.mat + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts.meta b/Assets/Plugins/HTraceSSGI/Scripts.meta new file mode 100644 index 0000000..29e9db8 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5699a0ef0e92fc04c8113e890307e4d2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data.meta new file mode 100644 index 0000000..34654a2 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1ad0041b45384f34390fd7a858775b12 +timeCreated: 1674799562 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public.meta new file mode 100644 index 0000000..61bfbbb --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d4c715d58c472f42a3bc5699eeeedcb +timeCreated: 1735034400 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DebugSettings.cs b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DebugSettings.cs new file mode 100644 index 0000000..e7eb166 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DebugSettings.cs @@ -0,0 +1,21 @@ +//pipelinedefine +#define H_URP + +using System; +using HTraceSSGI.Scripts.Globals; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Data.Public +{ + [Serializable] + public class DebugSettings + { + public bool ShowBowels = false; + public bool ShowFullDebugLog = false; + public LayerMask HTraceLayer = ~0; + + public bool TestCheckBox1; + public bool TestCheckBox2; + public bool TestCheckBox3; + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DebugSettings.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DebugSettings.cs.meta new file mode 100644 index 0000000..683aff7 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DebugSettings.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5b9df31ca246dfc47be48062d77712a0 +timeCreated: 1734159459 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Data/Public/DebugSettings.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DenoisingSettings.cs b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DenoisingSettings.cs new file mode 100644 index 0000000..9827f79 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DenoisingSettings.cs @@ -0,0 +1,122 @@ +//pipelinedefine +#define H_URP + +using System; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Data.Public +{ + [Serializable] + public class DenoisingSettings + { + // ----------------------------------------------- DENOISING ----------------------------------------------- + + [SerializeField] + public BrightnessClamp BrightnessClamp = BrightnessClamp.Automatic; + + [SerializeField] + private float _maxValueBrightnessClamp + = 1.0f; + /// + /// + /// + /// [1.0;30.0] + [HExtensions.HRangeAttribute(1.0f,30.0f)] + public float MaxValueBrightnessClamp + { + get => _maxValueBrightnessClamp; + set + { + if (Mathf.Abs(value - _maxValueBrightnessClamp) < Mathf.Epsilon) + return; + + _maxValueBrightnessClamp = HExtensions.Clamp(value, typeof(DenoisingSettings), nameof(DenoisingSettings.MaxValueBrightnessClamp)); + } + } + + [SerializeField] + private float _maxDeviationBrightnessClamp + = 3.0f; + + + /// + /// + /// + /// [1.0;5.0] + [HExtensions.HRangeAttribute(1.0f,5.0f)] + public float MaxDeviationBrightnessClamp + { + get => _maxDeviationBrightnessClamp; + set + { + if (Mathf.Abs(value - _maxDeviationBrightnessClamp) < Mathf.Epsilon) + return; + + _maxDeviationBrightnessClamp = HExtensions.Clamp(value, typeof(DenoisingSettings), nameof(DenoisingSettings.MaxDeviationBrightnessClamp)); + } + } + + // ----------------------------------------------- ReSTIR Validation ----------------------------------------------- + + [SerializeField] + public bool HalfStepValidation = false; + + [SerializeField] + public bool SpatialOcclusionValidation = true; + + [SerializeField] + public bool TemporalLightingValidation = true; + + [SerializeField] + public bool TemporalOcclusionValidation = true; + + + // ----------------------------------------------- Spatial ----------------------------------------------- + + [SerializeField] + private float _spatialRadius = 0.6f; + /// + /// + /// + /// [0.0;1.0] + [HExtensions.HRangeAttribute(0.0f,1.0f)] + public float SpatialRadius + { + get => _spatialRadius; + set + { + if (Mathf.Abs(value - _spatialRadius) < Mathf.Epsilon) + return; + + _spatialRadius = HExtensions.Clamp(value, typeof(DenoisingSettings), nameof(DenoisingSettings.SpatialRadius)); + } + } + + [SerializeField] + private float _adaptivity = 0.9f; + /// + /// + /// + /// [0.0;1.0] + [HExtensions.HRangeAttribute(0.0f,1.0f)] + public float Adaptivity + { + get => _adaptivity; + set + { + if (Mathf.Abs(value - _adaptivity) < Mathf.Epsilon) + return; + + _adaptivity = HExtensions.Clamp(value, typeof(DenoisingSettings), nameof(DenoisingSettings.Adaptivity)); + } + } + + [SerializeField] + public bool RecurrentBlur = false; + + [SerializeField] + public bool FireflySuppression = true; + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DenoisingSettings.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DenoisingSettings.cs.meta new file mode 100644 index 0000000..120bda6 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/DenoisingSettings.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 360288ad30824b8eaa4113b727ffb011 +timeCreated: 1741602380 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Data/Public/DenoisingSettings.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/GeneralSettings.cs b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/GeneralSettings.cs new file mode 100644 index 0000000..0895b44 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/GeneralSettings.cs @@ -0,0 +1,129 @@ +//pipelinedefine +#define H_URP + +using System; +using HTraceSSGI.Scripts.Extensions; +using UnityEngine; +using HTraceSSGI.Scripts.Globals; + +namespace HTraceSSGI.Scripts.Data.Public +{ + [Serializable] + public class GeneralSettings + { + public DebugMode DebugMode = DebugMode.None; + public HBuffer HBuffer = HBuffer.Multi; + + [SerializeField] + public bool MetallicIndirectFallback = false; + [SerializeField] + public bool AmbientOverride = true; + + public bool Multibounce = true; + +#if UNITY_2023_3_OR_NEWER + public RenderingLayerMask ExcludeCastingMask = 0; + public RenderingLayerMask ExcludeReceivingMask = 0; +#endif + + [SerializeField] + public FallbackType FallbackType = FallbackType.None; + + [SerializeField] + private float _skyIntensity = 0.5f; + /// + /// + /// + /// [0.0;1.0] + [HExtensions.HRangeAttribute(0.0f,1.0f)] + public float SkyIntensity + { + get => _skyIntensity; + set + { + if (Mathf.Abs(value - _skyIntensity) < Mathf.Epsilon) + return; + + _skyIntensity = HExtensions.Clamp(value, typeof(GeneralSettings), nameof(GeneralSettings.SkyIntensity)); + } + } + + [SerializeField] + private float _viewBias = 0.0f; + /// + /// + /// + /// [0.0;2.0] + [HExtensions.HRangeAttribute(0.0f,2.0f)] + public float ViewBias + { + get => _viewBias; + set + { + if (Mathf.Abs(value - _viewBias) < Mathf.Epsilon) + return; + + _viewBias = HExtensions.Clamp(value, typeof(GeneralSettings), nameof(GeneralSettings.ViewBias)); + } + } + + [SerializeField] + private float _normalBias = 0.33f; + /// + /// + /// + /// [0.0;4.0] + [HExtensions.HRangeAttribute(0.0f,2.0f)] + public float NormalBias + { + get => _normalBias; + set + { + if (Mathf.Abs(value - _normalBias) < Mathf.Epsilon) + return; + + _normalBias = HExtensions.Clamp(value, typeof(GeneralSettings), nameof(GeneralSettings.NormalBias)); + } + } + + [SerializeField] + private float _samplingNoise = 0.1f; + /// + /// + /// + /// [0.0;1.0] + [HExtensions.HRangeAttribute(0.0f,1.0f)] + public float SamplingNoise + { + get => _samplingNoise; + set + { + if (Mathf.Abs(value - _samplingNoise) < Mathf.Epsilon) + return; + + _samplingNoise = HExtensions.Clamp(value, typeof(GeneralSettings), nameof(GeneralSettings.SamplingNoise)); + } + } + + [SerializeField] + private float _intensityMultiplier = 1f; + /// + /// + /// + /// [0.0;1.0] + [HExtensions.HRangeAttribute(0.0f,1.0f)] + public float IntensityMultiplier + { + get => _intensityMultiplier; + set + { + if (Mathf.Abs(value - _intensityMultiplier) < Mathf.Epsilon) + return; + + _intensityMultiplier = HExtensions.Clamp(value, typeof(GeneralSettings), nameof(GeneralSettings.IntensityMultiplier)); + } + } + + public bool DenoiseFallback = true; + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/GeneralSettings.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/GeneralSettings.cs.meta new file mode 100644 index 0000000..b5af0f6 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/GeneralSettings.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 4af08f11ccfe6994a994a99e74d35b5f +timeCreated: 1674799588 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Data/Public/GeneralSettings.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIPresetData.cs b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIPresetData.cs new file mode 100644 index 0000000..7adc683 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIPresetData.cs @@ -0,0 +1,246 @@ +//pipelinedefine +#define H_URP + +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Editor; +using HTraceSSGI.Scripts.Globals; +using UnityEngine; +using UnityEngine.Rendering; +using HTraceSSGI.Scripts.Infrastructure.URP; + +namespace HTraceSSGI.Scripts.Data.Public +{ + internal static class HTraceSSGIPresetData + { + public static void ApplyPresetVolume(HTraceSSGIVolumeEditorURP hTraceSSGIVolumeEditorUrp, HTraceSSGIPreset preset) + { + var stack = VolumeManager.instance.stack; + HTraceSSGIVolume volume = stack?.GetComponent(); + if (volume == null) return; + + HTraceSSGIProfile profile = CreatePresetProfile(HTraceSSGISettings.ActiveProfile, preset); + if (profile == null) return; + + // General Settings + hTraceSSGIVolumeEditorUrp.p_DebugMode.value.enumValueIndex = (int)profile.GeneralSettings.DebugMode; + hTraceSSGIVolumeEditorUrp.p_DebugMode.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_FallbackType.value.enumValueIndex = (int)profile.GeneralSettings.FallbackType; + hTraceSSGIVolumeEditorUrp.p_FallbackType.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_SkyIntensity.value.floatValue = profile.GeneralSettings.SkyIntensity; + hTraceSSGIVolumeEditorUrp.p_SkyIntensity.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_DenoiseFallback.value.boolValue = profile.GeneralSettings.DenoiseFallback; + hTraceSSGIVolumeEditorUrp.p_DenoiseFallback.overrideState.boolValue = true; + + // Visuals + hTraceSSGIVolumeEditorUrp.p_BackfaceLighting.value.floatValue = profile.SSGISettings.BackfaceLighting; + hTraceSSGIVolumeEditorUrp.p_BackfaceLighting.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_MaxRayLength.value.floatValue = profile.SSGISettings.MaxRayLength; + hTraceSSGIVolumeEditorUrp.p_MaxRayLength.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_ThicknessMode.value.enumValueIndex = (int)profile.SSGISettings.ThicknessMode; + hTraceSSGIVolumeEditorUrp.p_ThicknessMode.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_Thickness.value.floatValue = profile.SSGISettings.Thickness; + hTraceSSGIVolumeEditorUrp.p_Thickness.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_Falloff.value.floatValue = profile.SSGISettings.Falloff; + hTraceSSGIVolumeEditorUrp.p_Falloff.overrideState.boolValue = true; + + // Quality - Tracing + hTraceSSGIVolumeEditorUrp.p_RayCount.value.intValue = profile.SSGISettings.RayCount; + hTraceSSGIVolumeEditorUrp.p_RayCount.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_StepCount.value.intValue = profile.SSGISettings.StepCount; + hTraceSSGIVolumeEditorUrp.p_StepCount.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_RefineIntersection.value.boolValue = profile.SSGISettings.RefineIntersection; + hTraceSSGIVolumeEditorUrp.p_RefineIntersection.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_FullResolutionDepth.value.boolValue = profile.SSGISettings.FullResolutionDepth; + hTraceSSGIVolumeEditorUrp.p_FullResolutionDepth.overrideState.boolValue = true; + + // Quality - Rendering + hTraceSSGIVolumeEditorUrp.p_Checkerboard.value.boolValue = profile.SSGISettings.Checkerboard; + hTraceSSGIVolumeEditorUrp.p_Checkerboard.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_RenderScale.value.floatValue = profile.SSGISettings.RenderScale; + hTraceSSGIVolumeEditorUrp.p_RenderScale.overrideState.boolValue = true; + + // Denoising + hTraceSSGIVolumeEditorUrp.p_BrightnessClamp.value.enumValueIndex = (int)profile.DenoisingSettings.BrightnessClamp; + hTraceSSGIVolumeEditorUrp.p_BrightnessClamp.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_MaxValueBrightnessClamp.value.floatValue = profile.DenoisingSettings.MaxValueBrightnessClamp; + hTraceSSGIVolumeEditorUrp.p_MaxValueBrightnessClamp.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_MaxDeviationBrightnessClamp.value.floatValue = profile.DenoisingSettings.MaxDeviationBrightnessClamp; + hTraceSSGIVolumeEditorUrp.p_MaxDeviationBrightnessClamp.overrideState.boolValue = true; + + // Denoising - Temporal Validation + hTraceSSGIVolumeEditorUrp.p_HalfStepValidation.value.boolValue = profile.DenoisingSettings.HalfStepValidation; + hTraceSSGIVolumeEditorUrp.p_HalfStepValidation.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_SpatialOcclusionValidation.value.boolValue = profile.DenoisingSettings.SpatialOcclusionValidation; + hTraceSSGIVolumeEditorUrp.p_SpatialOcclusionValidation.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_TemporalLightingValidation.value.boolValue = profile.DenoisingSettings.TemporalLightingValidation; + hTraceSSGIVolumeEditorUrp.p_TemporalLightingValidation.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_TemporalOcclusionValidation.value.boolValue = profile.DenoisingSettings.TemporalOcclusionValidation; + hTraceSSGIVolumeEditorUrp.p_TemporalOcclusionValidation.overrideState.boolValue = true; + + // Denoising - Spatial Filter + hTraceSSGIVolumeEditorUrp.p_SpatialRadius.value.floatValue = profile.DenoisingSettings.SpatialRadius; + hTraceSSGIVolumeEditorUrp.p_SpatialRadius.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_Adaptivity.value.floatValue = profile.DenoisingSettings.Adaptivity; + hTraceSSGIVolumeEditorUrp.p_Adaptivity.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_RecurrentBlur.value.boolValue = profile.DenoisingSettings.RecurrentBlur; + hTraceSSGIVolumeEditorUrp.p_RecurrentBlur.overrideState.boolValue = true; + + hTraceSSGIVolumeEditorUrp.p_FireflySuppression.value.boolValue = profile.DenoisingSettings.FireflySuppression; + hTraceSSGIVolumeEditorUrp.p_FireflySuppression.overrideState.boolValue = true; + } + + /// + /// Creates a profile from the specified preset type. + /// + public static HTraceSSGIProfile CreatePresetProfile(HTraceSSGIProfile activeProfile, HTraceSSGIPreset preset) + { + switch (preset) + { + case HTraceSSGIPreset.Performance: + return CreatePerformancePreset(activeProfile); + case HTraceSSGIPreset.Optimized: + return CreateOptimizedPreset(activeProfile); + case HTraceSSGIPreset.Balanced: + return CreateBalancedPreset(activeProfile); + case HTraceSSGIPreset.Quality: + return CreateQualityPreset(activeProfile); + default: + return null; + } + } + + public static HTraceSSGIProfile CreatePerformancePreset(HTraceSSGIProfile activeProfile) + { + var profile = Object.Instantiate(activeProfile); + + // Tracing + profile.SSGISettings.RayCount = 2; + profile.SSGISettings.StepCount = 28; + profile.SSGISettings.RefineIntersection = false; + profile.SSGISettings.FullResolutionDepth = false; + + // Rendering + profile.SSGISettings.Checkerboard = true; + profile.SSGISettings.RenderScale = 0.5f; + + // ReSTIR Validation + profile.DenoisingSettings.HalfStepValidation = true; + profile.DenoisingSettings.SpatialOcclusionValidation = true; + profile.DenoisingSettings.TemporalLightingValidation = false; + profile.DenoisingSettings.TemporalOcclusionValidation = false; + + // Spatial Filter + profile.DenoisingSettings.SpatialRadius = 0.65f; + profile.DenoisingSettings.Adaptivity = 0.7f; + profile.DenoisingSettings.RecurrentBlur = true; + profile.DenoisingSettings.FireflySuppression = false; + + return profile; + } + + public static HTraceSSGIProfile CreateOptimizedPreset(HTraceSSGIProfile activeProfile) + { + var profile = Object.Instantiate(activeProfile); + + // Tracing + profile.SSGISettings.RayCount = 3; + profile.SSGISettings.StepCount = 30; + profile.SSGISettings.RefineIntersection = true; + profile.SSGISettings.FullResolutionDepth = false; + + // Rendering + profile.SSGISettings.Checkerboard = true; + profile.SSGISettings.RenderScale = 0.75f; + + // ReSTIR Validation + profile.DenoisingSettings.HalfStepValidation = true; + profile.DenoisingSettings.SpatialOcclusionValidation = true; + profile.DenoisingSettings.TemporalLightingValidation = true; + profile.DenoisingSettings.TemporalOcclusionValidation = true; + + // Spatial Filter + profile.DenoisingSettings.SpatialRadius = 0.6f; + profile.DenoisingSettings.Adaptivity = 0.8f; + profile.DenoisingSettings.RecurrentBlur = true; + profile.DenoisingSettings.FireflySuppression = true; + + return profile; + } + + public static HTraceSSGIProfile CreateBalancedPreset(HTraceSSGIProfile activeProfile) + { + var profile = Object.Instantiate(activeProfile); + + // Tracing + profile.SSGISettings.RayCount = 3; + profile.SSGISettings.StepCount = 32; + profile.SSGISettings.RefineIntersection = true; + profile.SSGISettings.FullResolutionDepth = true; + + // Rendering + profile.SSGISettings.Checkerboard = true; + profile.SSGISettings.RenderScale = 1.0f; + + // ReSTIR Validation + profile.DenoisingSettings.HalfStepValidation = true; + profile.DenoisingSettings.SpatialOcclusionValidation = true; + profile.DenoisingSettings.TemporalLightingValidation = true; + profile.DenoisingSettings.TemporalOcclusionValidation = true; + + // Spatial Filter + profile.DenoisingSettings.SpatialRadius = 0.6f; + profile.DenoisingSettings.Adaptivity = 0.9f; + profile.DenoisingSettings.RecurrentBlur = false; + profile.DenoisingSettings.FireflySuppression = true; + + return profile; + } + + public static HTraceSSGIProfile CreateQualityPreset(HTraceSSGIProfile activeProfile) + { + var profile = Object.Instantiate(activeProfile); + + // Tracing + profile.SSGISettings.RayCount = 4; + profile.SSGISettings.StepCount = 36; + profile.SSGISettings.RefineIntersection = true; + profile.SSGISettings.FullResolutionDepth = true; + + // Rendering + profile.SSGISettings.Checkerboard = false; + profile.SSGISettings.RenderScale = 1.0f; + + // ReSTIR Validation + profile.DenoisingSettings.HalfStepValidation = false; + profile.DenoisingSettings.SpatialOcclusionValidation = true; + profile.DenoisingSettings.TemporalLightingValidation = true; + profile.DenoisingSettings.TemporalOcclusionValidation = true; + + // Spatial Filter + profile.DenoisingSettings.SpatialRadius = 0.6f; + profile.DenoisingSettings.Adaptivity = 0.9f; + profile.DenoisingSettings.RecurrentBlur = false; + profile.DenoisingSettings.FireflySuppression = true; + + return profile; + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIPresetData.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIPresetData.cs.meta new file mode 100644 index 0000000..422f23c --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIPresetData.cs.meta @@ -0,0 +1,18 @@ +fileFormatVersion: 2 +guid: 7a3e4f1b8c9d2a5e6f0b1c2d3e4f5a6b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Data/Public/HTraceSSGIPresetData.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIProfile.cs b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIProfile.cs new file mode 100644 index 0000000..61fb8cc --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIProfile.cs @@ -0,0 +1,91 @@ +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Editor; +using HTraceSSGI.Scripts.Globals; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Data.Private +{ + [CreateAssetMenu(fileName = "HTraceSSGI Profile", menuName = "HTrace/SSGI Profile", order = 251)] + [HelpURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK)] + public class HTraceSSGIProfile : ScriptableObject + { + [SerializeField] + public GeneralSettings GeneralSettings = new GeneralSettings(); + [SerializeField] + public SSGISettings SSGISettings = new SSGISettings(); + [SerializeField] + public DenoisingSettings DenoisingSettings = new DenoisingSettings(); + [SerializeField] + public DebugSettings DebugSettings = new DebugSettings(); + + /// + /// Applies a preset configuration to this profile. + /// This will overwrite all current settings with the preset values. + /// + /// The preset type to apply + public void ApplyPreset(HTraceSSGIPreset preset) + { + var presetProfile = HTraceSSGIPresetData.CreatePresetProfile(this, preset); + if (presetProfile == null) + return; + + // Copy all settings from preset profile + CopySettingsFrom(presetProfile); + } + + /// + /// Copies all settings from another profile to this profile. + /// + /// The profile to copy settings from + public void CopySettingsFrom(HTraceSSGIProfile sourceProfile) + { + if (sourceProfile == null) + return; + + // Copy General Settings + GeneralSettings.DebugMode = sourceProfile.GeneralSettings.DebugMode; + GeneralSettings.HBuffer = sourceProfile.GeneralSettings.HBuffer; + GeneralSettings.MetallicIndirectFallback = sourceProfile.GeneralSettings.MetallicIndirectFallback; + GeneralSettings.AmbientOverride = sourceProfile.GeneralSettings.AmbientOverride; + GeneralSettings.Multibounce = sourceProfile.GeneralSettings.Multibounce; +#if UNITY_2023_3_OR_NEWER + GeneralSettings.ExcludeCastingMask = sourceProfile.GeneralSettings.ExcludeCastingMask; + GeneralSettings.ExcludeReceivingMask = sourceProfile.GeneralSettings.ExcludeReceivingMask; +#endif + GeneralSettings.FallbackType = sourceProfile.GeneralSettings.FallbackType; + GeneralSettings.SkyIntensity = sourceProfile.GeneralSettings.SkyIntensity; + GeneralSettings.ViewBias = sourceProfile.GeneralSettings.ViewBias; + GeneralSettings.NormalBias = sourceProfile.GeneralSettings.NormalBias; + GeneralSettings.SamplingNoise = sourceProfile.GeneralSettings.SamplingNoise; + GeneralSettings.IntensityMultiplier = sourceProfile.GeneralSettings.IntensityMultiplier; + GeneralSettings.DenoiseFallback = sourceProfile.GeneralSettings.DenoiseFallback; + + // Copy SSGI Settings + SSGISettings.BackfaceLighting = sourceProfile.SSGISettings.BackfaceLighting; + SSGISettings.MaxRayLength = sourceProfile.SSGISettings.MaxRayLength; + SSGISettings.ThicknessMode = sourceProfile.SSGISettings.ThicknessMode; + SSGISettings.Thickness = sourceProfile.SSGISettings.Thickness; + SSGISettings.Intensity = sourceProfile.SSGISettings.Intensity; + SSGISettings.Falloff = sourceProfile.SSGISettings.Falloff; + SSGISettings.RayCount = sourceProfile.SSGISettings.RayCount; + SSGISettings.StepCount = sourceProfile.SSGISettings.StepCount; + SSGISettings.RefineIntersection = sourceProfile.SSGISettings.RefineIntersection; + SSGISettings.FullResolutionDepth = sourceProfile.SSGISettings.FullResolutionDepth; + SSGISettings.Checkerboard = sourceProfile.SSGISettings.Checkerboard; + SSGISettings.RenderScale = sourceProfile.SSGISettings.RenderScale; + + // Copy Denoising Settings + DenoisingSettings.BrightnessClamp = sourceProfile.DenoisingSettings.BrightnessClamp; + DenoisingSettings.MaxValueBrightnessClamp = sourceProfile.DenoisingSettings.MaxValueBrightnessClamp; + DenoisingSettings.MaxDeviationBrightnessClamp = sourceProfile.DenoisingSettings.MaxDeviationBrightnessClamp; + DenoisingSettings.HalfStepValidation = sourceProfile.DenoisingSettings.HalfStepValidation; + DenoisingSettings.SpatialOcclusionValidation = sourceProfile.DenoisingSettings.SpatialOcclusionValidation; + DenoisingSettings.TemporalLightingValidation = sourceProfile.DenoisingSettings.TemporalLightingValidation; + DenoisingSettings.TemporalOcclusionValidation = sourceProfile.DenoisingSettings.TemporalOcclusionValidation; + DenoisingSettings.SpatialRadius = sourceProfile.DenoisingSettings.SpatialRadius; + DenoisingSettings.Adaptivity = sourceProfile.DenoisingSettings.Adaptivity; + DenoisingSettings.RecurrentBlur = sourceProfile.DenoisingSettings.RecurrentBlur; + DenoisingSettings.FireflySuppression = sourceProfile.DenoisingSettings.FireflySuppression; + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIProfile.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIProfile.cs.meta new file mode 100644 index 0000000..727166d --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGIProfile.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 4cfa758cbcc84a509b4fbdd3a170a992 +timeCreated: 1745928800 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Data/Public/HTraceSSGIProfile.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGISettings.cs b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGISettings.cs new file mode 100644 index 0000000..03d6092 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGISettings.cs @@ -0,0 +1,29 @@ +//pipelinedefine +#define H_URP + +using HTraceSSGI.Scripts.Data.Private; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Data.Public +{ + /// + /// Change global HTrace SSGI settings, only for UseVolumes is disabled in HTrace SSGI Renderer Feature + /// + public static class HTraceSSGISettings + { + private static HTraceSSGIProfile _cachedProfile; + + public static HTraceSSGIProfile ActiveProfile + { + get + { + return _cachedProfile; + } + } + + public static void SetProfile(HTraceSSGIProfile profile) + { + _cachedProfile = profile; + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGISettings.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGISettings.cs.meta new file mode 100644 index 0000000..da997f9 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/HTraceSSGISettings.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d8283f6a3aff4a17b9edd5dfb9349cbe +timeCreated: 1761683456 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Data/Public/HTraceSSGISettings.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/SSGISettings.cs b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/SSGISettings.cs new file mode 100644 index 0000000..e4981e7 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/SSGISettings.cs @@ -0,0 +1,187 @@ +//pipelinedefine +#define H_URP + +using System; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Data.Public +{ + [Serializable] + public class SSGISettings + { + // ----------------------------------------------- Visuals ----------------------------------------------- + + [SerializeField] + private float _backfaceLighting = 0f; + /// + /// + /// + /// [0.0;1.0] + [HExtensions.HRangeAttribute(0.0f,1.0f)] + public float BackfaceLighting + { + get => _backfaceLighting; + set + { + if (Mathf.Abs(value - _backfaceLighting) < Mathf.Epsilon) + return; + + _backfaceLighting = HExtensions.Clamp(value, typeof(SSGISettings), nameof(SSGISettings.BackfaceLighting)); + } + } + + [SerializeField] + private float _maxRayLength = 100f; + /// + /// + /// + /// [0.0;infinity] + [HExtensions.HRangeAttribute(0.0f,float.MaxValue)] + public float MaxRayLength + { + get => _maxRayLength; + set + { + if (Mathf.Abs(value - _maxRayLength) < Mathf.Epsilon) + return; + + _maxRayLength = HExtensions.Clamp(value, typeof(SSGISettings), nameof(SSGISettings.MaxRayLength)); + } + } + + public ThicknessMode ThicknessMode = ThicknessMode.Relative; + + [SerializeField] + private float _thickness = 0.35f; + /// + /// + /// + /// [0.0;1.0] + [HExtensions.HRangeAttribute(0.0f,1.0f)] + public float Thickness + { + get => _thickness; + set + { + if (Mathf.Abs(value - _thickness) < Mathf.Epsilon) + return; + + _thickness = HExtensions.Clamp(value, typeof(SSGISettings), nameof(SSGISettings.Thickness)); + } + } + + [SerializeField] + private float _intensity = 1f; + /// + /// + /// + /// [0.1;5.0] + [HExtensions.HRangeAttribute(0.1f,5.0f)] + public float Intensity + { + get => _intensity; + set + { + if (Mathf.Abs(value - _intensity) < Mathf.Epsilon) + return; + + _intensity = HExtensions.Clamp(value, typeof(SSGISettings), nameof(SSGISettings.Intensity)); + } + } + + [SerializeField] + private float _falloff = 0.0f; + /// + /// + /// + /// [0.0;1.0] + [HExtensions.HRangeAttribute(0f,1.0f)] + public float Falloff + { + get => _falloff; + set + { + if (Mathf.Abs(value - _falloff) < Mathf.Epsilon) + return; + + _falloff = HExtensions.Clamp(value, typeof(SSGISettings), nameof(SSGISettings.Falloff)); + } + } + + // ----------------------------------------------- Quality ----------------------------------------------- + // ----------------------------------------------- Tracing ----------------------------------------------- + + [SerializeField] + private int _rayCount = 4; + /// + /// + /// + /// [2;16] + [HExtensions.HRangeAttribute(2,16)] + public int RayCount + { + get + { + return _rayCount; + } + set + { + if (value == _rayCount) + return; + + _rayCount = HExtensions.Clamp(value, typeof(SSGISettings), nameof(SSGISettings.RayCount)); + } + } + + [SerializeField] + private int _stepCount = 32; + /// + /// + /// + /// [8;64] + [HExtensions.HRangeAttribute(8,128)] + public int StepCount + { + get => _stepCount; + set + { + if (value == _stepCount) + return; + + _stepCount = HExtensions.Clamp(value, typeof(SSGISettings), nameof(SSGISettings.StepCount)); + } + } + + [SerializeField] + public bool RefineIntersection = true; + + [SerializeField] + public bool FullResolutionDepth = true; + + // ----------------------------------------------- Rendering ----------------------------------------------- + + [SerializeField] + public bool Checkerboard = false; + + [SerializeField] + private float _renderScale = 1f; + /// + /// + /// + /// [0.5;1.0] + [HExtensions.HRangeAttribute(0.5f,1.0f)] + public float RenderScale + { + get => _renderScale; + set + { + if (Mathf.Abs(value - _renderScale) < Mathf.Epsilon) + return; + + _renderScale = HExtensions.Clamp(value, typeof(SSGISettings), nameof(SSGISettings.RenderScale)); + } + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/SSGISettings.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/SSGISettings.cs.meta new file mode 100644 index 0000000..8024b44 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Data/Public/SSGISettings.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: ae21e1c951f5f51488fabe310b39c1e8 +timeCreated: 1731130646 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Data/Public/SSGISettings.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Default.asset b/Assets/Plugins/HTraceSSGI/Scripts/Default.asset new file mode 100644 index 0000000..15498bc --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Default.asset @@ -0,0 +1,122 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4881f9a2c4d568047b316028d20a8dca, type: 3} + m_Name: Default + m_EditorClassIdentifier: + singleSceneMode: 1 + dialogNoProbeVolumeInSetShown: 0 + settings: + m_Version: 1 + dilationSettings: + enableDilation: 0 + dilationDistance: 0 + dilationValidityThreshold: 0 + dilationIterations: 0 + squaredDistWeighting: 0 + virtualOffsetSettings: + useVirtualOffset: 0 + validityThreshold: 0 + outOfGeoOffset: 0 + searchMultiplier: 0 + rayOriginBias: -0.001 + collisionMask: + serializedVersion: 2 + m_Bits: 4294967291 + m_SceneGUIDs: [] + obsoleteScenesToNotBake: [] + m_LightingScenarios: + - Default + cellDescs: + m_Keys: + m_Values: [] + m_SerializedPerSceneCellList: [] + cellSharedDataAsset: + m_AssetGUID: + m_StreamableAssetPath: + m_ElementSize: 0 + m_StreamableCellDescs: + m_Keys: + m_Values: [] + m_Asset: {fileID: 0} + scenarios: + m_Keys: [] + m_Values: [] + cellBricksDataAsset: + m_AssetGUID: + m_StreamableAssetPath: + m_ElementSize: 0 + m_StreamableCellDescs: + m_Keys: + m_Values: [] + m_Asset: {fileID: 0} + cellSupportDataAsset: + m_AssetGUID: + m_StreamableAssetPath: + m_ElementSize: 0 + m_StreamableCellDescs: + m_Keys: + m_Values: [] + m_Asset: {fileID: 0} + chunkSizeInBricks: 0 + maxCellPosition: {x: 0, y: 0, z: 0} + minCellPosition: {x: 0, y: 0, z: 0} + globalBounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + bakedSimplificationLevels: 3 + bakedMinDistanceBetweenProbes: 1 + bakedProbeOcclusion: 0 + bakedSkyOcclusionValue: 0 + bakedSkyShadingDirectionValue: 0 + bakedProbeOffset: {x: 0, y: 0, z: 0} + bakedMaskCount: 1 + bakedLayerMasks: + x: 0 + y: 0 + z: 0 + w: 0 + maxSHChunkCount: -1 + L0ChunkSize: 0 + L1ChunkSize: 0 + L2TextureChunkSize: 0 + ProbeOcclusionChunkSize: 0 + sharedValidityMaskChunkSize: 0 + sharedSkyOcclusionL0L1ChunkSize: 0 + sharedSkyShadingDirectionIndicesChunkSize: 0 + sharedDataChunkSize: 0 + supportPositionChunkSize: 0 + supportValidityChunkSize: 0 + supportTouchupChunkSize: 0 + supportLayerMaskChunkSize: 0 + supportOffsetsChunkSize: 0 + supportDataChunkSize: 0 + lightingScenario: Default + version: 2 + freezePlacement: 0 + probeOffset: {x: 0, y: 0, z: 0} + simplificationLevels: 3 + minDistanceBetweenProbes: 1 + renderersLayerMask: + serializedVersion: 2 + m_Bits: 4294967295 + minRendererVolumeSize: 0.1 + skyOcclusion: 0 + skyOcclusionBakingSamples: 2048 + skyOcclusionBakingBounces: 2 + skyOcclusionAverageAlbedo: 0.6 + skyOcclusionBackFaceCulling: 0 + skyOcclusionShadingDirection: 0 + useRenderingLayers: 0 + renderingLayerMasks: [] + m_SceneBakeData: + m_Keys: [] + m_Values: [] diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Default.asset.meta b/Assets/Plugins/HTraceSSGI/Scripts/Default.asset.meta new file mode 100644 index 0000000..e4373dc --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Default.asset.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: 3efa5727399f12d458fa48a18a86be8d +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Default.asset + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor.meta new file mode 100644 index 0000000..50339c2 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e230c412c545e65479e9662bc63b1d47 +timeCreated: 1674796671 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HDEditorUtilsWrapper.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HDEditorUtilsWrapper.cs new file mode 100644 index 0000000..4ef6d70 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HDEditorUtilsWrapper.cs @@ -0,0 +1,305 @@ +#if UNITY_EDITOR +using System; +using System.Reflection; +using UnityEditor; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Editor +{ + public class HDEditorUtilsWrapper + { + #region Public Methods + + public static bool EnsureFrameSetting(int frameSettingsField) + { + try + { + Type hdEditorUtilsType = GetHDEditorUtilsType(); + if (hdEditorUtilsType == null) + { + return false; + } + + Type frameSettingsFieldType = GetFrameSettingsFieldType(); + if (frameSettingsFieldType == null) + { + return false; + } + + object frameSettingsFieldEnum = Enum.ToObject(frameSettingsFieldType, frameSettingsField); + + MethodInfo ensureFrameSettingMethod = hdEditorUtilsType.GetMethod("EnsureFrameSetting", + BindingFlags.NonPublic | BindingFlags.Static, + null, + new Type[] { frameSettingsFieldType }, + null); + + if (ensureFrameSettingMethod == null) + { + return false; + } + + object result = ensureFrameSettingMethod.Invoke(null, new object[] { frameSettingsFieldEnum }); + return result != null && (bool)result; + } + catch (Exception ex) + { + return false; + } + } + + public static void QualitySettingsHelpBox(string message, MessageType messageType, int expandableGroup, string propertyPath) + { + try + { + Type hdEditorUtilsType = GetHDEditorUtilsType(); + if (hdEditorUtilsType == null) + { + return; + } + + Type messageTypeEnum = typeof(MessageType); + Type expandableGroupType = GetExpandableGroupType(); + + if (expandableGroupType == null) + { + return; + } + + object messageTypeValue = Enum.ToObject(messageTypeEnum, messageType); + object expandableGroupValue = Enum.ToObject(expandableGroupType, expandableGroup); + + MethodInfo qualitySettingsHelpBoxMethod = hdEditorUtilsType.GetMethod("QualitySettingsHelpBox", + BindingFlags.NonPublic | BindingFlags.Static, + null, + new Type[] { typeof(string), messageTypeEnum, expandableGroupType, typeof(string) }, + null); + + if (qualitySettingsHelpBoxMethod == null) + { + return; + } + + qualitySettingsHelpBoxMethod.Invoke(null, new object[] { message, messageTypeValue, expandableGroupValue, propertyPath }); + } + catch (Exception ex) + { + //Debug.LogError($"Error calling HDEditorUtils.QualitySettingsHelpBox: {ex.Message}"); + } + } + + public static void QualitySettingsHelpBoxWithSection(string message, MessageType messageType, int expandableGroup, int expandableSection, string propertyPath) + { + try + { + Type hdEditorUtilsType = GetHDEditorUtilsType(); + if (hdEditorUtilsType == null) + { + Debug.LogError("Failed to find HDEditorUtils type"); + return; + } + + Type messageTypeEnum = typeof(MessageType); + Type expandableGroupType = GetExpandableGroupType(); + + if (expandableGroupType == null) + { + Debug.LogError("Failed to find ExpandableGroup type"); + return; + } + + object messageTypeValue = Enum.ToObject(messageTypeEnum, messageType); + object expandableGroupValue = Enum.ToObject(expandableGroupType, expandableGroup); + + MethodInfo[] methods = hdEditorUtilsType.GetMethods(BindingFlags.NonPublic | BindingFlags.Static); + MethodInfo genericMethod = null; + + foreach (var method in methods) + { + if (method.Name == "QualitySettingsHelpBox" && + method.IsGenericMethodDefinition && + method.GetParameters().Length == 5) + { + genericMethod = method; + break; + } + } + + if (genericMethod == null) + { + Debug.LogError("Failed to find generic QualitySettingsHelpBox method"); + return; + } + + Type expandableLightingType = GetExpandableLightingType(); + if (expandableLightingType == null) + { + expandableLightingType = expandableGroupType; + } + + MethodInfo concreteMethod = genericMethod.MakeGenericMethod(expandableLightingType); + + object expandableSectionValue = Enum.ToObject(expandableLightingType, expandableSection); + + concreteMethod.Invoke(null, new object[] { message, messageTypeValue, expandableGroupValue, expandableSectionValue, propertyPath }); + } + catch (Exception ex) + { + Debug.LogError($"Error calling HDEditorUtils.QualitySettingsHelpBox with section: {ex.Message}"); + } + } + + #endregion + + #region Helper Methods + + private static Type GetHDEditorUtilsType() + { + Type hdEditorUtilsType = Type.GetType("UnityEditor.Rendering.HighDefinition.HDEditorUtils, Unity.RenderPipelines.HighDefinition.Editor"); + + if (hdEditorUtilsType == null) + { + var assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); + foreach (var assembly in assemblies) + { + hdEditorUtilsType = assembly.GetType("UnityEditor.Rendering.HighDefinition.HDEditorUtils"); + if (hdEditorUtilsType != null) break; + } + } + + return hdEditorUtilsType; + } + + private static Type GetFrameSettingsFieldType() + { + Type frameSettingsFieldType = Type.GetType("UnityEngine.Rendering.HighDefinition.FrameSettingsField, Unity.RenderPipelines.HighDefinition.Runtime"); + + if (frameSettingsFieldType == null) + { + var assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); + foreach (var assembly in assemblies) + { + frameSettingsFieldType = assembly.GetType("UnityEngine.Rendering.HighDefinition.FrameSettingsField"); + if (frameSettingsFieldType != null) break; + } + } + + return frameSettingsFieldType; + } + + private static Type GetExpandableGroupType() + { + Type hdrpUIType = GetHDRPUIType(); + if (hdrpUIType == null) return null; + + return hdrpUIType.GetNestedType("ExpandableGroup", BindingFlags.NonPublic | BindingFlags.Public); + } + + private static Type GetExpandableLightingType() + { + Type hdrpUIType = GetHDRPUIType(); + if (hdrpUIType == null) return null; + + return hdrpUIType.GetNestedType("ExpandableLighting", BindingFlags.NonPublic | BindingFlags.Public); + } + + private static Type GetHDRPUIType() + { + Type hdrpUIType = Type.GetType("UnityEditor.Rendering.HighDefinition.HDRenderPipelineUI, Unity.RenderPipelines.HighDefinition.Editor"); + + if (hdrpUIType == null) + { + var assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); + foreach (var assembly in assemblies) + { + hdrpUIType = assembly.GetType("UnityEditor.Rendering.HighDefinition.HDRenderPipelineUI"); + if (hdrpUIType != null) break; + } + } + + return hdrpUIType; + } + + public static int GetFrameSettingsFieldValue(string fieldName) + { + try + { + Type frameSettingsFieldType = GetFrameSettingsFieldType(); + if (frameSettingsFieldType == null) + return -1; + + object enumValue = Enum.Parse(frameSettingsFieldType, fieldName); + return (int)enumValue; + } + catch (Exception ex) + { + Debug.LogError($"Error when get FrameSettingsField.{fieldName}: {ex.Message}"); + return -1; + } + } + + // internal enum ExpandableGroup + // { + // Rendering = 1 << 4, + // Lighting = 1 << 5, + // LightingTiers = 1 << 6, + // Material = 1 << 7, + // PostProcess = 1 << 8, + // PostProcessTiers = 1 << 9, + // XR = 1 << 10, + // VirtualTexturing = 1 << 11, + // Volumes = 1 << 12 + // } + + public static int GetExpandableGroupValue(string groupName) + { + try + { + Type expandableGroupType = GetExpandableGroupType(); + if (expandableGroupType == null) + return -1; + + object enumValue = Enum.Parse(expandableGroupType, groupName); + return (int)enumValue; + } + catch (Exception ex) + { + Debug.LogError($"Error when get ExpandableGroup.{groupName}: {ex.Message}"); + return -1; + } + } + + // internal enum ExpandableLighting + // { + // Volumetric = 1 << 0, + // ProbeVolume = 1 << 1, + // Cookie = 1 << 2, + // Reflection = 1 << 3, + // Sky = 1 << 4, + // // Illegal index 1 << 5 since parent Lighting section index is using it + // LightLoop = 1 << 6, + // Shadow = 1 << 7 + // } + + public static int GetExpandableLightingValue(string lightingName) + { + try + { + Type expandableLightingType = GetExpandableLightingType(); + if (expandableLightingType == null) + return -1; + + object enumValue = Enum.Parse(expandableLightingType, lightingName); + return (int)enumValue; + } + catch (Exception ex) + { + Debug.LogError($"Error when get ExpandableLighting.{lightingName}: {ex.Message}"); + return -1; + } + } + + #endregion + } +} +#endif diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HDEditorUtilsWrapper.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HDEditorUtilsWrapper.cs.meta new file mode 100644 index 0000000..0f09f0a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HDEditorUtilsWrapper.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d6c5a454614b45b1b4d9c443d62ee70b +timeCreated: 1758542957 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/HDEditorUtilsWrapper.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorStyles.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorStyles.cs new file mode 100644 index 0000000..27d3fbb --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorStyles.cs @@ -0,0 +1,133 @@ +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Editor +{ + internal static class HEditorStyles + { + public static float defaultLineSpace = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; + public static float additionalLineSpace = 10f; + public static float helpBoxHeight = EditorGUIUtility.singleLineHeight * 2; + public static float checkBoxOffsetWidth = 15f; + public static float checkBoxWidth = 15f; + public static float tabOffset = 8f; + + // Buttons name + public const string FixButtonName = "Fix"; + public const string ChangeButtonName = "Change"; + public const string OpenButtonName = "Open"; + + // Debug Tab + public static GUIContent DebugContent = new GUIContent("Debug"); + public static GUIContent hTraceLayerContent = new GUIContent("HTrace Layer", "Excludes objects from HTrace rendering on a per-layer basis"); + + // Foldout names + public static GUIContent GlobalSettings = new GUIContent("Global Settings"); + public static GUIContent PipelineIntegration = new GUIContent("Pipeline Integration"); + public static GUIContent Visuals = new GUIContent("Visuals"); + public static GUIContent Quality = new GUIContent("Quality"); + public static GUIContent Tracing = new GUIContent("Tracing"); + public static GUIContent Rendering = new GUIContent("Rendering"); + public static GUIContent Denoising = new GUIContent("Denoising"); + public static GUIContent ReSTIRValidation = new GUIContent("ReSTIR Validation"); + public static GUIContent ValidationTypes = new GUIContent("Validation Types:"); + public static GUIContent SpatialFilter = new GUIContent("Spatial Filter"); + public static GUIContent Debug = new GUIContent("Debug"); + + // General Tab + public static GUIContent DebugModeContent = new GUIContent("Debug Mode", "Visualizes the debug mode for different rendering components of H-Trace."); + public static GUIContent HBuffer = new GUIContent("Buffer", "Visualizes the debug mode for different buffers"); + + // Visuals + public static GUIContent ThicknessMode = new GUIContent("Thickness Mode", "Method for thickness estimation."); + public static GUIContent Thickness = new GUIContent("Thickness", "Virtual object thickness for ray intersections."); + public static GUIContent BackfaceLighting = new GUIContent("Backface Lighting", ""); + public static GUIContent MaxRayLength = new GUIContent("Max Ray Length", "Maximum ray distance in meters."); + public static GUIContent FallbackType = new("Fallback", "Method used when a ray misses."); + public static GUIContent SkyIntensity = new("Sky Intensity", "Brightness of Sky used for ray misses."); + public static GUIContent ExcludeCastingMask = new("Exclude Casting", "Prevents objects from casting GI."); + public static GUIContent ExcludeReceivingMask = new("Exclude Receiving", "Prevents objects from receiving screen-space GI."); + public static GUIContent NormalBias = new("APV Normal Bias"); + public static GUIContent ViewBias = new("APV View Bias"); + public static GUIContent SamplingNoise = new("APV Sampling Noise"); + public static GUIContent DenoiseFallback = new("Denoise Fallback", "Includes fallback lighting in denoising."); + public static GUIContent Intensity = new GUIContent("Intensity"); + public static GUIContent Falloff = new GUIContent("Falloff", "Softens indirect lighting over distance."); + + // Quality tab + // Tracing + public static GUIContent RayCount = new GUIContent("Ray Count", "Number of rays per pixel."); + public static GUIContent StepCount = new GUIContent("Step Count", "Number of steps per ray."); + public static GUIContent RefineIntersection = new GUIContent("Refine Intersection", "Extra check to confirm hits."); + public static GUIContent FullResolutionDepth = new GUIContent("Full Resolution Depth", "Uses full-res depth buffer for tracing."); + + //Rendering + public static GUIContent Checkerboard = new GUIContent("Checkerboard"); + public static GUIContent RenderScale = new GUIContent("Render Scale", "Local render scale of SSGI."); + + // Denoising tab + public static GUIContent BrightnessClamp = new("Brightness Clamp", "Method for clamping brightness at hit point."); + public static GUIContent MaxValueBrightnessClamp = new(" Max Value", "Maximum brightness allowed at hit points."); + public static GUIContent MaxDeviationBrightnessClamp = new(" Max Deviation", "Maximum standard deviation for brightness allowed at hit points."); + + // ReSTIR Validation + public static GUIContent HalfStepValidation = new("Half-Step Tracing", "Halves validation ray steps."); + public static GUIContent SpatialOcclusionValidation = new("Spatial Occlusion", "Preserves detail, reduces leaks during blur."); + public static GUIContent TemporalLightingValidation = new("Temporal Lighting", "Reacts faster to changing lights."); + public static GUIContent TemporalOcclusionValidation = new("Temporal Occlusion", "Reacts faster to moving shadows."); + + // Spatial Fliter + public static GUIContent SpatialRadius = new GUIContent("Radius", "Width of spatial filter."); + public static GUIContent Adaptivity = new GUIContent("Adaptivity", "Shrinks filter radius in geometry corners to preserve detail."); + public static GUIContent RecurrentBlur = new GUIContent("Recurrent Blur", "Stronger blur with low cost, less temporal reactivity."); + public static GUIContent FireflySuppression = new GUIContent("Firefly Suppression", "Removes bright outliers before denoising."); + + public static GUIStyle bold = new GUIStyle() + { + alignment = TextAnchor.MiddleLeft, + margin = new RectOffset(), + padding = new RectOffset(2, 0, 0, 0), + fontSize = 12, + normal = new GUIStyleState() + { + textColor = new Color(0.903f, 0.903f, 0.903f, 1f), + }, + fontStyle = FontStyle.Bold, + }; + + public static GUIStyle hiddenFoldout = new GUIStyle() + { + alignment = TextAnchor.MiddleLeft, + margin = new RectOffset(), + padding = new RectOffset(), + fontSize = 12, + normal = new GUIStyleState() + { + //textColor = new Color(0.703f, 0.703f, 0.703f, 1f), //default color + textColor = new Color(0.500f, 0.500f, 0.500f, 1f), + }, + fontStyle = FontStyle.Bold, + }; + + public static GUIStyle headerFoldout = new GUIStyle() + { + alignment = TextAnchor.MiddleLeft, + margin = new RectOffset(), + padding = new RectOffset(), + fontSize = 12, + normal = new GUIStyleState() + { + textColor = new Color(0.903f, 0.903f, 0.903f, 1f), + }, + fontStyle = FontStyle.Bold, + }; + + //buttons gui styles + public static Color warningBackgroundColor = new Color(1,1, 0); + public static Color warningColor = new Color(1, 1, 1); + + public static GUIStyle foldout = EditorStyles.foldout; + } +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorStyles.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorStyles.cs.meta new file mode 100644 index 0000000..116a521 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorStyles.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7b0103dbde10dd04eb57da14de01f702 +timeCreated: 1675231640 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/HEditorStyles.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorUtils.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorUtils.cs new file mode 100644 index 0000000..2e5717e --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorUtils.cs @@ -0,0 +1,243 @@ +#if UNITY_EDITOR +using System; +using UnityEditor; +using UnityEditor.AnimatedValues; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Editor +{ + public static class HEditorUtils + { + private static GUIStyle s_linkStyle; + private static GUIStyle s_separatorStyle; + + public static void DrawLinkRow(params (string label, Action onClick)[] links) + { + if (s_linkStyle == null) + { + s_linkStyle = new GUIStyle(GUI.skin.label) + { + fontStyle = FontStyle.Bold, + fontSize = 10, + alignment = TextAnchor.MiddleLeft, + normal = { textColor = new Color(0.35f, 0.55f, 0.75f) }, + hover = { textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black }, + // padding = new RectOffset(0, 0, 0, 0), + // margin = new RectOffset(0, 0, 0, 0) + }; + } + + if (s_separatorStyle == null) + { + s_separatorStyle = new GUIStyle(GUI.skin.label) + { + fontSize = 12, + alignment = TextAnchor.MiddleCenter, + normal = { textColor = new Color(0.9f, 0.9f, 0.9f,1f) }, + padding = new RectOffset(0, 0, 1, 0), + margin = new RectOffset(0, 0, 0, 0) + }; + } + + float maxWidth = EditorGUIUtility.currentViewWidth - 40; // scroll + float currentLineWidth = 0; + + GUILayout.BeginVertical(); + GUILayout.BeginHorizontal(); + + for (int i = 0; i < links.Length; i++) + { + var content = new GUIContent(links[i].label); + Vector2 size = s_linkStyle.CalcSize(content); + float neededWidth = size.x + 8; // text + | + + // new line + if (currentLineWidth + neededWidth > maxWidth) + { + GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal(); + currentLineWidth = 0; + } + + if (DrawClickableButton(links[i].label, onClick: links[i].onClick)) + { + // nothing here + } + currentLineWidth += size.x; + + if (i < links.Length - 1) + { + GUILayout.Space(8); + // GUILayout.Label("|", s_separatorStyle, GUILayout.Width(12)); + // GUILayout.Space(2); + + currentLineWidth += 8; // width | + } + } + + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + } + + public static bool DrawClickableButton(string text, Action onClick = null, GUIStyle baseStyle = null) + { + if (s_linkStyle == null) + { + s_linkStyle = new GUIStyle(baseStyle ?? GUI.skin.label) + { + fontStyle = FontStyle.Bold, + fontSize = 10, + alignment = TextAnchor.MiddleLeft, + normal = { textColor = new Color(0.35f, 0.55f, 0.75f) }, + hover = { textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black } + }; + } + + Rect rect = GUILayoutUtility.GetRect(new GUIContent(text), s_linkStyle, GUILayout.ExpandWidth(false)); + bool clicked = GUI.Button(rect, text, s_linkStyle); + + EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link); + + if (clicked) + onClick?.Invoke(); + + return clicked; + } + + public static bool DrawClickableLink(string text, string url, bool useEmoji = false, GUIStyle baseStyle = null) + { + if (s_linkStyle == null) + { + s_linkStyle = new GUIStyle(baseStyle ?? GUI.skin.label) + { + fontStyle = FontStyle.Bold, + fontSize = 10, + //normal = { textColor = new Color(0.20f, 0.50f, 0.80f) }, + normal = { textColor = new Color(0.35f, 0.55f, 0.75f) }, + hover = { textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black } + }; + } + + if (useEmoji) + text += " \U0001F517"; //\U0001F310 + bool clicked = GUILayout.Button(text, s_linkStyle, GUILayout.ExpandWidth(false)); + EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); + + if (clicked) + { + Application.OpenURL(url); + } + + return clicked; + } + + public readonly struct FoldoutScope : IDisposable + { + private readonly bool wasIndent; + + public FoldoutScope(AnimBool value, out bool shouldDraw, string label, bool indent = true, SerializedProperty toggle = null) + { + value.target = Foldout(value.target, label, toggle); + shouldDraw = EditorGUILayout.BeginFadeGroup(value.faded); + if (shouldDraw && indent) + { + Indent(); + wasIndent = true; + } + else + { + wasIndent = false; + } + } + + public void Dispose() + { + if (wasIndent) + EndIndent(); + EditorGUILayout.EndFadeGroup(); + } + } + + public static void HorizontalLine(float height = 1, float width = -1, Vector2 margin = new Vector2()) + { + GUILayout.Space(margin.x); + + var rect = EditorGUILayout.GetControlRect(false, height); + if (width > -1) + { + var centerX = rect.width / 2; + rect.width = width; + rect.x += centerX - width / 2; + } + + Color color = EditorStyles.label.active.textColor; + color.a = 0.5f; + EditorGUI.DrawRect(rect, color); + + GUILayout.Space(margin.y); + } + + public static bool Foldout(bool value, string label, SerializedProperty toggle = null) + { + bool _value; + EditorGUILayout.BeginVertical(EditorStyles.helpBox); + EditorGUILayout.BeginHorizontal(); + + if (toggle != null && !toggle.boolValue) + { + EditorGUI.BeginDisabledGroup(true); + _value = EditorGUILayout.Toggle(value, EditorStyles.foldout); + EditorGUI.EndDisabledGroup(); + + _value = false; + } + else + { + _value = EditorGUILayout.Toggle(value, EditorStyles.foldout); + } + + if (toggle != null) + { + EditorGUI.BeginChangeCheck(); + EditorGUILayout.PropertyField(toggle, GUIContent.none, GUILayout.Width(20)); + if (EditorGUI.EndChangeCheck() && toggle.boolValue) + _value = true; + } + + EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndVertical(); + + var rect = GUILayoutUtility.GetLastRect(); + rect.x += 20; + rect.width -= 20; + + if (toggle != null && !toggle.boolValue) + { + EditorGUI.BeginDisabledGroup(true); + EditorGUI.LabelField(rect, label, EditorStyles.boldLabel); + EditorGUI.EndDisabledGroup(); + } + else + { + EditorGUI.LabelField(rect, label, EditorStyles.boldLabel); + } + + return _value; + } + + public static void Indent() + { + EditorGUILayout.BeginHorizontal(); + GUILayout.Space(16); + EditorGUILayout.BeginVertical(); + } + + public static void EndIndent() + { + GUILayout.Space(10); + EditorGUILayout.EndVertical(); + EditorGUILayout.EndHorizontal(); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorUtils.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorUtils.cs.meta new file mode 100644 index 0000000..37dbe10 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HEditorUtils.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: f1ca94cbca25bbd46b2e81a98884081a +timeCreated: 1675348234 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/HEditorUtils.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIEditor.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIEditor.cs new file mode 100644 index 0000000..83011e1 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIEditor.cs @@ -0,0 +1,140 @@ +//pipelinedefine +#define H_URP + +#if UNITY_EDITOR + +using System.IO; +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using UnityEditor; +using UnityEngine; + +using HTraceSSGI.Scripts.Infrastructure.URP; + +namespace HTraceSSGI.Scripts.Editor +{ + public enum HTraceSSGIPreset + { + Performance = 1, + Optimized = 2, + Balanced = 3, + Quality = 4, + } + + [CustomEditor(typeof(HTraceSSGI))] + public class HTraceSSGIEditor : UnityEditor.Editor + { + private SerializedProperty _profile; + + HTraceSSGIProfile _cachedProfile; + UnityEditor.Editor _cachedProfileEditor; + + static GUIStyle _boxStyle; + + private void OnEnable() + { + _profile = serializedObject.FindProperty("Profile"); + } + + public override void OnInspectorGUI() + { + if (_boxStyle == null) + { + _boxStyle = new GUIStyle(GUI.skin.box); + _boxStyle.padding = new RectOffset(15, 10, 5, 5); + } + + if (HTraceSSGIRendererFeature.IsUseVolumes == true) + { + EditorGUILayout.HelpBox("\"Use Volumes\" checkbox in the HTrace SSGI Renderer feature is enabled, use the HTraceSSGI volume override in your scenes.", MessageType.Warning, wide: true); + return; + } + + EditorGUILayout.PropertyField(_profile); + + EditorGUILayout.Space(5); + + if (_profile.objectReferenceValue != null) + { + if (_cachedProfile != _profile.objectReferenceValue) + { + _cachedProfile = null; + } + if (_cachedProfile == null) + { + _cachedProfile = (HTraceSSGIProfile)_profile.objectReferenceValue; + _cachedProfileEditor = CreateEditor(_profile.objectReferenceValue); + } + + EditorGUILayout.BeginVertical(); + _cachedProfileEditor.OnInspectorGUI(); + + EditorGUILayout.Separator(); + + if (GUILayout.Button("Save As New Profile")) + { + ExportProfile(); + } + EditorGUILayout.EndVertical(); + } + else + { + EditorGUILayout.HelpBox("Create or assign a profile.", MessageType.Info); + if (GUILayout.Button("New Profile")) + { + CreateProfile(); + } + } + + serializedObject.ApplyModifiedProperties(); + } + + void CreateProfile() { + + var fp = CreateInstance(); + fp.name = "New HTrace SSGI Profile"; + + string path = "Assets"; + foreach (Object obj in Selection.GetFiltered(typeof(Object), SelectionMode.Assets)) { + path = AssetDatabase.GetAssetPath(obj); + if (File.Exists(path)) { + path = Path.GetDirectoryName(path); + } + break; + } + + string fullPath = path + "/" + fp.name + ".asset"; + fullPath = AssetDatabase.GenerateUniqueAssetPath(fullPath); + + AssetDatabase.CreateAsset(fp, fullPath); + AssetDatabase.SaveAssets(); + _profile.objectReferenceValue = fp; + EditorGUIUtility.PingObject(fp); + } + + void ExportProfile() { + var fp = (HTraceSSGIProfile)_profile.objectReferenceValue; + var newProfile = Instantiate(fp); + + string path = AssetDatabase.GetAssetPath(fp); + string fullPath = path; + if (string.IsNullOrEmpty(path)) { + path = "Assets"; + foreach (Object obj in Selection.GetFiltered(typeof(Object), SelectionMode.Assets)) { + path = AssetDatabase.GetAssetPath(obj); + if (File.Exists(path)) { + path = Path.GetDirectoryName(path); + } + break; + } + fullPath = path + "/" + fp.name + ".asset"; + } + fullPath = AssetDatabase.GenerateUniqueAssetPath(fullPath); + AssetDatabase.CreateAsset(newProfile, fullPath); + AssetDatabase.SaveAssets(); + _profile.objectReferenceValue = newProfile; + EditorGUIUtility.PingObject(fp); + } + } +} +#endif diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIEditor.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIEditor.cs.meta new file mode 100644 index 0000000..afce8ee --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIEditor.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1f39d10a78f94348bef222fc6f34a37a +timeCreated: 1761566211 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/HTraceSSGIEditor.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIProfileEditor.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIProfileEditor.cs new file mode 100644 index 0000000..621eb2d --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIProfileEditor.cs @@ -0,0 +1,456 @@ +//pipelinedefine +#define H_URP + +#if UNITY_EDITOR +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Editor.WindowsAndMenu; +using HTraceSSGI.Scripts.Globals; +using UnityEditor; +using UnityEditor.AnimatedValues; +using UnityEditor.Rendering; +using UnityEngine; + + +namespace HTraceSSGI.Scripts.Editor +{ + [CustomEditor(typeof(HTraceSSGIProfile))] + internal class HTraceSSGIProfileEditor : UnityEditor.Editor + { + HTraceSSGIPreset _preset = HTraceSSGIPreset.Balanced; + + bool _globalSettingsTab = true; + bool _qualityTab = true; + bool _denoisingTab = true; + bool _debugTab = true; + + private AnimBool AnimBoolGeneralTab; + private AnimBool AnimBoolQualityTab; + private AnimBool AnimBoolDenoisingTab; + private AnimBool AnimBoolDebugTab; + private AnimBool AnimBoolEMPTY; + + bool _showPipelineIntegration = true; + bool _showVisualsArea = true; + bool _showTracingArea = true; + bool _showRenderingArea = true; + bool _showRestirValidationArea = true; + bool _showSpatialArea = true; + + SerializedProperty GeneralSettings; + SerializedProperty SSGISettings; + SerializedProperty DenoisingSettings; + SerializedProperty DebugSettings; + + // Debug Data + SerializedProperty EnableDebug; + SerializedProperty HTraceLayer; + + // General Tab + SerializedProperty DebugMode; + SerializedProperty HBuffer; + SerializedProperty MainCamera; + + SerializedProperty MetallicIndirectFallback; + SerializedProperty AmbientOverride; + SerializedProperty Multibounce; + + SerializedProperty ExcludeReceivingMask; + SerializedProperty ExcludeCastingMask; + SerializedProperty FallbackType; + SerializedProperty SkyIntensity; + //Apv + SerializedProperty ViewBias; + SerializedProperty NormalBias; + SerializedProperty SamplingNoise; + SerializedProperty DenoiseFallback; + + // Visuals + SerializedProperty BackfaceLighting; + SerializedProperty MaxRayLength; + SerializedProperty ThicknessMode; + SerializedProperty Thickness; + SerializedProperty Intensity; + SerializedProperty Falloff; + + // Quality tab + // Tracing + SerializedProperty RayCount; + SerializedProperty StepCount; + SerializedProperty RefineIntersection; + SerializedProperty FullResolutionDepth; + + // Rendering + SerializedProperty Checkerboard; + SerializedProperty RenderScale; + + // Denoising tab + SerializedProperty BrightnessClamp; + SerializedProperty MaxValueBrightnessClamp; + SerializedProperty MaxDeviationBrightnessClamp; + + // Temporal + SerializedProperty HalfStepValidation; + SerializedProperty SpatialOcclusionValidation; + SerializedProperty TemporalLightingValidation; + SerializedProperty TemporalOcclusionValidation; + + // Spatial Filter + SerializedProperty SpatialRadius; + SerializedProperty Adaptivity; + // SerializedProperty SpatialPassCount; + SerializedProperty RecurrentBlur; + SerializedProperty FireflySuppression; + + // Debug DEVS + SerializedProperty ShowBowels; + SerializedProperty ShowFullDebugLog; + SerializedProperty TestCheckBox1; + SerializedProperty TestCheckBox2; + SerializedProperty TestCheckBox3; + + private void OnEnable() + { + PropertiesRelative(); + + AnimBoolGeneralTab = new AnimBool(_globalSettingsTab); + AnimBoolGeneralTab.valueChanged.RemoveAllListeners(); + AnimBoolGeneralTab.valueChanged.AddListener(Repaint); + + AnimBoolQualityTab = new AnimBool(_qualityTab); + AnimBoolQualityTab.valueChanged.RemoveAllListeners(); + AnimBoolQualityTab.valueChanged.AddListener(Repaint); + + AnimBoolDenoisingTab = new AnimBool(_denoisingTab); + AnimBoolDenoisingTab.valueChanged.RemoveAllListeners(); + AnimBoolDenoisingTab.valueChanged.AddListener(Repaint); + + AnimBoolDebugTab = new AnimBool(_debugTab); + AnimBoolDebugTab.valueChanged.RemoveAllListeners(); + AnimBoolDebugTab.valueChanged.AddListener(Repaint); + + AnimBoolEMPTY = new AnimBool(false); + } + + protected virtual void OnSceneGUI() + { + HTraceSSGI hTraceSSGI = (HTraceSSGI)target; + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + UpdateStandartStyles(); + // base.OnInspectorGUI(); + //return; + + AnimBoolEMPTY = new AnimBool(false); + + Color standartBackgroundColor = GUI.backgroundColor; + Color standartColor = GUI.color; + + WarningsHandle(); + +// ------------------------------------- Global settings ---------------------------------------------------------- + + using (new HEditorUtils.FoldoutScope(AnimBoolGeneralTab, out var shouldDraw, "Global Settings")) + { + _globalSettingsTab = shouldDraw; + if (shouldDraw) + { + EditorGUILayout.Space(3f); + + EditorGUILayout.BeginHorizontal(); + _preset = (HTraceSSGIPreset)EditorGUILayout.EnumPopup(new GUIContent("Preset"), _preset); + if (GUILayout.Button("Apply", GUILayout.Width(60))) + { + HTraceSSGIProfile profileLocal = HTraceSSGISettings.ActiveProfile; + profileLocal.ApplyPreset(_preset); + EditorUtility.SetDirty(target); + } + EditorGUILayout.EndHorizontal(); + EditorGUILayout.Space(3f); + + serializedObject.Update(); + + EditorGUILayout.PropertyField(DebugMode, HEditorStyles.DebugModeContent); + if (DebugMode.enumValueIndex == 1) + EditorGUILayout.PropertyField(HBuffer, HEditorStyles.HBuffer); + EditorGUILayout.Space(5f); + + +#if UNITY_2023_3_OR_NEWER + EditorGUILayout.PropertyField(ExcludeCastingMask, HEditorStyles.ExcludeCastingMask); + EditorGUILayout.PropertyField(ExcludeReceivingMask, HEditorStyles.ExcludeReceivingMask); +#endif + EditorGUILayout.Space(3f); + + EditorGUILayout.PropertyField(FallbackType, HEditorStyles.FallbackType); + if ((Globals.FallbackType)FallbackType.enumValueIndex == Globals.FallbackType.Sky) + EditorGUILayout.Slider(SkyIntensity, 0.0f, 1.0f, HEditorStyles.SkyIntensity); + + _showPipelineIntegration = EditorGUILayout.BeginFoldoutHeaderGroup(_showPipelineIntegration, "Pipeline Integration"); + if (_showPipelineIntegration) + { + EditorGUI.indentLevel++; + EditorGUILayout.PropertyField(MetallicIndirectFallback, new GUIContent("Metallic Indirect Fallback")); + EditorGUILayout.PropertyField(AmbientOverride, new GUIContent("Ambient Override")); + if (RenderSettings.ambientIntensity > 1.0f && AmbientOverride.boolValue == true) + EditorGUILayout.HelpBox("Ambient Override may not work correctly when the Environment Lighting Multiplier is set above 1 !", MessageType.Warning); + EditorGUILayout.PropertyField(Multibounce, new GUIContent("Multibounce")); + EditorGUI.indentLevel--; + EditorGUILayout.Space(3f); + } + EditorGUILayout.EndFoldoutHeaderGroup(); + + EditorGUILayout.Space(3f); + + { + _showVisualsArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showVisualsArea, "Visuals"); + if (_showVisualsArea) + { + EditorGUI.indentLevel++; + + EditorGUILayout.Slider(BackfaceLighting, 0.0f, 1.0f, HEditorStyles.BackfaceLighting); + EditorGUILayout.PropertyField(MaxRayLength, HEditorStyles.MaxRayLength); + if (MaxRayLength.floatValue < 0) + MaxRayLength.floatValue = 0f; + EditorGUILayout.PropertyField(ThicknessMode, HEditorStyles.ThicknessMode); + EditorGUILayout.Slider(Thickness, 0.0f, 1.0f, HEditorStyles.Thickness); + EditorGUILayout.Slider(Intensity, 0.1f, 5.0f, HEditorStyles.Intensity); + EditorGUILayout.Slider(Falloff, 0.0f, 1.0f, HEditorStyles.Falloff); + EditorGUI.indentLevel--; + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(3f); + } + + + } + } + + // ------------------------------------- Quality ---------------------------------------------------------- + + using (new HEditorUtils.FoldoutScope(AnimBoolQualityTab, out var shouldDraw, "Quality")) + { + _qualityTab = shouldDraw; + if (shouldDraw) + { + EditorGUILayout.Space(3f); + _showTracingArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showTracingArea, "Tracing"); + if (_showTracingArea) + { + EditorGUI.indentLevel++; + + RayCount.intValue = EditorGUILayout.IntSlider(HEditorStyles.RayCount, RayCount.intValue, 2, 16); + StepCount.intValue = EditorGUILayout.IntSlider(HEditorStyles.StepCount, StepCount.intValue, 8, 64); + EditorGUILayout.PropertyField(RefineIntersection, HEditorStyles.RefineIntersection); + EditorGUILayout.PropertyField(FullResolutionDepth, HEditorStyles.FullResolutionDepth); + + EditorGUI.indentLevel--; + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(5f); + + _showRenderingArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showRenderingArea, "Rendering"); + if (_showRenderingArea) + { + EditorGUI.indentLevel++; + + EditorGUILayout.PropertyField(Checkerboard, HEditorStyles.Checkerboard); + EditorGUILayout.Slider(RenderScale, 0.5f, 1.0f, HEditorStyles.RenderScale); + RenderScale.floatValue = RenderScale.floatValue.RoundToCeilTail(2); + if (Mathf.Approximately(RenderScale.floatValue, 1.0f) == false) + { + EditorGUI.indentLevel++; + + EditorGUI.indentLevel--; + } + + EditorGUI.indentLevel--; + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(3f); + } + } + + // ------------------------------------- Denoising ---------------------------------------------------------- + + using (new HEditorUtils.FoldoutScope(AnimBoolDenoisingTab, out var shouldDraw, "Denoising")) + { + _denoisingTab = shouldDraw; + if (shouldDraw) + { + EditorGUILayout.Space(3f); + + EditorGUILayout.PropertyField(BrightnessClamp, HEditorStyles.BrightnessClamp); + if ((BrightnessClamp)BrightnessClamp.enumValueIndex == Globals.BrightnessClamp.Manual) + EditorGUILayout.Slider(MaxValueBrightnessClamp, 1.0f, 30.0f, HEditorStyles.MaxValueBrightnessClamp); + if ((BrightnessClamp)BrightnessClamp.enumValueIndex == Globals.BrightnessClamp.Automatic) + EditorGUILayout.Slider(MaxDeviationBrightnessClamp, 1.0f, 5.0f, HEditorStyles.MaxDeviationBrightnessClamp); + EditorGUILayout.Space(5f); + + _showRestirValidationArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showRestirValidationArea, "ReSTIR Validation"); + if (_showRestirValidationArea) + { + EditorGUI.indentLevel++; + + EditorGUILayout.PropertyField(HalfStepValidation, HEditorStyles.HalfStepValidation); + EditorGUILayout.Space(3f); + + EditorGUILayout.LabelField(new GUIContent("Validation Types:"), HEditorStyles.bold); + EditorGUILayout.PropertyField(SpatialOcclusionValidation, HEditorStyles.SpatialOcclusionValidation); + EditorGUILayout.PropertyField(TemporalLightingValidation, HEditorStyles.TemporalLightingValidation); + EditorGUILayout.PropertyField(TemporalOcclusionValidation, HEditorStyles.TemporalOcclusionValidation); + + EditorGUI.indentLevel--; + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(5f); + + _showSpatialArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showSpatialArea, "Spatial Filter"); + if (_showSpatialArea) + { + EditorGUI.indentLevel++; + EditorGUILayout.Slider(SpatialRadius, 0.0f, 1.0f, HEditorStyles.SpatialRadius); + EditorGUILayout.Slider(Adaptivity, 0.0f, 1.0f, HEditorStyles.Adaptivity); + // SpatialPassCount.intValue = EditorGUILayout.IntSlider(HEditorStyles.SpatialPassCount, SpatialPassCount.intValue, 0, 4); + EditorGUILayout.PropertyField(RecurrentBlur, HEditorStyles.RecurrentBlur); + EditorGUILayout.PropertyField(FireflySuppression, HEditorStyles.FireflySuppression); + + EditorGUI.indentLevel--; + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(3f); + } + } + + // ------------------------------------- Debug settings ---------------------------------------------------------- + + + HEditorUtils.HorizontalLine(1f); + EditorGUILayout.Space(3f); + + //HEditorUtils.DrawClickableLink($"HTrace AO Version: {HNames.HTRACE_AO_VERSION}", HNames.HTRACE_AO_DOCUMENTATION_LINK, true); + HEditorUtils.DrawLinkRow( + ($"Documentation (v." + HNames.HTRACE_SSGI_VERSION + ")", () => Application.OpenURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK)), + ("Discord", () => Application.OpenURL(HNames.HTRACE_DISCORD_LINK)), + ("Bug report", () => HBugReporterWindow.ShowWindow()) + ); + + GUI.backgroundColor = standartBackgroundColor; + GUI.color = standartColor; + + serializedObject.ApplyModifiedProperties(); + } + + private void WarningsHandle() + { + } + + private void DebugPart() + { + using (new HEditorUtils.FoldoutScope(AnimBoolDebugTab, out var shouldDraw, HEditorStyles.DebugContent.text, toggle: EnableDebug)) + { + _debugTab = shouldDraw; + if (shouldDraw) + { + //EditorGUILayout.PropertyField(EnableDebug, HEditorStyles.OcclusionEnable); + + //if (EnableDebug.boolValue == true) + { + EditorGUILayout.PropertyField(HTraceLayer, HEditorStyles.hTraceLayerContent); + } + + EditorGUILayout.PropertyField(ShowBowels, new GUIContent("Show Bowels")); + ShowFullDebugLog.boolValue = EditorGUILayout.Toggle(new GUIContent("Show Full Debug Log"), ShowFullDebugLog.boolValue); + + TestCheckBox1.boolValue = EditorGUILayout.Toggle(new GUIContent("TestCheckBox1"), TestCheckBox1.boolValue); + TestCheckBox2.boolValue = EditorGUILayout.Toggle(new GUIContent("TestCheckBox2"), TestCheckBox2.boolValue); + TestCheckBox3.boolValue = EditorGUILayout.Toggle(new GUIContent("TestCheckBox3"), TestCheckBox3.boolValue); + + EditorGUILayout.Space(3); + } + } + } + + private void UpdateStandartStyles() + { + HEditorStyles.foldout.fontStyle = FontStyle.Bold; + } + + private void PropertiesRelative() + { + GeneralSettings = serializedObject.FindProperty("GeneralSettings"); + SSGISettings = serializedObject.FindProperty("SSGISettings"); + DenoisingSettings = serializedObject.FindProperty("DenoisingSettings"); + DebugSettings = serializedObject.FindProperty("DebugSettings"); + + // Debug Data + HTraceLayer = DebugSettings.FindPropertyRelative("HTraceLayer"); + ShowBowels = DebugSettings.FindPropertyRelative("ShowBowels"); + ShowFullDebugLog = DebugSettings.FindPropertyRelative("ShowFullDebugLog"); + TestCheckBox1 = DebugSettings.FindPropertyRelative("TestCheckBox1"); + TestCheckBox2 = DebugSettings.FindPropertyRelative("TestCheckBox2"); + TestCheckBox3 = DebugSettings.FindPropertyRelative("TestCheckBox3"); + + // Global Tab + DebugMode = GeneralSettings.FindPropertyRelative("DebugMode"); + HBuffer = GeneralSettings.FindPropertyRelative("HBuffer"); + ExcludeReceivingMask = GeneralSettings.FindPropertyRelative("ExcludeReceivingMask"); + ExcludeCastingMask = GeneralSettings.FindPropertyRelative("ExcludeCastingMask"); + MetallicIndirectFallback = GeneralSettings.FindPropertyRelative("MetallicIndirectFallback"); + AmbientOverride = GeneralSettings.FindPropertyRelative("AmbientOverride"); + Multibounce = GeneralSettings.FindPropertyRelative("Multibounce"); + FallbackType = GeneralSettings.FindPropertyRelative("FallbackType"); + SkyIntensity = GeneralSettings.FindPropertyRelative("_skyIntensity"); + ViewBias = GeneralSettings.FindPropertyRelative("_viewBias"); + NormalBias = GeneralSettings.FindPropertyRelative("_normalBias"); + SamplingNoise = GeneralSettings.FindPropertyRelative("_samplingNoise"); + DenoiseFallback = GeneralSettings.FindPropertyRelative("DenoiseFallback"); + + // Visuals + BackfaceLighting = SSGISettings.FindPropertyRelative("_backfaceLighting"); + MaxRayLength = SSGISettings.FindPropertyRelative("_maxRayLength"); + ThicknessMode = SSGISettings.FindPropertyRelative("ThicknessMode"); + Thickness = SSGISettings.FindPropertyRelative("_thickness"); + Intensity = SSGISettings.FindPropertyRelative("_intensity"); + Falloff = SSGISettings.FindPropertyRelative("_falloff"); + + // Quality tab + // Tracing + RayCount = SSGISettings.FindPropertyRelative("_rayCount"); + StepCount = SSGISettings.FindPropertyRelative("_stepCount"); + RefineIntersection = SSGISettings.FindPropertyRelative("RefineIntersection"); + FullResolutionDepth = SSGISettings.FindPropertyRelative("FullResolutionDepth"); + + // Rendering + Checkerboard = SSGISettings.FindPropertyRelative("Checkerboard"); + RenderScale = SSGISettings.FindPropertyRelative("_renderScale"); + + // Denoising tab + BrightnessClamp = DenoisingSettings.FindPropertyRelative("BrightnessClamp"); + MaxValueBrightnessClamp = DenoisingSettings.FindPropertyRelative("_maxValueBrightnessClamp"); + MaxDeviationBrightnessClamp = DenoisingSettings.FindPropertyRelative("_maxDeviationBrightnessClamp"); + + // ReSTIR Validation + HalfStepValidation = DenoisingSettings.FindPropertyRelative("HalfStepValidation"); + SpatialOcclusionValidation = DenoisingSettings.FindPropertyRelative("SpatialOcclusionValidation"); + TemporalLightingValidation = DenoisingSettings.FindPropertyRelative("TemporalLightingValidation"); + TemporalOcclusionValidation = DenoisingSettings.FindPropertyRelative("TemporalOcclusionValidation"); + + // Spatial + SpatialRadius = DenoisingSettings.FindPropertyRelative("_spatialRadius"); + Adaptivity = DenoisingSettings.FindPropertyRelative("_adaptivity"); + // SpatialPassCount = DenoisingData.FindPropertyRelative("_spatialPassCount"); + RecurrentBlur = DenoisingSettings.FindPropertyRelative("RecurrentBlur"); + FireflySuppression = DenoisingSettings.FindPropertyRelative("FireflySuppression"); + } + } +} +#endif diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIProfileEditor.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIProfileEditor.cs.meta new file mode 100644 index 0000000..9caeb27 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIProfileEditor.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2a391e47a8d563041a61da4e5d3d9d51 +timeCreated: 1674796690 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/HTraceSSGIProfileEditor.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIRendererFeatureEditor.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIRendererFeatureEditor.cs new file mode 100644 index 0000000..fff09a4 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIRendererFeatureEditor.cs @@ -0,0 +1,31 @@ +//pipelinedefine +#define H_URP + +#if UNITY_EDITOR +using HTraceSSGI.Scripts.Infrastructure.URP; +using UnityEditor; +using UnityEditor.Rendering.Universal; + +namespace HTraceSSGI.Scripts.Editor +{ + [CustomEditor(typeof(HTraceSSGIRendererFeature))] + public class HTraceSSGIRendererFeatureEditor : ScriptableRendererFeatureEditor + { + SerializedProperty useVolumes; + + private void OnEnable() + { + useVolumes = serializedObject.FindProperty("UseVolumes"); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + EditorGUILayout.PropertyField(useVolumes); + + serializedObject.ApplyModifiedProperties(); + } + } +} +#endif diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIRendererFeatureEditor.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIRendererFeatureEditor.cs.meta new file mode 100644 index 0000000..55353de --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIRendererFeatureEditor.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c07ed2e0332d41d28f81cb8f1976129b +timeCreated: 1761571199 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/HTraceSSGIRendererFeatureEditor.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIVolumeEditorURP.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIVolumeEditorURP.cs new file mode 100644 index 0000000..0317337 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIVolumeEditorURP.cs @@ -0,0 +1,468 @@ +//pipelinedefine +#define H_URP + +using System; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +#if UNITY_EDITOR +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Editor.WindowsAndMenu; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Infrastructure.URP; +using UnityEditor; +using UnityEditor.Rendering; +using UnityEditor.AnimatedValues; + +namespace HTraceSSGI.Scripts.Editor +{ + [CanEditMultipleObjects] +#if UNITY_2022_2_OR_NEWER + [CustomEditor(typeof(HTraceSSGIVolume))] +#else +[VolumeComponentEditor(typeof(HTraceSSGIVolume))] +#endif + internal class HTraceSSGIVolumeEditorURP : VolumeComponentEditor + { + private const string NO_RENDERER_FEATURE_MESSAGE = "HTrace Screen Space Global Illumination feature is missing in the active URP renderer."; + private const string RENDERER_FEATURE_OFF_MESSAGE = "HTrace Screen Space Global Illumination is disabled in the active URP renderer."; + private const string LIGHTING_MULTIPLIER_ABOVE_1_MESSAGE = "Ambient Override may not work correctly when the Environment Lighting Multiplier is set above 1 !"; + private const string RENDETIN_LIGHTING_SETTINGS_WINDOW_PATH = "Window/Rendering/Lighting"; + + private Texture2D m_Icon; + + SerializedDataParameter p_Enable; + + // General + internal SerializedDataParameter p_DebugMode; + internal SerializedDataParameter p_HBuffer; + internal SerializedDataParameter p_ExcludeCastingMask; + internal SerializedDataParameter p_ExcludeReceivingMask; + internal SerializedDataParameter p_FallbackType; + internal SerializedDataParameter p_SkyIntensity; + internal SerializedDataParameter p_MetallicIndirectFallback; + internal SerializedDataParameter p_AmbientOverride; + internal SerializedDataParameter p_Multibounce; + + //Apv + internal SerializedDataParameter p_ViewBias; + internal SerializedDataParameter p_NormalBias; + internal SerializedDataParameter p_SamplingNoise; + internal SerializedDataParameter p_IntensityMultiplier; + internal SerializedDataParameter p_DenoiseFallback; + + // Visuals + internal SerializedDataParameter p_BackfaceLighting; + internal SerializedDataParameter p_MaxRayLength; + internal SerializedDataParameter p_ThicknessMode; + internal SerializedDataParameter p_Thickness; + internal SerializedDataParameter p_Intensity; + internal SerializedDataParameter p_Falloff; + + // Quality tab + // Tracing + internal SerializedDataParameter p_RayCount; + internal SerializedDataParameter p_StepCount; + internal SerializedDataParameter p_RefineIntersection; + internal SerializedDataParameter p_FullResolutionDepth; + + // Rendering + internal SerializedDataParameter p_Checkerboard; + internal SerializedDataParameter p_RenderScale; + + // Denoising tab + internal SerializedDataParameter p_BrightnessClamp; + internal SerializedDataParameter p_MaxValueBrightnessClamp; + internal SerializedDataParameter p_MaxDeviationBrightnessClamp; + + // Temporal + internal SerializedDataParameter p_HalfStepValidation; + internal SerializedDataParameter p_SpatialOcclusionValidation; + internal SerializedDataParameter p_TemporalLightingValidation; + internal SerializedDataParameter p_TemporalOcclusionValidation; + + // Spatial Filter + internal SerializedDataParameter p_SpatialRadius; + internal SerializedDataParameter p_Adaptivity; + internal SerializedDataParameter p_RecurrentBlur; + internal SerializedDataParameter p_FireflySuppression; + + //Debug + internal SerializedDataParameter p_ShowBowels; + + // Main foldout groups + private AnimBool AnimBoolGeneralTab; + private AnimBool AnimBoolQualityTab; + private AnimBool AnimBoolDenoisingTab; + private AnimBool AnimBoolDebugTab; + private AnimBool AnimBoolEMPTY; + + // Menu state + private bool _showPipelineIntegration = true; + private bool _showVisualsArea = true; + private bool _showTracingArea = true; + private bool _showRenderingArea = true; + private bool _showRestirValidationArea = true; + private bool _showSpatialArea = true; + + static HTraceSSGIPreset _preset = HTraceSSGIPreset.Balanced; + + public override void OnEnable() + { + var o = new PropertyFetcher(serializedObject); + + m_Icon = Resources.Load("SSGI UI Card"); + + p_Enable = Unpack(o.Find(x => x.Enable)); + // General Settings + p_DebugMode = Unpack(o.Find(x => x.DebugMode)); + p_HBuffer = Unpack(o.Find(x => x.HBuffer)); +#if UNITY_2023_3_OR_NEWER + p_ExcludeReceivingMask = Unpack(o.Find(x => x.ExcludeReceivingMask)); + p_ExcludeCastingMask = Unpack(o.Find(x => x.ExcludeCastingMask)); +#endif + p_FallbackType = Unpack(o.Find(x => x.FallbackType)); + p_SkyIntensity = Unpack(o.Find(x => x.SkyIntensity)); + //Pipeline integration + p_MetallicIndirectFallback = Unpack(o.Find(x => x.MetallicIndirectFallback)); + p_AmbientOverride = Unpack(o.Find(x => x.AmbientOverride)); + p_Multibounce = Unpack(o.Find(x => x.Multibounce)); + //Apv + p_ViewBias = Unpack(o.Find(x => x.ViewBias)); + p_NormalBias = Unpack(o.Find(x => x.NormalBias)); + p_SamplingNoise = Unpack(o.Find(x => x.SamplingNoise)); + p_IntensityMultiplier = Unpack(o.Find(x => x.IntensityMultiplier)); + p_DenoiseFallback = Unpack(o.Find(x => x.DenoiseFallback)); + + // Visuals + p_BackfaceLighting = Unpack(o.Find(x => x.BackfaceLighting)); + p_MaxRayLength = Unpack(o.Find(x => x.MaxRayLength)); + p_ThicknessMode = Unpack(o.Find(x => x.ThicknessMode)); + p_Thickness = Unpack(o.Find(x => x.Thickness)); + p_Intensity = Unpack(o.Find(x => x.Intensity)); + p_Falloff = Unpack(o.Find(x => x.Falloff)); + + // Quality tab + // Tracing + p_RayCount = Unpack(o.Find(x => x.RayCount)); + p_StepCount = Unpack(o.Find(x => x.StepCount)); + p_RefineIntersection = Unpack(o.Find(x => x.RefineIntersection)); + p_FullResolutionDepth = Unpack(o.Find(x => x.FullResolutionDepth)); + + // Rendering + p_Checkerboard = Unpack(o.Find(x => x.Checkerboard)); + p_RenderScale = Unpack(o.Find(x => x.RenderScale)); + + // Denoising tab + p_BrightnessClamp = Unpack(o.Find(x => x.BrightnessClamp)); + p_MaxValueBrightnessClamp = Unpack(o.Find(x => x.MaxValueBrightnessClamp)); + p_MaxDeviationBrightnessClamp = Unpack(o.Find(x => x.MaxDeviationBrightnessClamp)); + + // Temporal + p_HalfStepValidation = Unpack(o.Find(x => x.HalfStepValidation)); + p_SpatialOcclusionValidation = Unpack(o.Find(x => x.SpatialOcclusionValidation)); + p_TemporalLightingValidation = Unpack(o.Find(x => x.TemporalLightingValidation)); + p_TemporalOcclusionValidation = Unpack(o.Find(x => x.TemporalOcclusionValidation)); + + // Spatial Filter + p_SpatialRadius = Unpack(o.Find(x => x.SpatialRadius)); + p_Adaptivity = Unpack(o.Find(x => x.Adaptivity)); + p_RecurrentBlur = Unpack(o.Find(x => x.RecurrentBlur)); + p_FireflySuppression = Unpack(o.Find(x => x.FireflySuppression)); + + // Debug + p_ShowBowels = Unpack(o.Find(x => x.ShowBowels)); + + AnimBoolGeneralTab = new AnimBool(true); + AnimBoolGeneralTab.valueChanged.RemoveAllListeners(); + AnimBoolGeneralTab.valueChanged.AddListener(Repaint); + + AnimBoolQualityTab = new AnimBool(true); + AnimBoolQualityTab.valueChanged.RemoveAllListeners(); + AnimBoolQualityTab.valueChanged.AddListener(Repaint); + + AnimBoolDenoisingTab = new AnimBool(true); + AnimBoolDenoisingTab.valueChanged.RemoveAllListeners(); + AnimBoolDenoisingTab.valueChanged.AddListener(Repaint); + + AnimBoolDebugTab = new AnimBool(true); //_debugTab.boolValue + AnimBoolDebugTab.valueChanged.RemoveAllListeners(); + AnimBoolDebugTab.valueChanged.AddListener(Repaint); + + AnimBoolEMPTY = new AnimBool(false); + } + + public override void OnInspectorGUI() + { + var hTraceRendererFeature = HRendererURP.GetRendererFeatureByTypeName(nameof(HTraceSSGIRendererFeature)) as HTraceSSGIRendererFeature; + if (hTraceRendererFeature == null) + { + EditorGUILayout.Space(); + CoreEditorUtils.DrawFixMeBox(NO_RENDERER_FEATURE_MESSAGE, MessageType.Error, HEditorStyles.FixButtonName, () => + { + HRendererURP.AddHTraceRendererFeatureToUniversalRendererData(); + GUIUtility.ExitGUI(); + }); + //EditorGUILayout.HelpBox(NO_RENDERER_FEATURE_MESSAGE, MessageType.Error, wide: true); + return; + } + else if (!hTraceRendererFeature.isActive) + { + EditorGUILayout.Space(); + CoreEditorUtils.DrawFixMeBox(RENDERER_FEATURE_OFF_MESSAGE, MessageType.Warning, HEditorStyles.FixButtonName, () => + { + hTraceRendererFeature.SetActive(true); + GUIUtility.ExitGUI(); + }); + EditorGUILayout.Space(); + } + + if (m_Icon != null) + { + //GUILayout.Label(m_Icon, HEditorStyles.icon, GUILayout.ExpandWidth(false)); + Rect rect = GUILayoutUtility.GetAspectRect((float)m_Icon.width / m_Icon.height); + rect.xMin += 4; + rect.xMax -= 4; + GUI.DrawTexture(rect, m_Icon, ScaleMode.ScaleToFit); + EditorGUILayout.Space(5f); + } + + if (HTraceSSGIRendererFeature.IsUseVolumes == false) + { + CoreEditorUtils.DrawFixMeBox("\"Use Volumes\" checkbox in the HTrace SSGI Renderer feature is disabled, use the HTraceSSGI component in your scenes.", MessageType.Warning, HEditorStyles.ChangeButtonName, () => + { + hTraceRendererFeature.UseVolumes = true; + GUIUtility.ExitGUI(); + }); + return; + } + + PropertyField(p_Enable); + EditorGUILayout.Space(5f); + + // ------------------------------------- Global settings ---------------------------------------------------------- + + using (new HEditorUtils.FoldoutScope(AnimBoolGeneralTab, out var shouldDraw, HEditorStyles.GlobalSettings.text)) + { + if (shouldDraw) + { + + using (new IndentLevelScope(10)) + { + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.PrefixLabel("Preset"); + + _preset = (HTraceSSGIPreset)EditorGUILayout.EnumPopup(_preset); + + if (GUILayout.Button("Apply", GUILayout.Width(60))) + { + HTraceSSGIPresetData.ApplyPresetVolume(this, _preset); + EditorUtility.SetDirty(target); + } + EditorGUILayout.EndHorizontal(); + } + + EditorGUILayout.Space(5f); + + PropertyField(p_DebugMode); + if((DebugMode)p_DebugMode.value.enumValueIndex == DebugMode.MainBuffers) + { + PropertyField(p_HBuffer); + } + EditorGUILayout.Space(5f); + +#if UNITY_2023_3_OR_NEWER + PropertyField(p_ExcludeCastingMask); + PropertyField(p_ExcludeReceivingMask); +#endif + EditorGUILayout.Space(3f); + + PropertyField(p_FallbackType); + if ((Globals.FallbackType)p_FallbackType.value.enumValueIndex == Globals.FallbackType.Sky) + PropertyField(p_SkyIntensity); + +#if UNITY_6000_0_OR_NEWER + if ((FallbackType)p_FallbackType.value.enumValueIndex == Globals.FallbackType.APV) + { + using (new IndentLevelScope()) + { + PropertyField(p_ViewBias); + PropertyField(p_NormalBias); + PropertyField(p_SamplingNoise); + PropertyField(p_IntensityMultiplier); + PropertyField(p_DenoiseFallback); + } + } + if ((FallbackType)p_FallbackType.value.enumValueIndex == Globals.FallbackType.Sky) + { + using (new IndentLevelScope()) + PropertyField(p_DenoiseFallback); + } +#endif + EditorGUILayout.Space(5f); + { + _showPipelineIntegration = EditorGUILayout.BeginFoldoutHeaderGroup(_showPipelineIntegration, HEditorStyles.PipelineIntegration.text); + if (_showPipelineIntegration) + { + using (new IndentLevelScope()) + { + PropertyField(p_MetallicIndirectFallback); + PropertyField(p_AmbientOverride); + if (RenderSettings.ambientIntensity > 1.0f && p_AmbientOverride.value.boolValue == true) + { + CoreEditorUtils.DrawFixMeBox(LIGHTING_MULTIPLIER_ABOVE_1_MESSAGE, MessageType.Warning, HEditorStyles.OpenButtonName, () => + { + EditorApplication.ExecuteMenuItem(RENDETIN_LIGHTING_SETTINGS_WINDOW_PATH); + GUIUtility.ExitGUI(); + }); + } + PropertyField(p_Multibounce); + } + EditorGUILayout.Space(3f); + } + EditorGUILayout.EndFoldoutHeaderGroup(); + } + EditorGUILayout.Space(3f); + + { + _showVisualsArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showVisualsArea, HEditorStyles.Visuals.text); + if (_showVisualsArea) + { + using (new IndentLevelScope()) + { + PropertyField(p_BackfaceLighting); + PropertyField(p_MaxRayLength); + if (p_MaxRayLength.value.floatValue < 0) + p_MaxRayLength.value.floatValue = 0f; + PropertyField(p_ThicknessMode); + PropertyField(p_Thickness); + PropertyField(p_Intensity); + PropertyField(p_Falloff); + } + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(3f); + } + } + } + + // ------------------------------------- Quality ---------------------------------------------------------- + + using (new HEditorUtils.FoldoutScope(AnimBoolQualityTab, out var shouldDraw, HEditorStyles.Quality.text)) + { + if (shouldDraw) + { + EditorGUILayout.Space(3f); + _showTracingArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showTracingArea, HEditorStyles.Tracing.text); + if (_showTracingArea) + { + using (new IndentLevelScope()) + { + PropertyField(p_RayCount); + PropertyField(p_StepCount); + PropertyField(p_RefineIntersection); + PropertyField(p_FullResolutionDepth); + } + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(5f); + + _showRenderingArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showRenderingArea, HEditorStyles.Rendering.text); + if (_showRenderingArea) + { + using (new IndentLevelScope()) + { + PropertyField(p_Checkerboard); + PropertyField(p_RenderScale); + p_RenderScale.value.floatValue = p_RenderScale.value.floatValue.RoundToCeilTail(2); + } + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(3f); + } + } + + // ------------------------------------- Denoising ---------------------------------------------------------- + + using (new HEditorUtils.FoldoutScope(AnimBoolDenoisingTab, out var shouldDraw, HEditorStyles.Denoising.text)) + { + if (shouldDraw) + { + EditorGUILayout.Space(3f); + + PropertyField(p_BrightnessClamp); + if ((BrightnessClamp)p_BrightnessClamp.value.enumValueIndex == Globals.BrightnessClamp.Manual) + PropertyField(p_MaxValueBrightnessClamp); + if ((BrightnessClamp)p_BrightnessClamp.value.enumValueIndex == Globals.BrightnessClamp.Automatic) + PropertyField(p_MaxDeviationBrightnessClamp); + EditorGUILayout.Space(5f); + + _showRestirValidationArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showRestirValidationArea, HEditorStyles.ReSTIRValidation.text); + if (_showRestirValidationArea) + { + using (new IndentLevelScope()) + { + PropertyField(p_HalfStepValidation); + EditorGUILayout.Space(3f); + + EditorGUILayout.LabelField(HEditorStyles.ValidationTypes, HEditorStyles.bold); + PropertyField(p_SpatialOcclusionValidation); + PropertyField(p_TemporalLightingValidation); + PropertyField(p_TemporalOcclusionValidation); + } + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(5f); + + _showSpatialArea = EditorGUILayout.BeginFoldoutHeaderGroup(_showSpatialArea, HEditorStyles.SpatialFilter.text); + if (_showSpatialArea) + { + using (new IndentLevelScope()) + { + PropertyField(p_SpatialRadius); + PropertyField(p_Adaptivity); + PropertyField(p_RecurrentBlur); + PropertyField(p_FireflySuppression); + } + } + + EditorGUILayout.EndFoldoutHeaderGroup(); + EditorGUILayout.Space(3f); + } + } + + + HEditorUtils.HorizontalLine(1f); + EditorGUILayout.Space(3f); + + //HEditorUtils.DrawClickableLink($"HTrace AO Version: {HNames.HTRACE_AO_VERSION}", HNames.HTRACE_AO_DOCUMENTATION_LINK, true); + HEditorUtils.DrawLinkRow( + ($"Documentation (v." + HNames.HTRACE_SSGI_VERSION + ")", () => Application.OpenURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK)), + ("Discord", () => Application.OpenURL(HNames.HTRACE_DISCORD_LINK)), + ("Bug report", () => HBugReporterWindow.ShowWindow()) + ); + } + + private void DebugPart() + { + using (new HEditorUtils.FoldoutScope(AnimBoolDebugTab, out var shouldDraw, HEditorStyles.Debug.text)) + { + if (shouldDraw) + { + EditorGUILayout.Space(3f); + + PropertyField(p_ShowBowels); + + EditorGUILayout.Space(3f); + } + } + } + } +} +#endif //UNITY_EDITOR diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIVolumeEditorURP.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIVolumeEditorURP.cs.meta new file mode 100644 index 0000000..5ecae6a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/HTraceSSGIVolumeEditorURP.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b83a85dd560147da90cf7c0d4143a78c +timeCreated: 1757342219 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/HTraceSSGIVolumeEditorURP.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu.meta new file mode 100644 index 0000000..3e06865 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f30ffee4f8a6491fa30599d846fd00eb +timeCreated: 1757344404 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeLoader.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeLoader.cs new file mode 100644 index 0000000..4ebe9ac --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeLoader.cs @@ -0,0 +1,41 @@ +#if UNITY_EDITOR +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using UnityEditor; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Editor.WindowsAndMenu +{ + [InitializeOnLoad] + public static class AssetWelcomeLoader + { + static AssetWelcomeLoader() + { + EditorApplication.delayCall += TryShowWelcome; + } + + private static void TryShowWelcome() + { + if (SessionState.GetBool(HNames.HTRACE_WELCOME_SHOW_SESSION, false)) + return; + SessionState.SetBool(HNames.HTRACE_WELCOME_SHOW_SESSION, true); + + bool dontShowAgain = EditorPrefs.GetBool(HNames.HTRACE_SHOW_KEY, false); + string currentUnityVersion = Application.unityVersion; + string savedUnityVersion = EditorPrefs.GetString(HNames.HTRACE_UNITY_VERSION_KEY, string.Empty); + + bool unityVersionChanged = savedUnityVersion != currentUnityVersion; + bool isLts = HExtensions.IsUnityLTS(currentUnityVersion); + + bool shouldShowWelcome = !dontShowAgain || (unityVersionChanged && !isLts); + + if (shouldShowWelcome) + { + AssetWelcomeWindow.ShowWindow(); + } + + EditorPrefs.SetString(HNames.HTRACE_UNITY_VERSION_KEY, currentUnityVersion); + } + } +} +#endif diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeLoader.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeLoader.cs.meta new file mode 100644 index 0000000..05906eb --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeLoader.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b548ee64286c45f48d34d1dc643c5c30 +timeCreated: 1766077710 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeLoader.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeWindow.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeWindow.cs new file mode 100644 index 0000000..acd9019 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeWindow.cs @@ -0,0 +1,139 @@ +#if UNITY_EDITOR +using System; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using UnityEditor; +using UnityEngine; + +namespace HTraceSSGI.Scripts.Editor.WindowsAndMenu +{ + public class AssetWelcomeWindow : EditorWindow + { + private static Texture2D _icon; + + public static void ShowWindow() + { + _icon = Resources.Load("SSGI UI Card"); + + var window = GetWindow("Welcome"); + + Vector2 minSize = new Vector2(600, 240); + + if (HExtensions.IsUnityLTS(Application.unityVersion)) + minSize.y -= 45; + + if (_icon != null) + minSize.y += 100; + + Vector2 maxSize = minSize - new Vector2(1, 1); + window.minSize = minSize; + window.maxSize = maxSize; + + Rect main = EditorGUIUtility.GetMainWindowPosition(); + window.position = new Rect( + main.x + (main.width - minSize.x) / 2, + main.y + (main.height - minSize.y) / 2, + minSize.x, + minSize.y + ); + } + + private void OnGUI() + { + if (_icon != null) + { + GUILayout.Space(5); + Rect rect = GUILayoutUtility.GetAspectRect((float)_icon.width / _icon.height); + rect.xMin += 4; + rect.xMax -= 4; + GUI.DrawTexture(rect, _icon, ScaleMode.ScaleToFit); + EditorGUILayout.Space(5f); + } + + GUILayout.Space(5); + + GUILayout.Label($"Thank you for purchasing {HNames.ASSET_NAME_FULL_WITH_DOTS}!", EditorStyles.boldLabel); + GUILayout.Space(5); + + DrawUnityVersionWarning(); + + GUILayout.Space(10); + + var richLabel = new GUIStyle(EditorStyles.wordWrappedLabel) + { + richText = true + }; + GUILayout.Label( + "Please make sure to read the Documentation before using the asset.\n" + + "If you run into any issues, check the Known Issues and FAQ sections before reporting a bug.", + richLabel + ); + GUILayout.Space(5); + + DrawLinksLine(); + + GUILayout.Space(10); + GUILayout.Label( + "Shortcuts to the Documentation, Discord support channel, and Bug Report form " + + "can be found at the bottom of the HTrace UI.", + EditorStyles.wordWrappedLabel + ); + + GUILayout.Space(15); + + bool dontShow = GUILayout.Toggle( + EditorPrefs.GetBool(HNames.HTRACE_SHOW_KEY, false), + "Don't show next time" + ); + + EditorPrefs.SetBool(HNames.HTRACE_SHOW_KEY, dontShow); + + GUILayout.Space(10); + + if (GUILayout.Button("I understand, close window")) + { + Close(); + } + } + private static void DrawUnityVersionWarning() + { + string unityVersion = Application.unityVersion; + + if (!HExtensions.IsUnityLTS(unityVersion)) + { + EditorGUILayout.HelpBox( + $"The current Unity version ({unityVersion}) is not an LTS release.\n" + + "Bug fixes for non-LTS releases are not guaranteed.", + MessageType.Warning + ); + } + } + + private static void DrawLinksLine() + { + EditorGUILayout.BeginHorizontal(); + + DrawLinkButton("Documentation", HNames.HTRACE_SSGI_DOCUMENTATION_LINK); + GUILayout.Label("|", GUILayout.Width(10)); + DrawLinkButton("Known Issues", HNames.HTRACE_SSGI_DOCUMENTATION_LINK_KNOWN_ISSUES); + GUILayout.Label("|", GUILayout.Width(10)); + DrawLinkButton("FAQ", HNames.HTRACE_SSGI_DOCUMENTATION_LINK_FAQ); + + EditorGUILayout.EndHorizontal(); + } + + private static void DrawLinkButton(string label, string url) + { + var style = new GUIStyle(EditorStyles.linkLabel) + { + wordWrap = false + }; + + if (GUILayout.Button(label, style, GUILayout.Width(EditorStyles.linkLabel.CalcSize(new GUIContent(label)).x))) + { + Application.OpenURL(url); + } + } + } +} +#endif diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeWindow.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeWindow.cs.meta new file mode 100644 index 0000000..a0666fc --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeWindow.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 37241604af0a4e2ea194f52d530a3b97 +timeCreated: 1766077786 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/WindowsAndMenu/AssetWelcomeWindow.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HBugReporterWindow.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HBugReporterWindow.cs new file mode 100644 index 0000000..8856e8c --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HBugReporterWindow.cs @@ -0,0 +1,98 @@ +using HTraceSSGI.Scripts.Globals; +using UnityEngine; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace HTraceSSGI.Scripts.Editor.WindowsAndMenu +{ +#if UNITY_EDITOR + public class HBugReporterWindow : EditorWindow + { + private string _reportData = ""; + + private GUIStyle _styleLabel; + private Vector2 _scrollPosition = Vector2.zero; + + [MenuItem("Window/HTrace/Report a Bug HTrace SSGI", false, priority: 32)] + public static void ShowWindow() + { + var window = GetWindow(false, "Report Bug", true); + window.minSize = new Vector2(400, 330); + } + + void OnEnable() + { + _reportData = ""; + + var pipeline = HRenderer.CurrentHRenderPipeline.ToString(); + + _reportData += $"{HNames.ASSET_NAME_FULL} Version: {HNames.HTRACE_SSGI_VERSION}" + "\n"; + + _reportData += "\n"; + + _reportData += "Unity Version: " + Application.unityVersion + "\n"; + _reportData += "Pipeline: " + pipeline + "\n"; + _reportData += "Platform: " + Application.platform + "\n"; + _reportData += "Graphics API: " + SystemInfo.graphicsDeviceType + "\n"; + + _reportData += "\n"; + + _reportData += "OS: " + SystemInfo.operatingSystem + "\n"; + _reportData += "Graphics: " + SystemInfo.graphicsDeviceName + "\n"; + + _reportData += "\n"; + _reportData += "Additional details:\n"; + } + + void OnGUI() + { + SetGUIStyles(); + + GUILayout.Space(-2); + + GUILayout.BeginHorizontal(); + GUILayout.Space(15); + + GUILayout.BeginVertical(); + + _scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, false, GUILayout.Width(this.position.width - 28), GUILayout.Height(this.position.height - 80)); + + GUILayout.Label(_reportData, _styleLabel); + + GUILayout.Space(15); + + if (GUILayout.Button("Copy Details To Clipboard", GUILayout.Height(24))) + { + var copyData = _reportData; + + GUIUtility.systemCopyBuffer = copyData; + } + if (GUILayout.Button("Report Bug on Discord", GUILayout.Height(24))) + { + Application.OpenURL(HNames.HTRACE_DISCORD_BUGS_SSGI_LINK); + } + + GUILayout.FlexibleSpace(); + + GUILayout.Space(20); + + GUILayout.EndScrollView(); + + GUILayout.EndVertical(); + + GUILayout.Space(13); + GUILayout.EndHorizontal(); + } + + void SetGUIStyles() + { + _styleLabel = new GUIStyle(EditorStyles.label) + { + richText = true, + }; + } + } + +#endif +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HBugReporterWindow.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HBugReporterWindow.cs.meta new file mode 100644 index 0000000..5faec78 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HBugReporterWindow.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dba5cecf144f410fb38b07e1de8c0ca1 +timeCreated: 1757344409 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HBugReporterWindow.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HMenuAndFilesManager.cs b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HMenuAndFilesManager.cs new file mode 100644 index 0000000..5aee484 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HMenuAndFilesManager.cs @@ -0,0 +1,52 @@ +//pipelinedefine +#define H_URP + +#if UNITY_EDITOR +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using UnityEditor; +using UnityEditor.ShortcutManagement; +using UnityEngine; +using HTraceSSGI.Scripts.Infrastructure.URP; + +namespace HTraceSSGI.Scripts.Editor.WindowsAndMenu +{ + +#if UNITY_EDITOR + + public class HMenuAndFilesManager : EditorWindow + { + [MenuItem("GameObject/Rendering/HTrace Screen Space Global Illumination", false, priority: 30)] + static void CreateHTraceGameObject(MenuCommand menuCommand) + { + HTraceSSGI[] hTraces = FindObjectsOfType(typeof(HTraceSSGI)) as HTraceSSGI[]; + if (hTraces != null && hTraces.Length > 0) + { + return; + } + + GameObject go = new GameObject(HNames.ASSET_NAME); + GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject); + go.AddComponent(); + + Undo.RegisterCreatedObjectUndo(go, "Create " + go.name); + Selection.activeObject = go; + } + + [MenuItem("Window/HTrace/Add HTrace SSGI Render Feature to active RendererData", false, priority: 32)] + private static void AddRenderFeature() + { + HRendererURP.AddHTraceRendererFeatureToUniversalRendererData(); + } + + [MenuItem("Window/HTrace/Open HTrace SSGI documentation", false, priority: 32)] + private static void OpenDocumentation() + { + Application.OpenURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK); + } + } + +#endif +} +#endif diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HMenuAndFilesManager.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HMenuAndFilesManager.cs.meta new file mode 100644 index 0000000..a919b56 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HMenuAndFilesManager.cs.meta @@ -0,0 +1,18 @@ +fileFormatVersion: 2 +guid: 4097973eb33709247ad51c90310a5018 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Editor/WindowsAndMenu/HMenuAndFilesManager.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions.meta b/Assets/Plugins/HTraceSSGI/Scripts/Extensions.meta new file mode 100644 index 0000000..d1b2767 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7c37931430e142a8a8c9147d0094a187 +timeCreated: 1756743171 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem.meta b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem.meta new file mode 100644 index 0000000..72fefa5 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2ce18ebb0d794317835a43506e011560 +timeCreated: 1756743209 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/CameraHistorySystem.cs b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/CameraHistorySystem.cs new file mode 100644 index 0000000..8dd9a6a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/CameraHistorySystem.cs @@ -0,0 +1,71 @@ +using System; + +namespace HTraceSSGI.Scripts.Extensions.CameraHistorySystem +{ + public class CameraHistorySystem where T : struct, ICameraHistoryData + { + private const int MaxCameraCount = 4; // minimum 2 + + private int _cameraHistoryIndex; + private readonly T[] _cameraHistoryData = new T[MaxCameraCount]; + + + public int UpdateCameraHistoryIndex(int currentCameraHash) + { + _cameraHistoryIndex = GetCameraHistoryDataIndex(currentCameraHash); + return _cameraHistoryIndex; + } + + private int GetCameraHistoryDataIndex(int cameraHash) + { + // Unroll manually for MAX_CAMERA_COUNT = 4 + if (_cameraHistoryData[0].GetHash() == cameraHash) return 0; + if (_cameraHistoryData[1].GetHash() == cameraHash) return 1; + if (_cameraHistoryData[2].GetHash() == cameraHash) return 2; + if (_cameraHistoryData[3].GetHash() == cameraHash) return 3; + return -1; // new camera + } + + public void UpdateCameraHistoryData() + { + bool cameraHasChanged = _cameraHistoryIndex == -1; + + if (cameraHasChanged) + { + const int lastIndex = MaxCameraCount - 1; + + if (_cameraHistoryData[lastIndex] is IDisposable disposable) + disposable.Dispose(); + + // Shift the camera history data back by one + Array.Copy(_cameraHistoryData, 0, _cameraHistoryData, 1, lastIndex); + + _cameraHistoryIndex = 0; + _cameraHistoryData[0] = new T(); //it's critical + } + } + + public ref T GetCameraData() + { + return ref _cameraHistoryData[_cameraHistoryIndex]; + } + + public T[] GetCameraDatas() + { + return _cameraHistoryData; + } + + public void SetCameraData(T data) + { + _cameraHistoryData[_cameraHistoryIndex] = data; + } + + public void Cleanup() + { + for (int index = 0; index < _cameraHistoryData.Length; index++) + { + _cameraHistoryData[index] = default; + } + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/CameraHistorySystem.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/CameraHistorySystem.cs.meta new file mode 100644 index 0000000..0ebb99a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/CameraHistorySystem.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: c3e05482e5474c74ac2640b07596bc39 +timeCreated: 1756743219 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/CameraHistorySystem.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/ICameraHistoryData.cs b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/ICameraHistoryData.cs new file mode 100644 index 0000000..7540cfb --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/ICameraHistoryData.cs @@ -0,0 +1,8 @@ +namespace HTraceSSGI.Scripts.Extensions.CameraHistorySystem +{ + public interface ICameraHistoryData + { + int GetHash(); + void SetHash(int hashIn); + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/ICameraHistoryData.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/ICameraHistoryData.cs.meta new file mode 100644 index 0000000..efbc64b --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/ICameraHistoryData.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 0c7d445abdf7490a9ce172328c1955e4 +timeCreated: 1756743242 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Extensions/CameraHistorySystem/ICameraHistoryData.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/ExtensionsURP.cs b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/ExtensionsURP.cs new file mode 100644 index 0000000..da7c861 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/ExtensionsURP.cs @@ -0,0 +1,32 @@ +//pipelinedefine +#define H_URP + +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Experimental.Rendering; + +using UnityEngine.Rendering.Universal; +#if UNITY_2023_3_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + +namespace HTraceSSGI.Scripts.Extensions +{ + public class ExtensionsURP + { +#if UNITY_2023_3_OR_NEWER + public static TextureHandle CreateTexture(string name, RenderGraph rg, ref TextureDesc desc, GraphicsFormat format, DepthBits depthBufferBits = DepthBits.None, + bool enableRandomWrite = true, bool useMipMap = false, bool autoGenerateMips = false) + { + desc.name = name; + desc.format = format; + desc.depthBufferBits = depthBufferBits; + desc.enableRandomWrite = enableRandomWrite; + desc.useMipMap = useMipMap; + desc.autoGenerateMips = autoGenerateMips; + desc.msaaSamples = MSAASamples.None; + return rg.CreateTexture(desc); + } +#endif //UNITY_2023_3_OR_NEWER + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/ExtensionsURP.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/ExtensionsURP.cs.meta new file mode 100644 index 0000000..f15b37e --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/ExtensionsURP.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: dac8d0f9113f40878aad789181576a57 +timeCreated: 1757339719 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Extensions/ExtensionsURP.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/HExtensions.cs b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/HExtensions.cs new file mode 100644 index 0000000..ad7ea34 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/HExtensions.cs @@ -0,0 +1,261 @@ +//pipelinedefine +#define H_URP + +using System; +using System.Reflection; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Wrappers; +using UnityEditor; +using UnityEngine; +using UnityEngine.Rendering; +#if UNITY_2021 || UNITY_2022 +using UnityEngine.Experimental.Rendering; +#endif + +namespace HTraceSSGI.Scripts.Extensions +{ + + public static class HExtensions + { + public static void DebugPrint(DebugType type, string msg) + { + msg = "HTrace log: " + msg; + + switch (type) + { + case DebugType.Log: + Debug.Log(msg); + break; + case DebugType.Warning: + Debug.LogWarning(msg); + break; + case DebugType.Error: + Debug.LogError(msg); + break; + } + } + + public static ComputeShader LoadComputeShader(string shaderName) + { + var computeShader = (ComputeShader)UnityEngine.Resources.Load($"HTraceSSGI/Computes/{shaderName}"); + if (computeShader == null) + { + Debug.LogError($"{shaderName} is missing in HTraceSSGI/Computes folder"); + return null; + } + + return computeShader; + } + + public static RayTracingShader LoadRayTracingShader(string shaderName) + { + var rtShader = (RayTracingShader)UnityEngine.Resources.Load($"HTraceSSGI/Computes/{shaderName}"); + if (rtShader == null) + { + Debug.LogError($"{shaderName} is missing in HTraceSSGI/Computes folder"); + return null; + } + + return rtShader; + } + + public static bool ContainsOnOfElement(this string str, string[] elements) + { + foreach (var element in elements) + { + if (str.Contains(element)) + return true; + } + return false; + } + + public static T NextEnum(this T src) where T : struct + { + if (!typeof(T).IsEnum) throw new ArgumentException(String.Format("Argument {0} is not an Enum", typeof(T).FullName)); + + T[] Arr = (T[])Enum.GetValues(src.GetType()); + int j = Array.IndexOf(Arr, src) + 1; + src = (Arr.Length == j) ? Arr[0] : Arr[j]; + return src; + } + + public static bool IsUnityLTS(string version) + { + // 2023.1.5f1 + if (!Version.TryParse(GetNumericVersion(version), out var current)) + return false; + + return + current >= new Version(6000, 3, 0) && current < new Version(6000, 3, 100) || + current >= new Version(6000, 0, 23) && current < new Version(6000, 0, 100) || + current >= new Version(2022, 3, 0) && current < new Version(2022, 3, 100) || + current >= new Version(2023, 1, 0) && current < new Version(2023, 1, 100) || + current >= new Version(2023, 2, 0) && current < new Version(2023, 2, 100); + } + + private static string GetNumericVersion(string version) + { + int index = version.IndexOfAny(new[] { 'f', 'a', 'b' }); + return index > 0 ? version.Substring(0, index) : version; + } + + //custom Attributes +#if UNITY_EDITOR + + /// + /// Read Only attribute. + /// Attribute is use only to mark ReadOnly properties. + /// + public class ReadOnlyAttribute : PropertyAttribute + { + } + + /// + /// This class contain custom drawer for ReadOnly attribute. + /// + [CustomPropertyDrawer(typeof(ReadOnlyAttribute))] + public class ReadOnlyDrawer : PropertyDrawer + { + /// + /// Unity method for drawing GUI in Editor + /// + /// Position. + /// Property. + /// Label. + public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) + { + // Saving previous GUI enabled value + var previousGUIState = GUI.enabled; + // Disabling edit for property + GUI.enabled = false; + // Drawing Property + EditorGUI.PropertyField(position, property, label); + // Setting old GUI enabled value + GUI.enabled = previousGUIState; + } + } +#endif + + /// + /// Attribute used to make a float or int variable in a script be restricted to a specific range. + /// + [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] + public class HRangeAttribute : Attribute + { + public readonly bool isFloat; + + public readonly float minFloat; + public readonly float maxFloat; + public readonly int minInt; + public readonly int maxInt; + + /// + /// Attribute used to make a float or int variable in a script be restricted to a specific range. + /// + /// The minimum allowed value. + /// The maximum allowed value. + public HRangeAttribute(float minFloat, float maxFloat) + { + this.minFloat = minFloat; + this.maxFloat = maxFloat; + isFloat = true; + } + + /// + /// Attribute used to make a float or int variable in a script be restricted to a specific range. + /// + /// The minimum allowed value. + /// The maximum allowed value. + public HRangeAttribute(int minInt, int maxInt) + { + this.minInt = minInt; + this.maxInt = maxInt; + isFloat = false; + } + } + + public struct HRangeAttributeElement + { + public bool isFloat; + public float minFloat; + public float maxFloat; + public int minInt; + public int maxInt; + } + + public static float Clamp(float value, Type type, string nameOfField) + { + HRangeAttribute rangeAttribute = null; + + var filed = type.GetField(nameOfField); + if (filed != null) + { + rangeAttribute = filed.GetCustomAttribute(); + } + var property = type.GetProperty(nameOfField); + if (property != null) + { + rangeAttribute = property.GetCustomAttribute(); + } + + return Mathf.Clamp(value, rangeAttribute.minFloat, rangeAttribute.maxFloat); + } + + public static int Clamp(int value, Type type, string nameOfField) + { + HRangeAttribute rangeAttribute = null; + + var filed = type.GetField(nameOfField); + if (filed != null) + { + rangeAttribute = filed.GetCustomAttribute(); + } + var property = type.GetProperty(nameOfField); + if (property != null) + { + rangeAttribute = property.GetCustomAttribute(); + } + + return Mathf.Clamp(value, rangeAttribute.minInt, rangeAttribute.maxInt); + } + + public static void HRelease(this ComputeBuffer computeBuffer) + { + if (computeBuffer != null) + computeBuffer.Release(); + } + + public static void HRelease(this CommandBuffer commandBuffer) + { + if (commandBuffer != null) + { + commandBuffer.Clear(); + commandBuffer.Release(); + } + } + + public static void HRelease(this GraphicsBuffer graphicsBuffer) + { + if (graphicsBuffer != null) + { + graphicsBuffer.Release(); + } + } + + public static void HRelease(this HDynamicBuffer hDynamicBuffer) + { + if (hDynamicBuffer != null) + { + hDynamicBuffer.Release(); + } + } + + public static void HRelease(this RayTracingAccelerationStructure rayTracingAccelerationStructure) + { + if (rayTracingAccelerationStructure != null) + { + rayTracingAccelerationStructure.Release(); + } + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/HExtensions.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/HExtensions.cs.meta new file mode 100644 index 0000000..82184ab --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/HExtensions.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b25052d2c30a3664f886c0a9848fdc72 +timeCreated: 1659691524 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Extensions/HExtensions.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/IHistoryData.cs b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/IHistoryData.cs new file mode 100644 index 0000000..24c396f --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/IHistoryData.cs @@ -0,0 +1,7 @@ +namespace HTraceSSGI.Scripts.Extensions +{ + public interface IHistoryData + { + void Update(); + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Extensions/IHistoryData.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/IHistoryData.cs.meta new file mode 100644 index 0000000..ee7a7af --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Extensions/IHistoryData.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 09c7949fa72d433aa944d9be383f2372 +timeCreated: 1757489511 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Extensions/IHistoryData.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals.meta b/Assets/Plugins/HTraceSSGI/Scripts/Globals.meta new file mode 100644 index 0000000..72cc344 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 03f7f99440026054c98bc8c2d855fe55 +timeCreated: 1728989246 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HEnums.cs b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HEnums.cs new file mode 100644 index 0000000..d69f547 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HEnums.cs @@ -0,0 +1,71 @@ +//pipelinedefine +#define H_URP + +using UnityEngine.Rendering; + +namespace HTraceSSGI.Scripts.Globals +{ + public enum ThicknessMode + { + Relative = 0, + Uniform, + } + + public enum FallbackType + { + None = 0, + Sky = 1, + +#if UNITY_6000_0_OR_NEWER + APV = 2, +#endif + } + + public enum BrightnessClamp + { + Manual = 0, + Automatic = 1, + } + + public enum ReprojectionFilter + { + Linear4Taps = 0, + Lanczos12Taps = 1, + } + + public enum AlphaCutout + { + Evaluate = 0, + DepthTest = 1, + } + + public enum DebugMode + { + None = 0, + MainBuffers = 1, + DirectLighting = 2, + GlobalIllumination = 3, + TemporalDisocclusion = 4, + } + + public enum HBuffer + { + Multi, + Depth, + Diffuse, + Normal, + MotionMask, + MotionVectors, + } + + public enum HInjectionPoint + { + } + + public enum DebugType + { + Log, + Warning, + Error, + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HEnums.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HEnums.cs.meta new file mode 100644 index 0000000..6de2757 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HEnums.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 597ae110d1b52354ba4a3f4c6452b96e +timeCreated: 1661865051 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Globals/HEnums.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HMath.cs b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HMath.cs new file mode 100644 index 0000000..06e4c87 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HMath.cs @@ -0,0 +1,183 @@ +using UnityEngine; + +namespace HTraceSSGI.Scripts.Globals +{ + public static class HMath + { + private static Vector2 RemapVoxelsCoeff = new Vector2(64f, 512f); //min - 64 VoxelResolution, max - 512 VoxelResolution + + /// + /// Remap from one range to another + /// + /// + /// + /// + /// + /// + /// + public static float Remap(float input, float oldLow, float oldHigh, float newLow, float newHigh) + { + float t = Mathf.InverseLerp(oldLow, oldHigh, input); + return Mathf.Lerp(newLow, newHigh, t); + } + + // public static float RemapThickness(float thickness, ThicknessMode thicknessMode) + // { + // float result = 0f; + // switch (thicknessMode) + // { + // case ThicknessMode.Standard: + // result = Remap(thickness, 0f, 1f, 0f, 0.15f); + // break; + // case ThicknessMode.Accurate: + // result = Remap(thickness, 0f, 1f, 0f, 0.05f); + // break; + // default: + // Debug.LogError($"RemapThickness ERROR: thickness: {thickness}, ThicknessMode: {thicknessMode}"); + // break; + // } + // + // return result; + // } + + /// + /// Thickness value pre-calculation for GI + /// + /// + /// + /// + public static Vector2 ThicknessBias(float baseThickness, Camera camera) + { + baseThickness = Remap(baseThickness, 0f, 1f, 0f, 0.5f); + float n = camera.nearClipPlane; + float f = camera.farClipPlane; + float thicknessScale = 1.0f / (1.0f + baseThickness); + float thicknessBias = -n / (f - n) * (baseThickness * thicknessScale); + return new Vector2((float)thicknessScale, (float)thicknessBias); + } + + public static Vector4 ComputeViewportScaleAndLimit(Vector2Int viewportSize, Vector2Int bufferSize) + { + return new Vector4(ComputeViewportScale(viewportSize.x, bufferSize.x), // Scale(x) + ComputeViewportScale(viewportSize.y, bufferSize.y), // Scale(y) + ComputeViewportLimit(viewportSize.x, bufferSize.x), // Limit(x) + ComputeViewportLimit(viewportSize.y, bufferSize.y)); // Limit(y) + } + + public static float PixelSpreadTangent(float Fov, int Width, int Height) + { + return Mathf.Tan(Fov * Mathf.Deg2Rad * 0.5f) * 2.0f / Mathf.Min(Width, Height); + } + + public static float CalculateVoxelSizeInCM_UI(int bounds, float density) + { + float resolution = Mathf.CeilToInt(bounds / (bounds / HMath.Remap(density, 0f, 1f, HMath.RemapVoxelsCoeff.x, HMath.RemapVoxelsCoeff.y))); + return bounds / resolution * 100f; //100 -> cm + } + + public static float TexturesSizeInMB_UI(int voxelBounds, float density, bool overrideGroundEnable, int GroundLevel) + { + float resolution = voxelBounds / (voxelBounds / HMath.Remap(density, 0f, 1f, HMath.RemapVoxelsCoeff.x, HMath.RemapVoxelsCoeff.y)); + float voxelSize = voxelBounds / resolution; + float textureResolution = resolution * resolution; + textureResolution *= overrideGroundEnable == true ? (GroundLevel / voxelSize) : resolution; + float colorMemorySize = textureResolution * 32 / (1024 * 1024 * 8); + float positionMemorySize = (textureResolution * 32 / (1024 * 1024 * 8)) + (textureResolution * 8 / (1024 * 1024 * 8)); + + return colorMemorySize + positionMemorySize; + } + + public static float TexturesSizeInMB_UI(Vector3Int voxelsRelosution) + { + float textureResolution = voxelsRelosution.x * voxelsRelosution.y * voxelsRelosution.z; + float colorMemorySize = textureResolution * 32 / (1024 * 1024 * 8); + float positionMemorySize = (textureResolution * 32 / (1024 * 1024 * 8)) + (textureResolution * 8 / (1024 * 1024 * 8)); + + return colorMemorySize + positionMemorySize; + } + + public static Vector3Int CalculateVoxelResolution_UI(int voxelBounds, float density, bool overrideGroundEnable, int GroundLevel) + { + Vector3Int resolutionResult = new Vector3Int(); + float resolution = HMath.Remap(density, 0f, 1f, HMath.RemapVoxelsCoeff.x, HMath.RemapVoxelsCoeff.y); + resolutionResult.x = Mathf.CeilToInt(resolution); + resolutionResult.y = Mathf.CeilToInt(resolution); + + float height = (overrideGroundEnable == false ? voxelBounds : GroundLevel); + resolutionResult.z = Mathf.CeilToInt(height / (voxelBounds / resolution)); + + resolutionResult.x = HMath.DevisionBy4(resolutionResult.x); + resolutionResult.y = HMath.DevisionBy4(resolutionResult.y); + resolutionResult.z = HMath.DevisionBy4(resolutionResult.z); + + return resolutionResult; + } + + public static Vector3 Truncate(this Vector3 input, int digits) + { + return new Vector3(input.x.RoundTail(digits), input.y.RoundTail(digits), input.z.RoundTail(digits)); + } + + public static Vector3 Ceil(this Vector3 input, int digits) + { + return new Vector3(input.x.RoundToCeilTail(digits), input.y.RoundToCeilTail(digits), input.z.RoundToCeilTail(digits)); + } + + public static float RoundTail(this float value, int digits) + { + float mult = Mathf.Pow(10.0f, digits); + float result = Mathf.Round(mult * value) / mult; + return result; + } + + public static float RoundToCeilTail(this float value, int digits) + { + float mult = Mathf.Pow(10.0f, digits); + float result = Mathf.Ceil(mult * value) / mult; + return result; + } + + public static Vector2Int CalculateDepthPyramidResolution(Vector2Int screenResolution, int lowestMipLevel) + { + int lowestMipScale = (int)Mathf.Pow(2.0f, lowestMipLevel); + Vector2Int lowestMipResolutiom = new Vector2Int(Mathf.CeilToInt( (float)screenResolution.x / (float)lowestMipScale), + Mathf.CeilToInt( (float)screenResolution.y / (float)lowestMipScale)); + + Vector2Int paddedDepthPyramidResolution = lowestMipResolutiom * lowestMipScale; + return paddedDepthPyramidResolution; + } + + public static int CalculateStepCountSSGI(float giRadius, float giAccuracy) + { + if (giRadius <= 25.0f) + { + //5 -> 16, 10 -> 20, 25 -> 25 + return Mathf.FloorToInt((-0.0233f * giRadius * giRadius + 1.15f * giRadius + 10.833f) * giAccuracy); + } + + //50 -> 35, 100 -> 50, 150 -> 64 + return Mathf.FloorToInt((-0.0002f * giRadius * giRadius + 0.33f * giRadius + 19f) * giAccuracy); + } + + private static int DevisionBy4(int value) + { + return value % 4 == 0 ? value : DevisionBy4(value + 1); + } + + private static float ComputeViewportScale(int viewportSize, int bufferSize) + { + float rcpBufferSize = 1.0f / bufferSize; + + // Scale by (vp_dim / buf_dim). + return viewportSize * rcpBufferSize; + } + + private static float ComputeViewportLimit(int viewportSize, int bufferSize) + { + float rcpBufferSize = 1.0f / bufferSize; + + // Clamp to (vp_dim - 0.5) / buf_dim. + return (viewportSize - 0.5f) * rcpBufferSize; + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HMath.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HMath.cs.meta new file mode 100644 index 0000000..65dcbf6 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HMath.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 120dbec02a6a0a4439d6623081e5ed7b +timeCreated: 1661871568 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Globals/HMath.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HNames.cs b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HNames.cs new file mode 100644 index 0000000..64b81f5 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HNames.cs @@ -0,0 +1,32 @@ +namespace HTraceSSGI.Scripts.Globals +{ + internal static class HNames + { + public const string ASSET_NAME = "HTraceSSGI"; + public const string ASSET_NAME_FULL = "HTrace Screen Space Global Illumination"; + public const string ASSET_NAME_FULL_WITH_DOTS = "HTrace: Screen Space Global Illumination"; + public const string HTRACE_SSGI_DOCUMENTATION_LINK = "https://ipgames.gitbook.io/htrace-ssgi"; + public const string HTRACE_SSGI_DOCUMENTATION_LINK_KNOWN_ISSUES = "https://ipgames.gitbook.io/htrace-ssgi/known-issues"; + public const string HTRACE_SSGI_DOCUMENTATION_LINK_FAQ = "https://ipgames.gitbook.io/htrace-ssgi/frequently-asked-questions"; + public const string HTRACE_DISCORD_LINK = "https://discord.com/invite/Nep56Efu7A"; + public const string HTRACE_DISCORD_BUGS_SSGI_LINK = "https://discord.gg/4FN9wsYt5T"; + public const string HTRACE_SSGI_VERSION = "1.2.0"; + + //Prefs + public const string HTRACE_SHOW_KEY = "HTraceSSGI_ShowWelcomeWindow"; + public const string HTRACE_WELCOME_SHOW_SESSION = "HTraceSSGI_ShowWelcomeWindowSessions"; + public const string HTRACE_UNITY_VERSION_KEY = "HTraceSSGI_UnityVersion"; + + // ---------------- Profiling ---------------- + public const string HTRACE_PRE_PASS_NAME = "HTraceSSGI Pre Pass"; + public const string HTRACE_MV_PASS_NAME = "HTraceSSGI Motion Vectors Pass"; + public const string HTRACE_OBJECTS_MV_PASS_NAME = "HTraceSSGI Objects Motion Vectors Pass"; + public const string HTRACE_CAMERA_MV_PASS_NAME = "HTraceSSGI Camera Motion Vectors Pass"; + public const string HTRACE_GBUFFER_PASS_NAME = "HTraceSSGI GBuffer Pass"; + public const string HTRACE_SSGI_PASS_NAME = "HTraceSSGI SSGI Pass"; + public const string HTRACE_FINAL_PASS_NAME = "HTraceSSGI Final Pass"; + + public const string KEYWORD_SWITCHER = "HTRACEGI_OVERRIDE"; + //public const string INT_SWITCHER = "_HTRACE_INT_OVERRIDE"; + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HNames.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HNames.cs.meta new file mode 100644 index 0000000..ba3c538 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HNames.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5a739df963d4e354f8d13ac9e5e6ee44 +timeCreated: 1691582446 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Globals/HNames.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRenderer.cs b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRenderer.cs new file mode 100644 index 0000000..095deb6 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRenderer.cs @@ -0,0 +1,135 @@ +//pipelinedefine +#define H_URP + +using System.Collections.Generic; +using System.Reflection; +using UnityEditor; +using UnityEngine; +using UnityEngine.Rendering; +using HTraceSSGI.Scripts.Infrastructure.URP; +using UnityEngine.Rendering.Universal; + +namespace HTraceSSGI.Scripts.Globals +{ + public enum HRenderPipeline + { + None, + BIRP, + URP, + HDRP + } + + public static class HRenderer + { + static HRenderPipeline s_CurrentHRenderPipeline = HRenderPipeline.None; + + public static HRenderPipeline CurrentHRenderPipeline + { + get + { + if (s_CurrentHRenderPipeline == HRenderPipeline.None) + { + s_CurrentHRenderPipeline = GetRenderPipeline(); + } + return s_CurrentHRenderPipeline; + } + } + + private static HRenderPipeline GetRenderPipeline() + { + if (GraphicsSettings.currentRenderPipeline) + { + if (GraphicsSettings.currentRenderPipeline.GetType().ToString().Contains("HighDefinition")) + return HRenderPipeline.HDRP; + else + return HRenderPipeline.URP; + } + + return HRenderPipeline.BIRP; + } + + public static bool SupportsInlineRayTracing + { + get + { + #if UNITY_2023_1_OR_NEWER + return SystemInfo.supportsInlineRayTracing; + #else + return false; + #endif + } + } + + public static bool SupportsRayTracing + { + get + { + #if UNITY_2023_1_OR_NEWER // TODO: revert this to 2019 when raytracing issue in 2022 is resolved + if (SystemInfo.supportsRayTracing == false) + return false; + + + return true; + #else + return false; + #endif + } + } + + + public static int TextureXrSlices + { + get + { + if (Application.isPlaying == false) + return 1; + + + return 1; + } + } + + static RenderTexture emptyTexture; + public static RenderTexture EmptyTexture + { + get + { + if (emptyTexture == null) + { + emptyTexture = new RenderTexture(4, 4, 0); + emptyTexture.enableRandomWrite = true; + emptyTexture.dimension = TextureDimension.Tex2D; + emptyTexture.format = RenderTextureFormat.ARGBFloat; + emptyTexture.Create(); + } + + return emptyTexture; + } + } + + private static Mesh _fullscreenTriangle; + public static Mesh FullscreenTriangle + { + get + { + if (_fullscreenTriangle != null) + return _fullscreenTriangle; + + _fullscreenTriangle = new Mesh { name = "Fullscreen Triangle" }; + + // Because we have to support older platforms (GLES2/3, DX9 etc) we can't do all of + // this directly in the vertex shader using vertex ids :( + _fullscreenTriangle.SetVertices(new List + { + new Vector3(-1f, -1f, 0f), + new Vector3(-1f, 3f, 0f), + new Vector3( 3f, -1f, 0f) + }); + _fullscreenTriangle.SetIndices(new[] { 0, 1, 2 }, MeshTopology.Triangles, 0, false); + _fullscreenTriangle.UploadMeshData(false); + + return _fullscreenTriangle; + } + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRenderer.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRenderer.cs.meta new file mode 100644 index 0000000..dffe269 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRenderer.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 360412b93660c734f943ed19ba9c2e52 +timeCreated: 1727432136 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Globals/HRenderer.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRendererURP.cs b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRendererURP.cs new file mode 100644 index 0000000..f93647f --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRendererURP.cs @@ -0,0 +1,264 @@ +//pipelinedefine +#define H_URP + +using System; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; +using UnityEngine.Rendering; +using HTraceSSGI.Scripts.Infrastructure.URP; +using UnityEditor; +using UnityEngine.Rendering.Universal; + +namespace HTraceSSGI.Scripts.Globals +{ + public static class HRendererURP + { + public static bool RenderGraphEnabled + { + get + { +#if UNITY_2023_3_OR_NEWER + return GraphicsSettings.GetRenderPipelineSettings().enableRenderCompatibilityMode == false; +#endif + return false; + } + } + + public static UniversalRenderPipelineAsset UrpAsset => + GraphicsSettings.currentRenderPipeline is UniversalRenderPipelineAsset urpAsset ? urpAsset : null; + +#if UNITY_EDITOR + private static FieldInfo s_rendererDataListFieldInfo; + private static FieldInfo s_defaultRendererIndexFieldInfo; + + private static ScriptableRendererData[] GetRendererDataList() + { + var urpAsset = UrpAsset; + if (urpAsset == null) + return null; + + try + { + if (s_rendererDataListFieldInfo == null) + s_rendererDataListFieldInfo = typeof(UniversalRenderPipelineAsset) + .GetField("m_RendererDataList", BindingFlags.Instance | BindingFlags.NonPublic); + + if (s_rendererDataListFieldInfo == null) + return null; + + return (ScriptableRendererData[])s_rendererDataListFieldInfo.GetValue(urpAsset); + } + catch (Exception e) + { + Debug.LogError($"Failed to get renderer data list: {e.Message}"); + return null; + } + } + + private static int GetDefaultRendererIndex() + { + var urpAsset = UrpAsset; + if (urpAsset == null) + return -1; + + try + { + if (s_defaultRendererIndexFieldInfo == null) + s_defaultRendererIndexFieldInfo = typeof(UniversalRenderPipelineAsset) + .GetField("m_DefaultRendererIndex", BindingFlags.Instance | BindingFlags.NonPublic); + + if (s_defaultRendererIndexFieldInfo == null) + return -1; + + return (int)s_defaultRendererIndexFieldInfo.GetValue(urpAsset); + } + catch (Exception e) + { + Debug.LogError($"Failed to get default renderer index: {e.Message}"); + return -1; + } + } + + public static UniversalRendererData UniversalRendererData => GetUniversalRendererData(); + + /// + /// Get UniversalRendererData by index or default + /// + /// Renderer index. If -1 - than default + /// + private static UniversalRendererData GetUniversalRendererData(int rendererIndex = -1) + { + var rendererDataList = GetRendererDataList(); + if (rendererDataList == null || rendererDataList.Length == 0) + return null; + + if (rendererIndex == -1) rendererIndex = GetDefaultRendererIndex(); + + // Index validation + if (rendererIndex < 0 || rendererIndex >= rendererDataList.Length) + { + Debug.LogWarning( + $"Invalid renderer index {rendererIndex}. Available renderers: {rendererDataList.Length}"); + return null; + } + + return rendererDataList[rendererIndex] as UniversalRendererData; + } + + public static bool IsSsaoNativeEnabled() + { + return HasRendererFeatureByTypeName("ScreenSpaceAmbientOcclusion"); + } + + private static bool HasRendererFeatureByTypeName(string typeName, int rendererIndex = -1) + { + return GetRendererFeatureByTypeName(typeName, rendererIndex) != null; + } + + public static ScriptableRendererFeature GetRendererFeatureByTypeName(string typeName, int rendererIndex = -1) + { + var rendererDataList = GetRendererDataList(); + if (rendererDataList == null || rendererDataList.Length == 0) + return null; + + var renderersToSearch = new List(); + + if (rendererIndex >= 0 && rendererIndex < rendererDataList.Length) + renderersToSearch.Add(rendererDataList[rendererIndex]); + else + renderersToSearch.AddRange(rendererDataList); + + foreach (var rendererData in renderersToSearch) + { + if (rendererData?.rendererFeatures == null) continue; + + foreach (var feature in rendererData.rendererFeatures) + { + if (feature == null) continue; + + if (feature.GetType().Name.Contains(typeName, StringComparison.OrdinalIgnoreCase)) return feature; + } + } + + return null; + } + + public static T GetRendererFeature(int rendererIndex = -1) where T : ScriptableRendererFeature + { + var rendererDataList = GetRendererDataList(); + if (rendererDataList == null || rendererDataList.Length == 0) + return null; + + var renderersToSearch = new List(); + + if (rendererIndex >= 0 && rendererIndex < rendererDataList.Length) + renderersToSearch.Add(rendererDataList[rendererIndex]); + else + renderersToSearch.AddRange(rendererDataList); + + foreach (var rendererData in renderersToSearch) + { + if (rendererData?.rendererFeatures == null) continue; + + foreach (var feature in rendererData.rendererFeatures) + if (feature is T typedFeature) + return typedFeature; + } + + return null; + } + + private static bool ContainsRenderFeature(List features, string name) + { + if (features == null) return false; + + for (var i = 0; i < features.Count; i++) + if (features[i]?.name == name) + return true; + return false; + } + + public static void AddHTraceRendererFeatureToUniversalRendererData() + { + var universalRendererData = UniversalRendererData; + if (universalRendererData?.rendererFeatures == null) + { + Debug.LogWarning("Universal Renderer Data not found or has no features list"); + return; + } + + var features = universalRendererData.rendererFeatures; + + CleanupRendererFeatures(features); + + if (!ContainsRenderFeature(features, nameof(HTraceSSGIRendererFeature))) + AddHTraceRendererFeature(universalRendererData, features); + + universalRendererData.SetDirty(); + } + + private static void CleanupRendererFeatures(List features) + { + for (var i = features.Count - 1; i >= 0; i--) + { + var feature = features[i]; + + // Delete null elements + if (feature == null) + { + features.RemoveAt(i); + continue; + } + + if (feature.GetType() == typeof(HTraceSSGIRendererFeature)) features.RemoveAt(i); + } + } + + private static void AddHTraceRendererFeature(UniversalRendererData universalRendererData, List features) + { + try + { + var hTraceFeature = ScriptableObject.CreateInstance(); + AssetDatabase.AddObjectToAsset(hTraceFeature, universalRendererData); + features.Add(hTraceFeature); + + Debug.Log($"{HNames.ASSET_NAME} Renderer Feature added successfully"); + } + catch (Exception e) + { + Debug.LogError($"Failed to add {HNames.ASSET_NAME} Renderer Feature: {e.Message}"); + } + } + + /// + /// Get all renderer features by Type in all RendererDatas + /// + /// Тип renderer feature + /// + public static List GetAllRendererFeatures() where T : ScriptableRendererFeature + { + var result = new List(); + var rendererDataList = GetRendererDataList(); + + if (rendererDataList == null) return result; + + foreach (var rendererData in rendererDataList) + { + if (rendererData?.rendererFeatures == null) continue; + + foreach (var feature in rendererData.rendererFeatures) + if (feature is T typedFeature) + result.Add(typedFeature); + } + + return result; + } + + public static int GetRenderersCount() + { + return GetRendererDataList()?.Length ?? 0; + } +#endif // UNITY_EDITOR + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRendererURP.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRendererURP.cs.meta new file mode 100644 index 0000000..153d5d5 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HRendererURP.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 7c6ca928c19f4bff95978f4d91d3733e +timeCreated: 1757343206 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Globals/HRendererURP.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HShaderParams.cs b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HShaderParams.cs new file mode 100644 index 0000000..5064320 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HShaderParams.cs @@ -0,0 +1,75 @@ +using UnityEngine; +using UnityEngine.Rendering; + +namespace HTraceSSGI.Scripts.Globals +{ + public static class HShaderParams + { + // ---------------------------------------------- Globals, "g_" prefix ---------------------------------------------- + public static readonly int g_HTraceGBuffer0 = Shader.PropertyToID("g_HTraceGBuffer0"); + public static readonly int g_HTraceGBuffer1 = Shader.PropertyToID("g_HTraceGBuffer1"); + public static readonly int g_HTraceGBuffer2 = Shader.PropertyToID("g_HTraceGBuffer2"); + public static readonly int g_HTraceGBuffer3 = Shader.PropertyToID("g_HTraceGBuffer3"); + public static readonly int g_HTraceRenderLayerMask = Shader.PropertyToID("g_HTraceRenderLayerMask"); + public static readonly int g_HTraceColor = Shader.PropertyToID("g_HTraceColor"); + public static readonly int g_HTraceDepth = Shader.PropertyToID("g_HTraceDepth"); + public static readonly int g_HTraceNormals = Shader.PropertyToID("g_HTraceNormals"); + public static readonly int g_HTraceSSAO = Shader.PropertyToID("g_HTraceSSAO"); + public static readonly int g_HTraceDepthPyramidSSGI = Shader.PropertyToID("g_HTraceDepthPyramidSSGI"); + public static readonly int g_HTraceStencilBuffer = Shader.PropertyToID("g_HTraceStencilBuffer"); + public static readonly int g_HTraceMotionVectors = Shader.PropertyToID("g_HTraceMotionVectors"); + public static readonly int g_HTraceMotionMask = Shader.PropertyToID("g_HTraceMotionMask"); + public static readonly int g_HTraceBufferAO = Shader.PropertyToID("_HTraceBufferAO"); + public static readonly int g_ScreenSpaceOcclusionTexture = Shader.PropertyToID("_ScreenSpaceOcclusionTexture"); + public static readonly int g_CameraDepthTexture = Shader.PropertyToID("_CameraDepthTexture"); + public static readonly int g_CameraNormalsTexture = Shader.PropertyToID("_CameraNormalsTexture"); + + + // ---------------------------------------------- GBuffer ---------------------------------------------- + public static readonly int _GBuffer0 = Shader.PropertyToID("_GBuffer0"); + public static readonly int _GBuffer1 = Shader.PropertyToID("_GBuffer1"); + public static readonly int _GBuffer2 = Shader.PropertyToID("_GBuffer2"); + public static readonly int _GBuffer3 = Shader.PropertyToID("_GBuffer3"); + public static readonly int _CameraRenderingLayersTexture = Shader.PropertyToID("_CameraRenderingLayersTexture"); + public static readonly int _GBufferTexture0 = Shader.PropertyToID("_GBufferTexture0"); + public static readonly int _RenderingLayerMaskTexture = Shader.PropertyToID("_RenderingLayersTexture"); + public static readonly int _CameraGBufferTexture0 = Shader.PropertyToID("_CameraGBufferTexture0"); + + public static readonly int _DepthPyramid_OutputMIP0 = Shader.PropertyToID("_DepthPyramid_OutputMIP0"); + public static readonly int _DepthPyramid_OutputMIP1 = Shader.PropertyToID("_DepthPyramid_OutputMIP1"); + public static readonly int _DepthPyramid_OutputMIP2 = Shader.PropertyToID("_DepthPyramid_OutputMIP2"); + public static readonly int _DepthPyramid_OutputMIP3 = Shader.PropertyToID("_DepthPyramid_OutputMIP3"); + public static readonly int _DepthPyramid_OutputMIP4 = Shader.PropertyToID("_DepthPyramid_OutputMIP4"); + + public static readonly int H_SHAr = Shader.PropertyToID("H_SHAr"); + public static readonly int H_SHAg = Shader.PropertyToID("H_SHAg"); + public static readonly int H_SHAb = Shader.PropertyToID("H_SHAb"); + public static readonly int H_SHBr = Shader.PropertyToID("H_SHBr"); + public static readonly int H_SHBg = Shader.PropertyToID("H_SHBg"); + public static readonly int H_SHBb = Shader.PropertyToID("H_SHBb"); + public static readonly int H_SHC = Shader.PropertyToID("H_SHC"); + + public static readonly string _GBUFFER_NORMALS_OCT = "_GBUFFER_NORMALS_OCT"; + public static readonly string _WRITE_RENDERING_LAYERS = "_WRITE_RENDERING_LAYERS"; + + public static readonly ShaderTagId UniversalGBufferTag = new ShaderTagId("UniversalGBuffer"); + + // ---------------------------------------------- Matrix ---------------------------------------------- + public static readonly int H_MATRIX_VP = Shader.PropertyToID("_H_MATRIX_VP"); + public static readonly int H_MATRIX_I_VP = Shader.PropertyToID("_H_MATRIX_I_VP"); + public static readonly int H_MATRIX_PREV_VP = Shader.PropertyToID("_H_MATRIX_PREV_VP"); + public static readonly int H_MATRIX_PREV_I_VP = Shader.PropertyToID("_H_MATRIX_PREV_I_VP"); + + // ---------------------------------------------- Additional ---------------------------------------------- + public static int HRenderScale = Shader.PropertyToID("_HRenderScale"); + public static int HRenderScalePrevious = Shader.PropertyToID("_HRenderScalePrevious"); + public static int FrameCount = Shader.PropertyToID("_FrameCount"); + public static int ScreenSize = Shader.PropertyToID("_ScreenSize"); + + // ---------------------------------------------- Shared Params Other ---------------------------------------------- + public static readonly int SliceXR = Shader.PropertyToID("_SliceXR"); + public static readonly int IndexXR = Shader.PropertyToID("_IndexXR"); + + public static readonly int RTAS = Shader.PropertyToID("_RTAS"); + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Globals/HShaderParams.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HShaderParams.cs.meta new file mode 100644 index 0000000..5fd81a6 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Globals/HShaderParams.cs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 4df35d7b3e464734bb736f10640562a2 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Globals/HShaderParams.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/HTraceSSGI.cs b/Assets/Plugins/HTraceSSGI/Scripts/HTraceSSGI.cs new file mode 100644 index 0000000..2491979 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/HTraceSSGI.cs @@ -0,0 +1,51 @@ +//pipelinedefine +#define H_URP + + +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Infrastructure.URP; +using UnityEngine; + +namespace HTraceSSGI.Scripts +{ + [ExecuteAlways, ExecuteInEditMode, ImageEffectAllowedInSceneView, DefaultExecutionOrder(100)] + [HelpURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK)] + public class HTraceSSGI : MonoBehaviour + { + [Tooltip("Currently used HTrace SSGI profile with settings")] + public HTraceSSGIProfile Profile; + + private void OnEnable() { + CheckProfile(); + } + + private void OnDisable() + { + HTraceSSGISettings.SetProfile(null); + } + + void OnValidate() { + CheckProfile(); + } + + private void Reset() { + CheckProfile(); + } + + void CheckProfile() + { + if (Profile == null) + { + Profile = ScriptableObject.CreateInstance(); + Profile.name = "New HTrace SSGI Profile"; +#if UNITY_EDITOR + UnityEditor.EditorUtility.SetDirty(this); +#endif + } + + HTraceSSGISettings.SetProfile(this.Profile); + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/HTraceSSGI.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/HTraceSSGI.cs.meta new file mode 100644 index 0000000..1777641 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/HTraceSSGI.cs.meta @@ -0,0 +1,18 @@ +fileFormatVersion: 2 +guid: dc3b78b63e384f78ba4235b7e210bccc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 72a9ca4a910cb6e478e3b0b89afa0b3c, type: 3} + userData: + assetBundleName: + assetBundleVariant: +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/HTraceSSGI.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure.meta b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure.meta new file mode 100644 index 0000000..987d994 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f6b3ef9f6a43b53428590848541b0650 +timeCreated: 1724837665 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP.meta b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP.meta new file mode 100644 index 0000000..2ad4627 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 39d33876f15f45c091746aa50bedf133 +timeCreated: 1745943075 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HAmbientOverrideVolume.cs b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HAmbientOverrideVolume.cs new file mode 100644 index 0000000..ac691b0 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HAmbientOverrideVolume.cs @@ -0,0 +1,180 @@ +//pipelinedefine +#define H_URP + +using System; +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Globals; +using UnityEngine; +using UnityEngine.Rendering; +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace HTraceSSGI.Scripts.Infrastructure.URP +{ + [ExecuteAlways] + public class HAmbientOverrideVolume: MonoBehaviour + { + private Volume _volumeComponent; +#if UNITY_6000_0_OR_NEWER + private ProbeVolumesOptions _probeVolumesOptionsOverrideComponent; +#endif + + private static HAmbientOverrideVolume s_instance; + + public static HAmbientOverrideVolume Instance + { + get + { + if (s_instance == null) + { + s_instance = FindObjectOfType(); + + if (s_instance == null) + { + GameObject singletonObject = new GameObject($"HTrace AmbientOverride"); + s_instance = singletonObject.AddComponent(); + + if (Application.isPlaying) + DontDestroyOnLoad(singletonObject); + } + } + + return s_instance; + } + } + + public void SetActiveVolume(bool isActive) + { + _volumeComponent.enabled = isActive; +#if UNITY_6000_0_OR_NEWER + _probeVolumesOptionsOverrideComponent.active = isActive; +#endif + } + + private void Awake() + { + InitializeSingleton(); + SetupVolumeURP(); + } + + private void InitializeSingleton() + { + if (s_instance == null) + { + s_instance = this; + if (Application.isPlaying) + DontDestroyOnLoad(gameObject); + } + else if (s_instance != this) + { + if (Application.isPlaying) + Destroy(gameObject); + else + DestroyImmediate(gameObject); + } + } + +#if UNITY_EDITOR + private void OnValidate() + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + if (!EditorApplication.isPlayingOrWillChangePlaymode) + SetupVolumeURP(); + + gameObject.hideFlags = HideFlags.HideAndDontSave; + if (s_instance != null && profile != null && profile.DebugSettings != null) + s_instance.gameObject.hideFlags = profile.DebugSettings.ShowBowels ? HideFlags.None : HideFlags.HideAndDontSave; + } +#endif + + private void OnDestroy() + { + if (s_instance == this) + { + s_instance = null; + } + } + + private void SetupVolumeURP() + { +#if UNITY_6000_0_OR_NEWER + CreateSSGIOverrideComponent(); + ApplySSGIOverrideComponentSettings(); + ChangeObjectWithSerialization_ONLYEDITOR(); +#endif + } + +#if UNITY_6000_0_OR_NEWER + private void CreateSSGIOverrideComponent() + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + if (profile != null && profile != null && profile.DebugSettings != null) + gameObject.hideFlags = profile.DebugSettings.ShowBowels ? HideFlags.None : HideFlags.HideAndDontSave; + + _volumeComponent = gameObject.GetComponent(); + if (_volumeComponent == null) + { + _volumeComponent = gameObject.AddComponent(); + _volumeComponent.enabled = false; + } + + if (_volumeComponent.sharedProfile == null) + { + //We can't crate it in runtime, because after build it will break. + //it will call only in editor, but if someone changes it in runtime, we will override. + _volumeComponent.sharedProfile = Resources.Load($"{HNames.ASSET_NAME}/HTraceSSGI Volume Profile URP"); + } + + if (_probeVolumesOptionsOverrideComponent == null) + _volumeComponent.sharedProfile.TryGet(out _probeVolumesOptionsOverrideComponent); + } + + private void ApplySSGIOverrideComponentSettings() + { + _volumeComponent.weight = 1; + _volumeComponent.priority = 100; +#if UNITY_EDITOR + _volumeComponent.runInEditMode = true; +#endif + if (_probeVolumesOptionsOverrideComponent != null) + { + _probeVolumesOptionsOverrideComponent.normalBias.overrideState = true; + _probeVolumesOptionsOverrideComponent.viewBias.overrideState = true; + _probeVolumesOptionsOverrideComponent.samplingNoise.overrideState = true; + } + } + + private void ChangeObjectWithSerialization_ONLYEDITOR() + { +#if UNITY_EDITOR + if (_probeVolumesOptionsOverrideComponent == null) + return; + + SerializedObject probeVolumesOptionsObject = new SerializedObject(_probeVolumesOptionsOverrideComponent); + + var normalBias = probeVolumesOptionsObject.FindProperty("normalBias"); + var m_OverrideState_normalBias = normalBias.FindPropertyRelative("m_OverrideState"); + var m_Value_normalBias = normalBias.FindPropertyRelative("m_Value"); + m_OverrideState_normalBias.boolValue = true; + m_Value_normalBias.floatValue = 0.0f; + + var viewBias = probeVolumesOptionsObject.FindProperty("viewBias"); + var m_OverrideState_viewBias = viewBias.FindPropertyRelative("m_OverrideState"); + var m_Value_viewBias = viewBias.FindPropertyRelative("m_Value"); + m_OverrideState_viewBias.boolValue = true; + m_Value_viewBias.floatValue = 0.0f; + + var samplingNoise = probeVolumesOptionsObject.FindProperty("samplingNoise"); + var m_OverrideState_samplingNoise = samplingNoise.FindPropertyRelative("m_OverrideState"); + var m_Value_samplingNoise = samplingNoise.FindPropertyRelative("m_Value"); + m_OverrideState_samplingNoise.boolValue = true; + m_Value_samplingNoise.floatValue = 0.0f; + + probeVolumesOptionsObject.ApplyModifiedProperties(); +#endif + } +#endif + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HAmbientOverrideVolume.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HAmbientOverrideVolume.cs.meta new file mode 100644 index 0000000..120249e --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HAmbientOverrideVolume.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 665d2080decf49c2b73ac4747dbde1df +timeCreated: 1757588204 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Infrastructure/URP/HAmbientOverrideVolume.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIRendererFeature.cs b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIRendererFeature.cs new file mode 100644 index 0000000..6b53cc3 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIRendererFeature.cs @@ -0,0 +1,229 @@ +//pipelinedefine +#define H_URP + +using System; +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Editor; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Passes.URP; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; +#if UNITY_EDITOR +using HTraceSSGI.Scripts.PipelelinesConfigurator; +using UnityEditor; +#endif + +namespace HTraceSSGI.Scripts.Infrastructure.URP +{ + [DisallowMultipleRendererFeature] + [ExecuteAlways, ExecuteInEditMode] + [HelpURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK)] + public class HTraceSSGIRendererFeature : ScriptableRendererFeature + { + public bool UseVolumes = true; + internal static bool IsUseVolumes { get; private set; } + + private PrePassURP _prePassURP; + private MotionVectorsURP _motionVectors; + private GBufferPassURP _gBufferPass; + private SSGIPassURP _ssgiPassUrp; + private FinalPassURP _finalPassURP; + + private bool _initialized = false; + + /// + /// Initializes this feature's resources. This is called every time serialization happens. + /// + public override void Create() + { + name = HNames.ASSET_NAME_FULL; + // ActiveProfile = Profile; + IsUseVolumes = UseVolumes; + Dispose(); + + if (UseVolumes) + { + var stack = VolumeManager.instance.stack; + HTraceSSGIVolume hTraceVolume = stack?.GetComponent(); + SettingsBuild(hTraceVolume); + } + + _prePassURP = new PrePassURP(); + _prePassURP.renderPassEvent = RenderPassEvent.AfterRenderingOpaques; + _motionVectors = new MotionVectorsURP(); + _motionVectors.renderPassEvent = RenderPassEvent.AfterRenderingOpaques; + _gBufferPass = new GBufferPassURP(); + _gBufferPass.renderPassEvent = RenderPassEvent.AfterRenderingOpaques; + _ssgiPassUrp = new SSGIPassURP(); + _ssgiPassUrp.renderPassEvent = RenderPassEvent.AfterRenderingOpaques; + _finalPassURP = new FinalPassURP(); + _finalPassURP.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing; + +#if UNITY_EDITOR + HPipelinesConfigurator.AlwaysIncludedShaders(); +#endif + + _initialized = true; + } + + /// + /// Called when render targets are allocated and ready to be used. + /// + /// + /// + /// + public override void SetupRenderPasses(ScriptableRenderer renderer, in RenderingData renderingData) + { + if (_initialized == false) + return; + + if (HRendererURP.RenderGraphEnabled == false) + { + _prePassURP.Initialize(renderer); + _motionVectors.Initialize(renderer); + _gBufferPass.Initialize(renderer); + _ssgiPassUrp.Initialize(renderer); + _finalPassURP.Initialize(renderer); + } + } + + /// + /// Injects one or multiple ScriptableRenderPass in the renderer. + /// + /// + /// + public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) + { + if (renderingData.cameraData.cameraType == CameraType.Reflection || renderingData.cameraData.cameraType == CameraType.Preview) + return; + + var isActive = HTraceSSGISettings.ActiveProfile != null; + + IsUseVolumes = UseVolumes; + if (UseVolumes) + { + var stack = VolumeManager.instance.stack; + var hTraceVolume = stack.GetComponent(); + isActive = hTraceVolume != null && hTraceVolume.IsActive(); + + SettingsBuild(hTraceVolume); + } + +#if UNITY_6000_0_OR_NEWER + HAmbientOverrideVolume.Instance.SetActiveVolume(isActive && HTraceSSGISettings.ActiveProfile != null && HTraceSSGISettings.ActiveProfile.GeneralSettings != null && HTraceSSGISettings.ActiveProfile.GeneralSettings.AmbientOverride); +#endif + + if (!isActive) + return; + +#if !UNITY_2022_1_OR_NEWER + _prePassURP.Initialize(renderer); + _motionVectors.Initialize(renderer); + _gBufferPass.Initialize(renderer); + _ssgiPassUrp.Initialize(renderer); + _finalPassURP.Initialize(renderer); +#endif + renderer.EnqueuePass(_prePassURP); + renderer.EnqueuePass(_motionVectors); + renderer.EnqueuePass(_gBufferPass); + renderer.EnqueuePass(_ssgiPassUrp); + renderer.EnqueuePass(_finalPassURP); + } + + private void SettingsBuild(HTraceSSGIVolume hTraceVolume) + { + if (hTraceVolume == null || UseVolumes == false) + return; + + if (HTraceSSGISettings.ActiveProfile == null) + { + HTraceSSGISettings.SetProfile(ScriptableObject.CreateInstance()); +#if UNITY_EDITOR + HTraceSSGISettings.ActiveProfile.ApplyPreset(HTraceSSGIPreset.Balanced); +#endif + HTraceSSGISettings.ActiveProfile.name = "New HTrace SSGI Profile"; + } + + var activeProfile = HTraceSSGISettings.ActiveProfile; + + // Global Settings + activeProfile.GeneralSettings.DebugMode = hTraceVolume.DebugMode.value; + activeProfile.GeneralSettings.HBuffer = hTraceVolume.HBuffer.value; + + // Global - Pipeline Integration + activeProfile.GeneralSettings.MetallicIndirectFallback = hTraceVolume.MetallicIndirectFallback.value; + activeProfile.GeneralSettings.AmbientOverride = hTraceVolume.AmbientOverride.value; + activeProfile.GeneralSettings.Multibounce = hTraceVolume.Multibounce.value; +#if UNITY_2023_3_OR_NEWER + activeProfile.GeneralSettings.ExcludeReceivingMask = hTraceVolume.ExcludeReceivingMask.value; + activeProfile.GeneralSettings.ExcludeCastingMask = hTraceVolume.ExcludeCastingMask.value; +#endif + activeProfile.GeneralSettings.FallbackType = hTraceVolume.FallbackType.value; + activeProfile.GeneralSettings.SkyIntensity = hTraceVolume.SkyIntensity.value; + + // APV parameters + activeProfile.GeneralSettings.ViewBias = hTraceVolume.ViewBias.value; + activeProfile.GeneralSettings.NormalBias = hTraceVolume.NormalBias.value; + activeProfile.GeneralSettings.SamplingNoise = hTraceVolume.SamplingNoise.value; + activeProfile.GeneralSettings.IntensityMultiplier = hTraceVolume.IntensityMultiplier.value; + activeProfile.GeneralSettings.DenoiseFallback = hTraceVolume.DenoiseFallback.value; + + // Global - Visuals + activeProfile.SSGISettings.BackfaceLighting = hTraceVolume.BackfaceLighting.value; + activeProfile.SSGISettings.MaxRayLength = hTraceVolume.MaxRayLength.value; + activeProfile.SSGISettings.ThicknessMode = hTraceVolume.ThicknessMode.value; + activeProfile.SSGISettings.Thickness = hTraceVolume.Thickness.value; + activeProfile.SSGISettings.Intensity = hTraceVolume.Intensity.value; + activeProfile.SSGISettings.Falloff = hTraceVolume.Falloff.value; + + // Quality - Tracing + activeProfile.SSGISettings.RayCount = hTraceVolume.RayCount.value; + activeProfile.SSGISettings.StepCount = hTraceVolume.StepCount.value; + activeProfile.SSGISettings.RefineIntersection = hTraceVolume.RefineIntersection.value; + activeProfile.SSGISettings.FullResolutionDepth = hTraceVolume.FullResolutionDepth.value; + + // Quality - Rendering + activeProfile.SSGISettings.Checkerboard = hTraceVolume.Checkerboard.value; + activeProfile.SSGISettings.RenderScale = hTraceVolume.RenderScale.value; + + // Denoising + activeProfile.DenoisingSettings.BrightnessClamp = hTraceVolume.BrightnessClamp.value; + activeProfile.DenoisingSettings.MaxValueBrightnessClamp = hTraceVolume.MaxValueBrightnessClamp.value; + activeProfile.DenoisingSettings.MaxDeviationBrightnessClamp = hTraceVolume.MaxDeviationBrightnessClamp.value; + + // Denoising - ReSTIR Validation + activeProfile.DenoisingSettings.HalfStepValidation = hTraceVolume.HalfStepValidation.value; + activeProfile.DenoisingSettings.SpatialOcclusionValidation = hTraceVolume.SpatialOcclusionValidation.value; + activeProfile.DenoisingSettings.TemporalLightingValidation = hTraceVolume.TemporalLightingValidation.value; + activeProfile.DenoisingSettings.TemporalOcclusionValidation = hTraceVolume.TemporalOcclusionValidation.value; + + // Denoising - Spatial Filter + activeProfile.DenoisingSettings.SpatialRadius = hTraceVolume.SpatialRadius.value; + activeProfile.DenoisingSettings.Adaptivity = hTraceVolume.Adaptivity.value; + activeProfile.DenoisingSettings.RecurrentBlur = hTraceVolume.RecurrentBlur.value; + activeProfile.DenoisingSettings.FireflySuppression = hTraceVolume.FireflySuppression.value; + + // Debug + activeProfile.DebugSettings.ShowBowels = hTraceVolume.ShowBowels.value; + } + + protected override void Dispose(bool disposing) + { + _prePassURP?.Dispose(); + _motionVectors?.Dispose(); + _gBufferPass?.Dispose(); + _ssgiPassUrp?.Dispose(); + _finalPassURP?.Dispose(); + + _prePassURP = null; + _motionVectors = null; + _gBufferPass = null; + _ssgiPassUrp = null; + _finalPassURP = null; + + _initialized = false; + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIRendererFeature.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIRendererFeature.cs.meta new file mode 100644 index 0000000..106be19 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIRendererFeature.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 43a84b065505d8f41b624b74c882ed4b +timeCreated: 1729922427 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIRendererFeature.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIVolume.cs b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIVolume.cs new file mode 100644 index 0000000..095902b --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIVolume.cs @@ -0,0 +1,231 @@ +//pipelinedefine +#define H_URP + + +using System; +using HTraceSSGI.Scripts.Globals; +using UnityEditor; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +namespace HTraceSSGI.Scripts.Infrastructure.URP +{ +#if UNITY_2023_1_OR_NEWER + [VolumeComponentMenu("Lighting/HTrace: Screen Space Global Illumination"), SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] +#else +[VolumeComponentMenuForRenderPipeline("Lighting/HTrace: Screen Space Global Illumination", typeof(UniversalRenderPipeline))] +#endif +#if UNITY_2023_3_OR_NEWER + [VolumeRequiresRendererFeatures(typeof(HTraceSSGIRendererFeature))] +#endif + [HelpURL(HNames.HTRACE_SSGI_DOCUMENTATION_LINK)] + public sealed class HTraceSSGIVolume : VolumeComponent, IPostProcessComponent + { + public HTraceSSGIVolume() + { + displayName = HNames.ASSET_NAME_FULL; + } + + /// + /// Enable Screen Space Global Illumination. + /// + [Tooltip("Enable HTrace Screen Space Global Illumination")] + public BoolParameter Enable = new BoolParameter(false, BoolParameter.DisplayType.EnumPopup); + + // --------------------------------------- GLOBAL SETTINGS --------------------------------------------- + + [InspectorName("Debug Mode"), Tooltip("")] + public DebugModeParameter DebugMode = new(Globals.DebugMode.None, false); + + [InspectorName("Buffer"), Tooltip("Visualizes data from different buffers for debugging")] + public HBufferParameter HBuffer = new(Globals.HBuffer.Multi, false); + +#if UNITY_2023_3_OR_NEWER + [InspectorName("Exclude Casting Mask"), Tooltip("Prevents objects on the selected layers from contributing to GI")] + public RenderingLayerMaskEnumParameter ExcludeCastingMask = new(0, false); + + [InspectorName("Exclude Receiving Mask"), Tooltip("Prevents objects on the selected layers from receiving GI")] + public RenderingLayerMaskEnumParameter ExcludeReceivingMask = new(0, false); +#endif + + [InspectorName("Fallback Type"), Tooltip("Fallback data for rays that failed to find a hit in screen space")] + public FallbackTypeParameter FallbackType = new FallbackTypeParameter(Globals.FallbackType.None, false); + + [InspectorName("Sky Intensity"), Tooltip("Brightness of the sky used for fallback")] + public ClampedFloatParameter SkyIntensity = new ClampedFloatParameter(0.5f, 0.0f, 1.0f, false); + + [InspectorName("View Bias"), Tooltip("Offsets the APV sample position towards the camera")] + public ClampedFloatParameter ViewBias = new ClampedFloatParameter(0.1f, 0.0f, 2.0f, false); + + [InspectorName("Normal Bias"), Tooltip("Offsets the APV sample position along the pixel’s surface normal")] + public ClampedFloatParameter NormalBias = new ClampedFloatParameter(0.25f, 0.0f, 2.0f, false); + + [InspectorName("Sampling Noise"), Tooltip("Amount of jitter noise added to the APV sample position")] + public ClampedFloatParameter SamplingNoise = new ClampedFloatParameter(0.1f, 0.0f, 1.0f, false); + + [InspectorName("Intensity Multiplier"), Tooltip("Strength of the light contribution from APV")] + public ClampedFloatParameter IntensityMultiplier = new ClampedFloatParameter(1.0f, 0.0f, 1.0f, false); + + [InspectorName("Denoise Fallback"), Tooltip("Includes fallback lighting in denoising")] + public BoolParameter DenoiseFallback = new BoolParameter(true, false); + + // ------------------------------------- Pipeline Integration ----------------------------------------- + + [InspectorName("Metallic Indirect Fallback"), Tooltip("Renders metals as diffuse when no reflections exist, preventing them from going black")] + public BoolParameter MetallicIndirectFallback = new BoolParameter(false, false); + + [InspectorName("Ambient Override"), Tooltip("Removes Unity’s ambient lighting before HTrace SSGI runs to avoid double GI")] + public BoolParameter AmbientOverride = new BoolParameter(true, false); + + [InspectorName("Multibounce"), Tooltip("Uses previous frame GI to approximate additional light bounces")] + public BoolParameter Multibounce = new BoolParameter(true, false); + + // -------------------------------------------- Visuals ----------------------------------------------- + + [InspectorName("Backface Lighting"), Tooltip("Include lighting from back-facing surfaces")] + public ClampedFloatParameter BackfaceLighting = new ClampedFloatParameter(0.25f, 0.0f, 1.0f, false); + + [InspectorName("Max Ray Length"), Tooltip("Maximum ray distance in meters")] + public ClampedFloatParameter MaxRayLength = new ClampedFloatParameter(100.0f, 0.0f, float.MaxValue, false); + + [InspectorName("Thickness Mode"), Tooltip("Method used for thickness estimation")] + public ThicknessModeParameter ThicknessMode = new(Globals.ThicknessMode.Relative, false); + + [InspectorName("Thickness"), Tooltip("Virtual object thickness for ray intersections")] + public ClampedFloatParameter Thickness = new ClampedFloatParameter(0.35f, 0.0f, 1.0f, false); + + [InspectorName("Intensity"), Tooltip("Indirect lighting intensity multiplier")] + public ClampedFloatParameter Intensity = new ClampedFloatParameter(1.0f, 0.1f, 5.0f, false); + + [InspectorName("Falloff"), Tooltip("Softens indirect lighting over distance")] + public ClampedFloatParameter Falloff = new ClampedFloatParameter(0.0f, 0.0f, 1.0f, false); + + // -------------------------------------------- QUALITY ----------------------------------------------- + + // -------------------------------------------- Tracing ----------------------------------------------- + + [InspectorName("Ray Count"), Tooltip("Number of rays per pixel")] + public ClampedIntParameter RayCount = new ClampedIntParameter(3, 2, 16, false); + + [InspectorName("Step Count"), Tooltip("Number of steps per ray")] + public ClampedIntParameter StepCount = new ClampedIntParameter(24, 8, 64, false); + + [InspectorName("Refine Intersection"), Tooltip("Extra check to confirm intersection")] + public BoolParameter RefineIntersection = new BoolParameter(true, false); + + [InspectorName("Full Resolution Depth"), Tooltip("Uses full-res depth buffer for tracing")] + public BoolParameter FullResolutionDepth = new BoolParameter(true, false); + + // ------------------------------------------- Rendering ----------------------------------------------- + + [InspectorName("Checkerboard"), Tooltip("Enables checkerboard rendering, processing only half of the pixels per frame")] + public BoolParameter Checkerboard = new BoolParameter(false, false); + + [InspectorName("Render Scale"), Tooltip("Local render scale of SSGI pipeline")] + public ClampedFloatParameter RenderScale = new ClampedFloatParameter(1.0f, 0.5f, 1.0f, false); + + // ------------------------------------------- DENOISING ----------------------------------------------- + + [InspectorName("Brightness Clamp"), Tooltip("Defines the maximum brightness at the hit point")] + public BrightnessClampParameter BrightnessClamp = new(Globals.BrightnessClamp.Manual, false); + + [InspectorName("Max Value"), Tooltip("Maximum brightness allowed at hit points.")] + public ClampedFloatParameter MaxValueBrightnessClamp = new ClampedFloatParameter(7.0f, 1.0f, 30.0f, false); + + [InspectorName("Max Deviation"), Tooltip("Maximum standard deviation for brightness allowed at hit points")] + public ClampedFloatParameter MaxDeviationBrightnessClamp = new ClampedFloatParameter(3.0f, 1.0f, 5.0f, false); + + // ---------------------------------------- ReSTIR Validation ------------------------------------------ + + [InspectorName("Half Step"), Tooltip("Halves validation ray steps")] + public BoolParameter HalfStepValidation = new BoolParameter(false, false); + + [InspectorName("Spatial Occlusion"), Tooltip("Protects indirect shadows and details from overblurring")] + public BoolParameter SpatialOcclusionValidation = new BoolParameter(true, false); + + [InspectorName("Temporal Lighting"), Tooltip("Faster reaction to changing lighting conditions")] + public BoolParameter TemporalLightingValidation = new BoolParameter(true, false); + + [InspectorName("Temporal Occlusion"), Tooltip("Faster reaction to moving indirect shadows")] + public BoolParameter TemporalOcclusionValidation = new BoolParameter(true, false); + + + // ----------------------------------------- Spatial Filter --------------------------------------------------- + + [InspectorName("Spatial"), Tooltip("Width of spatial filter")] + public ClampedFloatParameter SpatialRadius = new ClampedFloatParameter(0.6f, 0.0f, 1.0f, false); + + [InspectorName("Adaptivity"), Tooltip("Shrinks the filter radius in geometry corners to preserve details")] + public ClampedFloatParameter Adaptivity = new ClampedFloatParameter(0.9f, 0.0f, 1.0f, false); + + [InspectorName("Recurrent Blur"), Tooltip("Makes blur stronger by using the spatial output as temporal history")] + public BoolParameter RecurrentBlur = new BoolParameter(false, false); + + [InspectorName("Firefly Suppression"), Tooltip("Removes bright outliers before denoising")] + public BoolParameter FireflySuppression = new BoolParameter(false, false); + + // ----------------------------------------------- Debug ----------------------------------------------------- + + public BoolParameter ShowBowels = new BoolParameter(false, true); + + public bool IsActive() + { + return Enable.value; + } + +#if !UNITY_2023_2_OR_NEWER + public bool IsTileCompatible() => false; +#endif + + [Serializable] + public sealed class HBufferParameter : VolumeParameter + { + /// The initial value to store in the parameter. + /// The initial override state for the parameter. + public HBufferParameter(HBuffer value, bool overrideState = false) : base(value, overrideState) { } + } + + [Serializable] + public sealed class DebugModeParameter : VolumeParameter + { + /// The initial value to store in the parameter. + /// The initial override state for the parameter. + public DebugModeParameter(DebugMode value, bool overrideState = false) : base(value, overrideState) { } + } + +#if UNITY_2023_3_OR_NEWER + [Serializable] + public sealed class RenderingLayerMaskEnumParameter : VolumeParameter + { + /// The initial value to store in the parameter. + /// The initial override state for the parameter. + public RenderingLayerMaskEnumParameter(RenderingLayerMask value, bool overrideState = false) : base(value, overrideState) { } + } +#endif + + [Serializable] + public sealed class FallbackTypeParameter : VolumeParameter + { + /// The initial value to store in the parameter. + /// The initial override state for the parameter. + public FallbackTypeParameter(FallbackType value, bool overrideState = false) : base(value, overrideState) { } + } + + [Serializable] + public sealed class ThicknessModeParameter : VolumeParameter + { + /// The initial value to store in the parameter. + /// The initial override state for the parameter. + public ThicknessModeParameter(ThicknessMode value, bool overrideState = false) : base(value, overrideState) { } + } + + [Serializable] + public sealed class BrightnessClampParameter : VolumeParameter + { + /// The initial value to store in the parameter. + /// The initial override state for the parameter. + public BrightnessClampParameter(BrightnessClamp value, bool overrideState = false) : base(value, overrideState) { } + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIVolume.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIVolume.cs.meta new file mode 100644 index 0000000..c46bd90 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIVolume.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 5f17acff6deb4f089d110375635d4e37 +timeCreated: 1756743404 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Infrastructure/URP/HTraceSSGIVolume.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes.meta new file mode 100644 index 0000000..e20176d --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1da92c815c29dea40bd8c6c3d6f75312 +timeCreated: 1674801896 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared.meta new file mode 100644 index 0000000..b3a17c8 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7a79b752c0a5472889da303294bb41c1 +timeCreated: 1756743088 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/HBlueNoise.cs b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/HBlueNoise.cs new file mode 100644 index 0000000..d0c0fc9 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/HBlueNoise.cs @@ -0,0 +1,63 @@ +using UnityEngine; +using UnityEngine.Rendering; + +namespace HTraceSSGI.Scripts.Passes.Shared +{ + internal static class HBlueNoise + { + internal static readonly int g_OwenScrambledTexture = Shader.PropertyToID("g_OwenScrambledTexture"); + internal static readonly int g_ScramblingTileXSPP = Shader.PropertyToID("g_ScramblingTileXSPP"); + internal static readonly int g_RankingTileXSPP = Shader.PropertyToID("g_RankingTileXSPP"); + internal static readonly int g_ScramblingTexture = Shader.PropertyToID("g_ScramblingTexture"); + + private static Texture2D _owenScrambledTexture; + public static Texture2D OwenScrambledTexture + { + get + { + if (_owenScrambledTexture == null) + _owenScrambledTexture = UnityEngine.Resources.Load("HTraceSSGI/BlueNoise/OwenScrambledNoise256"); + return _owenScrambledTexture; + } + } + + private static Texture2D _scramblingTileXSPP; + public static Texture2D ScramblingTileXSPP + { + get + { + if (_scramblingTileXSPP == null) + _scramblingTileXSPP = UnityEngine.Resources.Load("HTraceSSGI/BlueNoise/ScramblingTile8SPP"); + return _scramblingTileXSPP; + } + } + private static Texture2D _rankingTileXSPP; + public static Texture2D RankingTileXSPP + { + get + { + if (_rankingTileXSPP == null) + _rankingTileXSPP = UnityEngine.Resources.Load("HTraceSSGI/BlueNoise/RankingTile8SPP"); + return _rankingTileXSPP; + } + } + private static Texture2D _scramblingTexture; + public static Texture2D ScramblingTexture + { + get + { + if (_scramblingTexture == null) + _scramblingTexture = UnityEngine.Resources.Load("HTraceSSGI/BlueNoise/ScrambleNoise"); + return _scramblingTexture; + } + } + + public static void SetTextures(CommandBuffer cmdList) + { + cmdList.SetGlobalTexture(g_OwenScrambledTexture, OwenScrambledTexture); + cmdList.SetGlobalTexture(g_ScramblingTileXSPP, ScramblingTileXSPP); + cmdList.SetGlobalTexture(g_RankingTileXSPP, RankingTileXSPP); + cmdList.SetGlobalTexture(g_ScramblingTexture, ScramblingTexture); + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/HBlueNoise.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/HBlueNoise.cs.meta new file mode 100644 index 0000000..60aec01 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/HBlueNoise.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 9b39dbedfe8559c4984c466e938fdf33 +timeCreated: 1729617470 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Passes/Shared/HBlueNoise.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/SSGI.cs b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/SSGI.cs new file mode 100644 index 0000000..179b775 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/SSGI.cs @@ -0,0 +1,667 @@ +//pipelinedefine +#define H_URP + +using System; +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Extensions.CameraHistorySystem; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Wrappers; +using UnityEngine; +using UnityEngine.Rendering; +using HTraceSSGI.Scripts.Infrastructure.URP; + +namespace HTraceSSGI.Scripts.Passes.Shared +{ + internal class SSGI + { + // Kernels + internal enum HTemporalReprojectionKernels + { + TemporalReprojection = 0, + ColorReprojection = 1, + CopyHistory = 2, + LuminanceMomentsGeneration = 3, + LuminanceMomentsClear = 4, + } + + internal enum HCheckerboardingKernels + { + CheckerboardClassification = 0, + IndirectArguments = 1, + } + + internal enum HRenderSSGIKernels + { + TraceSSGI = 0, + MaskExclude = 1, + } + + internal enum HReSTIRKernels + { + TemporalResampling = 0, + FireflySuppression = 1, + SpatialResampling = 2, + SpatialValidation = 3, + } + + internal enum HDenoiserKernels + { + TemporalAccumulation = 0, + TemporalStabilization = 1, + PointDistributionFill = 2, + SpatialFilter = 3, + SpatialFilter1 = 4, + SpatialFilter2 = 5, + } + + internal enum HInterpolationKernels + { + Interpolation = 0, + } + + // Textures, except History + public static RTWrapper ColorCopy_URP = new RTWrapper(); // URP only + public static RTWrapper DebugOutput = new RTWrapper(); + public static RTWrapper ReservoirLuminance = new RTWrapper(); + public static RTWrapper Reservoir = new RTWrapper(); + public static RTWrapper ReservoirReprojected = new RTWrapper(); + public static RTWrapper ReservoirSpatial = new RTWrapper(); + public static RTWrapper SamplecountReprojected = new RTWrapper(); + public static RTWrapper TemporalInvalidityFilteredA = new RTWrapper(); + public static RTWrapper TemporalInvalidityFilteredB = new RTWrapper(); + public static RTWrapper TemporalInvalidityReprojected = new RTWrapper(); + public static RTWrapper SpatialOcclusionReprojected = new RTWrapper(); + public static RTWrapper AmbientOcclusion = new RTWrapper(); + public static RTWrapper AmbientOcclusionGuidance = new RTWrapper(); + public static RTWrapper AmbientOcclusionInvalidity = new RTWrapper(); + public static RTWrapper AmbientOcclusionReprojected = new RTWrapper(); + public static RTWrapper RadianceReprojected = new RTWrapper(); + public static RTWrapper RadianceFiltered = new RTWrapper(); + public static RTWrapper RadianceInterpolated = new RTWrapper(); + public static RTWrapper RadianceStabilized = new RTWrapper(); + public static RTWrapper RadianceStabilizedReprojected = new RTWrapper(); + public static RTWrapper RadianceNormalDepth = new RTWrapper(); + public static RTWrapper ColorReprojected = new RTWrapper(); + public static RTWrapper DummyBlackTexture = new RTWrapper(); + + // History Textures + internal struct HistoryCameraDataSSGI : ICameraHistoryData, IDisposable + { + private int hash; + public RTWrapper ColorPreviousFrame; + public RTWrapper ReservoirTemporal; + public RTWrapper SampleCount; + public RTWrapper NormalDepth; + public RTWrapper NormalDepthFullRes; + public RTWrapper Radiance; + public RTWrapper RadianceAccumulated; + public RTWrapper SpatialOcclusionAccumulated; + public RTWrapper TemporalInvalidityAccumulated; + public RTWrapper AmbientOcclusionAccumulated; + + public HistoryCameraDataSSGI(int hash = 0) + { + this.hash = hash; + ColorPreviousFrame = new RTWrapper(); + ReservoirTemporal = new RTWrapper(); + SampleCount = new RTWrapper(); + NormalDepth = new RTWrapper(); + NormalDepthFullRes = new RTWrapper(); + Radiance = new RTWrapper(); + RadianceAccumulated = new RTWrapper(); + SpatialOcclusionAccumulated = new RTWrapper(); + TemporalInvalidityAccumulated = new RTWrapper(); + AmbientOcclusionAccumulated = new RTWrapper(); + } + + public int GetHash() => hash; + public void SetHash(int hashIn) => this.hash = hashIn; + + public void Dispose() + { + ColorPreviousFrame?.HRelease(); + ReservoirTemporal?.HRelease(); + SampleCount?.HRelease(); + NormalDepth?.HRelease(); + NormalDepthFullRes?.HRelease(); + Radiance?.HRelease(); + RadianceAccumulated?.HRelease(); + SpatialOcclusionAccumulated?.HRelease(); + TemporalInvalidityAccumulated?.HRelease(); + AmbientOcclusionAccumulated?.HRelease(); + } + } + + internal static readonly CameraHistorySystem CameraHistorySystem = new CameraHistorySystem(); + + // Shader Properties + public static readonly int _RayCounter = Shader.PropertyToID("_RayCounter"); + public static readonly int _RayCounter_Output = Shader.PropertyToID("_RayCounter_Output"); + public static readonly int _IndirectCoords_Output = Shader.PropertyToID("_IndirectCoords_Output"); + public static readonly int _IndirectArguments_Output = Shader.PropertyToID("_IndirectArguments_Output"); + public static readonly int _TracingCoords = Shader.PropertyToID("_TracingCoords"); + public static readonly int _RayTracedCounter = Shader.PropertyToID("_RayTracedCounter"); + public static readonly int _DepthToViewParams = Shader.PropertyToID("_DepthToViewParams"); + public static readonly int _HScaleFactorSSGI = Shader.PropertyToID("_HScaleFactorSSGI"); + public static readonly int _HPreviousScaleFactorSSGI = Shader.PropertyToID("_HPreviousScaleFactorSSGI"); + public static readonly int _ReservoirDiffuseWeight = Shader.PropertyToID("_ReservoirDiffuseWeight"); + public static readonly int _ExcludeCastingLayerMaskSSGI = Shader.PropertyToID("_ExcludeCastingLayerMaskSSGI"); + public static readonly int _ExcludeReceivingLayerMaskSSGI = Shader.PropertyToID("_ExcludeReceivingLayerMaskSSGI"); + public static readonly int _APVParams = Shader.PropertyToID("_APVParams"); + public static readonly int _BrightnessClamp = Shader.PropertyToID("_BrightnessClamp"); + public static readonly int _MaxDeviation = Shader.PropertyToID("_MaxDeviation"); + public static readonly int _RayCount = Shader.PropertyToID("_RayCount"); + public static readonly int _StepCount = Shader.PropertyToID("_StepCount"); + public static readonly int _RayLength = Shader.PropertyToID("_RayLength"); + public static readonly int _SkyFallbackIntensity = Shader.PropertyToID("_SkyFallbackIntensity"); + public static readonly int _BackfaceLighting = Shader.PropertyToID("_BackfaceLighting"); + public static readonly int _Falloff = Shader.PropertyToID("_Falloff"); + public static readonly int _ThicknessParams = Shader.PropertyToID("_ThicknessParams"); + public static readonly int _DenoiseFallback = Shader.PropertyToID("_DenoiseFallback"); + public static readonly int _FilterAdaptivity = Shader.PropertyToID("_FilterAdaptivity"); + public static readonly int _FilterRadius = Shader.PropertyToID("_FilterRadius"); + public static readonly int _ColorCopy = Shader.PropertyToID("_ColorCopy"); + public static readonly int _Color_History = Shader.PropertyToID("_Color_History"); + public static readonly int _LuminanceMoments = Shader.PropertyToID("_LuminanceMoments"); + public static readonly int _Radiance_History = Shader.PropertyToID("_Radiance_History"); + public static readonly int _RadianceNormalDepth = Shader.PropertyToID("_RadianceNormalDepth"); + public static readonly int _Radiance_Output = Shader.PropertyToID("_Radiance_Output"); + public static readonly int _NormalDepth_History = Shader.PropertyToID("_NormalDepth_History"); + public static readonly int _ReprojectedColor_Output = Shader.PropertyToID("_ReprojectedColor_Output"); + public static readonly int _Samplecount_History = Shader.PropertyToID("_Samplecount_History"); + public static readonly int _Samplecount_Output = Shader.PropertyToID("_Samplecount_Output"); + public static readonly int _SpatialOcclusion_History = Shader.PropertyToID("_SpatialOcclusion_History"); + public static readonly int _SpatialOcclusion_Output = Shader.PropertyToID("_SpatialOcclusion_Output"); + public static readonly int _PointDistribution_Output = Shader.PropertyToID("_PointDistribution_Output"); + public static readonly int _Reservoir = Shader.PropertyToID("_Reservoir"); + public static readonly int _Reservoir_Output = Shader.PropertyToID("_Reservoir_Output"); + public static readonly int _TemporalInvalidity_History = Shader.PropertyToID("_TemporalInvalidity_History"); + public static readonly int _TemporalInvalidity_Output = Shader.PropertyToID("_TemporalInvalidity_Output"); + public static readonly int _AmbientOcclusion_History = Shader.PropertyToID("_AmbientOcclusion_History"); + public static readonly int _AmbientOcclusion_Output = Shader.PropertyToID("_AmbientOcclusion_Output"); + public static readonly int _SampleCount = Shader.PropertyToID("_SampleCount"); + public static readonly int _Color = Shader.PropertyToID("_Color"); + public static readonly int _AmbientOcclusion = Shader.PropertyToID("_AmbientOcclusion"); + public static readonly int _AmbientOcclusionInvalidity = Shader.PropertyToID("_AmbientOcclusionInvalidity"); + public static readonly int _AmbientOcclusionReprojected = Shader.PropertyToID("_AmbientOcclusionReprojected"); + public static readonly int _SpatialOcclusion = Shader.PropertyToID("_SpatialOcclusion"); + public static readonly int _ReservoirReprojected = Shader.PropertyToID("_ReservoirReprojected"); + public static readonly int _ReservoirSpatial_Output = Shader.PropertyToID("_ReservoirSpatial_Output"); + public static readonly int _ReservoirLuminance = Shader.PropertyToID("_ReservoirLuminance"); + public static readonly int _ReservoirTemporal_Output = Shader.PropertyToID("_ReservoirTemporal_Output"); + public static readonly int _TemporalInvalidity = Shader.PropertyToID("_TemporalInvalidity"); + public static readonly int _NormalDepth_HistoryOutput = Shader.PropertyToID("_NormalDepth_HistoryOutput"); + public static readonly int _ReservoirLuminance_Output = Shader.PropertyToID("_ReservoirLuminance_Output"); + public static readonly int _SpatialGuidance_Output = Shader.PropertyToID("_SpatialGuidance_Output"); + public static readonly int _PointDistribution = Shader.PropertyToID("_PointDistribution"); + public static readonly int _NormalDepth = Shader.PropertyToID("_NormalDepth"); + public static readonly int _RadianceNormalDepth_Output = Shader.PropertyToID("_RadianceNormalDepth_Output"); + public static readonly int _SpatialGuidance = Shader.PropertyToID("_SpatialGuidance"); + public static readonly int _SamplecountReprojected = Shader.PropertyToID("_SamplecountReprojected"); + public static readonly int _Radiance = Shader.PropertyToID("_Radiance"); + public static readonly int _RadianceReprojected = Shader.PropertyToID("_RadianceReprojected"); + public static readonly int _Radiance_TemporalOutput = Shader.PropertyToID("_Radiance_TemporalOutput"); + public static readonly int _Radiance_SpatialOutput = Shader.PropertyToID("_Radiance_SpatialOutput"); + public static readonly int _SampleCountSSGI = Shader.PropertyToID("_SampleCountSSGI"); + public static readonly int _HTraceBufferGI = Shader.PropertyToID("_HTraceBufferGI"); + public static readonly int _IndirectLightingIntensity = Shader.PropertyToID("_IndirectLightingIntensity"); + public static readonly int _MetallicIndirectFallback = Shader.PropertyToID("_MetallicIndirectFallback"); + private static readonly int _DebugSwitch = Shader.PropertyToID("_DebugSwitch"); + private static readonly int _BuffersSwitch = Shader.PropertyToID("_BuffersSwitch"); + private static readonly int _Debug_Output = Shader.PropertyToID("_Debug_Output"); + + // Keywords + public static readonly string VR_COMPATIBILITY = "VR_COMPATIBILITY"; + public static readonly string USE_TEMPORAL_INVALIDITY = "USE_TEMPORAL_INVALIDITY"; + public static readonly string USE_RECEIVE_LAYER_MASK = "USE_RECEIVE_LAYER_MASK"; + public static readonly string USE_SPATIAL_OCCLUSION = "USE_SPATIAL_OCCLUSION"; + public static readonly string INTERPOLATION_OUTPUT = "INTERPOLATION_OUTPUT"; + public static readonly string VALIDATE_SPATIAL_OCCLUSION = "VALIDATE_SPATIAL_OCCLUSION"; + public static readonly string AUTOMATIC_THICKNESS = "AUTOMATIC_THICKNESS"; + public static readonly string LINEAR_THICKNESS = "LINEAR_THICKNESS"; + public static readonly string UNIFORM_THICKNESS = "UNIFORM_THICKNESS"; + public static readonly string CHECKERBOARDING = "CHECKERBOARDING"; + public static readonly string FALLBACK_APV = "FALLBACK_APV"; + public static readonly string FALLBACK_SKY = "FALLBACK_SKY"; + public static readonly string FULL_RESOLUTION_DEPTH = "FULL_RESOLUTION_DEPTH"; + public static readonly string REFINE_INTERSECTION = "REFINE_INTERSECTION"; + public static readonly string VALIDATE_TEMPORAL_OCCLUSION = "VALIDATE_TEMPORAL_OCCLUSION"; + public static readonly string VALIDATE_TEMPORAL_LIGHTING = "VALIDATE_TEMPORAL_LIGHTING"; + public static readonly string HALF_STEP_VALIDATION = "HALF_STEP_VALIDATION"; + public static readonly string REPROJECT_TEMPORAL_INVALIDITY = "REPROJECT_TEMPORAL_INVALIDITY"; + public static readonly string AUTOMATIC_BRIGHTNESS_CLAMP = "AUTOMATIC_BRIGHTNESS_CLAMP"; + public static readonly string REPROJECT_SPATIAL_OCCLUSION = "REPROJECT_SPATIAL_OCCLUSION"; + public static readonly string FULL_RESOLUTION_REPROJECTION = "FULL_RESOLUTION_REPROJECTION"; + public static readonly string REPROJECT_COLOR = "REPROJECT_COLOR"; + + // Profiler Samplers + public static ProfilingSampler AmbientLightingOverrideSampler = new ProfilingSampler("Ambient Lighting Override"); + public static ProfilingSampler TemporalReprojectionSampler = new ProfilingSampler("Temporal Reprojection"); + public static ProfilingSampler CheckerboardingSampler = new ProfilingSampler("Checkerboarding"); + public static ProfilingSampler RadianceTracingSampler = new ProfilingSampler("Trace Radiance"); + public static ProfilingSampler RestirTemporalSampler = new ProfilingSampler("ReSTIR Temporal"); + public static ProfilingSampler RestirFireflySampler = new ProfilingSampler("ReSTIR Firefly"); + public static ProfilingSampler RestirSpatialSampler = new ProfilingSampler("ReSTIR Spatial"); + public static ProfilingSampler TemporalAccumulationSampler = new ProfilingSampler("Temporal Accumulation"); + public static ProfilingSampler SpatialFilterSampler = new ProfilingSampler("Spatial Filter"); + public static ProfilingSampler InterpolationSampler = new ProfilingSampler("Interpolation"); + public static ProfilingSampler DebugSampler = new ProfilingSampler("Debug"); + public static ProfilingSampler IndirectLightingInjectionSampler = new ProfilingSampler("Indirect Lighting Injection"); + + // Computes + public static ComputeShader HDebug = null; + public static ComputeShader HRenderSSGI = null; + public static ComputeShader HReSTIR = null; + public static ComputeShader HDenoiser = null; + public static ComputeShader HInterpolation = null; + public static ComputeShader HCheckerboarding = null; + public static ComputeShader PyramidGeneration = null; + public static ComputeShader HTemporalReprojection = null; + + // Materials + public static Material ColorCompose_BIRP; + public static Material ColorCompose_URP; + + // Buffers + public static ComputeBuffer PointDistributionBuffer; + public static ComputeBuffer LuminanceMoments; + public static ComputeBuffer IndirectArguments; + public static ComputeBuffer RayCounter; + public static HDynamicBuffer IndirectCoords; + + // Variables + public static RenderTexture finalOutput; + + internal struct HistoryData : IHistoryData + { + public bool RecurrentBlur; + public float ScaleFactor; + public void Update() + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + RecurrentBlur = profile.DenoisingSettings.RecurrentBlur; + ScaleFactor = Mathf.Round(1.0f / profile.SSGISettings.RenderScale * 100f) / 100f; + } + } + + internal static HistoryData History = new HistoryData(); + + internal static void Execute(CommandBuffer cmd, Camera camera, int cameraWidth, int cameraHeight, RTHandle cameraColorBuffer = null, RTHandle previousColorBuffer = null) + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + + bool UseAPV = false; + bool UseInterpolation = Mathf.Approximately(profile.SSGISettings.RenderScale, 1.0f) ? false : true; + float RenderScaleFactor = (Mathf.Round(1.0f / profile.SSGISettings.RenderScale * 100f) / 100f); + + // Depth to PositionVS parameters + float FovRadians = camera.fieldOfView * Mathf.Deg2Rad; + float TanHalfFOVY = Mathf.Tan(FovRadians * 0.5f); + float invHalfTanFov = 1 / TanHalfFOVY; + Vector2 focalLen = new Vector2(invHalfTanFov * ((float)cameraWidth / (float)cameraWidth), invHalfTanFov); + Vector2 invFocalLen = new Vector2(1 / focalLen.x, 1 / focalLen.y); + Vector4 DepthToViewParams = new Vector4(2 * invFocalLen.x, 2 * invFocalLen.y, -1 * invFocalLen.x, -1 * invFocalLen.y); + + // Tracing thickness management + float Thickness = Mathf.Clamp(profile.SSGISettings.Thickness, 0.05f, 1.0f); + float n = camera.nearClipPlane; + float f = camera.farClipPlane; + Vector4 ThicknessScaleBias = new Vector4(); + ThicknessScaleBias.x = 1.0f / (1.0f + Thickness / 5.0f); + ThicknessScaleBias.y = -n / (f - n) * (Thickness / 5.0f * ThicknessScaleBias.x); + ThicknessScaleBias.z = 1.0f / (1.0f + Thickness / 5.0f * 2.0f); + ThicknessScaleBias.w = -n / (f - n) * (Thickness / 5.0f * 2.0f * ThicknessScaleBias.z); + + if ((int)profile.SSGISettings.ThicknessMode == 1) + { + ThicknessScaleBias.x = 1.0f; + ThicknessScaleBias.y = Thickness; + ThicknessScaleBias.z = 1.0f; + ThicknessScaleBias.w = Thickness * 2.0f; + } + + // Spatial radius management + float FilterRadiusReSTIR = profile.DenoisingSettings.SpatialRadius - 0.25f; // HData.DenoisingData.SpatialRadius / 2.0f; + float FilterRadiusDenoiser = FilterRadiusReSTIR * 0.7f; + FilterRadiusReSTIR = FilterRadiusReSTIR.RoundToCeilTail(1); + FilterRadiusDenoiser = FilterRadiusDenoiser.RoundToCeilTail(1); + + + + // ---------------------------------------- PARAMETERS SET ---------------------------------------- // + cmd.SetGlobalVector(_DepthToViewParams, DepthToViewParams); + cmd.SetGlobalFloat(_HScaleFactorSSGI, RenderScaleFactor); + cmd.SetGlobalFloat(_HPreviousScaleFactorSSGI, History.ScaleFactor); + cmd.SetGlobalFloat(_ReservoirDiffuseWeight, profile.GeneralSettings.DebugMode == DebugMode.GlobalIllumination ? 0.0f : 1.0f); + +#if UNITY_2023_3_OR_NEWER + cmd.SetGlobalInt(_ExcludeCastingLayerMaskSSGI, profile.GeneralSettings.ExcludeCastingMask); + cmd.SetGlobalInt(_ExcludeReceivingLayerMaskSSGI, profile.GeneralSettings.ExcludeReceivingMask); +#endif + + cmd.SetGlobalVector(_APVParams, new Vector4(profile.GeneralSettings.NormalBias, profile.GeneralSettings.ViewBias, profile.GeneralSettings.SamplingNoise, profile.GeneralSettings.IntensityMultiplier)); + + cmd.SetComputeFloatParam(HTemporalReprojection, _BrightnessClamp, profile.DenoisingSettings.MaxValueBrightnessClamp); + cmd.SetComputeFloatParam(HTemporalReprojection, _MaxDeviation, profile.DenoisingSettings.MaxDeviationBrightnessClamp); + + cmd.SetComputeIntParam(HRenderSSGI, _RayCount, profile.SSGISettings.RayCount); + cmd.SetComputeIntParam(HRenderSSGI, _StepCount, profile.SSGISettings.StepCount); + cmd.SetComputeFloatParam(HRenderSSGI, _RayLength, Mathf.Max(profile.SSGISettings.MaxRayLength, 0.1f)); + cmd.SetComputeFloatParam(HRenderSSGI, _BackfaceLighting, profile.SSGISettings.BackfaceLighting); + cmd.SetComputeFloatParam(HRenderSSGI, _SkyFallbackIntensity, profile.GeneralSettings.SkyIntensity); + cmd.SetComputeFloatParam(HRenderSSGI, _Falloff, profile.SSGISettings.Falloff); + cmd.SetComputeVectorParam(HRenderSSGI, _ThicknessParams, ThicknessScaleBias); + + cmd.SetComputeIntParam(HReSTIR, _DenoiseFallback, (profile.GeneralSettings.DenoiseFallback || profile.GeneralSettings.FallbackType == FallbackType.None) ? 1 : 0); + cmd.SetComputeIntParam(HReSTIR, _RayCount, profile.SSGISettings.RayCount); + cmd.SetComputeIntParam(HReSTIR, _StepCount, profile.SSGISettings.StepCount); + cmd.SetComputeFloatParam(HReSTIR, _RayLength, Mathf.Max(profile.SSGISettings.MaxRayLength, 0.1f)); + cmd.SetComputeFloatParam(HReSTIR, _BackfaceLighting, profile.SSGISettings.BackfaceLighting); + cmd.SetComputeFloatParam(HReSTIR, _FilterAdaptivity, profile.DenoisingSettings.Adaptivity); + cmd.SetComputeFloatParam(HReSTIR, _Falloff, profile.SSGISettings.Falloff); + cmd.SetComputeFloatParam(HReSTIR, _FilterRadius, FilterRadiusReSTIR); + cmd.SetComputeVectorParam(HReSTIR, _ThicknessParams, ThicknessScaleBias); + + cmd.SetComputeFloatParam(HDenoiser, _FilterAdaptivity, profile.DenoisingSettings.Adaptivity); + cmd.SetComputeFloatParam(HDenoiser, _FilterRadius, FilterRadiusDenoiser); + cmd.SetComputeFloatParam(HDenoiser, _StepCount, profile.SSGISettings.StepCount); + + RTWrapper ColorPreviousFrame = CameraHistorySystem.GetCameraData().ColorPreviousFrame; + RTWrapper ReservoirTemporal = CameraHistorySystem.GetCameraData().ReservoirTemporal; + RTWrapper SampleCount = CameraHistorySystem.GetCameraData().SampleCount; + RTWrapper NormalDepth = CameraHistorySystem.GetCameraData().NormalDepth; + RTWrapper NormalDepthFullRes = CameraHistorySystem.GetCameraData().NormalDepthFullRes; + RTWrapper Radiance = CameraHistorySystem.GetCameraData().Radiance; + RTWrapper RadianceAccumulated = CameraHistorySystem.GetCameraData().RadianceAccumulated; + RTWrapper SpatialOcclusionAccumulated = CameraHistorySystem.GetCameraData().SpatialOcclusionAccumulated; + RTWrapper TemporalInvalidityAccumulated = CameraHistorySystem.GetCameraData().TemporalInvalidityAccumulated; + RTWrapper AmbientOcclusionAccumulated = CameraHistorySystem.GetCameraData().AmbientOcclusionAccumulated; + + + // ---------------------------------------- TEMPORAL REPROJECTION ---------------------------------------- // + using (new ProfilingScope(cmd, TemporalReprojectionSampler)) + { + var CurrentColorBuffer = ColorPreviousFrame.rt; + var PreviousColorBuffer = ColorPreviousFrame.rt; + + CurrentColorBuffer = cameraColorBuffer; + + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.LuminanceMomentsGeneration, _Color_History, profile.GeneralSettings.Multibounce ? PreviousColorBuffer : CurrentColorBuffer); + cmd.SetComputeBufferParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.LuminanceMomentsGeneration, _LuminanceMoments, LuminanceMoments); + cmd.DispatchCompute(HTemporalReprojection, (int)HTemporalReprojectionKernels.LuminanceMomentsGeneration, Mathf.CeilToInt(cameraWidth / 8.0f), Mathf.CeilToInt(cameraHeight / 8.0f), 1); + + KeywordSwitch(HTemporalReprojection, profile.DenoisingSettings.TemporalLightingValidation | profile.DenoisingSettings.TemporalOcclusionValidation, REPROJECT_TEMPORAL_INVALIDITY); + KeywordSwitch(HTemporalReprojection, profile.DenoisingSettings.BrightnessClamp == BrightnessClamp.Automatic, AUTOMATIC_BRIGHTNESS_CLAMP); + KeywordSwitch(HTemporalReprojection, profile.DenoisingSettings.SpatialOcclusionValidation, REPROJECT_SPATIAL_OCCLUSION); + KeywordSwitch(HTemporalReprojection, UseInterpolation == false, FULL_RESOLUTION_REPROJECTION); + KeywordSwitch(HTemporalReprojection, profile.GeneralSettings.Multibounce, REPROJECT_COLOR); + + if (UseInterpolation) + { + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.ColorReprojection, _Color_History, PreviousColorBuffer); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.ColorReprojection, _Radiance_History, RadianceStabilized.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.ColorReprojection, _Radiance_Output, RadianceStabilizedReprojected.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.ColorReprojection, _NormalDepth_History, NormalDepthFullRes.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.ColorReprojection, _ReprojectedColor_Output, ColorReprojected.rt); + cmd.SetComputeBufferParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.ColorReprojection, _LuminanceMoments, LuminanceMoments); + cmd.DispatchCompute(HTemporalReprojection, (int)HTemporalReprojectionKernels.ColorReprojection, Mathf.CeilToInt(cameraWidth / 8.0f), Mathf.CeilToInt(cameraHeight / 8.0f), HRenderer.TextureXrSlices); + } + + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _Color_History, PreviousColorBuffer); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _Samplecount_History, SampleCount.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _Samplecount_Output, SamplecountReprojected.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _NormalDepth_History, NormalDepth.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _ReprojectedColor_Output, ColorReprojected.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _Radiance_Output, RadianceReprojected.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _Radiance_History, profile.DenoisingSettings.RecurrentBlur ? Radiance.rt : RadianceAccumulated.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _SpatialOcclusion_History, SpatialOcclusionAccumulated.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _SpatialOcclusion_Output, SpatialOcclusionReprojected.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _Reservoir, ReservoirTemporal.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _Reservoir_Output, ReservoirReprojected.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _TemporalInvalidity_History, TemporalInvalidityAccumulated.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _TemporalInvalidity_Output, TemporalInvalidityReprojected.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _AmbientOcclusion_History, AmbientOcclusionAccumulated.rt); + cmd.SetComputeTextureParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _AmbientOcclusion_Output, AmbientOcclusionReprojected.rt); + cmd.SetComputeBufferParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, _LuminanceMoments, LuminanceMoments); + cmd.DispatchCompute(HTemporalReprojection, (int)HTemporalReprojectionKernels.TemporalReprojection, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + + cmd.SetComputeBufferParam(HTemporalReprojection, (int)HTemporalReprojectionKernels.LuminanceMomentsClear, _LuminanceMoments, LuminanceMoments); + cmd.DispatchCompute(HTemporalReprojection, (int)HTemporalReprojectionKernels.LuminanceMomentsClear, 1, 1, 1); + } + + + // ---------------------------------------- CHECKERBOARDING ---------------------------------------- // + if (profile.SSGISettings.Checkerboard) + { + using (new ProfilingScope(cmd, CheckerboardingSampler)) + { + cmd.SetComputeTextureParam(HCheckerboarding, (int)HCheckerboardingKernels.CheckerboardClassification, _SampleCount, SamplecountReprojected.rt); + cmd.SetComputeBufferParam(HCheckerboarding, (int)HCheckerboardingKernels.CheckerboardClassification, _RayCounter_Output, RayCounter); + cmd.SetComputeBufferParam(HCheckerboarding, (int)HCheckerboardingKernels.CheckerboardClassification, _IndirectCoords_Output, IndirectCoords.ComputeBuffer); + cmd.DispatchCompute(HCheckerboarding, (int)HCheckerboardingKernels.CheckerboardClassification, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + + cmd.SetComputeIntParam(HCheckerboarding, _RayTracedCounter, 0); + cmd.SetComputeBufferParam(HCheckerboarding, (int)HCheckerboardingKernels.IndirectArguments, _RayCounter, RayCounter); + cmd.SetComputeBufferParam(HCheckerboarding, (int)HCheckerboardingKernels.IndirectArguments, _IndirectArguments_Output, IndirectArguments); + cmd.DispatchCompute(HCheckerboarding, (int)HCheckerboardingKernels.IndirectArguments, 1, 1, HRenderer.TextureXrSlices); + } + } + + + // ---------------------------------------- GI TRACING ---------------------------------------- // + using (new ProfilingScope(cmd, RadianceTracingSampler)) + { + CoreUtils.SetRenderTarget(cmd, RadianceFiltered.rt, ClearFlag.Color, Color.clear, 0, CubemapFace.Unknown, -1); + + KeywordSwitch(HRenderSSGI, profile.GeneralSettings.FallbackType == FallbackType.Sky, FALLBACK_SKY); + KeywordSwitch(HRenderSSGI, (int)profile.GeneralSettings.FallbackType == 2 /* Only in HDRP & URP 6000+ */, FALLBACK_APV); + KeywordSwitch(HRenderSSGI, profile.SSGISettings.Checkerboard, CHECKERBOARDING); + KeywordSwitch(HRenderSSGI, profile.SSGISettings.RefineIntersection, REFINE_INTERSECTION); + KeywordSwitch(HRenderSSGI, profile.SSGISettings.FullResolutionDepth, FULL_RESOLUTION_DEPTH); + + if ((int)profile.SSGISettings.ThicknessMode == 0) {HRenderSSGI.EnableKeyword(LINEAR_THICKNESS); HRenderSSGI.DisableKeyword(UNIFORM_THICKNESS); HRenderSSGI.DisableKeyword(AUTOMATIC_THICKNESS);} + if ((int)profile.SSGISettings.ThicknessMode == 1) {HRenderSSGI.EnableKeyword(UNIFORM_THICKNESS); HRenderSSGI.DisableKeyword(LINEAR_THICKNESS); HRenderSSGI.DisableKeyword(AUTOMATIC_THICKNESS);} + + cmd.SetComputeTextureParam(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, _Color, ColorReprojected.rt); + cmd.SetComputeTextureParam(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, _Radiance_Output, RadianceFiltered.rt); + cmd.SetComputeTextureParam(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, _Reservoir_Output, Reservoir.rt); + cmd.SetComputeTextureParam(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, _AmbientOcclusion_Output, AmbientOcclusion.rt); + cmd.SetComputeTextureParam(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, _SampleCount, SamplecountReprojected.rt); + cmd.SetComputeBufferParam(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, _RayCounter, RayCounter); + cmd.SetComputeBufferParam(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, _TracingCoords, IndirectCoords.ComputeBuffer); + + if (profile.SSGISettings.Checkerboard) + { + cmd.SetComputeIntParam(HRenderSSGI, HShaderParams.IndexXR, 0); + cmd.DispatchCompute(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, IndirectArguments, 0); + + if (HRenderer.TextureXrSlices > 1) + { + cmd.SetComputeIntParam(HRenderSSGI, HShaderParams.IndexXR, 1); + cmd.DispatchCompute(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, IndirectArguments, sizeof(uint) * 3); + } + } + else cmd.DispatchCompute(HRenderSSGI, (int)HRenderSSGIKernels.TraceSSGI, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + } + + + // ---------------------------------------- RESTIR TEMPORAL ---------------------------------------- // + using (new ProfilingScope(cmd, RestirTemporalSampler)) + { + KeywordSwitch(HReSTIR, profile.DenoisingSettings.TemporalOcclusionValidation, VALIDATE_TEMPORAL_OCCLUSION); + KeywordSwitch(HReSTIR, profile.DenoisingSettings.TemporalLightingValidation, VALIDATE_TEMPORAL_LIGHTING); + KeywordSwitch(HReSTIR, profile.DenoisingSettings.HalfStepValidation, HALF_STEP_VALIDATION); + KeywordSwitch(HReSTIR, profile.SSGISettings.FullResolutionDepth, FULL_RESOLUTION_DEPTH); + KeywordSwitch(HReSTIR, profile.SSGISettings.Checkerboard, CHECKERBOARDING); + + if ((int)profile.SSGISettings.ThicknessMode == 0) {HReSTIR.EnableKeyword(LINEAR_THICKNESS); HReSTIR.DisableKeyword(UNIFORM_THICKNESS); HReSTIR.DisableKeyword(AUTOMATIC_THICKNESS);} + if ((int)profile.SSGISettings.ThicknessMode == 1) {HReSTIR.EnableKeyword(UNIFORM_THICKNESS); HReSTIR.DisableKeyword(LINEAR_THICKNESS); HReSTIR.DisableKeyword(AUTOMATIC_THICKNESS);} + + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _Radiance_Output, RadianceFiltered.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _SampleCount, SamplecountReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _Color, ColorReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _AmbientOcclusion, AmbientOcclusion.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _AmbientOcclusionInvalidity, AmbientOcclusionInvalidity.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _AmbientOcclusionReprojected, AmbientOcclusionReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _AmbientOcclusion_Output, AmbientOcclusionAccumulated.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _SpatialOcclusion, SpatialOcclusionReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _Reservoir, Reservoir.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _ReservoirReprojected, ReservoirReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _ReservoirSpatial_Output, ReservoirSpatial.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _ReservoirTemporal_Output, ReservoirTemporal.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _TemporalInvalidity, TemporalInvalidityReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _TemporalInvalidity_Output, TemporalInvalidityAccumulated.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _NormalDepth_HistoryOutput, NormalDepth.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _ReservoirLuminance_Output, ReservoirLuminance.rt); + cmd.SetComputeBufferParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _RayCounter, RayCounter); + cmd.SetComputeBufferParam(HReSTIR, (int)HReSTIRKernels.TemporalResampling, _TracingCoords, IndirectCoords.ComputeBuffer); + cmd.DispatchCompute(HReSTIR, (int)HReSTIRKernels.TemporalResampling, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + } + + + // ---------------------------------------- RESTIR FIREFLY ---------------------------------------- // + using (new ProfilingScope(cmd, RestirFireflySampler)) + { + if (profile.DenoisingSettings.FireflySuppression) + { + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.FireflySuppression, _SampleCount, SamplecountReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.FireflySuppression, _ReservoirLuminance, ReservoirLuminance.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.FireflySuppression, _ReservoirSpatial_Output, ReservoirSpatial.rt); + cmd.DispatchCompute(HReSTIR, (int)HReSTIRKernels.FireflySuppression, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + } + } + + + // ---------------------------------------- RESTIR SPATIAL ---------------------------------------- // + using (new ProfilingScope(cmd, RestirSpatialSampler)) + { + KeywordSwitch(HReSTIR, profile.DenoisingSettings.SpatialOcclusionValidation, VALIDATE_SPATIAL_OCCLUSION); + KeywordSwitch(HReSTIR, HRenderer.TextureXrSlices > 1, VR_COMPATIBILITY); + + cmd.SetComputeBufferParam(HDenoiser, (int)HDenoiserKernels.PointDistributionFill, _PointDistribution_Output, PointDistributionBuffer); + cmd.DispatchCompute(HDenoiser, (int)HDenoiserKernels.PointDistributionFill, 1, 1, 1); + + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialResampling, _Reservoir, ReservoirSpatial.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialResampling, _Reservoir_Output, Reservoir.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialResampling, _SampleCount, SamplecountReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialResampling, _TemporalInvalidity, TemporalInvalidityAccumulated.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialResampling, _TemporalInvalidity_Output, TemporalInvalidityFilteredA.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialResampling, _AmbientOcclusion, AmbientOcclusionAccumulated.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialResampling, _SpatialGuidance_Output, AmbientOcclusionGuidance.rt); + cmd.SetComputeBufferParam(HReSTIR, (int)HReSTIRKernels.SpatialResampling, _PointDistribution, PointDistributionBuffer); + cmd.DispatchCompute(HReSTIR, (int)HReSTIRKernels.SpatialResampling, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _Color, ColorReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _Radiance_Output, Radiance.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _SampleCount, SamplecountReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _AmbientOcclusion, AmbientOcclusionAccumulated.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _Reservoir, Reservoir.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _Reservoir_Output, ReservoirSpatial.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _SpatialOcclusion, SpatialOcclusionReprojected.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _SpatialOcclusion_Output, SpatialOcclusionAccumulated.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _TemporalInvalidity, TemporalInvalidityFilteredA.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _TemporalInvalidity_Output, TemporalInvalidityFilteredB.rt); + cmd.SetComputeTextureParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _SpatialGuidance, AmbientOcclusionGuidance.rt); + cmd.SetComputeBufferParam(HReSTIR, (int)HReSTIRKernels.SpatialValidation, _PointDistribution, PointDistributionBuffer); + cmd.DispatchCompute(HReSTIR, (int)HReSTIRKernels.SpatialValidation, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + } + + + // ---------------------------------------- DENOISER TEMPORAL ---------------------------------------- // + using (new ProfilingScope(cmd, TemporalAccumulationSampler)) + { + KeywordSwitch(HDenoiser, profile.DenoisingSettings.TemporalLightingValidation | profile.DenoisingSettings.TemporalOcclusionValidation, USE_TEMPORAL_INVALIDITY); + KeywordSwitch(HDenoiser, HRenderer.TextureXrSlices > 1, VR_COMPATIBILITY); + + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalAccumulation, _TemporalInvalidity, TemporalInvalidityFilteredB.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalAccumulation, _SamplecountReprojected, SamplecountReprojected.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalAccumulation, _Samplecount_Output, SampleCount.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalAccumulation, _Radiance, Radiance.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalAccumulation, _RadianceReprojected, RadianceReprojected.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalAccumulation, _Radiance_TemporalOutput, RadianceAccumulated.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalAccumulation, _Radiance_SpatialOutput, RadianceFiltered.rt); + cmd.DispatchCompute(HDenoiser, (int)HDenoiserKernels.TemporalAccumulation, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + } + + + // ---------------------------------------- DENOISER SPATIAL ---------------------------------------- // + using (new ProfilingScope(cmd, SpatialFilterSampler)) + { + KeywordSwitch(HDenoiser, profile.DenoisingSettings.SpatialOcclusionValidation, USE_SPATIAL_OCCLUSION); + KeywordSwitch(HDenoiser, UseInterpolation, INTERPOLATION_OUTPUT); + + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter1, _NormalDepth, NormalDepth.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter1, _SpatialGuidance, AmbientOcclusionGuidance.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter1, _AmbientOcclusion, AmbientOcclusionAccumulated.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter1, _Radiance, RadianceFiltered.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter1, _Radiance_Output, Radiance.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter1, _SpatialOcclusion, SpatialOcclusionAccumulated.rt); + cmd.SetComputeBufferParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter1, _PointDistribution, PointDistributionBuffer); + cmd.DispatchCompute(HDenoiser, (int)HDenoiserKernels.SpatialFilter1, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, _NormalDepth, NormalDepth.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, _SpatialGuidance, AmbientOcclusionGuidance.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, _AmbientOcclusion, AmbientOcclusionAccumulated.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, _Radiance, Radiance.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, _Radiance_Output, RadianceFiltered.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, _RadianceNormalDepth_Output, RadianceNormalDepth.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, _SpatialOcclusion, SpatialOcclusionAccumulated.rt); + cmd.SetComputeBufferParam(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, _PointDistribution, PointDistributionBuffer); + cmd.DispatchCompute(HDenoiser, (int)HDenoiserKernels.SpatialFilter2, Mathf.CeilToInt(cameraWidth / RenderScaleFactor / 8.0f), Mathf.CeilToInt(cameraHeight / RenderScaleFactor / 8.0f), HRenderer.TextureXrSlices); + } + + + // ---------------------------------------- INTERPOLATION SPATIAL ---------------------------------------- // + using (new ProfilingScope(cmd, InterpolationSampler)) + { + if (UseInterpolation) + { + KeywordSwitch(HInterpolation, HRenderer.TextureXrSlices > 1, VR_COMPATIBILITY); + + // Interpolation + cmd.SetComputeTextureParam(HInterpolation, (int)HInterpolationKernels.Interpolation, _RadianceNormalDepth, RadianceNormalDepth.rt); + cmd.SetComputeTextureParam(HInterpolation, (int)HInterpolationKernels.Interpolation, _Radiance_Output, RadianceInterpolated.rt); + cmd.SetComputeTextureParam(HInterpolation, (int)HInterpolationKernels.Interpolation, _NormalDepth_HistoryOutput, NormalDepthFullRes.rt); + cmd.DispatchCompute(HInterpolation, (int)HInterpolationKernels.Interpolation, Mathf.CeilToInt(cameraWidth / 8.0f), Mathf.CeilToInt(cameraHeight / 8.0f), HRenderer.TextureXrSlices); + + // Stabilization + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalStabilization, _TemporalInvalidity, TemporalInvalidityFilteredB.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalStabilization, _SamplecountReprojected, SamplecountReprojected.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalStabilization, _Radiance, RadianceInterpolated.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalStabilization, _RadianceReprojected, RadianceStabilizedReprojected.rt); + cmd.SetComputeTextureParam(HDenoiser, (int)HDenoiserKernels.TemporalStabilization, _Radiance_TemporalOutput, RadianceStabilized.rt); + cmd.DispatchCompute(HDenoiser, (int)HDenoiserKernels.TemporalStabilization, Mathf.CeilToInt(cameraWidth / 8.0f), Mathf.CeilToInt(cameraHeight / 8.0f), HRenderer.TextureXrSlices); + } + } + + finalOutput = Mathf.Approximately(profile.SSGISettings.RenderScale, 1.0f) ? SSGI.RadianceFiltered.rt : SSGI.RadianceInterpolated.rt; + + // --------------------------------------------- DEBUG ----------------------------------------------- // + using (new ProfilingScope(cmd, DebugSampler)) + { + if (profile.GeneralSettings.DebugMode != DebugMode.None && profile.GeneralSettings.DebugMode != DebugMode.DirectLighting) + { + cmd.SetComputeIntParams(HDebug, _DebugSwitch, (int)profile.GeneralSettings.DebugMode); + cmd.SetComputeIntParams(HDebug, _BuffersSwitch, (int)profile.GeneralSettings.HBuffer); + cmd.SetComputeTextureParam(HDebug, 0, _Debug_Output, DebugOutput.rt); + cmd.SetComputeTextureParam(HDebug, 0, _SampleCountSSGI, SamplecountReprojected.rt); + cmd.SetComputeTextureParam(HDebug, 0, _HTraceBufferGI, finalOutput); + cmd.DispatchCompute(HDebug, 0, Mathf.CeilToInt(cameraWidth / 8.0f), Mathf.CeilToInt(cameraHeight / 8.0f), HRenderer.TextureXrSlices); + + cmd.SetGlobalTexture(_Debug_Output, DebugOutput.rt); + } + } + } + + private static void KeywordSwitch(ComputeShader compute, bool state, string keyword) + { + if (state) + compute.EnableKeyword(keyword); + else + compute.DisableKeyword(keyword); + } + } + +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/SSGI.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/SSGI.cs.meta new file mode 100644 index 0000000..4db81ef --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/Shared/SSGI.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 899f5117c46144a4bd16bfff7845aff3 +timeCreated: 1745928754 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Passes/Shared/SSGI.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP.meta new file mode 100644 index 0000000..609b57a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e4b8bb5cb72847444bf29135c1e77513 +timeCreated: 1729952262 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/FinalPassURP.cs b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/FinalPassURP.cs new file mode 100644 index 0000000..f8eb83a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/FinalPassURP.cs @@ -0,0 +1,110 @@ +//pipelinedefine +#define H_URP + +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Passes.Shared; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Infrastructure.URP; +using HTraceSSGI.Scripts.Wrappers; +using UnityEngine; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +#if UNITY_2023_3_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + +namespace HTraceSSGI.Scripts.Passes.URP +{ + internal class FinalPassURP : ScriptableRenderPass + { + private ScriptableRenderer _renderer; + + #region --------------------------- Non Render Graph --------------------------- + protected internal void Initialize(ScriptableRenderer renderer) + { + _renderer = renderer; + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) + { + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) + { + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + var cmd = CommandBufferPool.Get(HNames.HTRACE_FINAL_PASS_NAME); + + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + if (profile.GeneralSettings.DebugMode != DebugMode.None && profile.GeneralSettings.DebugMode != DebugMode.DirectLighting) + { + Blitter.BlitCameraTexture(cmd, SSGI.DebugOutput.rt, _renderer.cameraColorTargetHandle); + } + + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + CommandBufferPool.Release(cmd); + } + #endregion --------------------------- Non Render Graph --------------------------- + + #region --------------------------- Render Graph --------------------------- + +#if UNITY_2023_3_OR_NEWER + private class PassData + { + public TextureHandle ColorTexture; + } + + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + using (var builder = renderGraph.AddUnsafePass(HNames.HTRACE_FINAL_PASS_NAME, out var passData, new ProfilingSampler(HNames.HTRACE_FINAL_PASS_NAME))) + { + UniversalResourceData resourceData = frameData.Get(); + UniversalRenderingData universalRenderingData = frameData.Get(); + + builder.AllowGlobalStateModification(true); + builder.AllowPassCulling(false); + + passData.ColorTexture = universalRenderingData.renderingMode == RenderingMode.Deferred ? resourceData.activeColorTexture : resourceData.cameraColor; + + builder.SetRenderFunc((PassData data, UnsafeGraphContext context) => ExecutePass(data, context)); + } + } + + private static void ExecutePass(PassData data, UnsafeGraphContext rgContext) + { + var cmd = CommandBufferHelpers.GetNativeCommandBuffer(rgContext.cmd); + + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + if (profile.GeneralSettings.DebugMode != DebugMode.None && profile.GeneralSettings.DebugMode != DebugMode.DirectLighting) + { + Blitter.BlitCameraTexture(cmd, SSGI.DebugOutput.rt, data.ColorTexture); + } + } +#endif + #endregion --------------------------- Render Graph --------------------------- + + #region --------------------------- Shared --------------------------- + + protected internal void Dispose() + { + } + + #endregion --------------------------- Shared --------------------------- + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/FinalPassURP.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/FinalPassURP.cs.meta new file mode 100644 index 0000000..9c1223e --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/FinalPassURP.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 38d0808db5cb55c4b820dedf6eaec8aa +timeCreated: 1729952288 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Passes/URP/FinalPassURP.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/GBufferPassURP.cs b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/GBufferPassURP.cs new file mode 100644 index 0000000..abf391d --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/GBufferPassURP.cs @@ -0,0 +1,498 @@ +//pipelinedefine +#define H_URP + +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Infrastructure.URP; +using HTraceSSGI.Scripts.Wrappers; +using UnityEngine; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering; +using UnityEngine.Rendering.RendererUtils; +using UnityEngine.Rendering.Universal; + +#if UNITY_2023_3_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#endif + +namespace HTraceSSGI.Scripts.Passes.URP +{ + internal class GBufferPassURP : ScriptableRenderPass + { + // Texture Names + private const string _Dummy = "_Dummy"; + private const string _DepthPyramid = "_DepthPyramid"; + private const string _ForwardGBuffer0 = "_ForwardGBuffer0"; + private const string _ForwardGBuffer1 = "_ForwardGBuffer1"; + private const string _ForwardGBuffer2 = "_ForwardGBuffer2"; + private const string _ForwardGBuffer3 = "_ForwardGBuffer3"; + private const string _ForwardRenderLayerMask = "_ForwardRenderLayerMask"; + private const string _ForwardGBufferDepth = "_ForwardGBufferDepth"; + + // Materials & Computes + internal static ComputeShader HDepthPyramid = null; + + // Samplers + internal static readonly ProfilingSampler GBufferProfilingSampler = new("GBuffer"); + private static readonly ProfilingSampler DepthPyramidGenerationProfilingSampler = new ProfilingSampler("Depth Pyramid Generation"); + + // Textures + internal static RTWrapper Dummy = new RTWrapper(); + internal static RTWrapper ForwardGBuffer0 = new RTWrapper(); + internal static RTWrapper ForwardGBuffer1 = new RTWrapper(); + internal static RTWrapper ForwardGBuffer2 = new RTWrapper(); + internal static RTWrapper ForwardGBuffer3 = new RTWrapper(); + internal static RTWrapper ForwardRenderLayerMask = new RTWrapper(); + internal static RTWrapper ForwardGBufferDepth = new RTWrapper(); + internal static RTWrapper DepthPyramidRT = new RTWrapper(); + + // MRT Arrays + internal static RenderTargetIdentifier[] GBufferMRT = null; + + // Misc + internal static RenderStateBlock ForwardGBufferRenderStateBlock = new RenderStateBlock(RenderStateMask.Nothing); + + #region --------------------------- Non Render Graph --------------------------- + + private ScriptableRenderer _renderer; + + protected internal void Initialize(ScriptableRenderer renderer) + { + _renderer = renderer; + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) + { + Setup(renderingData.cameraData.camera, renderingData.cameraData.renderScale, renderingData.cameraData.cameraTargetDescriptor); + } + + private static void Setup(Camera camera, float renderScale, RenderTextureDescriptor desc) + { + if (HDepthPyramid == null) HDepthPyramid = HExtensions.LoadComputeShader("HDepthPyramid"); + + int width = (int)(camera.scaledPixelWidth * renderScale); + int height = (int)(camera.scaledPixelHeight * renderScale); + + if (desc.width != width || desc.height != height) + desc = new RenderTextureDescriptor(width, height); + desc.depthBufferBits = 0; // Color and depth cannot be combined in RTHandles + desc.stencilFormat = GraphicsFormat.None; + desc.depthStencilFormat = GraphicsFormat.None; + desc.msaaSamples = 1; + desc.bindMS = false; + + var graphicsFormatRenderingLayerMask = GraphicsFormat.R8G8B8A8_UNorm; + + #if UNITY_6000_2_OR_NEWER + graphicsFormatRenderingLayerMask = GraphicsFormat.R8G8_UInt; + #endif + + ForwardGBuffer0.ReAllocateIfNeeded(_ForwardGBuffer0, ref desc, graphicsFormat: GraphicsFormat.R8G8B8A8_SRGB); + ForwardGBuffer1.ReAllocateIfNeeded(_ForwardGBuffer1, ref desc, graphicsFormat: GraphicsFormat.R8G8B8A8_UNorm); + ForwardGBuffer2.ReAllocateIfNeeded(_ForwardGBuffer2, ref desc, graphicsFormat: GraphicsFormat.R8G8B8A8_SNorm); + ForwardGBuffer3.ReAllocateIfNeeded(_ForwardGBuffer3, ref desc, graphicsFormat: GraphicsFormat.B10G11R11_UFloatPack32); + ForwardRenderLayerMask.ReAllocateIfNeeded(_ForwardRenderLayerMask, ref desc, graphicsFormat: graphicsFormatRenderingLayerMask); + DepthPyramidRT.ReAllocateIfNeeded(_DepthPyramid, ref desc, graphicsFormat: GraphicsFormat.R16_SFloat, useMipMap: true); + + RenderTextureDescriptor depthDesc = desc; + depthDesc.depthBufferBits = 32; + depthDesc.depthStencilFormat = GraphicsFormat.None; + ForwardGBufferDepth.ReAllocateIfNeeded(_ForwardGBufferDepth, ref depthDesc, graphicsFormat: GraphicsFormat.R16_SFloat, useMipMap: false, enableRandomWrite: false); + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) + { + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + Camera camera = renderingData.cameraData.camera; + + var cmd = CommandBufferPool.Get(HNames.HTRACE_GBUFFER_PASS_NAME); + + int width = (int)(camera.scaledPixelWidth * renderingData.cameraData.renderScale); + int height = (int)(camera.scaledPixelHeight * renderingData.cameraData.renderScale); + + var nativeGBuffer0 = Shader.GetGlobalTexture(HShaderParams._GBuffer0); + var nativeGBuffer1 = Shader.GetGlobalTexture(HShaderParams._GBuffer1); + var nativeGBuffer2 = Shader.GetGlobalTexture(HShaderParams._GBuffer2); + var renderLayerMaskTexture = Shader.GetGlobalTexture(HShaderParams._CameraRenderingLayersTexture); + var screenSpaceOcclusionTexture = Shader.GetGlobalTexture(HShaderParams.g_ScreenSpaceOcclusionTexture); + + // Set Depth, Color and SSAO to HTrace passes + cmd.SetGlobalTexture(HShaderParams.g_HTraceColor, _renderer.cameraColorTargetHandle); + cmd.SetGlobalTexture(HShaderParams.g_HTraceDepth, _renderer.cameraDepthTargetHandle); + cmd.SetGlobalTexture(HShaderParams.g_HTraceSSAO, screenSpaceOcclusionTexture == null ? Texture2D.whiteTexture : screenSpaceOcclusionTexture); + + GBufferGenerationNonRenderGraph(cmd, width, height, nativeGBuffer0, nativeGBuffer1, nativeGBuffer2, renderLayerMaskTexture, _renderer.cameraColorTargetHandle, _renderer.cameraDepthTargetHandle, ref context, ref renderingData); + + GenerateDepthPyramidShared(cmd, width, height, DepthPyramidRT.rt); + + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + CommandBufferPool.Release(cmd); + } + + + private static void GBufferGenerationNonRenderGraph(CommandBuffer cmd, int width, int height, Texture nativeGBuffer0, Texture nativeGBuffer1, + Texture nativeGBuffer2, Texture renderLayerMask, RTHandle cameraColorBuffer, RTHandle cameraDepthBuffer, + ref ScriptableRenderContext context, ref RenderingData renderingData) + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + var camera = renderingData.cameraData.camera; + using (new ProfilingScope(cmd, GBufferProfilingSampler)) + { + // Set sky probe management + SphericalHarmonicsL2 ambientProbe = RenderSettings.ambientProbe; + cmd.SetGlobalVector(HShaderParams.H_SHAr, new Vector4(ambientProbe[0, 3], ambientProbe[0, 1], ambientProbe[0, 2], ambientProbe[0, 0] - ambientProbe[0, 6])); + cmd.SetGlobalVector(HShaderParams.H_SHAg, new Vector4(ambientProbe[1, 3], ambientProbe[1, 1], ambientProbe[1, 2], ambientProbe[1, 0] - ambientProbe[1, 6])); + cmd.SetGlobalVector(HShaderParams.H_SHAb, new Vector4(ambientProbe[2, 3], ambientProbe[2, 1], ambientProbe[2, 2], ambientProbe[2, 0] - ambientProbe[2, 6])); + cmd.SetGlobalVector(HShaderParams.H_SHBr, new Vector4(ambientProbe[0, 4], ambientProbe[0, 5], ambientProbe[0, 6] * 3, ambientProbe[0, 7])); + cmd.SetGlobalVector(HShaderParams.H_SHBg, new Vector4(ambientProbe[1, 4], ambientProbe[1, 5], ambientProbe[1, 6] * 3, ambientProbe[1, 7])); + cmd.SetGlobalVector(HShaderParams.H_SHBb, new Vector4(ambientProbe[2, 4], ambientProbe[2, 5], ambientProbe[2, 6] * 3, ambientProbe[2, 7])); + cmd.SetGlobalVector(HShaderParams.H_SHC, new Vector4(ambientProbe[0, 8], ambientProbe[1, 8], ambientProbe[2, 8], 1)); + + // Check if GBuffer is valid (e.g. Forward / wrong scale / is not set, etc.) + bool RequestForwardGBufferRender = false; + if (nativeGBuffer0 == null || nativeGBuffer1 == null || nativeGBuffer2 == null) + { RequestForwardGBufferRender = true; } + else if ( nativeGBuffer0.width != width || nativeGBuffer0.height != height) // CameraDepthBuffer.rtHandleProperties.currentViewportSize.x + { RequestForwardGBufferRender = true; } + + // Set Render Layer Mask to black dummy in case it's disabled as a feature and we can't render it + if (renderLayerMask == null) + renderLayerMask = Texture2D.blackTexture;// Dummy.rt; + + // RequestForwardGBufferRender = true; + + // GBuffer can't be rendered because its resolution doesn't match the resolution of Unity's depth buffer. Happens when switching between Scene and Game windows + if (ForwardGBuffer0.rt.rt.width != cameraDepthBuffer.rt.width || ForwardGBuffer0.rt.rt.height != cameraDepthBuffer.rt.height) + { + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer0, ForwardGBuffer0.rt); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer1, ForwardGBuffer1.rt); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer2, ForwardGBuffer2.rt); + cmd.SetGlobalTexture(HShaderParams.g_HTraceRenderLayerMask, ForwardRenderLayerMask.rt); + return; + } + + // Set GBuffer to HTrace passes if valid or render it otherwise + if (RequestForwardGBufferRender == false) + { + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer0, nativeGBuffer0); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer1, nativeGBuffer1); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer2, nativeGBuffer2); + cmd.SetGlobalTexture(HShaderParams.g_HTraceRenderLayerMask, renderLayerMask); + } + else + { + + if (HRendererURP.RenderGraphEnabled) + GBufferMRT = new RenderTargetIdentifier[] { ForwardGBuffer0.rt, ForwardGBuffer1.rt, ForwardGBuffer2.rt, ForwardGBuffer3.rt, ForwardGBufferDepth.rt, ForwardRenderLayerMask.rt }; + else + GBufferMRT = new RenderTargetIdentifier[] { ForwardGBuffer0.rt, ForwardGBuffer1.rt, ForwardGBuffer2.rt, ForwardGBuffer3.rt, ForwardRenderLayerMask.rt }; + + // If CameraDepthBuffer.rt doesn't work for any reason - we can replace it with our ForwardGBufferDepth.rt, but GBuffer rendering performance will suffer. + CoreUtils.SetRenderTarget(cmd, GBufferMRT, cameraDepthBuffer.rt); + + CullingResults cullingResults = renderingData.cullResults; + int layerMask = camera.cullingMask; + + ForwardGBufferRenderStateBlock.depthState = new DepthState(false, CompareFunction.LessEqual); + ForwardGBufferRenderStateBlock.mask |= RenderStateMask.Depth; + + var renderList = new UnityEngine.Rendering.RendererUtils.RendererListDesc(HShaderParams.UniversalGBufferTag, cullingResults, camera) + { + rendererConfiguration = PerObjectData.None, + renderQueueRange = RenderQueueRange.opaque, + sortingCriteria = SortingCriteria.OptimizeStateChanges, + layerMask = layerMask, + stateBlock = ForwardGBufferRenderStateBlock, + }; + + // Cache the current keyword state set by Unity + bool RenderLayerKeywordState = Shader.IsKeywordEnabled(HShaderParams._WRITE_RENDERING_LAYERS); + + // If we don't need render layers we do not touch the keyword at all +#if UNITY_2023_3_OR_NEWER + if (profile.GeneralSettings.ExcludeReceivingMask != 0 || profile.GeneralSettings.ExcludeCastingMask != 0) + CoreUtils.SetKeyword(cmd, HShaderParams._WRITE_RENDERING_LAYERS, true); +#endif + + CoreUtils.DrawRendererList(context, cmd, context.CreateRendererList(renderList)); + + // If we altered the keyword, we restore it to the original state +#if UNITY_2023_3_OR_NEWER + if (profile.GeneralSettings.ExcludeReceivingMask != 0 || profile.GeneralSettings.ExcludeCastingMask != 0) + CoreUtils.SetKeyword(cmd, HShaderParams._WRITE_RENDERING_LAYERS, RenderLayerKeywordState); +#endif + + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer0, ForwardGBuffer0.rt); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer1, ForwardGBuffer1.rt); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer2, ForwardGBuffer2.rt); + cmd.SetGlobalTexture(HShaderParams.g_HTraceRenderLayerMask, ForwardRenderLayerMask.rt); + } + } + } + #endregion --------------------------- Non Render Graph --------------------------- + + #region --------------------------- Render Graph --------------------------- + +#if UNITY_2023_3_OR_NEWER + private class PassData + { + public TextureHandle[] GBufferTextures; + public TextureHandle SSAOTexture; + public TextureHandle ColorTexture; + public TextureHandle DepthTexture; + public TextureHandle NormalsTexture; + public RendererListHandle ForwardGBufferRendererListHandle; + public UniversalCameraData UniversalCameraData; + + public TextureHandle ForwardGBuffer0Texture; + public TextureHandle ForwardGBuffer1Texture; + public TextureHandle ForwardGBuffer2Texture; + public TextureHandle ForwardGBuffer3Texture; + public TextureHandle ForwardRenderLayerMaskTexture; + public TextureHandle DepthPyramidTexture; + public TextureHandle DepthPyramidIntermediateTexture; + public TextureHandle ForwardGBufferDepthTexture; + } + + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + using (var builder = renderGraph.AddUnsafePass(HNames.HTRACE_GBUFFER_PASS_NAME, out var passData, new ProfilingSampler(HNames.HTRACE_GBUFFER_PASS_NAME))) + { + UniversalResourceData resourceData = frameData.Get(); + UniversalCameraData universalCameraData = frameData.Get(); + UniversalRenderingData universalRenderingData = frameData.Get(); + UniversalLightData lightData = frameData.Get(); + + builder.AllowGlobalStateModification(true); + builder.AllowPassCulling(false); + + TextureHandle colorTexture = universalRenderingData.renderingMode == RenderingMode.Deferred ? resourceData.activeColorTexture : resourceData.cameraColor; + TextureHandle depthTexture = universalRenderingData.renderingMode == RenderingMode.Deferred ? resourceData.activeDepthTexture : resourceData.cameraDepth; + TextureHandle normalsTexture = resourceData.cameraNormalsTexture; + builder.UseTexture(depthTexture, AccessFlags.Read); + builder.UseTexture(normalsTexture, AccessFlags.Read); + + passData.NormalsTexture = resourceData.cameraNormalsTexture; + passData.ColorTexture = colorTexture; + passData.DepthTexture = depthTexture; + passData.UniversalCameraData = universalCameraData; + passData.GBufferTextures = resourceData.gBuffer; + passData.SSAOTexture = resourceData.ssaoTexture; + + if (HDepthPyramid == null) HDepthPyramid = HExtensions.LoadComputeShader("HDepthPyramid"); + + TextureHandle colorTextureHandle = resourceData.cameraColor; + TextureDesc desc = colorTextureHandle.GetDescriptor(renderGraph); + desc.clearBuffer = false; + TextureHandle depthTextureHandle = resourceData.cameraDepthTexture; + TextureDesc descDepth = depthTextureHandle.GetDescriptor(renderGraph); + descDepth.clearBuffer = false; + var graphicsFormatRenderingLayerMask = GraphicsFormat.R8G8B8A8_UNorm; + +#if UNITY_6000_2_OR_NEWER + graphicsFormatRenderingLayerMask = GraphicsFormat.R8G8_UInt; +#endif + passData.ForwardGBuffer0Texture = ExtensionsURP.CreateTexture(_ForwardGBuffer0, renderGraph, ref desc, format: GraphicsFormat.R8G8B8A8_SRGB); + builder.UseTexture(passData.ForwardGBuffer0Texture, AccessFlags.Write); + passData.ForwardGBuffer1Texture = ExtensionsURP.CreateTexture(_ForwardGBuffer1, renderGraph, ref desc, format: GraphicsFormat.R8G8B8A8_UNorm); + builder.UseTexture(passData.ForwardGBuffer1Texture, AccessFlags.Write); + passData.ForwardGBuffer2Texture = ExtensionsURP.CreateTexture(_ForwardGBuffer2, renderGraph, ref desc, format: GraphicsFormat.R8G8B8A8_SNorm); + builder.UseTexture(passData.ForwardGBuffer2Texture, AccessFlags.Write); + passData.ForwardGBuffer3Texture = ExtensionsURP.CreateTexture(_ForwardGBuffer3, renderGraph, ref desc, format: GraphicsFormat.B10G11R11_UFloatPack32); + builder.UseTexture(passData.ForwardGBuffer3Texture, AccessFlags.Write); + passData.ForwardRenderLayerMaskTexture = ExtensionsURP.CreateTexture(_ForwardRenderLayerMask, renderGraph, ref desc, format: graphicsFormatRenderingLayerMask); + builder.UseTexture(passData.ForwardRenderLayerMaskTexture, AccessFlags.Write); + passData.DepthPyramidTexture = ExtensionsURP.CreateTexture(_DepthPyramid, renderGraph, ref desc, format: GraphicsFormat.R16_SFloat, useMipMap: true); + builder.UseTexture(passData.DepthPyramidTexture, AccessFlags.Write); + + desc.width /= 16; + desc.height /= 16; + + passData.ForwardGBufferDepthTexture = ExtensionsURP.CreateTexture(_ForwardGBufferDepth, renderGraph, ref descDepth, format: GraphicsFormat.R16_SFloat, useMipMap: false, enableRandomWrite: false); + builder.UseTexture(passData.ForwardGBufferDepthTexture, AccessFlags.Write); + + if (universalRenderingData.renderingMode == RenderingMode.Deferred +#if UNITY_6000_1_OR_NEWER + || universalRenderingData.renderingMode == RenderingMode.DeferredPlus +#endif + ) + { + if (resourceData.ssaoTexture.IsValid()) + builder.UseTexture(resourceData.ssaoTexture, AccessFlags.Read); + builder.UseTexture(resourceData.gBuffer[0], AccessFlags.Read); + builder.UseTexture(resourceData.gBuffer[1], AccessFlags.Read); + builder.UseTexture(resourceData.gBuffer[2], AccessFlags.Read); + builder.UseTexture(resourceData.gBuffer[3], AccessFlags.Read); + if (resourceData.gBuffer.Length >= 6 && resourceData.gBuffer[5].IsValid()) + builder.UseTexture(resourceData.gBuffer[5], AccessFlags.Read); + } + + + CullingResults cullingResults = universalRenderingData.cullResults; + ShaderTagId tags = new ShaderTagId("UniversalGBuffer"); + int layerMask = universalCameraData.camera.cullingMask; + + ForwardGBufferRenderStateBlock.depthState = new DepthState(false, CompareFunction.LessEqual); + ForwardGBufferRenderStateBlock.mask |= RenderStateMask.Depth; + + RendererListDesc rendererListDesc = new RendererListDesc(tags, cullingResults, universalCameraData.camera) + { + rendererConfiguration = PerObjectData.None, + renderQueueRange = RenderQueueRange.opaque, + sortingCriteria = SortingCriteria.OptimizeStateChanges, + layerMask = layerMask, + stateBlock = ForwardGBufferRenderStateBlock, + }; + + passData.ForwardGBufferRendererListHandle = renderGraph.CreateRendererList(rendererListDesc); + builder.UseRendererList(passData.ForwardGBufferRendererListHandle); + + builder.SetRenderFunc((PassData data, UnsafeGraphContext context) => ExecutePass(data, context)); + } + } + + private static void ExecutePass(PassData data, UnsafeGraphContext rgContext) + { + var cmd = CommandBufferHelpers.GetNativeCommandBuffer(rgContext.cmd); + + int width = (int)(data.UniversalCameraData.camera.scaledPixelWidth * data.UniversalCameraData.renderScale); + int height = (int)(data.UniversalCameraData.camera.scaledPixelHeight * data.UniversalCameraData.renderScale); + + // Set Depth, Color and SSAO to HTrace passes + cmd.SetGlobalTexture(HShaderParams.g_HTraceDepth, data.DepthTexture); + cmd.SetGlobalTexture(HShaderParams.g_HTraceColor, data.ColorTexture); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer2, data.NormalsTexture); + cmd.SetGlobalTexture(HShaderParams.g_HTraceSSAO, data.SSAOTexture.IsValid() ? data.SSAOTexture : Texture2D.whiteTexture); + + var nativeGBuffer0 = data.GBufferTextures[0]; + var nativeGBuffer1 = data.GBufferTextures[1]; + var nativeGBuffer2 = data.GBufferTextures[2]; + Texture renderLayerMaskTexture = data.GBufferTextures.Length >= 6 ? data.GBufferTextures[5] : null; + GBufferGenerationRenderGraph(cmd, data, width, height, nativeGBuffer0, nativeGBuffer1, nativeGBuffer2, renderLayerMaskTexture); + + GenerateDepthPyramidShared(cmd, width, height, data.DepthPyramidTexture); + } + + private static void GBufferGenerationRenderGraph(CommandBuffer cmd, PassData data, int width, int height, Texture nativeGBuffer0, Texture nativeGBuffer1, + Texture nativeGBuffer2, Texture renderLayerMask) + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + using (new ProfilingScope(cmd, GBufferProfilingSampler)) + { + // Sky probe management + SphericalHarmonicsL2 ambientProbe = RenderSettings.ambientProbe; + cmd.SetGlobalVector(HShaderParams.H_SHAr, new Vector4(ambientProbe[0, 3], ambientProbe[0, 1], ambientProbe[0, 2], ambientProbe[0, 0] - ambientProbe[0, 6])); + cmd.SetGlobalVector(HShaderParams.H_SHAg, new Vector4(ambientProbe[1, 3], ambientProbe[1, 1], ambientProbe[1, 2], ambientProbe[1, 0] - ambientProbe[1, 6])); + cmd.SetGlobalVector(HShaderParams.H_SHAb, new Vector4(ambientProbe[2, 3], ambientProbe[2, 1], ambientProbe[2, 2], ambientProbe[2, 0] - ambientProbe[2, 6])); + cmd.SetGlobalVector(HShaderParams.H_SHBr, new Vector4(ambientProbe[0, 4], ambientProbe[0, 5], ambientProbe[0, 6] * 3, ambientProbe[0, 7])); + cmd.SetGlobalVector(HShaderParams.H_SHBg, new Vector4(ambientProbe[1, 4], ambientProbe[1, 5], ambientProbe[1, 6] * 3, ambientProbe[1, 7])); + cmd.SetGlobalVector(HShaderParams.H_SHBb, new Vector4(ambientProbe[2, 4], ambientProbe[2, 5], ambientProbe[2, 6] * 3, ambientProbe[2, 7])); + cmd.SetGlobalVector(HShaderParams.H_SHC, new Vector4(ambientProbe[0, 8], ambientProbe[1, 8], ambientProbe[2, 8], 1)); + + // Check if GBuffer is valid (e.g. Forward / wrong scale / is not set, etc.) + bool requestForwardGBufferRender = false; + if (nativeGBuffer0 == null || nativeGBuffer1 == null || nativeGBuffer2 == null) + { requestForwardGBufferRender = true; } + else if ( nativeGBuffer0.width != width || nativeGBuffer0.height != height) // CameraDepthBuffer.rtHandleProperties.currentViewportSize.x + { requestForwardGBufferRender = true; } + + // Set Render Layer Mask to black dummy in case it's disabled as a feature and we can't render it + if (renderLayerMask == null) + renderLayerMask = Texture2D.blackTexture; // HRenderer.EmptyTexture; + + // RequestForwardGBufferRender = true; + + // Set GBuffer to HTrace passes if valid or render it otherwise + if (requestForwardGBufferRender == false) + { + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer0, nativeGBuffer0); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer1, nativeGBuffer1); + // cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer2, nativeGBuffer2); + cmd.SetGlobalTexture(HShaderParams.g_HTraceRenderLayerMask, renderLayerMask); + } + else + { + + if (HRendererURP.RenderGraphEnabled) + GBufferMRT = new RenderTargetIdentifier[] { data.ForwardGBuffer0Texture, data.ForwardGBuffer1Texture, data.ForwardGBuffer2Texture, data.ForwardGBuffer3Texture, data.ForwardGBufferDepthTexture, data.ForwardRenderLayerMaskTexture }; + else + GBufferMRT = new RenderTargetIdentifier[] { data.ForwardGBuffer0Texture, data.ForwardGBuffer1Texture, data.ForwardGBuffer2Texture, data.ForwardGBuffer3Texture, data.ForwardRenderLayerMaskTexture }; + + // If CameraDepthBuffer.rt doesn't work for any reason - we can replace it with our ForwardGBufferDepth.rt, but GBuffer rendering performance will suffer. + CoreUtils.SetRenderTarget(cmd, GBufferMRT, data.DepthTexture, ClearFlag.None); + + // Cache the current keyword state set by Unity + bool RenderLayerKeywordState = Shader.IsKeywordEnabled(HShaderParams._WRITE_RENDERING_LAYERS); + + // If we don't need render layers we do not touch the keyword at all +#if UNITY_2023_3_OR_NEWER + if (profile.GeneralSettings.ExcludeReceivingMask != 0 || profile.GeneralSettings.ExcludeCastingMask != 0) + CoreUtils.SetKeyword(cmd, HShaderParams._WRITE_RENDERING_LAYERS, true); +#endif + + cmd.DrawRendererList(data.ForwardGBufferRendererListHandle); + + // If we altered the keyword, we restore it to the original state +#if UNITY_2023_3_OR_NEWER + if (profile.GeneralSettings.ExcludeReceivingMask != 0 || profile.GeneralSettings.ExcludeCastingMask != 0) + CoreUtils.SetKeyword(cmd, HShaderParams._WRITE_RENDERING_LAYERS, RenderLayerKeywordState); +#endif + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer0, data.ForwardGBuffer0Texture); + cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer1, data.ForwardGBuffer1Texture); + // cmd.SetGlobalTexture(HShaderParams.g_HTraceGBuffer2, data.ForwardGBuffer2Texture); + cmd.SetGlobalTexture(HShaderParams.g_HTraceRenderLayerMask, data.ForwardRenderLayerMaskTexture); + } + } + } +#endif + #endregion --------------------------- Render Graph --------------------------- + + #region --------------------------- Shared --------------------------- + + private static void GenerateDepthPyramidShared(CommandBuffer cmd, int width, int height, RTHandle depthPyramidTexture) + { + using (new ProfilingScope(cmd, DepthPyramidGenerationProfilingSampler)) + { + int generate_depth_pyramid_kernel = HDepthPyramid.FindKernel("GenerateDepthPyramid"); + cmd.SetComputeTextureParam(HDepthPyramid, generate_depth_pyramid_kernel, HShaderParams._DepthPyramid_OutputMIP0, depthPyramidTexture, 0); + cmd.SetComputeTextureParam(HDepthPyramid, generate_depth_pyramid_kernel, HShaderParams._DepthPyramid_OutputMIP1, depthPyramidTexture, 1); + cmd.SetComputeTextureParam(HDepthPyramid, generate_depth_pyramid_kernel, HShaderParams._DepthPyramid_OutputMIP2, depthPyramidTexture, 2); + cmd.SetComputeTextureParam(HDepthPyramid, generate_depth_pyramid_kernel, HShaderParams._DepthPyramid_OutputMIP3, depthPyramidTexture, 3); + cmd.SetComputeTextureParam(HDepthPyramid, generate_depth_pyramid_kernel, HShaderParams._DepthPyramid_OutputMIP4, depthPyramidTexture, 4); + cmd.DispatchCompute(HDepthPyramid, generate_depth_pyramid_kernel, Mathf.CeilToInt(width / 16.0f), Mathf.CeilToInt(height / 16.0f), HRenderer.TextureXrSlices); + + cmd.SetGlobalTexture(HShaderParams.g_HTraceDepthPyramidSSGI, depthPyramidTexture); + } + } + + + protected internal void Dispose() + { + Dummy?.HRelease(); + ForwardGBuffer0?.HRelease(); + ForwardGBuffer1?.HRelease(); + ForwardGBuffer2?.HRelease(); + ForwardGBuffer3?.HRelease(); + ForwardRenderLayerMask?.HRelease(); + ForwardGBufferDepth?.HRelease(); + DepthPyramidRT?.HRelease(); + } + + #endregion --------------------------- Shared --------------------------- + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/GBufferPassURP.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/GBufferPassURP.cs.meta new file mode 100644 index 0000000..515e643 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/GBufferPassURP.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: fd63347b53844f7fa3fdc1ef13ff65ba +timeCreated: 1757347187 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Passes/URP/GBufferPassURP.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/MotionVectorsURP.cs b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/MotionVectorsURP.cs new file mode 100644 index 0000000..2c18b01 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/MotionVectorsURP.cs @@ -0,0 +1,345 @@ +//pipelinedefine +#define H_URP + +using System; +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Wrappers; +using UnityEngine; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; +#if UNITY_2023_3_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#else +using UnityEngine.Experimental.Rendering.RenderGraphModule; +#endif + + +namespace HTraceSSGI.Scripts.Passes.URP +{ + internal class MotionVectorsURP : ScriptableRenderPass + { + // Texture Names + const string _ObjectMotionVectorsColorURP = "_ObjectMotionVectorsColorURP"; + const string _ObjectMotionVectorsDepthURP = "_ObjectMotionVectorsDepthURP"; + const string _CustomCameraMotionVectorsURP_0 = "_CustomCameraMotionVectorsURP_0"; + const string _CustomCameraMotionVectorsURP_1 = "_CustomCameraMotionVectorsURP_1"; + const string _MotionVectorsTagID = "MotionVectors"; + + // Shader Properties + private static readonly int _ObjectMotionVectorsColor = Shader.PropertyToID("_ObjectMotionVectors"); + private static readonly int _ObjectMotionVectorsDepth = Shader.PropertyToID("_ObjectMotionVectorsDepth"); + private static readonly int _BiasOffset = Shader.PropertyToID("_BiasOffset"); + + // Textures + internal static RTWrapper[] CustomCameraMotionVectorsURP = new RTWrapper[2] {new RTWrapper(), new RTWrapper()}; + internal static RTWrapper ObjectMotionVectorsColorURP = new RTWrapper(); + internal static RTWrapper ObjectMotionVectorsDepthURP = new RTWrapper(); + + // Materials + private static Material MotionVectorsMaterial_URP; + + private static ProfilingSampler ObjectMVProfilingSampler = new ProfilingSampler(HNames.HTRACE_OBJECTS_MV_PASS_NAME); + private static ProfilingSampler MVProfilingSampler = new ProfilingSampler(HNames.HTRACE_CAMERA_MV_PASS_NAME); + + + #region --------------------------- Non Render Graph --------------------------- + + private ScriptableRenderer _renderer; + private static int _historyCameraIndex; + + protected internal void Initialize(ScriptableRenderer renderer) + { + _renderer = renderer; + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) + { + Setup(renderingData.cameraData.camera, renderingData.cameraData.renderScale, renderingData.cameraData.cameraTargetDescriptor); + } + + private static void Setup(Camera camera, float renderScale, RenderTextureDescriptor desc) + { + if (MotionVectorsMaterial_URP == null) MotionVectorsMaterial_URP = new Material(Shader.Find($"Hidden/{HNames.ASSET_NAME}/MotionVectorsURP")); + + int width = (int)(camera.scaledPixelWidth * renderScale); + int height = (int)(camera.scaledPixelHeight * renderScale); + + if (desc.width != width || desc.height != height) + desc = new RenderTextureDescriptor(width, height); + + desc.depthBufferBits = 0; // Color and depth cannot be combined in RTHandles + desc.stencilFormat = GraphicsFormat.None; + desc.depthStencilFormat = GraphicsFormat.None; + desc.msaaSamples = 1; + desc.bindMS = false; + desc.enableRandomWrite = true; + + RenderTextureDescriptor depthDesc = desc; + depthDesc.depthBufferBits = 32; + depthDesc.enableRandomWrite = false; + depthDesc.colorFormat = RenderTextureFormat.Depth; + + CustomCameraMotionVectorsURP[0].ReAllocateIfNeeded(_CustomCameraMotionVectorsURP_0, ref desc, graphicsFormat: GraphicsFormat.R16G16_SFloat); + CustomCameraMotionVectorsURP[1].ReAllocateIfNeeded(_CustomCameraMotionVectorsURP_1, ref desc, graphicsFormat: GraphicsFormat.R8_SNorm); + ObjectMotionVectorsColorURP.ReAllocateIfNeeded(_ObjectMotionVectorsColorURP, ref desc, graphicsFormat: GraphicsFormat.R16G16_SFloat); + ObjectMotionVectorsDepthURP.ReAllocateIfNeeded(_ObjectMotionVectorsDepthURP, ref depthDesc, enableRandomWrite: false); + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) + { + ConfigureInput(ScriptableRenderPassInput.Motion | ScriptableRenderPassInput.Depth); + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + var cmd = CommandBufferPool.Get(HNames.HTRACE_MV_PASS_NAME); + + Camera camera = renderingData.cameraData.camera; + + + RenderMotionVectorsNonRenderGraph(cmd, camera, ref renderingData, ref context); + + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + CommandBufferPool.Release(cmd); + } + + private void RenderMotionVectorsNonRenderGraph(CommandBuffer cmd, Camera camera, ref RenderingData renderingData, ref ScriptableRenderContext context) + { + void RenderObjectsMotionVectors(ref RenderingData renderingData, ref ScriptableRenderContext context) + { +#if UNITY_2023_3_OR_NEWER + if (camera.cameraType == CameraType.SceneView) + return; +#endif + + CoreUtils.SetRenderTarget(cmd, ObjectMotionVectorsColorURP.rt, ClearFlag.All, Color.clear); + CoreUtils.SetRenderTarget(cmd, ObjectMotionVectorsDepthURP.rt, ClearFlag.All, Color.clear); +#if UNITY_2023_1_OR_NEWER + // We'll write not only to our own Color, but also to our own Depth target to use it later (in Camera MV) to compose per-object mv + CoreUtils.SetRenderTarget(cmd, ObjectMotionVectorsColorURP.rt, ObjectMotionVectorsDepthURP.rt); +#else + // Prior to 2023 camera motion vectors are rendered directly on objects, so we write to both motion mask and motion vectors via MRT + RenderTargetIdentifier[] motionVectorsMRT = { CustomCameraMotionVectorsURP[0].rt, CustomCameraMotionVectorsURP[1].rt,}; + CoreUtils.SetRenderTarget(cmd, motionVectorsMRT, ObjectMotionVectorsDepthURP.rt); + +#endif // UNITY_2023_1_OR_NEWER + + CullingResults cullingResults = renderingData.cullResults; + + ShaderTagId[] tags +#if UNITY_2023_1_OR_NEWER + = {new ShaderTagId("MotionVectors")}; +#else + = {new ShaderTagId("Meta")}; +#endif // UNITY_2023_1_OR_NEWER + + var renderList = new UnityEngine.Rendering.RendererUtils.RendererListDesc(tags, cullingResults, camera) + { + rendererConfiguration = PerObjectData.MotionVectors, + renderQueueRange = RenderQueueRange.opaque, + sortingCriteria = SortingCriteria.CommonOpaque, + layerMask = camera.cullingMask, + overrideMaterial +#if UNITY_2023_1_OR_NEWER + = null, +#else + = MotionVectorsMaterial_URP, + overrideMaterialPassIndex = 1, + // If somethingis wrong with our custom shader we can always use the standard one (and ShaderPass = 0) instead + // Material ObjectMotionVectorsMaterial = new Material(Shader.Find("Hidden/Universal Render Pipeline/ObjectMotionVectors")); + // overrideMaterialPassIndex = 0, +#endif //UNITY_2023_1_OR_NEWER + + }; + + CoreUtils.DrawRendererList(context, cmd, context.CreateRendererList(renderList)); + +#if !UNITY_2023_1_OR_NEWER + // Prior to 2023 camera motion vectors are rendered directly on objects, so we will finish mv calculation here and won't execute camera mv + cmd.SetGlobalTexture(HShaderParams.g_HTraceMotionVectors, CustomCameraMotionVectorsURP[0].rt); + cmd.SetGlobalTexture(HShaderParams.g_HTraceMotionMask, CustomCameraMotionVectorsURP[1].rt); +#endif // UNITY_2023_1_OR_NEWER + } + + + void RenderCameraMotionVectors() + { +#if UNITY_2023_1_OR_NEWER + + float DepthBiasOffset = 0; +#if UNITY_2023_1_OR_NEWER + DepthBiasOffset = 0.00099f; +#endif // UNITY_2023_1_OR_NEWER +#if UNITY_6000_0_OR_NEWER + DepthBiasOffset = 0; +#endif // UNITY_6000_0_OR_NEWER + + // Target target[0] is set as a Depth Buffer, just because this method requires Depth, but we don't care for it in the fullscreen pass + RenderTargetIdentifier[] motionVectorsMRT = { CustomCameraMotionVectorsURP[0].rt, CustomCameraMotionVectorsURP[1].rt}; + CoreUtils.SetRenderTarget(cmd, motionVectorsMRT, motionVectorsMRT[0]); + + MotionVectorsMaterial_URP.SetTexture(_ObjectMotionVectorsColor, ObjectMotionVectorsColorURP.rt); + MotionVectorsMaterial_URP.SetTexture(_ObjectMotionVectorsDepth, ObjectMotionVectorsDepthURP.rt); + MotionVectorsMaterial_URP.SetFloat(_BiasOffset, DepthBiasOffset); + + cmd.DrawProcedural(Matrix4x4.identity, MotionVectorsMaterial_URP, 0, MeshTopology.Triangles, 3, 1); + + // This restores color camera color target (.SetRenderTarget can be used for Forward + any Depth Priming, but doesn't work in Deferred) +#pragma warning disable CS0618 + ConfigureTarget(_renderer.cameraColorTargetHandle); +#pragma warning restore CS0618 + + cmd.SetGlobalTexture(HShaderParams.g_HTraceMotionVectors, CustomCameraMotionVectorsURP[0].rt); + cmd.SetGlobalTexture(HShaderParams.g_HTraceMotionMask, CustomCameraMotionVectorsURP[1].rt); +#endif // UNITY_2023_1_OR_NEWER + } + + RenderObjectsMotionVectors(ref renderingData, ref context); + RenderCameraMotionVectors(); + } + + #endregion --------------------------- Non Render Graph --------------------------- + + #region --------------------------- Render Graph --------------------------- + +#if UNITY_2023_3_OR_NEWER + private class ObjectMVPassData + { + public RendererListHandle RendererListHandle; + } + + private class CameraMVPassData + { + public TextureHandle ObjectMotionVectorsColor; + public TextureHandle ObjectMotionVectorsDepth; + } + + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + UniversalCameraData universalCameraData = frameData.Get(); + + ConfigureInput(ScriptableRenderPassInput.Motion | ScriptableRenderPassInput.Depth); + + using (IRasterRenderGraphBuilder builder = renderGraph.AddRasterRenderPass(HNames.HTRACE_OBJECTS_MV_PASS_NAME, out var passData, ObjectMVProfilingSampler)) + { + UniversalResourceData resourceData = frameData.Get(); + UniversalRenderingData universalRenderingData = frameData.Get(); + + builder.AllowGlobalStateModification(true); + builder.AllowPassCulling(false); + + TextureHandle depthTexture = resourceData.activeDepthTexture; + TextureHandle motionVectorsTexture = resourceData.motionVectorColor; + if (motionVectorsTexture.IsValid()) + builder.UseTexture(motionVectorsTexture, AccessFlags.Read); + + AddRendererList(renderGraph, universalCameraData, universalRenderingData, passData, builder); + + // This was previously colorTexture.GetDescriptor(renderGraph); + TextureDesc descDepth = depthTexture.GetDescriptor(renderGraph); + descDepth.colorFormat = GraphicsFormat.R16G16_SFloat; + descDepth.name = _ObjectMotionVectorsColorURP; + TextureHandle objectMotionVectorsColorTexHandle = renderGraph.CreateTexture(descDepth); + + builder.SetRenderAttachment(objectMotionVectorsColorTexHandle, 0); + builder.SetRenderAttachmentDepth(depthTexture, AccessFlags.ReadWrite); + + //if (motionVectorsTexture.IsValid()) //seems to work fine without this + builder.SetGlobalTextureAfterPass(motionVectorsTexture, HShaderParams.g_HTraceMotionVectors); + builder.SetGlobalTextureAfterPass(objectMotionVectorsColorTexHandle, HShaderParams.g_HTraceMotionMask); + + builder.SetRenderFunc((ObjectMVPassData data, RasterGraphContext context) => + { + RasterCommandBuffer cmd = context.cmd; + + cmd.ClearRenderTarget(false, true, Color.black); + cmd.DrawRendererList(data.RendererListHandle); + }); + } + + // Render Graph + Game View - no need to render camera mv, as they are already available to us in this combination + if (universalCameraData.cameraType == CameraType.Game) + return; + + using (IRasterRenderGraphBuilder builder = renderGraph.AddRasterRenderPass(HNames.HTRACE_CAMERA_MV_PASS_NAME, out var passData, MVProfilingSampler)) + { + UniversalResourceData resourceData = frameData.Get(); + + builder.AllowGlobalStateModification(true); + builder.AllowPassCulling(false); + + TextureHandle colorTexture = resourceData.activeColorTexture; + + if (MotionVectorsMaterial_URP == null) MotionVectorsMaterial_URP = new Material(Shader.Find($"Hidden/{HNames.ASSET_NAME}/MotionVectorsURP")); + + TextureDesc desc = colorTexture.GetDescriptor(renderGraph); + desc.colorFormat = GraphicsFormat.R16G16_SFloat; + desc.name = _CustomCameraMotionVectorsURP_0; + TextureHandle cameraMotionVectorsColorTexHandle = renderGraph.CreateTexture(desc); + + builder.SetRenderAttachment(cameraMotionVectorsColorTexHandle, 0); + builder.SetGlobalTextureAfterPass(cameraMotionVectorsColorTexHandle, HShaderParams.g_HTraceMotionVectors); + + builder.SetRenderFunc((CameraMVPassData data, RasterGraphContext context) => + { + RasterCommandBuffer cmd = context.cmd; + + MotionVectorsMaterial_URP.SetTexture(_ObjectMotionVectorsColor, context.defaultResources.blackTexture); + MotionVectorsMaterial_URP.SetTexture(_ObjectMotionVectorsDepth, context.defaultResources.whiteTexture); + MotionVectorsMaterial_URP.SetFloat(_BiasOffset, 0); + + cmd.DrawProcedural(Matrix4x4.identity, MotionVectorsMaterial_URP, 0, MeshTopology.Triangles, 3, 1); + }); + } + } + + private static void AddRendererList(RenderGraph renderGraph, UniversalCameraData universalCameraData, UniversalRenderingData universalRenderingData, ObjectMVPassData objectMvPassData, IRasterRenderGraphBuilder builder) + { + RenderStateBlock ForwardGBufferRenderStateBlock = new RenderStateBlock(RenderStateMask.Nothing); + ForwardGBufferRenderStateBlock.depthState = new DepthState(false, CompareFunction.LessEqual); // Probably CompareFunction.Less ? + ForwardGBufferRenderStateBlock.mask |= RenderStateMask.Depth; + + ShaderTagId motionVectorsShaderTag = new ShaderTagId(_MotionVectorsTagID); + + var renderList = new UnityEngine.Rendering.RendererUtils.RendererListDesc(motionVectorsShaderTag, universalRenderingData.cullResults, universalCameraData.camera) + { + rendererConfiguration = PerObjectData.MotionVectors, + renderQueueRange = RenderQueueRange.opaque, + sortingCriteria = SortingCriteria.CommonOpaque, + stateBlock = ForwardGBufferRenderStateBlock, + }; + + objectMvPassData.RendererListHandle = renderGraph.CreateRendererList(renderList); + + builder.UseRendererList(objectMvPassData.RendererListHandle); + } +#endif + + #endregion --------------------------- Render Graph --------------------------- + + #region --------------------------- Share --------------------------- + + protected internal void Dispose() + { + CustomCameraMotionVectorsURP[0]?.HRelease(); + CustomCameraMotionVectorsURP[1]?.HRelease(); + ObjectMotionVectorsColorURP?.HRelease(); + ObjectMotionVectorsDepthURP?.HRelease(); + } + + #endregion --------------------------- Share --------------------------- + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/MotionVectorsURP.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/MotionVectorsURP.cs.meta new file mode 100644 index 0000000..ffc6f90 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/MotionVectorsURP.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 603fb045f7d843da93b9e3f0435072b7 +timeCreated: 1757339660 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Passes/URP/MotionVectorsURP.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/PrePassURP.cs b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/PrePassURP.cs new file mode 100644 index 0000000..8b12e69 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/PrePassURP.cs @@ -0,0 +1,225 @@ +//pipelinedefine +#define H_URP + +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Extensions.CameraHistorySystem; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Passes.Shared; +using HTraceSSGI.Scripts.Wrappers; +using Unity.Collections; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.RendererUtils; +using UnityEngine.Rendering.Universal; + +#if UNITY_2023_3_OR_NEWER +using UnityEngine.Rendering.RenderGraphModule; +#else +using UnityEngine.Experimental.Rendering.RenderGraphModule; +#endif + +namespace HTraceSSGI.Scripts.Passes.URP +{ + internal class PrePassURP : ScriptableRenderPass + { + private static Vector4 s_HRenderScalePrevious = Vector4.one; + + private struct HistoryCameraData : ICameraHistoryData + { + private int hash; + public Matrix4x4 previousViewProjMatrix; + public Matrix4x4 previousInvViewProjMatrix; + + public int GetHash() => hash; + public void SetHash(int hashIn) => this.hash = hashIn; + } + + private static readonly CameraHistorySystem CameraHistorySystem = new CameraHistorySystem(); + private static int s_FrameCount = 0; + + #region --------------------------- Non Render Graph --------------------------- + private ScriptableRenderer _renderer; + + protected internal void Initialize(ScriptableRenderer renderer) + { + _renderer = renderer; + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) + { + Camera camera = renderingData.cameraData.camera; + + CameraHistorySystem.UpdateCameraHistoryIndex(camera.GetHashCode()); + CameraHistorySystem.UpdateCameraHistoryData(); + CameraHistorySystem.GetCameraData().SetHash(camera.GetHashCode()); + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) + { + ConfigureInput(ScriptableRenderPassInput.Depth); // | ScriptableRenderPassInput.Normal); + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + var cmd = CommandBufferPool.Get(HNames.HTRACE_PRE_PASS_NAME); + + Camera camera = renderingData.cameraData.camera; + + // -------------- HRenderScale ----------------- + // Unity's _RTHandleScale in URP always (1,1,1,1)? We need to overwrite it anyway... + cmd.SetGlobalVector(HShaderParams.HRenderScalePrevious, s_HRenderScalePrevious); + //s_HRenderScalePrevious = new Vector4(RTHandles.rtHandleProperties.rtHandleScale.x, RTHandles.rtHandleProperties.rtHandleScale.y, 1 / RTHandles.rtHandleProperties.rtHandleScale.x, 1 / RTHandles.rtHandleProperties.rtHandleScale.y); //we don't needed it more + cmd.SetGlobalVector(HShaderParams.HRenderScale, s_HRenderScalePrevious); + + // -------------- Matrix ----------------- + Matrix4x4 projMatrix = GL.GetGPUProjectionMatrix(camera.projectionMatrix, true); //renderingData.cameraData.GetGPUProjectionMatrix(); + Matrix4x4 viewMatrix = renderingData.cameraData.GetViewMatrix(); + Matrix4x4 viewProjMatrix = projMatrix * viewMatrix; + Matrix4x4 invViewProjMatrix = Matrix4x4.Inverse(viewProjMatrix); + { + cmd.SetGlobalMatrix(HShaderParams.H_MATRIX_VP, viewProjMatrix); + cmd.SetGlobalMatrix(HShaderParams.H_MATRIX_I_VP, invViewProjMatrix); + ref var previousViewProjMatrix = ref CameraHistorySystem.GetCameraData().previousViewProjMatrix; + cmd.SetGlobalMatrix(HShaderParams.H_MATRIX_PREV_VP, previousViewProjMatrix); + ref var previousInvViewProjMatrix = ref CameraHistorySystem.GetCameraData().previousInvViewProjMatrix; + cmd.SetGlobalMatrix(HShaderParams.H_MATRIX_PREV_I_VP, previousInvViewProjMatrix); + + previousViewProjMatrix = viewProjMatrix; + previousInvViewProjMatrix = invViewProjMatrix; + CameraHistorySystem.GetCameraData().SetHash(camera.GetHashCode()); + + // HistoryCameraData currentData = CameraHistorySystem.GetCameraData(); + // currentData.previousViewProjMatrix = viewProjMatrix; + // currentData.previousInvViewProjMatrix = invViewProjMatrix; + // CameraHistorySystem.SetCameraData(currentData); + } + + + // -------------- Other ----------------- + cmd.SetGlobalInt(HShaderParams.FrameCount, s_FrameCount); + s_FrameCount++; + // Unity's blue noise is unreliable, so we'll use ours in all pipelines + HBlueNoise.SetTextures(cmd); + + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + CommandBufferPool.Release(cmd); + } + #endregion --------------------------- Non Render Graph --------------------------- + + #region --------------------------- Render Graph --------------------------- + +#if UNITY_2023_3_OR_NEWER + RTHandle OwenScrambledRTHandle; + RTHandle ScramblingTileXSPPRTHandle; + RTHandle RankingTileXSPPRTHandle; + RTHandle ScramblingTextureRTHandle; + + private class PassData + { + public RendererListHandle RendererListHandle; + public UniversalCameraData UniversalCameraData; + } + + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + using (var builder = renderGraph.AddRasterRenderPass(HNames.HTRACE_PRE_PASS_NAME, out var passData, new ProfilingSampler(HNames.HTRACE_PRE_PASS_NAME))) + { + UniversalResourceData resourceData = frameData.Get(); + UniversalCameraData universalCameraData = frameData.Get(); + UniversalRenderingData universalRenderingData = frameData.Get(); + UniversalLightData lightData = frameData.Get(); + + ConfigureInput(ScriptableRenderPassInput.Depth | ScriptableRenderPassInput.Normal); + + builder.AllowGlobalStateModification(true); + builder.AllowPassCulling(false); + + passData.UniversalCameraData = universalCameraData; + + Camera camera = universalCameraData.camera; + + CameraHistorySystem.UpdateCameraHistoryIndex(camera.GetHashCode()); + CameraHistorySystem.UpdateCameraHistoryData(); + CameraHistorySystem.GetCameraData().SetHash(camera.GetHashCode()); + + //Blue noise + if (OwenScrambledRTHandle == null) OwenScrambledRTHandle = RTHandles.Alloc(HBlueNoise.OwenScrambledTexture); + TextureHandle owenScrambledTextureHandle = renderGraph.ImportTexture(OwenScrambledRTHandle); + builder.SetGlobalTextureAfterPass(owenScrambledTextureHandle, HBlueNoise.g_OwenScrambledTexture); + + if (ScramblingTileXSPPRTHandle == null) ScramblingTileXSPPRTHandle = RTHandles.Alloc(HBlueNoise.ScramblingTileXSPP); + TextureHandle scramblingTileXSPPTextureHandle = renderGraph.ImportTexture(ScramblingTileXSPPRTHandle); + builder.SetGlobalTextureAfterPass(scramblingTileXSPPTextureHandle, HBlueNoise.g_ScramblingTileXSPP); + + if (RankingTileXSPPRTHandle == null) RankingTileXSPPRTHandle = RTHandles.Alloc(HBlueNoise.RankingTileXSPP); + TextureHandle rankingTileXSPPTextureHandle = renderGraph.ImportTexture(RankingTileXSPPRTHandle); + builder.SetGlobalTextureAfterPass(rankingTileXSPPTextureHandle, HBlueNoise.g_RankingTileXSPP); + + if (ScramblingTextureRTHandle == null) ScramblingTextureRTHandle = RTHandles.Alloc(HBlueNoise.ScramblingTexture); + TextureHandle scramblingTextureHandle = renderGraph.ImportTexture(ScramblingTextureRTHandle); + builder.SetGlobalTextureAfterPass(scramblingTextureHandle, HBlueNoise.g_ScramblingTexture); + + builder.SetRenderFunc((PassData data, RasterGraphContext context) => ExecutePass(data, context)); + } + } + + private static void ExecutePass(PassData data, RasterGraphContext rgContext) + { + var cmd = rgContext.cmd; + + Camera camera = data.UniversalCameraData.camera; + + // -------------- HRenderScale ----------------- + // Unity's _RTHandleScale in URP always (1,1,1,1)? We need to overwrite it anyway... + cmd.SetGlobalVector(HShaderParams.HRenderScalePrevious, s_HRenderScalePrevious); + //s_HRenderScalePrevious = new Vector4(RTHandles.rtHandleProperties.rtHandleScale.x, RTHandles.rtHandleProperties.rtHandleScale.y, 1 / RTHandles.rtHandleProperties.rtHandleScale.x, 1 / RTHandles.rtHandleProperties.rtHandleScale.y); //we don't needed it more + cmd.SetGlobalVector(HShaderParams.HRenderScale, s_HRenderScalePrevious); + + // -------------- Matrix ----------------- + + Matrix4x4 projMatrix = GL.GetGPUProjectionMatrix(camera.projectionMatrix, true); //renderingData.cameraData.GetGPUProjectionMatrix(); + Matrix4x4 viewMatrix = data.UniversalCameraData.GetViewMatrix(); + Matrix4x4 viewProjMatrix = projMatrix * viewMatrix; + Matrix4x4 invViewProjMatrix = Matrix4x4.Inverse(viewProjMatrix); + { + cmd.SetGlobalMatrix(HShaderParams.H_MATRIX_VP, viewProjMatrix); + cmd.SetGlobalMatrix(HShaderParams.H_MATRIX_I_VP, invViewProjMatrix); + ref var previousViewProjMatrix = ref CameraHistorySystem.GetCameraData().previousViewProjMatrix; + cmd.SetGlobalMatrix(HShaderParams.H_MATRIX_PREV_VP, previousViewProjMatrix); + ref var previousInvViewProjMatrix = ref CameraHistorySystem.GetCameraData().previousInvViewProjMatrix; + cmd.SetGlobalMatrix(HShaderParams.H_MATRIX_PREV_I_VP, previousInvViewProjMatrix); + + previousViewProjMatrix = viewProjMatrix; + previousInvViewProjMatrix = invViewProjMatrix; + CameraHistorySystem.GetCameraData().SetHash(camera.GetHashCode()); + + // HistoryCameraData currentData = CameraHistorySystem.GetCameraData(); + // currentData.previousViewProjMatrix = viewProjMatrix; + // currentData.previousInvViewProjMatrix = invViewProjMatrix; + // CameraHistorySystem.SetCameraData(currentData); + } + + // -------------- Other ----------------- + cmd.SetGlobalInt(HShaderParams.FrameCount, s_FrameCount); + s_FrameCount++; + } +#endif + + #endregion --------------------------- Render Graph --------------------------- + + protected internal void Dispose() + { + s_FrameCount = 0; + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/PrePassURP.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/PrePassURP.cs.meta new file mode 100644 index 0000000..36a4a06 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/PrePassURP.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 1499f9a9fbb1cf242835eeae03872d5d +timeCreated: 1729952288 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Passes/URP/PrePassURP.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/SSGIPassURP.cs b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/SSGIPassURP.cs new file mode 100644 index 0000000..e594de2 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/SSGIPassURP.cs @@ -0,0 +1,446 @@ +//pipelinedefine +#define H_URP + +using HTraceSSGI.Scripts.Data.Private; +using HTraceSSGI.Scripts.Data.Public; +using HTraceSSGI.Scripts.Extensions; +using HTraceSSGI.Scripts.Globals; +using HTraceSSGI.Scripts.Passes.Shared; +using HTraceSSGI.Scripts.Wrappers; +using UnityEngine; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +#if UNITY_2023_3_OR_NEWER +using HTraceSSGI.Scripts.Infrastructure.URP; +using UnityEngine.Rendering.RenderGraphModule; +#endif + +namespace HTraceSSGI.Scripts.Passes.URP +{ + internal class SSGIPassURP : ScriptableRenderPass + { + private static readonly int CameraNormalsTexture = Shader.PropertyToID("_CameraNormalsTexture"); + + // Texture Names + internal const string _ColorPreviousFrame = "_ColorPreviousFrame"; + internal const string _DebugOutput = "_DebugOutput"; + internal const string _ColorCopy = "_ColorCopy"; + internal const string _ReservoirLuminance = "_ReservoirLuminance"; + internal const string _Reservoir = "_Reservoir"; + internal const string _ReservoirReprojected = "_ReservoirReprojected"; + internal const string _ReservoirSpatial = "_ReservoirSpatial"; + internal const string _ReservoirTemporal = "_ReservoirTemporal"; + internal const string _SampleCount = "_Samplecount"; + internal const string _SamplecountReprojected = "_SamplecountReprojected"; + internal const string _TemporalInvalidityFilteredA = "_TemporalInvalidityFilteredA"; + internal const string _TemporalInvalidityFilteredB = "_TemporalInvalidityFilteredB"; + internal const string _TemporalInvalidityAccumulated = "_TemporalInvalidityAccumulated"; + internal const string _TemporalInvalidityReprojected = "_TemporalInvalidityReprojected"; + internal const string _SpatialOcclusionAccumulated = "_SpatialOcclusionAccumulated"; + internal const string _SpatialOcclusionReprojected = "_SpatialOcclusionReprojected"; + internal const string _AmbientOcclusion = "_AmbientOcclusion"; + internal const string _AmbientOcclusionGuidance = "_AmbientOcclusionGuidance"; + internal const string _AmbientOcclusionInvalidity = "_AmbientOcclusionInvalidity"; + internal const string _AmbientOcclusionAccumulated = "_AmbientOcclusionAccumulated"; + internal const string _AmbientOcclusionReprojected = "_AmbientOcclusionReprojected"; + internal const string _Radiance = "_Radiance"; + internal const string _RadianceReprojected = "_RadianceReprojected"; + internal const string _RadianceAccumulated = "_RadianceAccumulated"; + internal const string _RadianceFiltered = "_RadianceFiltered"; + internal const string _RadianceInterpolated = "_RadianceInterpolated"; + internal const string _RadianceStabilized = "_RadianceStabilized"; + internal const string _RadianceStabilizedReprojected = "_RadianceStabilizedReprojected"; + internal const string _RadianceNormalDepth = "_RadianceNormalDepth"; + internal const string _ColorReprojected = "_ColorReprojected"; + internal const string _NormalDepthHistory = "_NormalDepthHistory"; + internal const string _NormalDepthHistoryFullRes = "_NormalDepthHistoryFullRes"; + internal const string _DummyBlackTexture = "_DummyBlackTexture"; + + #region --------------------------- Non Render Graph --------------------------- + + private ScriptableRenderer _renderer; + + protected internal void Initialize(ScriptableRenderer renderer) + { + _renderer = renderer; + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData) + { + SSGI.CameraHistorySystem.UpdateCameraHistoryIndex(renderingData.cameraData.camera.GetHashCode()); + SSGI.CameraHistorySystem.UpdateCameraHistoryData(); + SSGI.CameraHistorySystem.GetCameraData().SetHash(renderingData.cameraData.camera.GetHashCode()); + + SetupShared(renderingData.cameraData.camera, renderingData.cameraData.renderScale, renderingData.cameraData.cameraTargetDescriptor); + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) + { + } + +#if UNITY_2023_3_OR_NEWER + [System.Obsolete] +#endif + public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + var cmd = CommandBufferPool.Get(HNames.HTRACE_SSGI_PASS_NAME); + + Camera camera = renderingData.cameraData.camera; + float renderScale = renderingData.cameraData.renderScale; + int width = (int)(camera.scaledPixelWidth * renderScale); + int height = (int)(camera.scaledPixelHeight * renderScale); + + if (Shader.GetGlobalTexture(CameraNormalsTexture) == null) + return; + + // ---------------------------------------- AMBIENT LIGHTING OVERRIDE ---------------------------------------- // + using (new ProfilingScope(cmd, SSGI.AmbientLightingOverrideSampler)) + { + cmd.SetGlobalFloat(SSGI._IndirectLightingIntensity, profile.SSGISettings.Intensity); + + if (profile.GeneralSettings.AmbientOverride) + { + // Copy Color buffer + CoreUtils.SetRenderTarget(cmd, SSGI.ColorCopy_URP.rt); + cmd.DrawProcedural(Matrix4x4.identity, SSGI.ColorCompose_URP, 0, MeshTopology.Triangles, 3, 1); + + // Subtract indirect lighting from Color buffer + CoreUtils.SetRenderTarget(cmd, _renderer.cameraColorTargetHandle); + SSGI.ColorCompose_URP.SetTexture(SSGI._ColorCopy, SSGI.ColorCopy_URP.rt); + cmd.DrawProcedural(Matrix4x4.identity, SSGI.ColorCompose_URP, 1, MeshTopology.Triangles, 3, 1); + } + + // Early out if we want to prview direct lighting only + if (profile.GeneralSettings.DebugMode == DebugMode.DirectLighting) + { + ConfigureTarget(_renderer.cameraColorTargetHandle); + + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + CommandBufferPool.Release(cmd); + + return; + } + } + + SSGI.Execute(cmd, camera, width, height, _renderer.cameraColorTargetHandle); + + // ---------------------------------------- INDIRECT LIGHTING INJECTION ---------------------------------------- // + using (new ProfilingScope(cmd, SSGI.IndirectLightingInjectionSampler)) + { + var finalOutput = Mathf.Approximately(profile.SSGISettings.RenderScale, 1.0f) ? SSGI.RadianceFiltered.rt : SSGI.RadianceInterpolated.rt; + cmd.SetGlobalTexture(SSGI._SampleCountSSGI, SSGI.SamplecountReprojected.rt); + cmd.SetGlobalTexture(SSGI._HTraceBufferGI, finalOutput); + + // Copy color buffer + indirect lighting (without intensity multiplication) for multibounce + if (profile.GeneralSettings.Multibounce == true) + { + cmd.SetComputeTextureParam(SSGI.HTemporalReprojection, (int)SSGI.HTemporalReprojectionKernels.CopyHistory, SSGI._Radiance_History, _renderer.cameraColorTargetHandle); + cmd.SetComputeTextureParam(SSGI.HTemporalReprojection, (int)SSGI.HTemporalReprojectionKernels.CopyHistory, SSGI._Radiance_Output, SSGI.CameraHistorySystem.GetCameraData().ColorPreviousFrame.rt); + cmd.DispatchCompute(SSGI.HTemporalReprojection, (int)SSGI.HTemporalReprojectionKernels.CopyHistory, Mathf.CeilToInt(width / 8.0f), Mathf.CeilToInt(height / 8.0f), HRenderer.TextureXrSlices); + } + +#if UNITY_2023_3_OR_NEWER + if (profile.GeneralSettings.ExcludeReceivingMask != 0) + SSGI.ColorCompose_URP.EnableKeyword(SSGI.USE_RECEIVE_LAYER_MASK); +#endif + + // Inject final indirect lighting (with intensity multiplication) into color buffer via additive blending + CoreUtils.SetRenderTarget(cmd, _renderer.cameraColorTargetHandle); + SSGI.ColorCompose_URP.SetInt(SSGI._MetallicIndirectFallback, profile.GeneralSettings.MetallicIndirectFallback ? 1 : 0); + cmd.DrawProcedural(Matrix4x4.identity, SSGI.ColorCompose_URP, 2, MeshTopology.Triangles, 3, 1); + + ConfigureTarget(_renderer.cameraColorTargetHandle); + } + + SSGI.History.Update(); + + context.ExecuteCommandBuffer(cmd); + cmd.Clear(); + CommandBufferPool.Release(cmd); + return; + } + + #endregion --------------------------- Non Render Graph --------------------------- + + #region --------------------------- Render Graph --------------------------- + +#if UNITY_2023_3_OR_NEWER + private class PassData + { + public UniversalCameraData UniversalCameraData; + public TextureHandle ColorTexture; + public TextureHandle DepthTexture; + } + + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + + using (var builder = renderGraph.AddUnsafePass(HNames.HTRACE_SSGI_PASS_NAME, out var passData, new ProfilingSampler(HNames.HTRACE_SSGI_PASS_NAME))) + { + UniversalResourceData resourceData = frameData.Get(); + UniversalCameraData universalCameraData = frameData.Get(); + UniversalRenderingData universalRenderingData = frameData.Get(); + UniversalLightData lightData = frameData.Get(); + + ConfigureInput(ScriptableRenderPassInput.Normal); + + builder.AllowGlobalStateModification(true); + builder.AllowPassCulling(false); + + RenderTextureDescriptor targetDesc = universalCameraData.cameraTargetDescriptor; + TextureHandle colorTexture = universalRenderingData.renderingMode == RenderingMode.Deferred +#if UNITY_6000_1_OR_NEWER + || universalRenderingData.renderingMode == RenderingMode.DeferredPlus +#endif + ? resourceData.activeColorTexture : resourceData.cameraColor; + TextureHandle depthTexture = universalRenderingData.renderingMode == RenderingMode.Deferred +#if UNITY_6000_1_OR_NEWER + || universalRenderingData.renderingMode == RenderingMode.DeferredPlus +#endif + ? resourceData.activeDepthTexture : resourceData.cameraDepth; + builder.UseTexture(colorTexture, AccessFlags.Write); + builder.UseTexture(resourceData.cameraNormalsTexture); + builder.UseTexture(resourceData.motionVectorColor); + + passData.UniversalCameraData = universalCameraData; + passData.ColorTexture = colorTexture; + passData.DepthTexture = depthTexture; + + Camera camera = universalCameraData.camera; + + SSGI.CameraHistorySystem.UpdateCameraHistoryIndex(camera.GetHashCode()); + SSGI.CameraHistorySystem.UpdateCameraHistoryData(); + SSGI.CameraHistorySystem.GetCameraData().SetHash(camera.GetHashCode()); + + SetupShared(camera, universalCameraData.renderScale, universalCameraData.cameraTargetDescriptor); + + builder.SetRenderFunc((PassData data, UnsafeGraphContext context) => ExecutePass(data, context)); + } + + } + + private static void ExecutePass(PassData data, UnsafeGraphContext rgContext) + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + var cmd = CommandBufferHelpers.GetNativeCommandBuffer(rgContext.cmd); + + Camera camera = data.UniversalCameraData.camera; + float renderScale = data.UniversalCameraData.renderScale; + int width = (int)(camera.scaledPixelWidth * renderScale); + int height = (int)(camera.scaledPixelHeight * renderScale); + + if (Shader.GetGlobalTexture(CameraNormalsTexture) == null) + return; + + // ---------------------------------------- AMBIENT LIGHTING OVERRIDE ---------------------------------------- // + using (new ProfilingScope(cmd, SSGI.AmbientLightingOverrideSampler)) + { + cmd.SetGlobalFloat(SSGI._IndirectLightingIntensity, profile.SSGISettings.Intensity); + + if (profile.GeneralSettings.AmbientOverride) + { + // Copy Color buffer + CoreUtils.SetRenderTarget(cmd, SSGI.ColorCopy_URP.rt); + cmd.DrawProcedural(Matrix4x4.identity, SSGI.ColorCompose_URP, 0, MeshTopology.Triangles, 3, 1); + + // Subtract indirect lighting from Color buffer + CoreUtils.SetRenderTarget(cmd, data.ColorTexture); + SSGI.ColorCompose_URP.SetTexture(SSGI._ColorCopy, SSGI.ColorCopy_URP.rt); + cmd.DrawProcedural(Matrix4x4.identity, SSGI.ColorCompose_URP, 1, MeshTopology.Triangles, 3, 1); + } + + // Early out if we want to prview direct lighting only + if (profile.GeneralSettings.DebugMode == DebugMode.DirectLighting) + { + return; + } + } + + SSGI.Execute(cmd, camera, width, height, data.ColorTexture); + + // ---------------------------------------- INDIRECT LIGHTING INJECTION ---------------------------------------- // + using (new ProfilingScope(cmd, SSGI.IndirectLightingInjectionSampler)) + { + cmd.SetGlobalTexture(SSGI._HTraceBufferGI, SSGI.finalOutput); + + // Copy color buffer + indirect lighting (without intensity multiplication) for multibounce + if (profile.GeneralSettings.Multibounce == true) + { + cmd.SetComputeTextureParam(SSGI.HTemporalReprojection, (int)SSGI.HTemporalReprojectionKernels.CopyHistory, SSGI._Radiance_History, data.ColorTexture); + cmd.SetComputeTextureParam(SSGI.HTemporalReprojection, (int)SSGI.HTemporalReprojectionKernels.CopyHistory, SSGI._Radiance_Output, SSGI.CameraHistorySystem.GetCameraData().ColorPreviousFrame.rt); + cmd.DispatchCompute(SSGI.HTemporalReprojection, (int)SSGI.HTemporalReprojectionKernels.CopyHistory, Mathf.CeilToInt(width / 8.0f), Mathf.CeilToInt(height / 8.0f), HRenderer.TextureXrSlices); + } + +#if UNITY_2023_3_OR_NEWER + if (profile.GeneralSettings.ExcludeReceivingMask != 0) + SSGI.ColorCompose_URP.EnableKeyword(SSGI.USE_RECEIVE_LAYER_MASK); +#endif + + // Inject final indirect lighting (with intensity multiplication) into color buffer via additive blending + CoreUtils.SetRenderTarget(cmd, data.ColorTexture); + SSGI.ColorCompose_URP.SetInt(SSGI._MetallicIndirectFallback, profile.GeneralSettings.MetallicIndirectFallback ? 1 : 0); + cmd.DrawProcedural(Matrix4x4.identity, SSGI.ColorCompose_URP, 2, MeshTopology.Triangles, 3, 1); + } + + SSGI.History.Update(); + } +#endif + #endregion --------------------------- Render Graph --------------------------- + + #region ------------------------------------ Shared ------------------------------------ + private static void SetupShared(Camera camera, float renderScale, RenderTextureDescriptor desc) + { + HTraceSSGIProfile profile = HTraceSSGISettings.ActiveProfile; + + if (SSGI.HDebug == null) SSGI.HDebug = HExtensions.LoadComputeShader("HDebugSSGI"); + if (SSGI.HReSTIR == null) SSGI.HReSTIR = HExtensions.LoadComputeShader("HRestirSSGI"); + if (SSGI.HRenderSSGI == null) SSGI.HRenderSSGI = HExtensions.LoadComputeShader("HRenderSSGI"); + if (SSGI.HDenoiser == null) SSGI.HDenoiser = HExtensions.LoadComputeShader("HDenoiserSSGI"); + if (SSGI.HInterpolation == null) SSGI.HInterpolation = HExtensions.LoadComputeShader("HInterpolationSSGI"); + if (SSGI.HCheckerboarding == null) SSGI.HCheckerboarding = HExtensions.LoadComputeShader("HCheckerboardingSSGI"); + if (SSGI.PyramidGeneration == null) SSGI.PyramidGeneration = HExtensions.LoadComputeShader("HDepthPyramid"); + if (SSGI.HTemporalReprojection == null) SSGI.HTemporalReprojection = HExtensions.LoadComputeShader("HTemporalReprojectionSSGI"); + + if (SSGI.ColorCompose_URP == null) SSGI.ColorCompose_URP = new Material(Shader.Find($"Hidden/{HNames.ASSET_NAME}/ColorComposeURP")); + + int width = (int)(camera.scaledPixelWidth * renderScale); + int height = (int)(camera.scaledPixelHeight * renderScale); + if (desc.width != width || desc.height != height) + desc = new RenderTextureDescriptor(width, height); + + // Debug.Log($"All params in cameraTargetDescriptor: width: {desc.width}, height:{desc.height}, volumeDepth: {desc.volumeDepth}, depthBufferBits: {desc.depthBufferBits}, \n" + + // $"graphicsFormat: {desc.graphicsFormat}, colorFormat: {desc.colorFormat}, stencilFormat: {desc.stencilFormat}, msaaSamples: {desc.msaaSamples}, \n" + + // $"useMipMap: {desc.useMipMap}, autoGenerateMips: {desc.autoGenerateMips}, mipCount: {desc.mipCount}, \n" + + // $"enableRandomWrite: {desc.enableRandomWrite}, useDynamicScale: {desc.useDynamicScale}, "); + + desc.depthBufferBits = 0; // Color and depth cannot be combined in RTHandles + desc.stencilFormat = GraphicsFormat.None; + desc.depthStencilFormat = GraphicsFormat.None; + desc.msaaSamples = 1; + desc.bindMS = false; + desc.enableRandomWrite = true; + + ref var cameraData = ref SSGI.CameraHistorySystem.GetCameraData(); + if (cameraData.ColorPreviousFrame == null) cameraData.ColorPreviousFrame = new RTWrapper(); + if (cameraData.ReservoirTemporal == null) cameraData.ReservoirTemporal = new RTWrapper(); + if (cameraData.SampleCount == null) cameraData.SampleCount = new RTWrapper(); + if (cameraData.NormalDepth == null) cameraData.NormalDepth = new RTWrapper(); + if (cameraData.NormalDepthFullRes == null) cameraData.NormalDepthFullRes = new RTWrapper(); + if (cameraData.Radiance == null) cameraData.Radiance = new RTWrapper(); + if (cameraData.RadianceAccumulated == null) cameraData.RadianceAccumulated = new RTWrapper(); + if (cameraData.SpatialOcclusionAccumulated == null) cameraData.SpatialOcclusionAccumulated = new RTWrapper(); + if (cameraData.TemporalInvalidityAccumulated == null) cameraData.TemporalInvalidityAccumulated = new RTWrapper(); + if (cameraData.AmbientOcclusionAccumulated == null) cameraData.AmbientOcclusionAccumulated = new RTWrapper(); + + cameraData.ColorPreviousFrame.ReAllocateIfNeeded(_ColorPreviousFrame, ref desc, graphicsFormat: GraphicsFormat.B10G11R11_UFloatPack32); + cameraData.ReservoirTemporal.ReAllocateIfNeeded(_ReservoirTemporal, ref desc, graphicsFormat: GraphicsFormat.R32G32B32A32_UInt); + cameraData.TemporalInvalidityAccumulated.ReAllocateIfNeeded(_TemporalInvalidityAccumulated, ref desc, graphicsFormat: GraphicsFormat.R8G8_UNorm); + cameraData.SpatialOcclusionAccumulated.ReAllocateIfNeeded(_SpatialOcclusionAccumulated, ref desc, graphicsFormat: GraphicsFormat.R8_UNorm); + cameraData.AmbientOcclusionAccumulated.ReAllocateIfNeeded(_AmbientOcclusionAccumulated, ref desc, graphicsFormat: GraphicsFormat.R8_UNorm); + cameraData.Radiance.ReAllocateIfNeeded(_Radiance, ref desc, graphicsFormat: profile.DenoisingSettings.RecurrentBlur ? GraphicsFormat.R16G16B16A16_SFloat : GraphicsFormat.B10G11R11_UFloatPack32); + cameraData.RadianceAccumulated.ReAllocateIfNeeded(_RadianceAccumulated, ref desc, graphicsFormat: GraphicsFormat.R16G16B16A16_SFloat); + cameraData.SampleCount.ReAllocateIfNeeded(_SampleCount, ref desc, graphicsFormat: GraphicsFormat.R16_SFloat); + cameraData.NormalDepth.ReAllocateIfNeeded(_NormalDepthHistory, ref desc, graphicsFormat: GraphicsFormat.R32_UInt); + cameraData.NormalDepthFullRes.ReAllocateIfNeeded(_NormalDepthHistoryFullRes, ref desc, graphicsFormat: GraphicsFormat.R32_UInt); + + SSGI.ColorCopy_URP.ReAllocateIfNeeded(_ColorCopy, ref desc, graphicsFormat: GraphicsFormat.B10G11R11_UFloatPack32); + SSGI.DebugOutput.ReAllocateIfNeeded(_ColorCopy, ref desc, graphicsFormat: GraphicsFormat.B10G11R11_UFloatPack32); + SSGI.ColorReprojected.ReAllocateIfNeeded(_ColorReprojected, ref desc, graphicsFormat: GraphicsFormat.R32_UInt); + SSGI.Reservoir.ReAllocateIfNeeded(_Reservoir, ref desc, graphicsFormat: GraphicsFormat.R32G32B32A32_UInt); + SSGI.ReservoirReprojected.ReAllocateIfNeeded(_ReservoirReprojected, ref desc, graphicsFormat: GraphicsFormat.R32G32B32A32_UInt); + SSGI.ReservoirSpatial.ReAllocateIfNeeded(_ReservoirSpatial, ref desc, graphicsFormat: GraphicsFormat.R32G32B32A32_UInt); + SSGI.ReservoirLuminance.ReAllocateIfNeeded(_ReservoirLuminance, ref desc, graphicsFormat: GraphicsFormat.R16_SFloat); + SSGI.TemporalInvalidityFilteredA.ReAllocateIfNeeded(_TemporalInvalidityFilteredA, ref desc, graphicsFormat: GraphicsFormat.R8G8_UNorm); + SSGI.TemporalInvalidityFilteredB.ReAllocateIfNeeded(_TemporalInvalidityFilteredB, ref desc, graphicsFormat: GraphicsFormat.R8G8_UNorm); + SSGI.TemporalInvalidityReprojected.ReAllocateIfNeeded(_TemporalInvalidityReprojected, ref desc, graphicsFormat: GraphicsFormat.R8G8_UNorm); + SSGI.SpatialOcclusionReprojected.ReAllocateIfNeeded(_SpatialOcclusionReprojected, ref desc, graphicsFormat: GraphicsFormat.R8_UNorm); + SSGI.AmbientOcclusion.ReAllocateIfNeeded(_AmbientOcclusion, ref desc, graphicsFormat: GraphicsFormat.R8_SNorm); + SSGI.AmbientOcclusionGuidance.ReAllocateIfNeeded(_AmbientOcclusionGuidance, ref desc, graphicsFormat: GraphicsFormat.R8G8_UInt); + SSGI.AmbientOcclusionInvalidity.ReAllocateIfNeeded(_AmbientOcclusionInvalidity, ref desc, graphicsFormat: GraphicsFormat.R8_UNorm); + SSGI.AmbientOcclusionReprojected.ReAllocateIfNeeded(_AmbientOcclusionReprojected, ref desc, graphicsFormat: GraphicsFormat.R8_UNorm); + SSGI.RadianceFiltered.ReAllocateIfNeeded(_RadianceFiltered, ref desc, graphicsFormat: GraphicsFormat.B10G11R11_UFloatPack32); + SSGI.RadianceReprojected.ReAllocateIfNeeded(_RadianceReprojected, ref desc, graphicsFormat: GraphicsFormat.R16G16B16A16_SFloat); + SSGI.RadianceNormalDepth.ReAllocateIfNeeded(_RadianceNormalDepth, ref desc, graphicsFormat: GraphicsFormat.R32G32_UInt); + SSGI.RadianceInterpolated.ReAllocateIfNeeded(_RadianceInterpolated, ref desc, graphicsFormat: GraphicsFormat.B10G11R11_UFloatPack32); + SSGI.RadianceStabilizedReprojected.ReAllocateIfNeeded(_RadianceStabilizedReprojected, ref desc, graphicsFormat: GraphicsFormat.R16G16B16A16_SFloat); + SSGI.RadianceStabilized.ReAllocateIfNeeded(_RadianceStabilized, ref desc, graphicsFormat: GraphicsFormat.R16G16B16A16_SFloat); + SSGI.SamplecountReprojected.ReAllocateIfNeeded(_SamplecountReprojected, ref desc, graphicsFormat: GraphicsFormat.R16_SFloat); + SSGI.DummyBlackTexture.ReAllocateIfNeeded(_DummyBlackTexture, ref desc, graphicsFormat: GraphicsFormat.R8_UNorm); + + if (SSGI.PointDistributionBuffer == null) SSGI.PointDistributionBuffer = new ComputeBuffer(32 * 4 * HRenderer.TextureXrSlices, 3 * sizeof(int)); + if (SSGI.LuminanceMoments == null) SSGI.LuminanceMoments = new ComputeBuffer(2 * HRenderer.TextureXrSlices, 2 * sizeof(int)); + if (SSGI.IndirectArguments == null) SSGI.IndirectArguments = new ComputeBuffer(3 * HRenderer.TextureXrSlices, sizeof(int), ComputeBufferType.IndirectArguments); + if (SSGI.IndirectCoords == null) SSGI.IndirectCoords = new HDynamicBuffer(BufferType.ComputeBuffer, 2 * sizeof(uint), HRenderer.TextureXrSlices, avoidDownscale: false); + SSGI.IndirectCoords.ReAllocIfNeeded(new Vector2Int(width, height)); + + if (SSGI.RayCounter == null) + { + SSGI.RayCounter = new ComputeBuffer(2 * 1, sizeof(uint)); + uint[] zeroArray = new uint[2 * 1]; + SSGI.RayCounter.SetData(zeroArray); + } + } + + protected internal void Dispose() + { + var historyCameraDataSSGI = SSGI.CameraHistorySystem.GetCameraData(); + historyCameraDataSSGI.ColorPreviousFrame?.HRelease(); + historyCameraDataSSGI.ReservoirTemporal?.HRelease(); + historyCameraDataSSGI.SampleCount?.HRelease(); + historyCameraDataSSGI.NormalDepth?.HRelease(); + historyCameraDataSSGI.NormalDepthFullRes?.HRelease(); + historyCameraDataSSGI.Radiance?.HRelease(); + historyCameraDataSSGI.RadianceAccumulated?.HRelease(); + historyCameraDataSSGI.SpatialOcclusionAccumulated?.HRelease(); + historyCameraDataSSGI.TemporalInvalidityAccumulated?.HRelease(); + historyCameraDataSSGI.AmbientOcclusionAccumulated?.HRelease(); + + SSGI.ColorCopy_URP?.HRelease(); + SSGI.DebugOutput?.HRelease(); + SSGI.ColorReprojected?.HRelease(); + SSGI.Reservoir?.HRelease(); + SSGI.ReservoirReprojected?.HRelease(); + SSGI.ReservoirSpatial?.HRelease(); + SSGI.ReservoirLuminance?.HRelease(); + SSGI.TemporalInvalidityFilteredA?.HRelease(); + SSGI.TemporalInvalidityFilteredB?.HRelease(); + SSGI.TemporalInvalidityReprojected?.HRelease(); + SSGI.SpatialOcclusionReprojected?.HRelease(); + SSGI.AmbientOcclusion?.HRelease(); + SSGI.AmbientOcclusionGuidance?.HRelease(); + SSGI.AmbientOcclusionInvalidity?.HRelease(); + SSGI.AmbientOcclusionReprojected?.HRelease(); + SSGI.RadianceFiltered?.HRelease(); + SSGI.RadianceReprojected?.HRelease(); + SSGI.RadianceNormalDepth?.HRelease(); + SSGI.RadianceInterpolated?.HRelease(); + SSGI.RadianceStabilizedReprojected?.HRelease(); + SSGI.RadianceStabilized?.HRelease(); + SSGI.SamplecountReprojected?.HRelease(); + SSGI.DummyBlackTexture?.HRelease(); + + SSGI.PointDistributionBuffer.HRelease(); + SSGI.LuminanceMoments.HRelease(); + SSGI.RayCounter.HRelease(); + SSGI.IndirectCoords.HRelease(); + SSGI.IndirectArguments.HRelease(); + + SSGI.PointDistributionBuffer = null; + SSGI.LuminanceMoments = null; + SSGI.RayCounter = null; + SSGI.IndirectCoords = null; + SSGI.IndirectArguments = null; + } + #endregion ------------------------------------ Shared ------------------------------------ + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/SSGIPassURP.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/SSGIPassURP.cs.meta new file mode 100644 index 0000000..7b5010a --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Passes/URP/SSGIPassURP.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 82482812f9bf9de4a878162fdf59954b +timeCreated: 1729952288 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Passes/URP/SSGIPassURP.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Patcher.meta b/Assets/Plugins/HTraceSSGI/Scripts/Patcher.meta new file mode 100644 index 0000000..10a0279 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Patcher.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5c9550853c2ae314088c0f219f0a04f3 +timeCreated: 1730454117 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Patcher/InstalledPackage.cs b/Assets/Plugins/HTraceSSGI/Scripts/Patcher/InstalledPackage.cs new file mode 100644 index 0000000..c683226 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Patcher/InstalledPackage.cs @@ -0,0 +1,48 @@ +//pipelinedefine +#define H_URP + +#if UNITY_EDITOR +using UnityEditor; + +namespace HTraceSSGI.Scripts.Patcher +{ + //it's Raytracing Patcher for 2022 + public class InstalledPackage// : AssetPostprocessor + { +// [InitializeOnLoadMethod] + private static void InitializeOnLoad() + { +// #if UNITY_2022 +// string filePath_hRenderRTAO = Path.Combine(ConfiguratorUtils.GetHTraceFolderPath(), "Resources", "HTraceSSGI", "Computes", "HRenderRTAO.compute"); +// +// if (File.Exists(filePath_hRenderRTAO) && File.ReadAllLines(filePath_hRenderRTAO).Length > 10) +// { +// string[] hRenderRTAO2022 = new string[] +// { +// "#pragma kernel RenderRTAO", +// "[numthreads(8, 8, 1)]", +// "void RenderRTAO(uint3 pixCoord : SV_DispatchThreadID, uint groupIndex : SV_GroupIndex, uint groupID : SV_GroupID)", +// "{", +// "}", +// }; +// +// File.WriteAllLines(filePath_hRenderRTAO, hRenderRTAO2022); +// } +// +// string filePath_hMainHSLS = Path.Combine(ConfiguratorUtils.GetHTraceFolderPath(), "Resources", "HTraceSSGI", "Headers", "HMain.hlsl"); +// if (File.Exists(filePath_hMainHSLS)) +// { +// string[] allLines_hMainHSLS = File.ReadAllLines(filePath_hMainHSLS); +// if (string.IsNullOrEmpty(allLines_hMainHSLS[3])) +// { +// allLines_hMainHSLS[3] = "#define _RTHandleScale float4(1.0f, 1.0f, 1.0f, 1.0f)"; +// File.WriteAllLines(filePath_hMainHSLS, allLines_hMainHSLS); +// } +// } +// +// AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); +// #endif + } + } +} +#endif diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Patcher/InstalledPackage.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Patcher/InstalledPackage.cs.meta new file mode 100644 index 0000000..b1b29fa --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Patcher/InstalledPackage.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a36a30b382dcbc14d8ff7380d9e2b473 +timeCreated: 1737699571 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Patcher/InstalledPackage.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator.meta b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator.meta new file mode 100644 index 0000000..8d8d6e8 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e00f51d0fe7b9fc4692645cfc5b3c9be +timeCreated: 1729006149 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/ConfiguratorUtiles.cs b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/ConfiguratorUtiles.cs new file mode 100644 index 0000000..f2a9546 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/ConfiguratorUtiles.cs @@ -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 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/ConfiguratorUtiles.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/ConfiguratorUtiles.cs.meta new file mode 100644 index 0000000..097f357 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/ConfiguratorUtiles.cs.meta @@ -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 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/HPipelinesConfigurator.cs b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/HPipelinesConfigurator.cs new file mode 100644 index 0000000..628c34e --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/HPipelinesConfigurator.cs @@ -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("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 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/HPipelinesConfigurator.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/HPipelinesConfigurator.cs.meta new file mode 100644 index 0000000..99ce578 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/PipelelinesConfigurator/HPipelinesConfigurator.cs.meta @@ -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 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Services.meta b/Assets/Plugins/HTraceSSGI/Scripts/Services.meta new file mode 100644 index 0000000..0b24048 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Services.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 75704b5f697549a6b9bcc6dfb54dc963 +timeCreated: 1751368284 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Services/IService.cs b/Assets/Plugins/HTraceSSGI/Scripts/Services/IService.cs new file mode 100644 index 0000000..2bd3be9 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Services/IService.cs @@ -0,0 +1,8 @@ +namespace HTraceSSGI.Scripts.Services +{ + public interface IService + { + void Update(); + void Cleanup(); + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Services/IService.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Services/IService.cs.meta new file mode 100644 index 0000000..c8406cc --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Services/IService.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 2a1440eebe644cd2bf2833e2b3da09c0 +timeCreated: 1751368305 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Services/IService.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Wrappers.meta b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers.meta new file mode 100644 index 0000000..2e1cd2e --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7d734c775b6af014a966a5d793257ea7 +timeCreated: 1729184091 \ No newline at end of file diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/HDynamicBuffer.cs b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/HDynamicBuffer.cs new file mode 100644 index 0000000..2aaab3c --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/HDynamicBuffer.cs @@ -0,0 +1,92 @@ +using UnityEngine; + +namespace HTraceSSGI.Scripts.Wrappers +{ + public enum BufferType + { + ComputeBuffer, + GraphicsBuffer, + } + + public class HDynamicBuffer + { + private ComputeBuffer _computeBuffer; + private GraphicsBuffer _graphicsBuffer; + + private readonly BufferType _bufferType; + private readonly int _stride; + private int _count; + private int _countScale; + private Vector2Int _resolution; + private readonly ComputeBufferType _computeBufferType; + private readonly GraphicsBuffer.Target _graphicsBufferType; + private readonly bool _avoidDownscale; + + public ComputeBuffer ComputeBuffer => _computeBuffer; + public GraphicsBuffer GraphicsBuffer => _graphicsBuffer; + public int Count => _count; + public Vector2Int Resolution => _resolution; + + public bool IsCreated => _bufferType == BufferType.GraphicsBuffer ? _graphicsBuffer != null : _computeBuffer != null; + + public HDynamicBuffer(BufferType bufferType, int stride, int countScale = 1, + ComputeBufferType computeBufferType = ComputeBufferType.Default, GraphicsBuffer.Target graphicsBufferType = GraphicsBuffer.Target.Structured, + bool avoidDownscale = false) + { + _countScale = Mathf.Max(1, countScale); + _stride = stride; + _bufferType = bufferType; + _computeBufferType = computeBufferType; + _graphicsBufferType = graphicsBufferType; + _avoidDownscale = avoidDownscale; + } + + public void ReAllocIfNeeded(Vector2Int newResolution) + { + if (_resolution == newResolution) + return; + + if (_avoidDownscale == true && _resolution.x * _resolution.y > newResolution.x * newResolution.y) + return; + + Release(); + + _resolution = newResolution; + _count = newResolution.x * newResolution.y * _countScale; + + switch (_bufferType) + { + case BufferType.ComputeBuffer: + _computeBuffer = new ComputeBuffer(_count, _stride, _computeBufferType); + break; + case BufferType.GraphicsBuffer: + _graphicsBuffer = new GraphicsBuffer(_graphicsBufferType, _count, _stride); + break; + } + } + + public void SetBuffer(ComputeShader shader, string name, int kernelIndex) + { + switch (_bufferType) + { + case BufferType.ComputeBuffer: + shader.SetBuffer(kernelIndex, name, _computeBuffer); + break; + case BufferType.GraphicsBuffer: + shader.SetBuffer(kernelIndex, name, _graphicsBuffer); + break; + } + } + + public void Release() + { + _computeBuffer?.Release(); + _computeBuffer = null; + + _graphicsBuffer?.Release(); + _graphicsBuffer = null; + + _resolution = Vector2Int.zero; + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/HDynamicBuffer.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/HDynamicBuffer.cs.meta new file mode 100644 index 0000000..7eee65c --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/HDynamicBuffer.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a65c00cd4f01459a94fbdad28894645c +timeCreated: 1745925251 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Wrappers/HDynamicBuffer.cs + uploadId: 840002 diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/RTWrapper.cs b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/RTWrapper.cs new file mode 100644 index 0000000..76224e2 --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/RTWrapper.cs @@ -0,0 +1,105 @@ +//pipelinedefine +#define H_URP + +using HTraceSSGI.Scripts.Globals; +using UnityEngine; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +namespace HTraceSSGI.Scripts.Wrappers +{ + public class RTWrapper + { + private RenderTextureDescriptor _dscr; + + public RTHandle rt; + + + + public void HTextureAlloc(string name, Vector2 scaleFactor, GraphicsFormat graphicsFormat, int volumeDepthOrSlices = -1, int depthBufferBits = 0, + TextureDimension textureDimension = TextureDimension.Unknown, + bool useMipMap = false, bool autoGenerateMips = false, bool enableRandomWrite = true, bool useDynamicScale = true) //useDynamicScale default = true for Upscalers switch between Hardware and Software + { + volumeDepthOrSlices = volumeDepthOrSlices == -1 ? TextureXR.slices : volumeDepthOrSlices; + textureDimension = textureDimension == TextureDimension.Unknown ? TextureXR.dimension : textureDimension; + + rt = RTHandles.Alloc(scaleFactor, volumeDepthOrSlices, dimension: textureDimension, colorFormat: graphicsFormat, name: name, + enableRandomWrite: enableRandomWrite, useMipMap: useMipMap, useDynamicScale: useDynamicScale, autoGenerateMips: autoGenerateMips, + depthBufferBits: (DepthBits)depthBufferBits); + } + + public void HTextureAlloc(string name, ScaleFunc scaleFunc, GraphicsFormat graphicsFormat, int volumeDepthOrSlices = -1, int depthBufferBits = 0, + TextureDimension textureDimension = TextureDimension.Unknown, + bool useMipMap = false, bool autoGenerateMips = false, bool enableRandomWrite = true, bool useDynamicScale = true) //useDynamicScale default = true for Upscalers switch between Hardware and Software + { + volumeDepthOrSlices = volumeDepthOrSlices == -1 ? TextureXR.slices : volumeDepthOrSlices; + textureDimension = textureDimension == TextureDimension.Unknown ? TextureXR.dimension : textureDimension; + + rt = RTHandles.Alloc(scaleFunc, volumeDepthOrSlices, dimension: textureDimension, colorFormat: graphicsFormat, name: name, + enableRandomWrite: enableRandomWrite, useMipMap: useMipMap, useDynamicScale: useDynamicScale, autoGenerateMips: autoGenerateMips, + depthBufferBits: (DepthBits)depthBufferBits); + } + + public void HTextureAlloc(string name, int width, int height, GraphicsFormat graphicsFormat, int volumeDepthOrSlices = -1, int depthBufferBits = 0, + TextureDimension textureDimension = TextureDimension.Unknown, + bool useMipMap = false, bool autoGenerateMips = false, bool enableRandomWrite = true, bool useDynamicScale = true) //useDynamicScale default = true for Upscalers switch between Hardware and Software + { + volumeDepthOrSlices = volumeDepthOrSlices == -1 ? TextureXR.slices : volumeDepthOrSlices; + textureDimension = textureDimension == TextureDimension.Unknown ? TextureXR.dimension : textureDimension; + + rt = RTHandles.Alloc(width, height, volumeDepthOrSlices, dimension: textureDimension, colorFormat: graphicsFormat, name: name, + enableRandomWrite: enableRandomWrite, useMipMap: useMipMap, useDynamicScale: useDynamicScale, autoGenerateMips: autoGenerateMips, + depthBufferBits: (DepthBits)depthBufferBits); + } + + public void HRelease() + { + RTHandles.Release(rt); + } + + public void ReAllocateIfNeeded(string name, ref RenderTextureDescriptor inputDescriptor, GraphicsFormat graphicsFormat = GraphicsFormat.None, + int width = -1, int height = -1, int volumeDepth = 1, + TextureDimension dimension = TextureDimension.Tex2D, + bool enableRandomWrite = true, bool useMipMap = false, bool autoGenerateMips = false, + bool useDynamicScale = false) + { + if (dimension != TextureDimension.Tex2D || width > 0 || height > 0) //conditions to create new descriptor + { + RenderTextureDescriptor newDesc = inputDescriptor; + + newDesc.width = width == -1 ? inputDescriptor.width : width; + newDesc.height = height == -1 ? inputDescriptor.height : height; + newDesc.volumeDepth = volumeDepth; + newDesc.dimension = dimension; + newDesc.graphicsFormat = graphicsFormat; + newDesc.autoGenerateMips = autoGenerateMips; + newDesc.useMipMap = useMipMap; + newDesc.enableRandomWrite = enableRandomWrite; + newDesc.msaaSamples = 1; + newDesc.useDynamicScale = false; + +#if UNITY_2023_3_OR_NEWER + RenderingUtils.ReAllocateHandleIfNeeded(ref rt, newDesc, name: name); +#else + RenderingUtils.ReAllocateIfNeeded(ref rt, newDesc, name: name); +#endif + return; + } + + inputDescriptor.volumeDepth = volumeDepth; + inputDescriptor.graphicsFormat = graphicsFormat; + inputDescriptor.autoGenerateMips = autoGenerateMips; + inputDescriptor.useMipMap = useMipMap; + inputDescriptor.enableRandomWrite = enableRandomWrite; + inputDescriptor.msaaSamples = 1; + inputDescriptor.useDynamicScale = false; + +#if UNITY_2023_3_OR_NEWER + RenderingUtils.ReAllocateHandleIfNeeded(ref rt, inputDescriptor, name: name); +#else + RenderingUtils.ReAllocateIfNeeded(ref rt, inputDescriptor, name: name); +#endif + } + } +} diff --git a/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/RTWrapper.cs.meta b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/RTWrapper.cs.meta new file mode 100644 index 0000000..31f80ce --- /dev/null +++ b/Assets/Plugins/HTraceSSGI/Scripts/Wrappers/RTWrapper.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 36cadb88827714842b7a17d1c36ca0aa +timeCreated: 1729184161 +AssetOrigin: + serializedVersion: 1 + productId: 336896 + packageName: 'HTrace: Screen Space Global Illumination URP' + packageVersion: 1.2.0 + assetPath: Assets/HTraceSSGI/Scripts/Wrappers/RTWrapper.cs + uploadId: 840002