diff --git a/README.md b/README.md index c9f7224b..73a49377 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@
  • OIDN for offline denoising
  • PBR Texture Support
  • Next Event Estimation with Multiple Importance Sampling
  • -
  • Efficient Light BVH from PBRT 4 for Next Event Estimation
  • +
  • Spherical Gaussian Light Tree or the Light BVH for Next Event Estimation
  • Support for all default unity lights(Using Next Event Estimation)
  • Bloom, Depth of Field, AutoExposure, TAA, Tonemapping
  • Precomputed Multiple Atmospheric Scattering for the sky
  • @@ -40,6 +40,7 @@
  • True Bindless texturing(Thanks to Meetem)
  • Convolution Bloom(Not mine)
  • Vulkan and Metal support(Your mileage may vary)
  • +
  • Mesh slicing using SDFs(Does not modify meshes, for rendering cuts only, like cross-sections)
  • MASSIVE thanks to @@ -48,6 +49,8 @@ for bringing bindless textures to unity!
    [Ylitie et al](https://research.nvidia.com/sites/default/files/publications/ylitie2017hpg-paper.pdf)
    [ebruneton](https://ebruneton.github.io/precomputed_atmospheric_scattering/)
    [Convolutional Bloom](https://github.com/AKGWSB/FFTConvolutionBloom) +
    [Spherical Gaussian Light Tree](https://gpuopen.com/download/publications/Hierarchical_Light_Sampling_with_Accurate_Spherical_Gaussian_Lighting.pdf) +
    [Light BVH(PBRT 4)](https://pbr-book.org/4ed/Light_Sources/Light_Sampling#x3-LightBoundingVolumeHierarchies)
    diff --git a/TrueTrace.unitypackage b/TrueTrace.unitypackage index 3a56b2cd..ff47a20a 100644 Binary files a/TrueTrace.unitypackage and b/TrueTrace.unitypackage differ diff --git a/TrueTrace/DemoScene.asset b/TrueTrace/DemoScene.asset index 633a2fa1..35e86197 100644 --- a/TrueTrace/DemoScene.asset +++ b/TrueTrace/DemoScene.asset @@ -19,20 +19,20 @@ MonoBehaviour: UseRussianRoulette: 1 UseNEE: 1 DoTLASUpdates: 1 - Accumulate: 0 + Accumulate: 1 PPBloom: 0 - BloomStrength: 0.849 + BloomStrength: 0.372 PPDoF: 0 - DoFAperature: 0.403 + DoFAperature: 0.079 DoFAperatureScale: 0.54 - DoFFocal: 5.1366353 + DoFFocal: 2 PPExposure: 0 - ExposureAuto: 0 + ExposureAuto: 1 PPToneMap: 0 PPTAA: 0 RenderScale: 1 - UseASVGF: 0 - UseTAAU: 0 + DenoiserMethod: 0 + UpscalerMethod: 2 ReSTIRGIUpdateRate: 7 UseReSTIRGITemporal: 1 UseReSTIRGISpatial: 1 @@ -41,7 +41,7 @@ MonoBehaviour: ReSTIRGISpatialRadius: 24 ReSTIRGITemporalMCap: 4 DoReSTIRGIConnectionValidation: 1 - Exposure: 22.8 + Exposure: 18.9 DoPartialRendering: 0 PartialRenderingFactor: 2 DoFirefly: 0 @@ -49,14 +49,13 @@ MonoBehaviour: RISCount: 12 ToneMapper: 0 SkyDesaturate: 0 - ClayColor: {x: 0.20754719, y: 0.20754719, z: 0.20754719} + ClayColor: {x: 0.38679248, y: 0.38679248, z: 0.38679248} GroundColor: {x: 0.11320752, y: 0.11320752, z: 0.11320752} - FireflyFrameCount: 12 + FireflyFrameCount: 1222 FireflyFrameInterval: 1 FireflyStrength: 1 FireflyOffset: 0 - OIDNFrameCount: 50 - UseOIDN: 0 + OIDNFrameCount: 1222 DoSharpen: 0 Sharpness: 1 MainDesiredRes: 16384 @@ -64,7 +63,7 @@ MonoBehaviour: LightEnergyScale: 1 BackgroundType: 0 BackgroundIntensity: {x: 1, y: 1} - SceneBackgroundColor: {x: 0, y: 0, z: 0} + SceneBackgroundColor: {x: 1, y: 1, z: 1} SecondaryBackgroundType: 0 SecondarySceneBackgroundColor: {x: 0, y: 0, z: 0} HDRILongLat: {x: 0, y: 0} @@ -74,11 +73,14 @@ MonoBehaviour: SecondarySkyDesaturate: 0 MatChangeResetsAccum: 1 PPFXAA: 0 - OIDNBlendRatio: 1 - ConvBloom: 0 - ConvStrength: 10 - ConvBloomThreshold: 4.69 + OIDNBlendRatio: 0.119 + ConvBloom: 1 + ConvStrength: 0.18 + ConvBloomThreshold: 0 ConvBloomSize: {x: 1, y: 1} ConvBloomDistExp: 0 ConvBloomDistExpClampMin: 1 ConvBloomDistExpScale: 1 + PrimaryBackgroundTintColor: {x: 0.32200065, y: 0.764151, z: 0.6593174} + PrimaryBackgroundTint: 0 + PrimaryBackgroundContrast: 1 diff --git a/TrueTrace/DemoScene.unity b/TrueTrace/DemoScene.unity index 46c8241d..0d2c379d 100644 --- a/TrueTrace/DemoScene.unity +++ b/TrueTrace/DemoScene.unity @@ -240,6 +240,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -339,6 +345,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -438,6 +450,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -537,6 +555,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -636,6 +660,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -747,6 +777,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -858,6 +894,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -977,6 +1019,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -1076,6 +1124,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -1212,6 +1266,15 @@ MonoBehaviour: - Material__57 - vase_round Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -1311,6 +1374,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -1416,6 +1485,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -1527,6 +1602,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -1652,6 +1733,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -1783,6 +1870,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -1896,6 +1989,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2021,6 +2120,12 @@ MonoBehaviour: Names: - fabric_d Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2120,6 +2225,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2249,6 +2360,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2368,6 +2485,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2551,6 +2674,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2676,6 +2805,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2775,6 +2910,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2900,6 +3041,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -3013,6 +3160,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -3118,6 +3271,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -3231,6 +3390,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -3381,6 +3546,15 @@ MonoBehaviour: - Material__25 - Material__298 Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -3512,6 +3686,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -3635,6 +3815,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -3734,6 +3920,12 @@ MonoBehaviour: Names: - fabric_e Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -3839,6 +4031,12 @@ MonoBehaviour: Names: - roof Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -3950,6 +4148,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -4067,6 +4271,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -4178,6 +4388,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -4333,6 +4549,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -4498,6 +4720,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -4623,6 +4851,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -4722,6 +4956,12 @@ MonoBehaviour: Names: - fabric_f Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -4827,6 +5067,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -4940,6 +5186,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5065,6 +5317,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5182,6 +5440,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5281,6 +5545,12 @@ MonoBehaviour: Names: - fabric_e Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5380,6 +5650,12 @@ MonoBehaviour: Names: - leaf Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5537,6 +5813,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5636,6 +5918,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5735,6 +6023,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5840,6 +6134,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -5945,6 +6245,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6044,6 +6350,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6201,6 +6513,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6300,6 +6618,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6425,6 +6749,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6530,6 +6860,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6629,6 +6965,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6746,6 +7088,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6851,6 +7199,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -6950,6 +7304,12 @@ MonoBehaviour: Names: - floor Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -7061,6 +7421,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -7198,6 +7564,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -7303,6 +7675,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -7414,6 +7792,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -7553,6 +7937,12 @@ MonoBehaviour: Names: - fabric_d Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -7652,6 +8042,12 @@ MonoBehaviour: Names: - fabric_e Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -7781,6 +8177,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -7908,6 +8310,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8041,6 +8449,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8182,6 +8596,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8293,6 +8713,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8392,6 +8818,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8491,6 +8923,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8624,6 +9062,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8723,6 +9167,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8822,6 +9272,12 @@ MonoBehaviour: Names: - fabric_f Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -8971,6 +9427,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -9090,6 +9552,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -9207,6 +9675,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -9312,6 +9786,12 @@ MonoBehaviour: Names: - leaf Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -9431,6 +9911,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -9558,6 +10044,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -9683,6 +10175,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -9810,6 +10308,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -9915,6 +10419,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -10127,6 +10637,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -10250,6 +10766,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -10349,6 +10871,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -10504,6 +11032,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -10609,6 +11143,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -10617,6 +11157,365 @@ MonoBehaviour: JustCreated: 0 TilingChanged: 0 MatOffset: 0 +--- !u!1 &499686669 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 499686670} + - component: {fileID: 499686675} + - component: {fileID: 499686674} + - component: {fileID: 499686673} + - component: {fileID: 499686672} + - component: {fileID: 499686671} + m_Layer: 0 + m_Name: Plane + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &499686670 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 499686669} + m_LocalRotation: {x: -1, y: 0, z: 0, w: 0} + m_LocalPosition: {x: -3.46, y: 1.8626499, z: -0.26748776} + m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1568839224} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: -180, y: 0, z: 0} +--- !u!114 &499686671 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 499686669} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3edaff1cd4be25f4eb0921104c840289, type: 3} + m_Name: + m_EditorClassIdentifier: + LBVH: + ParentBound: + aabb: + b: + BBMax: {x: 0.5, y: 0.5, z: 0.5} + BBMin: {x: -0.5, y: -0.5, z: -0.5} + w: {x: -0.26364112, y: 0.9558102, z: 0.13007213} + phi: 172.10973 + cosTheta_o: -0.99609 + cosTheta_e: 0.0000012675908 + LightCount: 768 + Pad1: 0 + left: 2 + isLeaf: 0 + SGTree: [] + PrimCount: 768 + FinalIndices: + MaxDepth: 12 + ExistsInQue: 1 + QueInProgress: 1 + IsDeformable: 0 + Name: Plane + CWBVHIndicesBufferInverted: + ChildObjects: + - {fileID: 499686672} + MeshCountChanged: 1 + AggTriangles: [] + ParentScale: {x: 0.0050000004, y: 0.0050000004, z: 0.0050000004} + LightTriangles: [] + BVH: + cwbvh_indices: + BVH8Nodes: [] + cwbvhindex_count: 0 + cwbvhnode_count: 0 + SkinnedMeshes: [] + DeformableMeshes: [] + IndexCounts: + MeshRefit: {fileID: 7200000, guid: 8375b50c4fc272d41ab1b7c55b853562, type: 3} + HasStarted: 0 + AggNodes: [] + InstanceMeshIndex: 0 + LightEndIndex: 0 + aabb_untransformed: + BBMax: {x: 0.5, y: 0.5, z: 0.5} + BBMin: {x: -0.5, y: -0.5, z: -0.5} + aabb: + BBMax: {x: 0, y: 0, z: 0} + BBMin: {x: 0, y: 0, z: 0} + AllFull: 0 + AggIndexCount: 0 + AggBVHNodeCount: 0 + _Materials: [] + MatOffset: 1 + CachedTransforms: + - WTL: + e00: 5 + e01: 0 + e02: 0 + e03: 17.3 + e10: 0 + e11: -5 + e12: 0 + e13: 9.31325 + e20: 0 + e21: 0 + e22: -5 + e23: -1.3374388 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + Position: {x: -3.46, y: 1.8626499, z: -0.26748776} + - WTL: + e00: 5 + e01: 0 + e02: 0 + e03: 17.3 + e10: 0 + e11: -5 + e12: 0 + e13: 9.31325 + e20: 0 + e21: 0 + e22: -5 + e23: -1.3374388 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + Position: {x: -3.46, y: 1.8626499, z: -0.26748776} + TotalObjects: 1 + TransformIndexes: [] + HasCompleted: 0 + TotEnergy: 0.124209486 + ThisTransform: {fileID: 499686670} + ConstructKernel: 0 + TransferKernel: 1 + RefitLayerKernel: 2 + NodeUpdateKernel: 4 + NodeCompressKernel: 5 + NodeInitializerKernel: 6 + LightBLASRefitKernel: 9 + CompactedMeshData: 0 + InstanceReferences: 0 + NeedsToUpdate: 1 + FailureCount: 0 + TotalTriangles: 0 + IsSkinnedGroup: 0 + HasLightTriangles: 1 + ForwardStack: [] + LayerStack: [] + NodePair: [] + MaxRecur: 0 + ToBVHIndex: + tempAABB: + BBMax: {x: 0, y: 0, z: 0} + BBMin: {x: 0, y: 0, z: 0} + NodeOffset: 0 + TriOffset: 0 + LightTriOffset: 0 + LightNodeOffset: 0 + SplitNodes: [] + AlbedoTexs: [] + NormalTexs: [] + SecondaryNormalTexs: [] + MetallicTexs: [] + MetallicTexChannelIndex: + RoughnessTexs: [] + RoughnessTexChannelIndex: + EmissionTexs: [] + AlphaTexs: [] + AlphaTexChannelIndex: + MatCapMasks: [] + MatCapMaskChannelIndex: + MatCapTexs: [] + SecondaryAlbedoTexMasks: [] + SecondaryAlbedoTexMaskChannelIndex: + SecondaryAlbedoTexs: [] + ChildObjectTransforms: + - {fileID: 499686670} + center: {x: 0, y: 0, z: 0} + extent: {x: 0.5, y: 0.5, z: 0.5} +--- !u!114 &499686672 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 499686669} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c103227aee5e4584a96e35173641b818, type: 3} + m_Name: + m_EditorClassIdentifier: + MaterialOptions: 00000000 + TransmissionColor: + - {x: 1, y: 1, z: 1} + BaseColor: + - {x: 1, y: 1, z: 1} + MetallicRemap: + - {x: 0, y: 1} + RoughnessRemap: + - {x: 0, y: 1} + emission: + - 32 + EmissionColor: + - {x: 1, y: 1, z: 1} + Roughness: + - 0 + IOR: + - 1 + Metallic: + - 0 + SpecularTint: + - 0 + Sheen: + - 0 + SheenTint: + - 0 + ClearCoat: + - 0 + ClearCoatGloss: + - 0 + Anisotropic: + - 0 + Flatness: + - 0 + DiffTrans: + - 0 + SpecTrans: + - 0 + FollowMaterial: 00 + ScatterDist: + - 0.1 + Specular: + - 0 + AlphaCutoff: + - 0.1 + NormalStrength: + - 1 + Hue: + - 0 + Saturation: + - 1 + Brightness: + - 1 + Contrast: + - 1 + BlendColor: + - {x: 1, y: 1, z: 1} + BlendFactor: + - 0 + MainTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + SecondaryAlbedoTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + SecondaryTextureScale: + - {x: 1, y: 1} + Rotation: + - 0 + Flags: 00000000 + UseKelvin: 00 + KelvinTemp: + - 0 + ColorBleed: + - 1 + AlbedoBlendFactor: + - 1 + SharedMaterials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + Names: + - Default-Material + Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + Indexes: 00000000 + NeedsToUpdate: 0 + IsReady: 1 + MaterialIndex: 00000000 + LocalMaterialIndex: 00000000 + JustCreated: 0 + TilingChanged: 0 + MatOffset: 0 +--- !u!64 &499686673 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 499686669} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 4 + m_Convex: 0 + m_CookingOptions: 30 + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &499686674 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 499686669} + 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_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + 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 &499686675 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 499686669} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} --- !u!114 &500366719 MonoBehaviour: m_ObjectHideFlags: 0 @@ -10708,6 +11607,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -10807,6 +11712,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -10924,6 +11835,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -11043,6 +11960,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -11156,6 +12079,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -11255,6 +12184,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -11368,6 +12303,12 @@ MonoBehaviour: Names: - fabric_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -11603,6 +12544,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -11722,6 +12669,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -11859,6 +12812,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -11964,6 +12923,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -12137,6 +13102,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -12236,6 +13207,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -12335,6 +13312,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -12468,6 +13451,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -12770,6 +13759,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -12909,6 +13904,12 @@ MonoBehaviour: Names: - fabric_g Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13028,6 +14029,12 @@ MonoBehaviour: Names: - fabric_g Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13139,6 +14146,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13238,6 +14251,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13355,6 +14374,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13454,6 +14479,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13553,6 +14584,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13652,6 +14689,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13763,6 +14806,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -13920,6 +14969,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -14006,7 +15061,7 @@ MonoBehaviour: m_EditorClassIdentifier: MaterialOptions: 00000000 TransmissionColor: - - {x: 0, y: 0, z: 0} + - {x: 1, y: 1, z: 1} BaseColor: - {x: 1, y: 1, z: 1} MetallicRemap: @@ -14041,9 +15096,9 @@ MonoBehaviour: - 0 SpecTrans: - 0 - FollowMaterial: 00 + FollowMaterial: 01 ScatterDist: - - 0 + - 0.1 Specular: - 0 AlphaCutoff: @@ -14083,6 +15138,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -14219,6 +15280,15 @@ MonoBehaviour: - Material__57 - vase_round Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -14247,7 +15317,7 @@ MonoBehaviour: m_EditorClassIdentifier: MaterialOptions: 00000000 TransmissionColor: - - {x: 0, y: 0, z: 0} + - {x: 1, y: 1, z: 1} BaseColor: - {x: 1, y: 1, z: 1} MetallicRemap: @@ -14282,7 +15352,7 @@ MonoBehaviour: - 0 SpecTrans: - 0 - FollowMaterial: 01 + FollowMaterial: 00 ScatterDist: - 0 Specular: @@ -14324,6 +15394,12 @@ MonoBehaviour: Names: - fabric_f Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -14423,6 +15499,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -14522,6 +15604,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -14641,6 +15729,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -14792,6 +15886,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -14891,6 +15991,12 @@ MonoBehaviour: Names: - fabric_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15004,6 +16110,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15129,6 +16241,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15248,6 +16366,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15361,6 +16485,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15460,6 +16590,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15559,6 +16695,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15658,6 +16800,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15769,6 +16917,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15874,6 +17028,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -15991,6 +17151,12 @@ MonoBehaviour: Names: - details Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -16090,6 +17256,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -16189,6 +17361,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -16288,6 +17466,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -16387,6 +17571,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -16553,6 +17743,15 @@ MonoBehaviour: - Material__57 - vase_round Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -16664,6 +17863,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -16781,6 +17986,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -16904,6 +18115,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -17023,6 +18240,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -17186,6 +18409,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -17311,6 +18540,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -17442,6 +18677,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -17553,6 +18794,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -17670,6 +18917,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -17825,6 +19078,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -17924,6 +19183,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18023,6 +19288,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18136,6 +19407,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18241,6 +19518,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18346,6 +19629,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18451,6 +19740,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18562,6 +19857,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18681,6 +19982,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18792,6 +20099,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -18897,6 +20210,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -19002,6 +20321,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -19125,6 +20450,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -19298,6 +20629,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -19397,6 +20734,12 @@ MonoBehaviour: Names: - details Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -19552,6 +20895,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -19733,6 +21082,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -19832,119 +21187,131 @@ MonoBehaviour: Names: - column_b Selected: 0 - Indexes: 00000000 - NeedsToUpdate: 0 - IsReady: 1 - MaterialIndex: ac000000 - LocalMaterialIndex: ac000000 - JustCreated: 0 - TilingChanged: 0 - MatOffset: 0 ---- !u!64 &972095940 -MeshCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1770587834} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 4 - m_Convex: 0 - m_CookingOptions: 30 - m_Mesh: {fileID: -7515676704403345910, guid: 16500a523b718314091d7e9b83146c62, type: 3} ---- !u!114 &977992481 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1770587841} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c103227aee5e4584a96e35173641b818, type: 3} - m_Name: - m_EditorClassIdentifier: - MaterialOptions: 00000000 - TransmissionColor: - - {x: 0, y: 0, z: 0} - BaseColor: - - {x: 1, y: 1, z: 1} - MetallicRemap: - - {x: 0, y: 1} - RoughnessRemap: - - {x: 0, y: 1} - emission: - - 0 - EmissionColor: - - {x: 1, y: 1, z: 1} - Roughness: + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + Indexes: 00000000 + NeedsToUpdate: 0 + IsReady: 1 + MaterialIndex: ac000000 + LocalMaterialIndex: ac000000 + JustCreated: 0 + TilingChanged: 0 + MatOffset: 0 +--- !u!64 &972095940 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1770587834} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 4 + m_Convex: 0 + m_CookingOptions: 30 + m_Mesh: {fileID: -7515676704403345910, guid: 16500a523b718314091d7e9b83146c62, type: 3} +--- !u!114 &977992481 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1770587841} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c103227aee5e4584a96e35173641b818, type: 3} + m_Name: + m_EditorClassIdentifier: + MaterialOptions: 00000000 + TransmissionColor: + - {x: 0, y: 0, z: 0} + BaseColor: + - {x: 1, y: 1, z: 1} + MetallicRemap: + - {x: 0, y: 1} + RoughnessRemap: + - {x: 0, y: 1} + emission: + - 0 + EmissionColor: + - {x: 1, y: 1, z: 1} + Roughness: + - 0 + IOR: + - 1 + Metallic: + - 0 + SpecularTint: + - 0 + Sheen: + - 0 + SheenTint: + - 0 + ClearCoat: + - 0 + ClearCoatGloss: + - 0 + Anisotropic: + - 0 + Flatness: + - 0 + DiffTrans: + - 0 + SpecTrans: + - 0 + FollowMaterial: 01 + ScatterDist: + - 0 + Specular: + - 0 + AlphaCutoff: + - 0.1 + NormalStrength: + - 1 + Hue: + - 0 + Saturation: + - 1 + Brightness: + - 1 + Contrast: + - 1 + BlendColor: + - {x: 1, y: 1, z: 1} + BlendFactor: + - 0 + MainTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + SecondaryAlbedoTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + SecondaryTextureScale: + - {x: 1, y: 1} + Rotation: + - 0 + Flags: 00000000 + UseKelvin: 00 + KelvinTemp: + - 0 + ColorBleed: + - 1 + AlbedoBlendFactor: + - 1 + SharedMaterials: + - {fileID: 2100000, guid: 054fa7f9449ea444daa035a3ec41ff31, type: 2} + Names: + - column_b + Selected: 0 + SecondaryNormalTexBlend: - 0 - IOR: + DetailNormalStrength: - 1 - Metallic: - - 0 - SpecularTint: - - 0 - Sheen: - - 0 - SheenTint: - - 0 - ClearCoat: - - 0 - ClearCoatGloss: - - 0 - Anisotropic: - - 0 - Flatness: - - 0 - DiffTrans: - - 0 - SpecTrans: - - 0 - FollowMaterial: 01 - ScatterDist: - - 0 - Specular: - - 0 - AlphaCutoff: - - 0.1 - NormalStrength: - - 1 - Hue: - - 0 - Saturation: - - 1 - Brightness: - - 1 - Contrast: - - 1 - BlendColor: - - {x: 1, y: 1, z: 1} - BlendFactor: - - 0 - MainTexScaleOffset: - - {x: 1, y: 1, z: 0, w: 0} - SecondaryAlbedoTexScaleOffset: + SecondaryNormalTexScaleOffset: - {x: 1, y: 1, z: 0, w: 0} - SecondaryTextureScale: - - {x: 1, y: 1} - Rotation: - - 0 - Flags: 00000000 - UseKelvin: 00 - KelvinTemp: - - 0 - ColorBleed: - - 1 - AlbedoBlendFactor: - - 1 - SharedMaterials: - - {fileID: 2100000, guid: 054fa7f9449ea444daa035a3ec41ff31, type: 2} - Names: - - column_b - Selected: 0 Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20070,6 +21437,12 @@ MonoBehaviour: Names: - floor Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20175,6 +21548,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20274,6 +21653,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20373,6 +21758,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20492,6 +21883,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20609,6 +22006,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20708,6 +22111,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20833,6 +22242,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -20932,6 +22347,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -21031,6 +22452,12 @@ MonoBehaviour: Names: - fabric_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -21130,6 +22557,12 @@ MonoBehaviour: Names: - vase Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -21229,6 +22662,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -21328,6 +22767,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -21423,115 +22868,127 @@ MonoBehaviour: AlbedoBlendFactor: - 1 SharedMaterials: - - {fileID: 2100000, guid: 1618f87d14c63104faacf1d322cd4b6b, type: 2} + - {fileID: 2100000, guid: 1618f87d14c63104faacf1d322cd4b6b, type: 2} + Names: + - Material__47 + Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + Indexes: 00000000 + NeedsToUpdate: 0 + IsReady: 1 + MaterialIndex: 02010000 + LocalMaterialIndex: 02010000 + JustCreated: 0 + TilingChanged: 0 + MatOffset: 0 +--- !u!4 &1026072045 stripped +Transform: + m_CorrespondingSourceObject: {fileID: -2344462320102304567, guid: 16500a523b718314091d7e9b83146c62, + type: 3} + m_PrefabInstance: {fileID: 1770587712} + m_PrefabAsset: {fileID: 0} +--- !u!114 &1029385940 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1770587886} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c103227aee5e4584a96e35173641b818, type: 3} + m_Name: + m_EditorClassIdentifier: + MaterialOptions: 00000000 + TransmissionColor: + - {x: 0, y: 0, z: 0} + BaseColor: + - {x: 1, y: 1, z: 1} + MetallicRemap: + - {x: 0, y: 1} + RoughnessRemap: + - {x: 0, y: 1} + emission: + - 0 + EmissionColor: + - {x: 1, y: 1, z: 1} + Roughness: + - 0 + IOR: + - 1 + Metallic: + - 0 + SpecularTint: + - 0 + Sheen: + - 0 + SheenTint: + - 0 + ClearCoat: + - 0 + ClearCoatGloss: + - 0 + Anisotropic: + - 0 + Flatness: + - 0 + DiffTrans: + - 0 + SpecTrans: + - 0 + FollowMaterial: 01 + ScatterDist: + - 0 + Specular: + - 0 + AlphaCutoff: + - 0.1 + NormalStrength: + - 1 + Hue: + - 0 + Saturation: + - 1 + Brightness: + - 1 + Contrast: + - 1 + BlendColor: + - {x: 1, y: 1, z: 1} + BlendFactor: + - 0 + MainTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + SecondaryAlbedoTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + SecondaryTextureScale: + - {x: 1, y: 1} + Rotation: + - 0 + Flags: 00000000 + UseKelvin: 00 + KelvinTemp: + - 0 + ColorBleed: + - 1 + AlbedoBlendFactor: + - 1 + SharedMaterials: + - {fileID: 2100000, guid: 054fa7f9449ea444daa035a3ec41ff31, type: 2} Names: - - Material__47 + - column_b Selected: 0 - Indexes: 00000000 - NeedsToUpdate: 0 - IsReady: 1 - MaterialIndex: 02010000 - LocalMaterialIndex: 02010000 - JustCreated: 0 - TilingChanged: 0 - MatOffset: 0 ---- !u!4 &1026072045 stripped -Transform: - m_CorrespondingSourceObject: {fileID: -2344462320102304567, guid: 16500a523b718314091d7e9b83146c62, - type: 3} - m_PrefabInstance: {fileID: 1770587712} - m_PrefabAsset: {fileID: 0} ---- !u!114 &1029385940 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1770587886} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c103227aee5e4584a96e35173641b818, type: 3} - m_Name: - m_EditorClassIdentifier: - MaterialOptions: 00000000 - TransmissionColor: - - {x: 0, y: 0, z: 0} - BaseColor: - - {x: 1, y: 1, z: 1} - MetallicRemap: - - {x: 0, y: 1} - RoughnessRemap: - - {x: 0, y: 1} - emission: - - 0 - EmissionColor: - - {x: 1, y: 1, z: 1} - Roughness: + SecondaryNormalTexBlend: - 0 - IOR: + DetailNormalStrength: - 1 - Metallic: - - 0 - SpecularTint: - - 0 - Sheen: - - 0 - SheenTint: - - 0 - ClearCoat: - - 0 - ClearCoatGloss: - - 0 - Anisotropic: - - 0 - Flatness: - - 0 - DiffTrans: - - 0 - SpecTrans: - - 0 - FollowMaterial: 01 - ScatterDist: - - 0 - Specular: - - 0 - AlphaCutoff: - - 0.1 - NormalStrength: - - 1 - Hue: - - 0 - Saturation: - - 1 - Brightness: - - 1 - Contrast: - - 1 - BlendColor: - - {x: 1, y: 1, z: 1} - BlendFactor: - - 0 - MainTexScaleOffset: - - {x: 1, y: 1, z: 0, w: 0} - SecondaryAlbedoTexScaleOffset: + SecondaryNormalTexScaleOffset: - {x: 1, y: 1, z: 0, w: 0} - SecondaryTextureScale: - - {x: 1, y: 1} - Rotation: - - 0 - Flags: 00000000 - UseKelvin: 00 - KelvinTemp: - - 0 - ColorBleed: - - 1 - AlbedoBlendFactor: - - 1 - SharedMaterials: - - {fileID: 2100000, guid: 054fa7f9449ea444daa035a3ec41ff31, type: 2} - Names: - - column_b - Selected: 0 Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -21631,6 +23088,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -21736,6 +23199,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -21881,6 +23350,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22000,6 +23475,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22131,6 +23612,12 @@ MonoBehaviour: Names: - fabric_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22262,6 +23749,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22433,6 +23926,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22572,6 +24071,12 @@ MonoBehaviour: Names: - vase Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22677,6 +24182,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22776,6 +24287,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22875,6 +24392,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -22911,6 +24434,50 @@ MeshCollider: m_Convex: 0 m_CookingOptions: 30 m_Mesh: {fileID: -7753846047792628251, guid: 16500a523b718314091d7e9b83146c62, type: 3} +--- !u!1 &1116657444 +GameObject: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1116657446} + - component: {fileID: 1116657445} + m_Layer: 0 + m_Name: Prefab Indexer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1116657445 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1116657444} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 05a7c62fccbafd342991629222351294, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1116657446 +Transform: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1116657444} + 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_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1124678509 MonoBehaviour: m_ObjectHideFlags: 0 @@ -23002,6 +24569,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -23115,6 +24688,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -23240,6 +24819,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -23339,6 +24924,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -23438,6 +25029,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -23575,6 +25172,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -23692,6 +25295,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -23817,6 +25426,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -23922,6 +25537,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24021,6 +25642,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24154,6 +25781,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24271,6 +25904,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24370,6 +26009,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24493,6 +26138,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24592,6 +26243,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24691,6 +26348,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24790,6 +26453,12 @@ MonoBehaviour: Names: - fabric_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -24889,6 +26558,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -25031,6 +26706,15 @@ MonoBehaviour: - Material__25 - Material__298 Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -25142,6 +26826,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -25247,6 +26937,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -25364,6 +27060,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -25463,6 +27165,12 @@ MonoBehaviour: Names: - leaf Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -25612,6 +27320,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -25731,6 +27445,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -25842,6 +27562,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -25969,6 +27695,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -26074,6 +27806,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -26217,6 +27955,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -26316,6 +28060,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -26427,6 +28177,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -26532,6 +28288,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -26631,6 +28393,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -26816,6 +28584,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -26958,6 +28732,15 @@ MonoBehaviour: - bricks - details Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -27101,6 +28884,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -27234,6 +29023,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -27333,6 +29128,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -27470,6 +29271,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -27569,6 +29376,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -27688,6 +29501,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -27787,6 +29606,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -27948,6 +29773,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -28084,6 +29915,15 @@ MonoBehaviour: - Material__57 - vase_round Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -28183,6 +30023,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -28282,6 +30128,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -28401,6 +30253,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -28500,6 +30358,12 @@ MonoBehaviour: Names: - roof Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -28649,6 +30513,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -28748,6 +30618,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -28847,6 +30723,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -28946,6 +30828,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29071,6 +30959,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29170,6 +31064,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29293,6 +31193,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29406,6 +31312,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29511,6 +31423,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29610,6 +31528,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29715,6 +31639,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29826,6 +31756,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -29925,6 +31861,12 @@ MonoBehaviour: Names: - vase Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30054,6 +31996,12 @@ MonoBehaviour: Names: - column_a Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30153,6 +32101,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30252,6 +32206,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30351,6 +32311,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30462,6 +32428,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30599,6 +32571,12 @@ MonoBehaviour: Names: - details Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30704,6 +32682,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30803,6 +32787,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -30902,6 +32892,12 @@ MonoBehaviour: Names: - leaf Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -31013,6 +33009,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -31112,6 +33114,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -31179,6 +33187,7 @@ Transform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 1770587713} + - {fileID: 499686670} m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -31237,6 +33246,8 @@ MonoBehaviour: AlphaMapAtlas: {fileID: 0} AlbedoAtlasSize: 0 IESAtlasSize: 0 + LightBVHTransforms: [] + SGTree: [] MaterialsChanged: [] _Materials: [] MyMeshesCompacted: [] @@ -31249,8 +33260,7 @@ MonoBehaviour: RenderTransforms: [] RenderQue: [] BuildQue: - - {fileID: 0} - - {fileID: 0} + - {fileID: 499686671} - {fileID: 1770588100} AddQue: [] RemoveQue: [] @@ -31267,6 +33277,7 @@ MonoBehaviour: LightMeshes: [] MeshAABBs: [] LightAABBs: [] + SGTreeNodes: [] ParentCountHasChanged: 0 LightMeshCount: 0 UnityLightCount: 0 @@ -31282,7 +33293,6 @@ MonoBehaviour: BVH8Nodes: [] cwbvhindex_count: 0 cwbvhnode_count: 0 - LightBVHTransforms: [] --- !u!114 &1572504600 MonoBehaviour: m_ObjectHideFlags: 0 @@ -31374,6 +33384,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -31479,6 +33495,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -31610,6 +33632,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -31753,6 +33781,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -31876,6 +33910,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -31975,6 +34015,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -32086,6 +34132,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -32229,6 +34281,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -32340,6 +34398,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -32439,6 +34503,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -32637,6 +34707,15 @@ MonoBehaviour: - Material__57 - vase_round Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -32736,6 +34815,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -32835,6 +34920,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -32954,6 +35045,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33053,6 +35150,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33172,6 +35275,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33271,6 +35380,12 @@ MonoBehaviour: Names: - leaf Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33396,6 +35511,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33513,6 +35634,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33618,6 +35745,12 @@ MonoBehaviour: Names: - leaf Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33737,6 +35870,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33892,6 +36031,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -33997,6 +36142,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -34096,6 +36247,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -34221,6 +36378,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -34358,6 +36521,12 @@ MonoBehaviour: Names: - fabric_g Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -34457,6 +36626,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -34570,6 +36745,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -34675,6 +36856,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -34788,6 +36975,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -34915,6 +37108,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35038,6 +37237,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35143,6 +37348,12 @@ MonoBehaviour: Names: - vase Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35276,6 +37487,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35375,6 +37592,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35480,6 +37703,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35579,6 +37808,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35698,6 +37933,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35797,6 +38038,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35896,6 +38143,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -35995,6 +38248,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -36108,6 +38367,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -36210,6 +38475,11 @@ PrefabInstance: propertyPath: m_ConstrainProportionsScale value: 1 objectReference: {fileID: 0} + - target: {fileID: -6641346280001039212, guid: 16500a523b718314091d7e9b83146c62, + type: 3} + propertyPath: m_Materials.Array.data[0] + value: + objectReference: {fileID: 2100000, guid: a1cdd2176aab1fc4bafb51e0afb03b48, type: 2} - target: {fileID: 919132149155446097, guid: 16500a523b718314091d7e9b83146c62, type: 3} propertyPath: m_Name @@ -38611,6 +40881,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -38710,6 +40986,12 @@ MonoBehaviour: Names: - Material__298 Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -38846,6 +41128,15 @@ MonoBehaviour: - Material__57 - vase_round Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -38945,6 +41236,12 @@ MonoBehaviour: Names: - leaf Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -38979,7 +41276,7 @@ MonoBehaviour: Pad1: 0 left: 2 isLeaf: 0 - nodes: [] + SGTree: [] PrimCount: 2952 FinalIndices: MaxDepth: 17 @@ -39374,7 +41671,6 @@ MonoBehaviour: AggTriangles: [] ParentScale: {x: 0.10000001, y: 0.10000001, z: 0.10000001} LightTriangles: [] - LightTriNorms: [] BVH: cwbvh_indices: BVH8Nodes: [] @@ -39765,7 +42061,6 @@ MonoBehaviour: - {fileID: 1730356156} IndexCounts: 380e0000770a0000520500000800000064000000180100001c090000b6000000b6000000b6000000b6000000b6000000b6000000b6000000b6000000500b0000100000001c09000024020000240200008c010000060100000601000006010000060100008c0100008c010000060100000601000006010000060100008c010000cc000000cc00000094000000a000000070000000a000000070000000a000000070000000a000000070000000a000000070000000a000000070000000a000000070000000a000000070000000a000000070000000280000002800000028000000280000002800000028000000280000002800000028000000280000002800000020000000180100001200000024000000a00000006a0000006a0000001601000016010000320000004a0000004a000000580000005800000058000000580000005800000058000000580000005800000058000000580000005800000058000000580000005800000058000000580000004a0000004a0000004a0000004a000000580000005800000058000000580000005800000058000000580000005800000058000000580000005800000058000000580000005800000058000000580000004a0000004a000000320000000500000054010000540100005401000054010000100000004407000044070000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a6000000c4040000120000002c000000120000002c000000120000002c000000120000002c0000002c010000a60000001200000040000000e2000000c8010000c8010000e2000000c8010000e2000000c8010000e2000000e2000000c8010000c8010000e2000000c8010000e2000000c8010000e20000002a170000d61200009c080000da0e0000ec0c000046110000ec0c00008015000080150000801500008015000080150000801500008015000080150000c8010000c0000000c8010000c8010000c0000000c8010000c8010000c0000000c8010000c8010000c0000000c8010000c8010000c0000000c8010000c8010000c0000000c8010000c8010000c0000000c8010000c8010000c0000000c8010000c8010000c0000000c8010000c8010000c0000000c80100000013000000120000001300000013000000120000001300000012000000130000001200000013000002000000020000000200000002000000690600002e020000dc040000dc0400000e01000002000000020000000200000002000000690600002e020000dc040000dc0400000e01000002000000020000000200000002000000690600002e020000dc040000dc0400000e01000002000000020000000200000002000000690600002e020000dc040000dc0400000e010000770a0000770a0000770a0000330a0000330a0000330a0000330a0000f8080000f8080000f8080000f8080000430b0000430b00001c000000f0010000a43600000a000000 MeshRefit: {fileID: 7200000, guid: 8375b50c4fc272d41ab1b7c55b853562, type: 3} - LightMeshRefit: {fileID: 7200000, guid: 80f1eb03ffee8414f9d999cc16c0a367, type: 3} HasStarted: 0 AggNodes: [] InstanceMeshIndex: 0 @@ -46658,13 +48953,6 @@ MonoBehaviour: e32: 0 e33: 1 Position: {x: 0, y: 0, z: 0} - CurMeshData: - Indices: - Verticies: [] - Normals: [] - Tangents: [] - UVs: [] - MatDat: TotalObjects: 381 TransformIndexes: [] HasCompleted: 0 @@ -46676,6 +48964,7 @@ MonoBehaviour: NodeUpdateKernel: 4 NodeCompressKernel: 5 NodeInitializerKernel: 6 + LightBLASRefitKernel: 9 CompactedMeshData: 0 InstanceReferences: 0 NeedsToUpdate: 1 @@ -46686,7 +48975,6 @@ MonoBehaviour: ForwardStack: [] LayerStack: [] NodePair: [] - LuminanceWeights: [] MaxRecur: 0 ToBVHIndex: tempAABB: @@ -2153169,15 +2155457,16 @@ MonoBehaviour: - {fileID: 2800000, guid: 6e15f02feebc6ba44bae8089381dd33e, type: 3} - {fileID: 2800000, guid: 7b87e3c0b539e4e409a7fda079a40320, type: 3} - {fileID: 2800000, guid: 31be800b72cfa1a40bfe519f1ab8a4e6, type: 3} - - {fileID: 2800000, guid: 2fd9297c087b1334195e475b89ed03cf, type: 3} - - {fileID: 2800000, guid: 485233ca597afda4fb7d18c571b6a801, type: 3} - {fileID: 2800000, guid: b73406b81b6cd484181dedc3f25e648f, type: 3} + - {fileID: 2800000, guid: 485233ca597afda4fb7d18c571b6a801, type: 3} + - {fileID: 2800000, guid: 2fd9297c087b1334195e475b89ed03cf, type: 3} - {fileID: 2800000, guid: 0f9d9bc0a5e565c45b3ec4eeb84952a6, type: 3} - {fileID: 2800000, guid: 29609964099711e45a99687857e420f5, type: 3} - {fileID: 2800000, guid: 59064697770591343a2192c9fcacab77, type: 3} - {fileID: 2800000, guid: 5ef3f472501aa1e409f199a63466c879, type: 3} - {fileID: 2800000, guid: dc60a0e0699fc544191f745f231e00e7, type: 3} NormalTexs: [] + SecondaryNormalTexs: [] MetallicTexs: [] MetallicTexChannelIndex: RoughnessTexs: [] @@ -2153200,9 +2155489,9 @@ MonoBehaviour: - {fileID: 2800000, guid: 6e15f02feebc6ba44bae8089381dd33e, type: 3} - {fileID: 2800000, guid: 7b87e3c0b539e4e409a7fda079a40320, type: 3} - {fileID: 2800000, guid: 31be800b72cfa1a40bfe519f1ab8a4e6, type: 3} - - {fileID: 2800000, guid: 2fd9297c087b1334195e475b89ed03cf, type: 3} - - {fileID: 2800000, guid: 485233ca597afda4fb7d18c571b6a801, type: 3} - {fileID: 2800000, guid: b73406b81b6cd484181dedc3f25e648f, type: 3} + - {fileID: 2800000, guid: 485233ca597afda4fb7d18c571b6a801, type: 3} + - {fileID: 2800000, guid: 2fd9297c087b1334195e475b89ed03cf, type: 3} - {fileID: 2800000, guid: 0f9d9bc0a5e565c45b3ec4eeb84952a6, type: 3} - {fileID: 2800000, guid: 29609964099711e45a99687857e420f5, type: 3} - {fileID: 2800000, guid: 59064697770591343a2192c9fcacab77, type: 3} @@ -2153763,6 +2156052,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2153914,6 +2156209,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2154039,6 +2156340,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2154190,6 +2156497,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2154335,6 +2156648,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2154508,6 +2156827,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2154633,6 +2156958,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2154798,6 +2157129,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2154989,6 +2157326,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2155114,6 +2157457,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2155319,6 +2157668,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2155510,6 +2157865,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2155767,6 +2158128,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2155970,6 +2158337,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2156095,6 +2158468,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2156246,6 +2158625,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2156385,6 +2158770,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2156544,6 +2158935,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2156669,6 +2159066,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2156932,6 +2159335,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2157077,6 +2159486,12 @@ MonoBehaviour: Names: - leaf Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2157202,6 +2159617,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2157327,6 +2159748,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2157452,6 +2159879,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2157591,6 +2160024,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2157742,6 +2160181,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2157887,6 +2160332,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2158118,6 +2160569,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2158243,6 +2160700,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2158382,6 +2160845,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2158673,6 +2161142,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2158798,6 +2161273,12 @@ MonoBehaviour: Names: - fabric_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2159009,6 +2161490,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2159180,6 +2161667,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2159305,6 +2161798,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2159464,6 +2161963,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2159635,6 +2162140,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2159774,6 +2162285,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2160245,6 +2162762,12 @@ MonoBehaviour: Names: - bricks Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2160370,6 +2162893,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2160495,6 +2163024,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2160634,6 +2163169,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2160779,6 +2163320,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2160938,6 +2163485,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2161063,6 +2163616,12 @@ MonoBehaviour: Names: - arch Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2161188,6 +2163747,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2161313,6 +2163878,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2161484,6 +2164055,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2161643,6 +2164220,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2161768,6 +2164351,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2161945,6 +2164534,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2162130,6 +2164725,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2162255,6 +2164856,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2162538,6 +2165145,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2162663,6 +2165276,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2162802,6 +2165421,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2162964,6 +2165589,15 @@ MonoBehaviour: - Material__57 - vase_round Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -2163082,7 +2165716,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2057202810} m_LocalRotation: {x: -0.09387351, y: 0.81802064, z: -0.13980192, w: -0.5499868} - m_LocalPosition: {x: 5.173573, y: 3.006142, z: 1.08526} + m_LocalPosition: {x: 7.13, y: 1.15, z: 1.08526} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -2163275,6 +2165909,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2163400,6 +2166040,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2163525,6 +2166171,12 @@ MonoBehaviour: Names: - column_c Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2163684,6 +2166336,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2163809,6 +2166467,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2163934,6 +2166598,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2164059,6 +2166729,12 @@ MonoBehaviour: Names: - column_b Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2164247,6 +2166923,15 @@ MonoBehaviour: - Material__57 - vase_round Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 @@ -2164486,6 +2167171,12 @@ MonoBehaviour: Names: - flagpole Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2164683,6 +2167374,12 @@ MonoBehaviour: Names: - chain Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2164908,6 +2167605,12 @@ MonoBehaviour: Names: - fabric_d Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2165067,6 +2167770,12 @@ MonoBehaviour: Names: - vase_hanging Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2165244,6 +2167953,12 @@ MonoBehaviour: Names: - ceiling Selected: 0 + SecondaryNormalTexBlend: + - 0 + DetailNormalStrength: + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} Indexes: 00000000 NeedsToUpdate: 0 IsReady: 1 @@ -2165406,6 +2168121,15 @@ MonoBehaviour: - bricks - details Selected: 0 + SecondaryNormalTexBlend: + - 0 + - 0 + DetailNormalStrength: + - 1 + - 1 + SecondaryNormalTexScaleOffset: + - {x: 1, y: 1, z: 0, w: 0} + - {x: 1, y: 1, z: 0, w: 0} Indexes: 0000000001000000 NeedsToUpdate: 0 IsReady: 1 diff --git a/TrueTrace/Editor/PathTracerSettings.cs b/TrueTrace/Editor/PathTracerSettings.cs index ff8a9452..07d6a631 100644 --- a/TrueTrace/Editor/PathTracerSettings.cs +++ b/TrueTrace/Editor/PathTracerSettings.cs @@ -69,7 +69,7 @@ public static void ShowWindow() { [SerializeField] public bool FXAA = false; [SerializeField] public bool ToneMap = false; [SerializeField] public int ToneMapIndex = 0; - [SerializeField] public bool TAAU = true; + [SerializeField] public int UpscalerMethod = 0; [SerializeField] public int AtmoScatter = 4; [SerializeField] public bool ShowFPS = true; [SerializeField] public float Exposure = 0; @@ -80,10 +80,13 @@ public static void ShowWindow() { [SerializeField] public bool ImprovedPrimaryHit = false; [SerializeField] public float ReSTIRGISpatialRadius = 50; [SerializeField] public int RISCount = 5; - [SerializeField] public int DenoiserSelection = 0; + [SerializeField] public int DenoiserMethod = 0; [SerializeField] public Color SceneBackgroundColor = new Color(1,1,1,1); + [SerializeField] public Color PrimaryBackgroundTintColor = new Color(1,1,1,1); [SerializeField] public Color SecondarySceneBackgroundColor = new Color(1,1,1,1); [SerializeField] public Vector2 BackgroundIntensity = Vector2.one; + [SerializeField] public float PrimaryBackgroundTint = 0.0f; + [SerializeField] public float PrimaryBackgroundContrast = 1.0f; [SerializeField] public float LightEnergyScale = 1; [SerializeField] public float LEMEnergyScale = 1; [SerializeField] public float IndirectBoost = 1; @@ -98,7 +101,6 @@ public static void ShowWindow() { [SerializeField] public float FireflyStrength = 1.0f; [SerializeField] public float FireflyOffset = 0; [SerializeField] public int OIDNFrameCount = 0; - [SerializeField] public bool UseOIDN = false; [SerializeField] public bool DoSharpen = false; [SerializeField] public float Sharpness = 1.0f; [SerializeField] public Vector2 HDRILongLat = Vector2.zero; @@ -114,6 +116,32 @@ public static void ShowWindow() { [SerializeField] public float ConvBloomDistExpClampMin = 1; [SerializeField] public float ConvBloomDistExpScale = 1; + public bool GetGlobalDefine(string DefineToGet) { + string globalDefinesPath = TTPathFinder.GetGlobalDefinesPath(); + + if(File.Exists(globalDefinesPath)) { + string[] GlobalDefines = System.IO.File.ReadAllLines(globalDefinesPath); + int Index = -1; + for(int i = 0; i < GlobalDefines.Length; i++) { + if(GlobalDefines[i].Equals("//END OF DEFINES")) break; + string TempString = GlobalDefines[i].Replace("#define ", ""); + TempString = TempString.Replace("// ", ""); + if(TempString.Equals(DefineToGet)) { + Index = i; + break; + } + } + if(Index == -1) { + Debug.Log("Cant find define \"" + DefineToGet + "\""); + return false; + } + bool CachedValue = true; + if(GlobalDefines[Index].Contains("// ")) CachedValue = false; + return CachedValue; + } else {Debug.Log("No GlobalDefinesFile");} + return false; + } + public void SetGlobalDefines(string DefineToSet, bool SetValue) { string globalDefinesPath = TTPathFinder.GetGlobalDefinesPath(); @@ -494,14 +522,16 @@ private void SolveChildren(ParentData Parent) { private void QuickStart() { - // RayTracingObject[] TempObjects = GameObject.FindObjectsOfType(); - // foreach(var a in TempObjects) { - // DestroyImmediate(a); - // } // ParentObject[] TempObjects2 = GameObject.FindObjectsOfType(); // foreach(var a in TempObjects2) { // DestroyImmediate(a); // } + // RayTracingObject[] TempObjects = GameObject.FindObjectsOfType(); + // foreach(var a in TempObjects) { + // // a.gameObject.AddComponent(); + // // DestroyImmediate(a); + // // if(a.gameObject.name.Contains("LOD") && !a.gameObject.name.Contains("LOD0")) DestroyImmediate(a); + // } var LightObjects = GameObject.FindObjectsOfType(true); foreach(var LightObj in LightObjects) { @@ -583,7 +613,6 @@ public void OnFocus() { Toggle SkinToggle; Toggle BloomToggle; [Delayed] FloatField ResField; -Toggle TAAUToggle; IntegerField AtmoScatterField; Toggle GIToggle; IntegerField GIUpdateRateField; @@ -600,7 +629,7 @@ public void OnFocus() { IntegerField RISCountField; IntegerField OIDNFrameField; FloatField FocalSlider; - +PopupField UpscalerField; private void StandardSet() { BounceCount = 7; @@ -628,7 +657,6 @@ private void StandardSet() { TAA = false; FXAA = false; ToneMap = false; - TAAU = true; AtmoScatter = 4; ShowFPS = true; Exposure = 0; @@ -728,9 +756,27 @@ void AddNormalSettings() { BackgroundIntensityField = new FloatField() {value = BackgroundIntensity.x, label = "Primary Background Intensity"}; BackgroundIntensityField.RegisterValueChangedCallback(evt => {BackgroundIntensity = new Vector2(evt.newValue, BackgroundIntensity.y); RayMaster.LocalTTSettings.BackgroundIntensity = BackgroundIntensity;}); BackgroundIntensityField.style.maxWidth = 345; + + Slider PrimaryBackgroundContrastSlider = new Slider() {label = "Background Contrast: ", value = PrimaryBackgroundContrast, highValue = 2.0f, lowValue = 0.0f}; + PrimaryBackgroundContrastSlider.RegisterValueChangedCallback(evt => {PrimaryBackgroundContrast = evt.newValue; RayMaster.LocalTTSettings.PrimaryBackgroundContrast = PrimaryBackgroundContrast;}); + PrimaryBackgroundContrastSlider.style.maxWidth = 345; + PrimaryBackgroundContrastSlider.showInputField = true; + + ColorField PrimaryBackgroundTintColorField = new ColorField() {label = "Tint Color"}; + PrimaryBackgroundTintColorField.value = PrimaryBackgroundTintColor; + PrimaryBackgroundTintColorField.style.width = 250; + PrimaryBackgroundTintColorField.RegisterValueChangedCallback(evt => {PrimaryBackgroundTintColor = evt.newValue; RayMaster.LocalTTSettings.PrimaryBackgroundTintColor = new Vector3(PrimaryBackgroundTintColor.r,PrimaryBackgroundTintColor.g,PrimaryBackgroundTintColor.b);}); + + Slider PrimaryBackgroundTintSlider = new Slider() {label = "Tint Strength: ", value = PrimaryBackgroundTint, highValue = 1.0f, lowValue = 0.0f}; + PrimaryBackgroundTintSlider.RegisterValueChangedCallback(evt => {PrimaryBackgroundTint = evt.newValue; RayMaster.LocalTTSettings.PrimaryBackgroundTint = PrimaryBackgroundTint;}); + PrimaryBackgroundTintSlider.style.maxWidth = 345; + PrimaryBackgroundFoldout.Add(BackgroundSettingsField); PrimaryBackgroundFoldout.Add(BackgroundIntensityField); PrimaryBackgroundFoldout.Add(SkyDesatSlider); + PrimaryBackgroundFoldout.Add(PrimaryBackgroundContrastSlider); + PrimaryBackgroundFoldout.Add(PrimaryBackgroundTintColorField); + PrimaryBackgroundFoldout.Add(PrimaryBackgroundTintSlider); } @@ -887,7 +933,8 @@ private enum Properties {AlbedoColor, MatCapTexture, MatCapMask, SecondaryAlbedoTexture, - SecondaryAlbedoTextureMask + SecondaryAlbedoTextureMask, + SecondaryNormalTexture }; VisualElement MaterialPairingMenu; @@ -1008,6 +1055,13 @@ void ConfirmMats() { TextureName = TextureProperties[VerboseTextureProperties.IndexOf(AvailableIndexes[i].title)] }); break; + case((int)Properties.SecondaryNormalTexture): + MatShader.AvailableTextures.Add(new TexturePairs() { + Purpose = (int)TexturePurpose.SecondaryNormalTexture, + ReadIndex = -3, + TextureName = TextureProperties[VerboseTextureProperties.IndexOf(AvailableIndexes[i].title)] + }); + break; } } @@ -1108,7 +1162,7 @@ void AddAssetsToMenu() { VerboseFloatProperties.Add("null"); VerboseTextureProperties.Add("null"); for(int i = 0; i < PropCount; i++) { - if(shader.GetPropertyType(i) == ShaderPropertyType.Texture) {TextureProperties.Add(shader.GetPropertyName(i)); VerboseTextureProperties.Add(shader.GetPropertyDescription(i));} + if(shader.GetPropertyType(i) == ShaderPropertyType.Texture) {TextureProperties.Add(shader.GetPropertyName(i)); VerboseTextureProperties.Add(shader.GetPropertyName(i));} if(shader.GetPropertyType(i) == ShaderPropertyType.Color) {ColorProperties.Add(shader.GetPropertyName(i)); VerboseColorProperties.Add(shader.GetPropertyDescription(i));} if(shader.GetPropertyType(i) == ShaderPropertyType.Float || shader.GetPropertyType(i) == ShaderPropertyType.Range) {FloatProperties.Add(shader.GetPropertyName(i)); VerboseFloatProperties.Add(shader.GetPropertyDescription(i));} } @@ -1180,6 +1234,7 @@ void AddAssetsToMenu() { OutputNode.inputContainer.Add(_graphView.GeneratePort(OutputNode, Direction.Input, typeof(Texture), Port.Capacity.Single, "MatCap Mask(Single Component)")); OutputNode.inputContainer.Add(_graphView.GeneratePort(OutputNode, Direction.Input, typeof(Texture), Port.Capacity.Single, "Secondary Base Texture")); OutputNode.inputContainer.Add(_graphView.GeneratePort(OutputNode, Direction.Input, typeof(Texture), Port.Capacity.Single, "Secondary Base Texture Mask(Single Component)")); + OutputNode.inputContainer.Add(_graphView.GeneratePort(OutputNode, Direction.Input, typeof(Texture), Port.Capacity.Single, "Detail Normal Texture")); _graphView.AddElement(OutputNode); Vector2 Pos = new Vector2(30, 10); @@ -1191,6 +1246,12 @@ void AddAssetsToMenu() { DialogueNode ThisNode = new DialogueNode(); Edge ThisEdge = new Edge(); switch((int)MatShader.AvailableTextures[i].Purpose) { + case((int)TexturePurpose.SecondaryNormalTexture): + Pos.y = 1380; + Debug.Log(MatShader.AvailableTextures[i].TextureName); + ThisNode = CreateInputNode("Texture", typeof(Texture), Pos, MatShader.AvailableTextures[i].TextureName); + ThisEdge = (ThisNode.outputContainer[0] as Port).ConnectTo(OutputNode.inputContainer[(int)Properties.SecondaryNormalTexture] as Port); + break; case((int)TexturePurpose.SecondaryAlbedoTextureMask): Pos.y = 1300; ThisNode = CreateInputNode("Texture", typeof(Texture), Pos, MatShader.AvailableTextures[i].TextureName, MatShader.AvailableTextures[i].ReadIndex); @@ -1410,9 +1471,22 @@ void FixRayObjects() { Toggle BindlessToggle; Toggle HardwareRTToggle; + Toggle GaussianTreeToggle; Toggle OIDNToggle; Toggle MaterialHelperToggle; Toggle DX11Toggle; + + + private Toggle CustomToggle(string Label, string TargetDefine) { + // VisualElement CustTogContainer = CreateHorizontalBox("Custom Horizontal Toggle"); + Toggle CustToggle = new Toggle() {value = GetGlobalDefine(TargetDefine), text = Label}; + CustToggle.RegisterValueChangedCallback(evt => {SetGlobalDefines(TargetDefine, evt.newValue);}); + return CustToggle; + } + + + + void ActiveDX11Overrides() { BindlessToggle.value = true; HardwareRTToggle.value = false; @@ -1427,78 +1501,132 @@ void ActiveDX11Overrides() { } void AddHardSettingsToMenu() { - definesList = GetDefines(); - SetGlobalDefines("HardwareRT", definesList.Contains("HardwareRT")); - SetGlobalDefines("UseBindless", !(definesList.Contains("UseAtlas"))); - if(definesList.Contains("DisableRadianceCache")) SetGlobalDefines("RadianceCache", false); - SetGlobalDefines("DX11", definesList.Contains("DX11Only")); - HardwareRTToggle = new Toggle() {value = (definesList.Contains("HardwareRT")), text = "Enable RT Cores (Requires Unity 2023+)"}; - HardwareRTToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) {AddDefine("HardwareRT"); SetGlobalDefines("HardwareRT", true);} else {RemoveDefine("HardwareRT"); SetGlobalDefines("HardwareRT", false);}}); + Button RemoveTrueTraceButton = new Button(() => RemoveTrueTrace()) {text = "Remove TrueTrace Scripts From Scene"}; + + Label NonPlayLabel = new Label("-- THESE CANT BE MODIFIED ON THE FLY/DURING PLAY --"); + + VisualElement NonPlayContainer = new VisualElement(); + NonPlayContainer.style.paddingLeft = 10; + definesList = GetDefines(); + SetGlobalDefines("HardwareRT", definesList.Contains("HardwareRT")); + SetGlobalDefines("UseSGTree", !(definesList.Contains("DontUseSGTree"))); + SetGlobalDefines("UseBindless", !(definesList.Contains("UseAtlas"))); + if(definesList.Contains("DisableRadianceCache")) SetGlobalDefines("RadianceCache", false); + SetGlobalDefines("DX11", definesList.Contains("DX11Only")); + HardwareRTToggle = new Toggle() {value = (definesList.Contains("HardwareRT")), text = "Enable RT Cores (Requires Unity 2023+)"}; + HardwareRTToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) {AddDefine("HardwareRT"); SetGlobalDefines("HardwareRT", true);} else {RemoveDefine("HardwareRT"); SetGlobalDefines("HardwareRT", false);}}); - BindlessToggle = new Toggle() {value = (definesList.Contains("UseAtlas")), text = "Disable Bindless Textures"}; - BindlessToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) {AddDefine("UseAtlas"); SetGlobalDefines("UseBindless", false);} else {RemoveDefine("UseAtlas"); SetGlobalDefines("UseBindless", true);}}); + GaussianTreeToggle = new Toggle() {value = (definesList.Contains("DontUseSGTree")), text = "Use Old Light BVH instead of Gaussian Tree"}; + GaussianTreeToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) {AddDefine("DontUseSGTree"); SetGlobalDefines("UseSGTree", false);} else {RemoveDefine("DontUseSGTree"); SetGlobalDefines("UseSGTree", true);}}); - Toggle NonAccurateLightTriToggle = new Toggle() {value = (definesList.Contains("AccurateLightTris")), text = "Enable Emissive Texture Aware Light BVH"}; - NonAccurateLightTriToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) AddDefine("AccurateLightTris"); else RemoveDefine("AccurateLightTris");}); - VisualElement ClayColorBox = new VisualElement(); - Toggle ClayModeToggle = new Toggle() {value = ClayMode, text = "Use ClayMode"}; - ClayModeToggle.RegisterValueChangedCallback(evt => {ClayMode = evt.newValue; RayMaster.LocalTTSettings.ClayMode = ClayMode; if(evt.newValue) HardSettingsMenu.Insert(HardSettingsMenu.IndexOf(ClayModeToggle) + 1, ClayColorBox); else HardSettingsMenu.Remove(ClayColorBox);}); + BindlessToggle = new Toggle() {value = (definesList.Contains("UseAtlas")), text = "Disable Bindless Textures"}; + BindlessToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) {AddDefine("UseAtlas"); SetGlobalDefines("UseBindless", false);} else {RemoveDefine("UseAtlas"); SetGlobalDefines("UseBindless", true);}}); - Slider OIDNBlendRatioSlider = new Slider() {label = "OIDN Blend Ratio: ", value = OIDNBlendRatio, highValue = 1.0f, lowValue = 0.0f}; - OIDNBlendRatioSlider.showInputField = true; - OIDNBlendRatioSlider.style.width = 300; - OIDNBlendRatioSlider.ElementAt(0).style.minWidth = 65; - OIDNBlendRatioSlider.RegisterValueChangedCallback(evt => {OIDNBlendRatio = evt.newValue; RayMaster.LocalTTSettings.OIDNBlendRatio = OIDNBlendRatio;}); + Toggle NonAccurateLightTriToggle = new Toggle() {value = (definesList.Contains("AccurateLightTris")), text = "Enable Emissive Texture Aware Light BVH"}; + NonAccurateLightTriToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) AddDefine("AccurateLightTris"); else RemoveDefine("AccurateLightTris");}); + VisualElement ClayColorBox = new VisualElement(); - ColorField ClayColorField = new ColorField(); - ClayColorField.label = "Clay Color: "; - ClayColorField.value = new Color(ClayColor.x, ClayColor.y, ClayColor.z, 1.0f); - ClayColorField.style.width = 250; - ClayColorField.RegisterValueChangedCallback(evt => {ClayColor = new Vector3(evt.newValue.r, evt.newValue.g, evt.newValue.b); RayMaster.LocalTTSettings.ClayColor = ClayColor;}); - ClayColorBox.Add(ClayColorField); + Toggle ClayModeToggle = new Toggle() {value = ClayMode, text = "Use ClayMode"}; + ClayModeToggle.RegisterValueChangedCallback(evt => {ClayMode = evt.newValue; RayMaster.LocalTTSettings.ClayMode = ClayMode; if(evt.newValue) HardSettingsMenu.Insert(HardSettingsMenu.IndexOf(ClayModeToggle) + 1, ClayColorBox); else HardSettingsMenu.Remove(ClayColorBox);}); + ColorField ClayColorField = new ColorField(); + ClayColorField.label = "Clay Color: "; + ClayColorField.value = new Color(ClayColor.x, ClayColor.y, ClayColor.z, 1.0f); + ClayColorField.style.width = 250; + ClayColorField.RegisterValueChangedCallback(evt => {ClayColor = new Vector3(evt.newValue.r, evt.newValue.g, evt.newValue.b); RayMaster.LocalTTSettings.ClayColor = ClayColor;}); + ClayColorBox.Add(ClayColorField); - OIDNToggle = new Toggle() {value = (definesList.Contains("UseOIDN")), text = "Enable OIDN(Does NOT work with DX11 Only)"}; - OIDNToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) AddDefine("UseOIDN"); else RemoveDefine("UseOIDN");}); + OIDNToggle = new Toggle() {value = (definesList.Contains("UseOIDN")), text = "Enable OIDN(Does NOT work with DX11 Only)"}; + OIDNToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) AddDefine("UseOIDN"); else RemoveDefine("UseOIDN");}); - Toggle RadCacheToggle = new Toggle() {value = (definesList.Contains("DisableRadianceCache")), text = "Disable Radiance Cache"}; - RadCacheToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) {SetGlobalDefines("RadianceCache", false); AddDefine("DisableRadianceCache");} else {SetGlobalDefines("RadianceCache", true); RemoveDefine("DisableRadianceCache");}}); + Toggle RadCacheToggle = new Toggle() {value = (definesList.Contains("DisableRadianceCache")), text = "FULLY Disable Radiance Cache"}; + RadCacheToggle.RegisterValueChangedCallback(evt => {if(evt.newValue) {SetGlobalDefines("RadianceCache", false); AddDefine("DisableRadianceCache");} else {SetGlobalDefines("RadianceCache", true); RemoveDefine("DisableRadianceCache");}}); - if(SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || definesList.Contains("DX11Only")) { - if(!definesList.Contains("DX11Only")) { - ActiveDX11Overrides(); + + if(Application.isPlaying) { + HardwareRTToggle.SetEnabled(false); + BindlessToggle.SetEnabled(false); + GaussianTreeToggle.SetEnabled(false); + OIDNToggle.SetEnabled(false); + RadCacheToggle.SetEnabled(false); + NonAccurateLightTriToggle.SetEnabled(false); + } else { + HardwareRTToggle.SetEnabled(true); + BindlessToggle.SetEnabled(true); + GaussianTreeToggle.SetEnabled(true); + OIDNToggle.SetEnabled(true); + RadCacheToggle.SetEnabled(true); + NonAccurateLightTriToggle.SetEnabled(true); } - BindlessToggle.SetEnabled(false); - HardwareRTToggle.SetEnabled(false); - OIDNToggle.SetEnabled(false); - } - DX11Toggle = new Toggle() {value = (definesList.Contains("DX11Only")), text = "Use DX11"}; - DX11Toggle.RegisterValueChangedCallback(evt => { - if(evt.newValue) { - ActiveDX11Overrides(); + + if(SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || definesList.Contains("DX11Only")) { + if(!definesList.Contains("DX11Only")) { + ActiveDX11Overrides(); + } BindlessToggle.SetEnabled(false); HardwareRTToggle.SetEnabled(false); OIDNToggle.SetEnabled(false); + } + + DX11Toggle = new Toggle() {value = (definesList.Contains("DX11Only")), text = "Use DX11"}; + + if(Application.isPlaying) { + DX11Toggle.SetEnabled(false); } else { - if(SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11) { - Debug.LogError("DX12 Not Found, Forcing DX11"); - DX11Toggle.value = true; - } else { - OIDNToggle.SetEnabled(true); - HardwareRTToggle.SetEnabled(true); - BindlessToggle.SetEnabled(true); - RemoveDefine("DX11Only"); - SetGlobalDefines("DX11", false); - } + DX11Toggle.SetEnabled(true); } - }); + + DX11Toggle.RegisterValueChangedCallback(evt => { + if(evt.newValue) { + ActiveDX11Overrides(); + BindlessToggle.SetEnabled(false); + HardwareRTToggle.SetEnabled(false); + OIDNToggle.SetEnabled(false); + } else { + if(SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11) { + Debug.LogError("DX12 Not Found, Forcing DX11"); + DX11Toggle.value = true; + } else { + OIDNToggle.SetEnabled(true); + HardwareRTToggle.SetEnabled(true); + BindlessToggle.SetEnabled(true); + RemoveDefine("DX11Only"); + SetGlobalDefines("DX11", false); + } + } + }); + + NonPlayContainer.Add(HardwareRTToggle); + NonPlayContainer.Add(BindlessToggle); + NonPlayContainer.Add(GaussianTreeToggle); + NonPlayContainer.Add(DX11Toggle); + NonPlayContainer.Add(OIDNToggle); + NonPlayContainer.Add(RadCacheToggle); + NonPlayContainer.Add(NonAccurateLightTriToggle); + NonPlayContainer.Add(new Label("-------------")); + + Label PlayLabel = new Label("-- THESE CAN BE MODIFIED ON THE FLY/DURING PLAY --"); + + VisualElement PlayContainer = new VisualElement(); + PlayContainer.style.paddingLeft = 10; + + PlayContainer.Add(CustomToggle("Fade Mapping", "FadeMapping")); + PlayContainer.Add(CustomToggle("Stained Glass", "StainedGlassShadows")); + PlayContainer.Add(CustomToggle("Ignore Backfacing Triangles", "IgnoreBackfacing")); + PlayContainer.Add(CustomToggle("Use Light BVH", "LBVH")); + PlayContainer.Add(CustomToggle("Quick RadCache Toggle", "RadianceCache")); + PlayContainer.Add(CustomToggle("Use Texture LOD", "UseTextureLOD")); + PlayContainer.Add(CustomToggle("Use vMF Diffuse", "vMFDiffuse")); + PlayContainer.Add(CustomToggle("Use EON Diffuse", "EONDiffuse")); + PlayContainer.Add(CustomToggle("Use Advanced Background", "AdvancedBackground")); + PlayContainer.Add(new Label("-------------")); + - Button RemoveTrueTraceButton = new Button(() => RemoveTrueTrace()) {text = "Remove TrueTrace Scripts From Scene"}; DingToggle = new Toggle() {value = DoDing, text = "Play Ding When Build Finishes"}; DingToggle.RegisterValueChangedCallback(evt => {DoDing = evt.newValue; RayTracingMaster.DoDing = DoDing;}); @@ -1547,20 +1675,17 @@ void AddHardSettingsToMenu() { TurnTableBox.Add(TurnTableLabel); TurnTableBox.Add(TurnTableAbsolutePath); - Button CorrectMatOptionsButton = new Button(() => FixRayObjects()) {text = "Correct Mat Options"}; + Button CorrectMatOptionsButton = new Button(() => FixRayObjects()) {text = "(Debug Button)Correct Mat Options"}; HardSettingsMenu.Add(RemoveTrueTraceButton); - HardSettingsMenu.Add(HardwareRTToggle); - HardSettingsMenu.Add(BindlessToggle); - HardSettingsMenu.Add(DX11Toggle); - HardSettingsMenu.Add(OIDNToggle); - HardSettingsMenu.Add(RadCacheToggle); - HardSettingsMenu.Add(NonAccurateLightTriToggle); + HardSettingsMenu.Add(NonPlayLabel); + HardSettingsMenu.Add(NonPlayContainer); + HardSettingsMenu.Add(PlayLabel); + HardSettingsMenu.Add(PlayContainer); HardSettingsMenu.Add(ClayModeToggle); HardSettingsMenu.Add(DingToggle); HardSettingsMenu.Add(MaterialHelperToggle); HardSettingsMenu.Add(MatChangeResetsAccumToggle); - HardSettingsMenu.Add(OIDNBlendRatioSlider); if(ClayMode) HardSettingsMenu.Add(ClayColorBox); VisualElement Spacer = new VisualElement(); Spacer.style.height = 10; @@ -1569,6 +1694,14 @@ void AddHardSettingsToMenu() { HardSettingsMenu.Add(ScreenShotBox); HardSettingsMenu.Add(PanoramaBox); HardSettingsMenu.Add(TurnTableBox); + HardSettingsMenu.Add(CorrectMatOptionsButton); + + + + + + + // HardSettingsMenu.Add(CorrectMatOptionsButton); } @@ -1800,7 +1933,7 @@ public void CreateGUI() { FXAA = RayMaster.LocalTTSettings.PPFXAA; ToneMap = RayMaster.LocalTTSettings.PPToneMap; ToneMapIndex = RayMaster.LocalTTSettings.ToneMapper; - TAAU = RayMaster.LocalTTSettings.UseTAAU; + UpscalerMethod = RayMaster.LocalTTSettings.UpscalerMethod; DoPartialRendering = RayMaster.LocalTTSettings.DoPartialRendering; PartialRenderingFactor = RayMaster.LocalTTSettings.PartialRenderingFactor; DoFirefly = RayMaster.LocalTTSettings.DoFirefly; @@ -1811,6 +1944,9 @@ public void CreateGUI() { SceneBackgroundColor = new Color(RayMaster.LocalTTSettings.SceneBackgroundColor.x, RayMaster.LocalTTSettings.SceneBackgroundColor.y, RayMaster.LocalTTSettings.SceneBackgroundColor.z, 1); SecondarySceneBackgroundColor = new Color(RayMaster.LocalTTSettings.SecondarySceneBackgroundColor.x, RayMaster.LocalTTSettings.SecondarySceneBackgroundColor.y, RayMaster.LocalTTSettings.SecondarySceneBackgroundColor.z, 1); BackgroundIntensity = RayMaster.LocalTTSettings.BackgroundIntensity; + PrimaryBackgroundTint = RayMaster.LocalTTSettings.PrimaryBackgroundTint; + PrimaryBackgroundTintColor = new Color(RayMaster.LocalTTSettings.PrimaryBackgroundTintColor.x, RayMaster.LocalTTSettings.PrimaryBackgroundTintColor.y, RayMaster.LocalTTSettings.PrimaryBackgroundTintColor.z, 1); + PrimaryBackgroundContrast = RayMaster.LocalTTSettings.PrimaryBackgroundContrast; IndirectBoost = RayMaster.LocalTTSettings.IndirectBoost; BackgroundType = RayMaster.LocalTTSettings.BackgroundType; SecondaryBackgroundType = RayMaster.LocalTTSettings.SecondaryBackgroundType; @@ -1847,6 +1983,7 @@ public void CreateGUI() { EditorUtility.SetDirty(Instanced); Instanced.ClearAll(); Cleared = true; + // Assets.RunningTasks = 0; } else Debug.Log("Cant Do This In Editor");}) {text = "Clear Parent Data"}; ClearButton.style.minWidth = 145; QuickStartButton = new Button(() => QuickStart()) {text = "Auto Assign Scripts"}; @@ -1882,7 +2019,14 @@ public void CreateGUI() { ResField.ElementAt(0).style.minWidth = 75; ResField.ElementAt(1).style.width = 35; TopEnclosingBox.Add(ResField); - ResField.RegisterValueChangedCallback(evt => {RenderRes = evt.newValue; RenderRes = Mathf.Max(RenderRes, 0.1f); RenderRes = Mathf.Min(RenderRes, 1.0f); RayMaster.LocalTTSettings.RenderScale = RenderRes;}); + ResField.RegisterValueChangedCallback(evt => { + ResField.value = Mathf.Max(Mathf.Min(evt.newValue, 1.0f), 0.1f); + RenderRes = ResField.value; + RayMaster.LocalTTSettings.RenderScale = RenderRes; + if(MainSource.Children().Contains(UpscalerField)) { + if(RenderRes == 1.0f) MainSource.Remove(UpscalerField); + } else if(RenderRes != 1.0f) MainSource.Insert(MainSource.IndexOf(DoPartialRenderingToggle), UpscalerField); + }); TopEnclosingBox.Add(AtlasField); MainSource.Add(TopEnclosingBox); @@ -1925,65 +2069,60 @@ public void CreateGUI() { DenoiserSettings.Add("OIDN"); #endif PopupField DenoiserField = new PopupField("Denoiser"); + VisualElement DenoiserExtrasContainer = CreateHorizontalBox("Denoiser Extra Info Container"); + #if !UseOIDN + RayMaster.LocalTTSettings.DenoiserMethod = Mathf.Min(RayMaster.LocalTTSettings.DenoiserMethod, 1); + #endif + DenoiserMethod = RayMaster.LocalTTSettings.DenoiserMethod; DenoiserField.ElementAt(0).style.minWidth = 55; - DenoiserField.style.width = 275; + DenoiserField.ElementAt(1).style.minWidth = 75; + DenoiserField.ElementAt(1).style.maxWidth = 75; + DenoiserField.style.width = 450; DenoiserField.choices = DenoiserSettings; - DenoiserField.index = DenoiserSelection; + DenoiserField.index = DenoiserMethod; DenoiserField.style.flexDirection = FlexDirection.Row; + DenoiserExtrasContainer.Clear(); DenoiserField.RegisterValueChangedCallback(evt => { - DenoiserSelection = DenoiserField.index; - RayMaster.LocalTTSettings.UseASVGF = false; - RayMaster.LocalTTSettings.UseOIDN = false; - if(DenoiserField.Contains(OIDNFrameField)) DenoiserField.Remove(OIDNFrameField); - switch(DenoiserSelection) { - case 0: - break; - case 1: - RayMaster.LocalTTSettings.UseASVGF = true; - break; - case 2: - #if UseOIDN - RayMaster.LocalTTSettings.UseOIDN = true; - OIDNFrameField = new IntegerField("Frames Before OIDN") {value = OIDNFrameCount}; - OIDNFrameField.ElementAt(0).style.minWidth = 95; - OIDNFrameField.RegisterValueChangedCallback(evt => {OIDNFrameCount = (int)evt.newValue; RayMaster.LocalTTSettings.OIDNFrameCount = OIDNFrameCount;}); - DenoiserField.Add(OIDNFrameField); - #else - RayMaster.LocalTTSettings.UseOIDN = false; - DenoiserField.index = 0; - DenoiserSelection = 0; - #endif - break; - - } + #if !UseOIDN + DenoiserField.index = Mathf.Min(DenoiserField.index, 1); + #endif + DenoiserMethod = DenoiserField.index; + RayMaster.LocalTTSettings.DenoiserMethod = DenoiserMethod; + DenoiserExtrasContainer.Clear(); + if(DenoiserMethod == 2) { + OIDNFrameField = new IntegerField("Frame Delay") {value = OIDNFrameCount}; + OIDNFrameField.ElementAt(0).style.minWidth = 65; + OIDNFrameField.RegisterValueChangedCallback(evt => {OIDNFrameCount = (int)evt.newValue; RayMaster.LocalTTSettings.OIDNFrameCount = OIDNFrameCount;}); + + + Slider OIDNBlendRatioSlider = new Slider() {label = "Blend Ratio: ", value = OIDNBlendRatio, highValue = 1.0f, lowValue = 0.0f}; + OIDNBlendRatioSlider.showInputField = true; + OIDNBlendRatioSlider.style.width = 200; + OIDNBlendRatioSlider.ElementAt(0).style.minWidth = 65; + OIDNBlendRatioSlider.RegisterValueChangedCallback(evt => {OIDNBlendRatio = evt.newValue; RayMaster.LocalTTSettings.OIDNBlendRatio = OIDNBlendRatio;}); + + DenoiserExtrasContainer.Add(OIDNFrameField); + DenoiserExtrasContainer.Add(OIDNBlendRatioSlider); + } }); - if(DenoiserField.Contains(OIDNFrameField)) DenoiserField.Remove(OIDNFrameField); - DenoiserSelection = DenoiserField.index; - if(RayMaster.LocalTTSettings.UseASVGF) { - DenoiserSelection = 1; - } else if(RayMaster.LocalTTSettings.UseOIDN) { - DenoiserSelection = 2; - } - switch(DenoiserSelection) { - case 0: - break; - case 1: - RayMaster.LocalTTSettings.UseASVGF = true; - break; - case 2: - #if UseOIDN - RayMaster.LocalTTSettings.UseOIDN = true; - OIDNFrameField = new IntegerField("Frames Before OIDN") {value = OIDNFrameCount}; - OIDNFrameField.ElementAt(0).style.minWidth = 95; - OIDNFrameField.RegisterValueChangedCallback(evt => {OIDNFrameCount = (int)evt.newValue; RayMaster.LocalTTSettings.OIDNFrameCount = OIDNFrameCount;}); - DenoiserField.Add(OIDNFrameField); - #else - RayMaster.LocalTTSettings.UseOIDN = false; - DenoiserField.index = 0; - DenoiserSelection = 0; - #endif - break; + if(DenoiserMethod == 2) { + OIDNFrameField = new IntegerField("Frame Delay") {value = OIDNFrameCount}; + OIDNFrameField.ElementAt(0).style.minWidth = 65; + OIDNFrameField.RegisterValueChangedCallback(evt => {OIDNFrameCount = (int)evt.newValue; RayMaster.LocalTTSettings.OIDNFrameCount = OIDNFrameCount;}); + + + Slider OIDNBlendRatioSlider = new Slider() {label = "Blend Ratio: ", value = OIDNBlendRatio, highValue = 1.0f, lowValue = 0.0f}; + OIDNBlendRatioSlider.showInputField = true; + OIDNBlendRatioSlider.style.width = 200; + OIDNBlendRatioSlider.ElementAt(0).style.minWidth = 65; + OIDNBlendRatioSlider.RegisterValueChangedCallback(evt => {OIDNBlendRatio = evt.newValue; RayMaster.LocalTTSettings.OIDNBlendRatio = OIDNBlendRatio;}); + + + + DenoiserExtrasContainer.Add(OIDNFrameField); + DenoiserExtrasContainer.Add(OIDNBlendRatioSlider); } + DenoiserField.Add(DenoiserExtrasContainer); MainSource.Add(DenoiserField); @@ -2196,10 +2335,24 @@ public void CreateGUI() { if(ToneMap) MainSource.Add(ToneMapFoldout); - TAAUToggle = new Toggle() {value = TAAU, text = "Enable TAAU"}; - TAAUToggle.tooltip = "On = Temporal Anti Aliasing Upscaling; Off = Semi Custom Upscaler, performs slightly differently"; - MainSource.Add(TAAUToggle); - TAAUToggle.RegisterValueChangedCallback(evt => {TAAU = evt.newValue; RayMaster.LocalTTSettings.UseTAAU = TAAU;}); + + List UpscalerSettings = new List(); + UpscalerSettings.Add("Bilinear"); + UpscalerSettings.Add("GSR"); + UpscalerSettings.Add("TAAU"); + UpscalerField = new PopupField("Upscaler"); + UpscalerField.ElementAt(0).style.minWidth = 55; + UpscalerField.ElementAt(1).style.minWidth = 75; + UpscalerField.ElementAt(1).style.maxWidth = 75; + UpscalerField.style.width = 275; + UpscalerField.choices = UpscalerSettings; + UpscalerField.index = UpscalerMethod; + UpscalerField.style.flexDirection = FlexDirection.Row; + UpscalerField.RegisterValueChangedCallback(evt => { + UpscalerMethod = UpscalerField.index; + RayMaster.LocalTTSettings.UpscalerMethod = UpscalerMethod; + }); + if(RenderRes != 1.0f) MainSource.Add(UpscalerField); @@ -2207,7 +2360,7 @@ public void CreateGUI() { PartialRenderingFoldout.style.flexDirection = FlexDirection.Row; IntegerField PartialRenderingField = new IntegerField() {value = PartialRenderingFactor, label = "Partial Factor"}; PartialRenderingField.ElementAt(0).style.minWidth = 65; - PartialRenderingField.RegisterValueChangedCallback(evt => {PartialRenderingFactor = evt.newValue; PartialRenderingFactor = Mathf.Max(PartialRenderingFactor, 1); RayMaster.LocalTTSettings.PartialRenderingFactor = PartialRenderingFactor;}); + PartialRenderingField.RegisterValueChangedCallback(evt => {PartialRenderingField.value = Mathf.Max(2, evt.newValue); PartialRenderingFactor = PartialRenderingField.value; RayMaster.LocalTTSettings.PartialRenderingFactor = PartialRenderingFactor;}); PartialRenderingFoldout.Add(PartialRenderingField); DoPartialRenderingToggle = new Toggle() {value = DoPartialRendering, text = "Use Partial Rendering"}; MainSource.Add(DoPartialRenderingToggle); @@ -2215,6 +2368,7 @@ public void CreateGUI() { if(DoPartialRendering) MainSource.Add(PartialRenderingFoldout); VisualElement FireflyFoldout = new VisualElement() {}; + FireflyFoldout.style.minWidth = 300; IntegerField FireflyFrameCountField = new IntegerField() {value = FireflyFrameCount, label = "Frames Before Anti-Firefly"}; FireflyFrameCountField.ElementAt(0).style.minWidth = 65; FireflyFrameCountField.RegisterValueChangedCallback(evt => {FireflyFrameCount = evt.newValue; RayMaster.LocalTTSettings.FireflyFrameCount = FireflyFrameCount;}); @@ -2251,7 +2405,7 @@ public void CreateGUI() { VisualElement AtmoBox = new VisualElement(); AtmoBox.style.flexDirection = FlexDirection.Row; AtmoScatterField = new IntegerField("Atmospheric Scattering Samples") {value = AtmoScatter}; - AtmoScatterField.RegisterValueChangedCallback(evt => {AtmoScatter = (int)evt.newValue; RayMaster.AtmoNumLayers = AtmoScatter;}); + AtmoScatterField.RegisterValueChangedCallback(evt => {AtmoScatterField.value = Mathf.Max(evt.newValue, 1); AtmoScatter = AtmoScatterField.value; RayMaster.AtmoNumLayers = AtmoScatter;}); AtmoBox.Add(AtmoScatterField); MainSource.Add(AtmoBox); @@ -2358,6 +2512,7 @@ void Update() { if(NameIndex == -1) { Debug.Log("Missing material marked for update"); } else { + EditorUtility.SetDirty(TempRTO); TempRTO.MaterialOptions[NameIndex] = (RayTracingObject.Options)Ray.OptionID; TempRTO.TransmissionColor[NameIndex] = Ray.TransCol; TempRTO.BaseColor[NameIndex] = Ray.BaseCol; @@ -2382,6 +2537,7 @@ void Update() { TempRTO.Specular[NameIndex] = Ray.Spec; TempRTO.AlphaCutoff[NameIndex] = Ray.AlphaCutoff; TempRTO.NormalStrength[NameIndex] = Ray.NormStrength; + TempRTO.DetailNormalStrength[NameIndex] = Ray.DetailNormalStrength; TempRTO.Hue[NameIndex] = Ray.Hue; TempRTO.Brightness[NameIndex] = Ray.Brightness; TempRTO.Contrast[NameIndex] = Ray.Contrast; @@ -2397,6 +2553,8 @@ void Update() { TempRTO.KelvinTemp[NameIndex] = Ray.KelvinTemp; TempRTO.ColorBleed[NameIndex] = Ray.ColorBleed; TempRTO.AlbedoBlendFactor[NameIndex] = Ray.AlbedoBlendFactor; + TempRTO.SecondaryNormalTexScaleOffset[NameIndex] = Ray.SecondaryNormalTexScaleOffset; + TempRTO.SecondaryNormalTexBlend[NameIndex] = Ray.SecondaryNormalTexBlend; TempRTO.CallMaterialEdited(); } } diff --git a/TrueTrace/Editor/RayTracingObjectEditor.cs b/TrueTrace/Editor/RayTracingObjectEditor.cs index 53a0d498..4d584b47 100644 --- a/TrueTrace/Editor/RayTracingObjectEditor.cs +++ b/TrueTrace/Editor/RayTracingObjectEditor.cs @@ -21,29 +21,129 @@ public SavePopup(RayTracingObject ThisOBJ, int SaveIndex) { } public override Vector2 GetWindowSize() { - return new Vector2(460, 50); + return new Vector2(460, 300); } - + Vector2 ScrollPosition; + string FolderName = ""; + int CopyIndex; + int FolderIndex; public override void OnGUI(Rect rect) { // Debug.Log("ONINSPECTORGUI"); - PresetName = GUILayout.TextField(PresetName, 32); + GUILayout.BeginHorizontal(); + GUILayout.Label("Preset Name: "); + PresetName = GUILayout.TextField(PresetName, 32); + GUILayout.EndHorizontal(); + GUILayout.BeginHorizontal(); + GUILayout.Label("Folder Name: "); + FolderName = GUILayout.TextField(FolderName, 32); + GUILayout.EndHorizontal(); + + CopyIndex = -1; + FolderIndex = -1; + UnityEditor.AssetDatabase.Refresh(); + RayObjFolderMaster PresetMaster; + using (var A = new StringReader(Resources.Load("Utility/MaterialPresets").text)) { + var serializer = new XmlSerializer(typeof(RayObjFolderMaster)); + PresetMaster = serializer.Deserialize(A) as RayObjFolderMaster; + int FolderCount = PresetMaster.PresetFolders.Count; + GUILayout.BeginScrollView(ScrollPosition, GUILayout.Width(100), GUILayout.Height(200)); + for(int i = 0; i < FolderCount; i++) { + if(!PresetMaster.PresetFolders[i].FolderName.Equals("COPYPASTEBUFFER")) { + if(GUILayout.Button(PresetMaster.PresetFolders[i].FolderName)) { + FolderName = PresetMaster.PresetFolders[i].FolderName; + FolderIndex = i; + } + } + } + GUILayout.EndScrollView(); + + + } if(GUILayout.Button("Save Preset")) { - RayObjs PresetRays; - int CopyIndex = -1; - UnityEditor.AssetDatabase.Refresh(); - using (var A = new StringReader(Resources.Load("Utility/MaterialPresets").text)) { - var serializer = new XmlSerializer(typeof(RayObjs)); - PresetRays = serializer.Deserialize(A) as RayObjs; - int RayReadCount = PresetRays.RayObj.Count; - for(int i = 0; i < RayReadCount; i++) { - if(PresetRays.RayObj[i].MatName.Equals(PresetName)) { - CopyIndex = i; - break; + int FolderCount = PresetMaster.PresetFolders.Count; + for(int j = 0; j < FolderCount; j++) { + if(PresetMaster.PresetFolders[j].FolderName.Equals(FolderName)) { + FolderIndex = j; + break; + } + } + if(FolderIndex == -1) { + PresetMaster.PresetFolders.Add(new RayObjFolder() { + FolderName = FolderName, + ContainedPresets = new List() + }); + FolderIndex = PresetMaster.PresetFolders.Count - 1; + } + int RayReadCount = PresetMaster.PresetFolders[FolderIndex].ContainedPresets.Count; + for(int j = 0; j < RayReadCount; j++) { + if(PresetMaster.PresetFolders[FolderIndex].ContainedPresets[j].MatName.Equals(PresetName)) { + CopyIndex = j; + break; + } + } + + Material TempMat = ThisOBJ.SharedMaterials[SaveIndex]; + int MatIndex = AssetManager.ShaderNames.IndexOf(TempMat.shader.name); + MaterialShader RelevantMat; + string AlbedoGUID = "null"; + string MetallicGUID = "null"; + string RoughnessGUID = "null"; + string EmissionGUID = "null"; + string AlphaGUID = "null"; + string MatCapGUID = "null"; + string MatcapMaskGUID = "null"; + string SecondaryAlbedoGUID = "null"; + string SecondaryAlbedoMaskGUID = "null"; + string NormalGUID = "null"; + if(MatIndex != -1) { + RelevantMat = AssetManager.data.Material[MatIndex]; + int TexCount = RelevantMat.AvailableTextures.Count; + for(int i2 = 0; i2 < TexCount; i2++) { + string TexName = RelevantMat.AvailableTextures[i2].TextureName; + if(TempMat.HasProperty(TexName) && TempMat.GetTexture(TexName) != null) { + switch((TexturePurpose)RelevantMat.AvailableTextures[i2].Purpose) { + case(TexturePurpose.SecondaryAlbedoTextureMask): + SecondaryAlbedoMaskGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.SecondaryAlbedoTexture): + SecondaryAlbedoGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.MatCapTex): + MatCapGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Normal): + NormalGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Emission): + EmissionGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Metallic): + MetallicGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Roughness): + RoughnessGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Alpha): + AlphaGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.MatCapMask): + MatcapMaskGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Albedo): + AlbedoGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + } } } } + else Debug.LogError("FUCK: " + ThisOBJ.SharedMaterials[SaveIndex].shader.name); + + + + + RayObjectDatas TempRay = new RayObjectDatas() { ID = 0, MatName = PresetName, @@ -71,6 +171,7 @@ public override void OnGUI(Rect rect) { Spec = ThisOBJ.Specular[SaveIndex], AlphaCutoff = ThisOBJ.AlphaCutoff[SaveIndex], NormStrength = ThisOBJ.NormalStrength[SaveIndex], + DetailNormalStrength = ThisOBJ.DetailNormalStrength[SaveIndex], Hue = ThisOBJ.Hue[SaveIndex], Brightness = ThisOBJ.Brightness[SaveIndex], Contrast = ThisOBJ.Contrast[SaveIndex], @@ -79,21 +180,35 @@ public override void OnGUI(Rect rect) { BlendFactor = ThisOBJ.BlendFactor[SaveIndex], MainTexScaleOffset = ThisOBJ.MainTexScaleOffset[SaveIndex], SecondaryAlbedoTexScaleOffset = ThisOBJ.SecondaryAlbedoTexScaleOffset[SaveIndex], + SecondaryNormalTexScaleOffset = ThisOBJ.SecondaryNormalTexScaleOffset[SaveIndex], SecondaryTextureScale = ThisOBJ.SecondaryTextureScale[SaveIndex], Rotation = ThisOBJ.Rotation[SaveIndex], Flags = ThisOBJ.Flags[SaveIndex], UseKelvin = ThisOBJ.UseKelvin[SaveIndex], KelvinTemp = ThisOBJ.KelvinTemp[SaveIndex], ColorBleed = ThisOBJ.ColorBleed[SaveIndex], - AlbedoBlendFactor = ThisOBJ.AlbedoBlendFactor[SaveIndex] + AlbedoBlendFactor = ThisOBJ.AlbedoBlendFactor[SaveIndex], + SecondaryNormalTexBlend = ThisOBJ.SecondaryNormalTexBlend[SaveIndex], + + AlbedoGUID = AlbedoGUID, + MetallicGUID = MetallicGUID, + RoughnessGUID = RoughnessGUID, + EmissionGUID = EmissionGUID, + NormalGUID = NormalGUID, + AlphaGUID = AlphaGUID, + MatCapGUID = MatCapGUID, + MatcapMaskGUID = MatcapMaskGUID, + SecondaryAlbedoGUID = SecondaryAlbedoGUID, + SecondaryAlbedoMaskGUID = SecondaryAlbedoMaskGUID, + + ShaderName = TempMat.shader.name }; - if(CopyIndex != -1) PresetRays.RayObj[CopyIndex] = TempRay; - else PresetRays.RayObj.Add(TempRay); + if(CopyIndex != -1) PresetMaster.PresetFolders[FolderIndex].ContainedPresets[CopyIndex] = TempRay; + else PresetMaster.PresetFolders[FolderIndex].ContainedPresets.Add(TempRay); string materialPresetsPath = TTPathFinder.GetMaterialPresetsPath(); using(StreamWriter writer = new StreamWriter(materialPresetsPath)) { - var serializer = new XmlSerializer(typeof(RayObjs)); - serializer.Serialize(writer.BaseStream, PresetRays); - UnityEditor.AssetDatabase.Refresh(); + var serializer = new XmlSerializer(typeof(RayObjFolderMaster)); + serializer.Serialize(writer.BaseStream, PresetMaster); } this.editorWindow.Close(); } @@ -108,39 +223,62 @@ public class LoadPopup : PopupWindowContent public LoadPopup(RayTracingObjectEditor editor) { this.SourceWindow = editor; } - private void CallEditorFunction(RayObjectDatas RayObj) { + private void CallEditorFunction(RayObjectDatas RayObj, bool LoadTextures) { if(SourceWindow != null) { - SourceWindow.LoadFunction(RayObj); + SourceWindow.LoadFunction(RayObj, LoadTextures); } } public override Vector2 GetWindowSize() { return new Vector2(460, 250); } - + bool[] FoldoutBool; public override void OnGUI(Rect rect) { - RayObjs PresetRays; + RayObjFolderMaster PresetMaster; UnityEditor.AssetDatabase.Refresh(); using (var A = new StringReader(Resources.Load("Utility/MaterialPresets").text)) { - var serializer = new XmlSerializer(typeof(RayObjs)); - PresetRays = serializer.Deserialize(A) as RayObjs; + var serializer = new XmlSerializer(typeof(RayObjFolderMaster)); + PresetMaster = serializer.Deserialize(A) as RayObjFolderMaster; } - int PresetLength = PresetRays.RayObj.Count; + int FolderLength = PresetMaster.PresetFolders.Count; + if(FoldoutBool == null) FoldoutBool = new bool[FolderLength]; ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, GUILayout.Width(460), GUILayout.Height(250)); string materialPresetsPath = TTPathFinder.GetMaterialPresetsPath(); - for(int i = 0; i < PresetLength; i++) { - GUILayout.BeginHorizontal(); - if(GUILayout.Button(PresetRays.RayObj[i].MatName)) {CallEditorFunction(PresetRays.RayObj[i]); this.editorWindow.Close();} - if(GUILayout.Button("Delete")) { - PresetRays.RayObj.RemoveAt(i); - using(StreamWriter writer = new StreamWriter(materialPresetsPath)) { - var serializer = new XmlSerializer(typeof(RayObjs)); - serializer.Serialize(writer.BaseStream, PresetRays); - UnityEditor.AssetDatabase.Refresh(); + for(int j = 0; j < FolderLength; j++) { + if(!PresetMaster.PresetFolders[j].FolderName.Equals("COPYPASTEBUFFER")) { + GUILayout.BeginHorizontal(); + FoldoutBool[j] = EditorGUILayout.Foldout(FoldoutBool[j], PresetMaster.PresetFolders[j].FolderName); + if(GUILayout.Button("Delete")) { + PresetMaster.PresetFolders.RemoveAt(j); + using(StreamWriter writer = new StreamWriter(materialPresetsPath)) { + var serializer = new XmlSerializer(typeof(RayObjFolderMaster)); + serializer.Serialize(writer.BaseStream, PresetMaster); + UnityEditor.AssetDatabase.Refresh(); + } + OnGUI(new Rect(0,0,100,10)); + } + GUILayout.EndHorizontal(); + if(FoldoutBool[j]) { + if (Selection.activeTransform) { + int PresetLength = PresetMaster.PresetFolders[j].ContainedPresets.Count; + for(int i = 0; i < PresetLength; i++) { + GUILayout.BeginHorizontal(); + if(GUILayout.Button(PresetMaster.PresetFolders[j].ContainedPresets[i].MatName)) {CallEditorFunction(PresetMaster.PresetFolders[j].ContainedPresets[i], true); this.editorWindow.Close();} + if(GUILayout.Button("Load Without Textures")) {CallEditorFunction(PresetMaster.PresetFolders[j].ContainedPresets[i], false); this.editorWindow.Close();} + if(GUILayout.Button("Delete")) { + PresetMaster.PresetFolders[j].ContainedPresets.RemoveAt(i); + using(StreamWriter writer = new StreamWriter(materialPresetsPath)) { + var serializer = new XmlSerializer(typeof(RayObjFolderMaster)); + serializer.Serialize(writer.BaseStream, PresetMaster); + UnityEditor.AssetDatabase.Refresh(); + } + OnGUI(new Rect(0,0,100,10)); + } + GUILayout.EndHorizontal(); + } } - OnGUI(new Rect(0,0,100,10)); } - GUILayout.EndHorizontal(); + } } GUILayout.EndScrollView(); } @@ -162,7 +300,7 @@ void OnEnable() (target as RayTracingObject).matfill(); } - public void LoadFunction(RayObjectDatas RayObj) { + public void LoadFunction(RayObjectDatas RayObj, bool LoadTextures) { t.MaterialOptions[Selected] = (RayTracingObject.Options)RayObj.OptionID; t.TransmissionColor[Selected] = RayObj.TransCol; t.BaseColor[Selected] = RayObj.BaseCol; @@ -187,6 +325,7 @@ public void LoadFunction(RayObjectDatas RayObj) { t.Specular[Selected] = RayObj.Spec; t.AlphaCutoff[Selected] = RayObj.AlphaCutoff; t.NormalStrength[Selected] = RayObj.NormStrength; + t.DetailNormalStrength[Selected] = RayObj.DetailNormalStrength; t.Hue[Selected] = RayObj.Hue; t.Brightness[Selected] = RayObj.Brightness; t.Contrast[Selected] = RayObj.Contrast; @@ -195,6 +334,7 @@ public void LoadFunction(RayObjectDatas RayObj) { t.BlendFactor[Selected] = RayObj.BlendFactor; t.MainTexScaleOffset[Selected] = RayObj.MainTexScaleOffset; t.SecondaryAlbedoTexScaleOffset[Selected] = RayObj.SecondaryAlbedoTexScaleOffset; + t.SecondaryNormalTexScaleOffset[Selected] = RayObj.SecondaryNormalTexScaleOffset; t.SecondaryTextureScale[Selected] = RayObj.SecondaryTextureScale; t.Rotation[Selected] = RayObj.Rotation; t.Flags[Selected] = RayObj.Flags; @@ -202,28 +342,207 @@ public void LoadFunction(RayObjectDatas RayObj) { t.KelvinTemp[Selected] = RayObj.KelvinTemp; t.ColorBleed[Selected] = RayObj.ColorBleed; t.AlbedoBlendFactor[Selected] = RayObj.AlbedoBlendFactor; + t.SecondaryNormalTexBlend[Selected] = RayObj.SecondaryNormalTexBlend; + + if(LoadTextures) { + Material TempMat = t.SharedMaterials[Selected]; + int MatIndex = AssetManager.ShaderNames.IndexOf(TempMat.shader.name); + MaterialShader RelevantMat; + if(MatIndex != -1) { + // if(TempMat.shader.name.Equals(RayObj.ShaderName)) { + RelevantMat = AssetManager.data.Material[MatIndex]; + int TexCount = RelevantMat.AvailableTextures.Count; + for(int i2 = 0; i2 < TexCount; i2++) { + string TexName = RelevantMat.AvailableTextures[i2].TextureName; + switch((TexturePurpose)RelevantMat.AvailableTextures[i2].Purpose) { + case(TexturePurpose.Albedo): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.AlbedoGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.AlbedoGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.AlbedoGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.SecondaryAlbedoTextureMask): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.SecondaryAlbedoMaskGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.SecondaryAlbedoMaskGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.SecondaryAlbedoMaskGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.SecondaryAlbedoTexture): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.SecondaryAlbedoGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.SecondaryAlbedoGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.SecondaryAlbedoGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.MatCapTex): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.MatCapGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.MatCapGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.MatCapGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.Normal): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.NormalGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.NormalGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.NormalGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.Emission): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.EmissionGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.EmissionGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.EmissionGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.Metallic): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.MetallicGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.MetallicGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.MetallicGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.Roughness): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.RoughnessGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.RoughnessGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.RoughnessGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.Alpha): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.AlphaGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.AlphaGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.AlphaGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + case(TexturePurpose.MatCapMask): + if (TempMat.HasProperty(TexName)) { + if(!(RayObj.MatcapMaskGUID.Equals("null"))) { + Texture2D TextureAsset = (AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(RayObj.MatcapMaskGUID), typeof(Texture)) as Texture2D); + if(TextureAsset != null) TempMat.SetTexture(TexName, TextureAsset); + else Debug.LogError("Missing Texture Asset At " + AssetDatabase.GUIDToAssetPath(RayObj.MatcapMaskGUID)); + } else TempMat.SetTexture(TexName, null); + } + break; + } + } + // } + } else Debug.LogError("FUCK: " + TempMat.shader.name); + // AssetManager.Assets.ForceUpdateAtlas(); + } + // else Debug.LogError("FUCK: " + ThisOBJ.SharedMaterials[SaveIndex].shader.name); + t.CallMaterialEdited(true); - OnInspectorGUI(); + // OnInspectorGUI(); } public void CopyFunction(RayTracingObject ThisOBJ, int SaveIndex) { - RayObjs PresetRays; + RayObjFolderMaster PresetMaster; int CopyIndex = -1; + int FolderIndex = -1; + string FolderName = "COPYPASTEBUFFER"; string PresetName = "COPYPASTEBUFFER"; UnityEditor.AssetDatabase.Refresh(); using (var A = new StringReader(Resources.Load("Utility/MaterialPresets").text)) { - var serializer = new XmlSerializer(typeof(RayObjs)); - PresetRays = serializer.Deserialize(A) as RayObjs; - int RayReadCount = PresetRays.RayObj.Count; + var serializer = new XmlSerializer(typeof(RayObjFolderMaster)); + PresetMaster = serializer.Deserialize(A) as RayObjFolderMaster; + int RayReadCount = PresetMaster.PresetFolders.Count; for(int i = 0; i < RayReadCount; i++) { - if(PresetRays.RayObj[i].MatName.Equals(PresetName)) { - CopyIndex = i; + if(PresetMaster.PresetFolders[i].FolderName.Equals(FolderName)) { + FolderIndex = i; + int PresetCount = PresetMaster.PresetFolders[i].ContainedPresets.Count; + for(int j = 0; j < PresetCount; j++) { + if(PresetMaster.PresetFolders[i].ContainedPresets[j].MatName.Equals(PresetName)) { + CopyIndex = j; + break; + } + } break; } } } + + Material TempMat = ThisOBJ.SharedMaterials[SaveIndex]; + int MatIndex = AssetManager.ShaderNames.IndexOf(TempMat.shader.name); + MaterialShader RelevantMat; + string AlbedoGUID = "null"; + string MetallicGUID = "null"; + string RoughnessGUID = "null"; + string EmissionGUID = "null"; + string AlphaGUID = "null"; + string MatCapGUID = "null"; + string MatcapMaskGUID = "null"; + string SecondaryAlbedoGUID = "null"; + string SecondaryAlbedoMaskGUID = "null"; + string NormalGUID = "null"; + if(MatIndex != -1) { + RelevantMat = AssetManager.data.Material[MatIndex]; + int TexCount = RelevantMat.AvailableTextures.Count; + for(int i2 = 0; i2 < TexCount; i2++) { + string TexName = RelevantMat.AvailableTextures[i2].TextureName; + if(TempMat.HasProperty(TexName) && TempMat.GetTexture(TexName) != null) { + switch((TexturePurpose)RelevantMat.AvailableTextures[i2].Purpose) { + case(TexturePurpose.SecondaryAlbedoTextureMask): + SecondaryAlbedoMaskGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.SecondaryAlbedoTexture): + SecondaryAlbedoGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.MatCapTex): + MatCapGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Normal): + NormalGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Emission): + EmissionGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Metallic): + MetallicGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Roughness): + RoughnessGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Alpha): + AlphaGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.MatCapMask): + MatcapMaskGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + case(TexturePurpose.Albedo): + AlbedoGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(TempMat.GetTexture(TexName))); + break; + } + } + } + } + else Debug.LogError("FUCK: " + ThisOBJ.SharedMaterials[SaveIndex].shader.name); + + + RayObjectDatas TempRay = new RayObjectDatas() { ID = 0, MatName = PresetName, @@ -251,6 +570,7 @@ public void CopyFunction(RayTracingObject ThisOBJ, int SaveIndex) { Spec = ThisOBJ.Specular[SaveIndex], AlphaCutoff = ThisOBJ.AlphaCutoff[SaveIndex], NormStrength = ThisOBJ.NormalStrength[SaveIndex], + DetailNormalStrength = ThisOBJ.DetailNormalStrength[SaveIndex], Hue = ThisOBJ.Hue[SaveIndex], Brightness = ThisOBJ.Brightness[SaveIndex], Contrast = ThisOBJ.Contrast[SaveIndex], @@ -259,40 +579,65 @@ public void CopyFunction(RayTracingObject ThisOBJ, int SaveIndex) { BlendFactor = ThisOBJ.BlendFactor[SaveIndex], MainTexScaleOffset = ThisOBJ.MainTexScaleOffset[SaveIndex], SecondaryAlbedoTexScaleOffset = ThisOBJ.SecondaryAlbedoTexScaleOffset[SaveIndex], + SecondaryNormalTexScaleOffset = ThisOBJ.SecondaryNormalTexScaleOffset[SaveIndex], SecondaryTextureScale = ThisOBJ.SecondaryTextureScale[SaveIndex], Rotation = ThisOBJ.Rotation[SaveIndex], Flags = ThisOBJ.Flags[SaveIndex], UseKelvin = ThisOBJ.UseKelvin[SaveIndex], KelvinTemp = ThisOBJ.KelvinTemp[SaveIndex], ColorBleed = ThisOBJ.ColorBleed[SaveIndex], - AlbedoBlendFactor = ThisOBJ.AlbedoBlendFactor[SaveIndex] + AlbedoBlendFactor = ThisOBJ.AlbedoBlendFactor[SaveIndex], + SecondaryNormalTexBlend = ThisOBJ.SecondaryNormalTexBlend[SaveIndex], + + AlbedoGUID = AlbedoGUID, + MetallicGUID = MetallicGUID, + RoughnessGUID = RoughnessGUID, + EmissionGUID = EmissionGUID, + NormalGUID = NormalGUID, + AlphaGUID = AlphaGUID, + MatCapGUID = MatCapGUID, + MatcapMaskGUID = MatcapMaskGUID, + SecondaryAlbedoGUID = SecondaryAlbedoGUID, + SecondaryAlbedoMaskGUID = SecondaryAlbedoMaskGUID, + + ShaderName = TempMat.shader.name }; - if(CopyIndex != -1) PresetRays.RayObj[CopyIndex] = TempRay; - else PresetRays.RayObj.Add(TempRay); + if(CopyIndex != -1) PresetMaster.PresetFolders[FolderIndex].ContainedPresets[CopyIndex] = TempRay; + else PresetMaster.PresetFolders[FolderIndex].ContainedPresets.Add(TempRay); string materialPresetsPath = TTPathFinder.GetMaterialPresetsPath(); using(StreamWriter writer = new StreamWriter(materialPresetsPath)) { - var serializer = new XmlSerializer(typeof(RayObjs)); - serializer.Serialize(writer.BaseStream, PresetRays); + var serializer = new XmlSerializer(typeof(RayObjFolderMaster)); + serializer.Serialize(writer.BaseStream, PresetMaster); UnityEditor.AssetDatabase.Refresh(); } } public void PasteFunction() { - RayObjs PresetRays; + RayObjFolderMaster PresetMaster; UnityEditor.AssetDatabase.Refresh(); using (var A = new StringReader(Resources.Load("Utility/MaterialPresets").text)) { - var serializer = new XmlSerializer(typeof(RayObjs)); - PresetRays = serializer.Deserialize(A) as RayObjs; + var serializer = new XmlSerializer(typeof(RayObjFolderMaster)); + PresetMaster = serializer.Deserialize(A) as RayObjFolderMaster; } int Index = -1; - int RayReadCount = PresetRays.RayObj.Count; - for(int i = 0; i < RayReadCount; i++) { - if(PresetRays.RayObj[i].MatName.Equals("COPYPASTEBUFFER")) { - Index = i; + int FolderIndex = -1; + + + int FolderCount = PresetMaster.PresetFolders.Count; + for(int i = 0; i < FolderCount; i++) { + if(PresetMaster.PresetFolders[i].FolderName.Equals("COPYPASTEBUFFER")) { + int PresetCount = PresetMaster.PresetFolders[i].ContainedPresets.Count; + for(int j = 0; j < PresetCount; j++) { + if(PresetMaster.PresetFolders[i].ContainedPresets[j].MatName.Equals("COPYPASTEBUFFER")) { + Index = j; + break; + } + } + FolderIndex = i; break; } } if(Index == -1) return; - LoadFunction(PresetRays.RayObj[Index]); + LoadFunction(PresetMaster.PresetFolders[FolderIndex].ContainedPresets[Index], true); } Dictionary> DictionaryLinks; @@ -612,12 +957,14 @@ public override void OnInspectorGUI() { ConnectionSourceNames.Add("Smoothness"); Flag = CommonFunctions.SetFlagVar(Flag, CommonFunctions.Flags.InvertSmoothnessTexture, EditorGUILayout.ToggleLeft("Invert Roughness Tex", Flag.GetFlag(CommonFunctions.Flags.InvertSmoothnessTexture), GUILayout.MaxWidth(135))); Flag = CommonFunctions.SetFlagVar(Flag, CommonFunctions.Flags.ShadowCaster, EditorGUILayout.ToggleLeft("Casts Shadows", Flag.GetFlag(CommonFunctions.Flags.ShadowCaster), GUILayout.MaxWidth(135))); + Flag = CommonFunctions.SetFlagVar(Flag, CommonFunctions.Flags.UseVertexColors, EditorGUILayout.ToggleLeft("Vertex Colors", Flag.GetFlag(CommonFunctions.Flags.UseVertexColors), GUILayout.MaxWidth(135))); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); Flag = CommonFunctions.SetFlagVar(Flag, CommonFunctions.Flags.Thin, EditorGUILayout.ToggleLeft("Thin", Flag.GetFlag(CommonFunctions.Flags.Thin), GUILayout.MaxWidth(135))); ConnectionSources.Add("Thin", GUILayoutUtility.GetLastRect()); // Store position ConnectionSourceNames.Add("Thin"); Flag = CommonFunctions.SetFlagVar(Flag, CommonFunctions.Flags.Invisible, EditorGUILayout.ToggleLeft("Invisible", Flag.GetFlag(CommonFunctions.Flags.Invisible), GUILayout.MaxWidth(135))); + Flag = CommonFunctions.SetFlagVar(Flag, CommonFunctions.Flags.IsBackground, EditorGUILayout.ToggleLeft("Is Background", Flag.GetFlag(CommonFunctions.Flags.IsBackground), GUILayout.MaxWidth(135))); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); @@ -633,6 +980,13 @@ public override void OnInspectorGUI() { serializedObject.FindProperty("SecondaryTextureScale").GetArrayElementAtIndex(Selected).vector2Value = EditorGUILayout.Vector2Field("SecondaryTex Scale: ", t.SecondaryTextureScale[Selected]); serializedObject.FindProperty("Rotation").GetArrayElementAtIndex(Selected).floatValue = EditorGUILayout.Slider("Texture Rotation: ", t.Rotation[Selected], 0, 1); serializedObject.FindProperty("AlbedoBlendFactor").GetArrayElementAtIndex(Selected).floatValue = EditorGUILayout.Slider("Albedo Blend Factor: ", t.AlbedoBlendFactor[Selected], 0, 1); + serializedObject.FindProperty("SecondaryNormalTexScaleOffset").GetArrayElementAtIndex(Selected).vector4Value = EditorGUILayout.Vector4Field("Detail Normal Scale/Offset: ", t.SecondaryNormalTexScaleOffset[Selected]); + serializedObject.FindProperty("SecondaryNormalTexBlend").GetArrayElementAtIndex(Selected).floatValue = EditorGUILayout.Slider("Detail Normal Blend Factor: ", t.SecondaryNormalTexBlend[Selected], 0, 1); + + + serializedObject.FindProperty("DetailNormalStrength").GetArrayElementAtIndex(Selected).floatValue = EditorGUILayout.Slider("Detail Normalmap Strength: ", t.DetailNormalStrength[Selected], 0, 20.0f); + ConnectionSources.Add("DetailNormalStrength", GUILayoutUtility.GetLastRect()); // Store position + ConnectionSourceNames.Add("DetailNormalStrength"); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); @@ -695,10 +1049,12 @@ public override void OnInspectorGUI() { t.Specular[i] = t.Specular[Selected]; t.AlphaCutoff[i] = t.AlphaCutoff[Selected]; t.NormalStrength[i] = t.NormalStrength[Selected]; + t.DetailNormalStrength[i] = t.DetailNormalStrength[Selected]; t.BlendColor[i] = t.BlendColor[Selected]; t.BlendFactor[i] = t.BlendFactor[Selected]; t.MainTexScaleOffset[i] = t.MainTexScaleOffset[Selected]; t.SecondaryAlbedoTexScaleOffset[i] = t.SecondaryAlbedoTexScaleOffset[Selected]; + t.SecondaryNormalTexScaleOffset[i] = t.SecondaryNormalTexScaleOffset[Selected]; t.SecondaryTextureScale[i] = t.SecondaryTextureScale[Selected]; t.Rotation[i] = t.Rotation[Selected]; t.Flags[i] = Flag; @@ -706,6 +1062,7 @@ public override void OnInspectorGUI() { t.KelvinTemp[i] = t.KelvinTemp[Selected]; t.ColorBleed[i] = t.ColorBleed[Selected]; t.AlbedoBlendFactor[i] = t.AlbedoBlendFactor[Selected]; + t.SecondaryNormalTexBlend[i] = t.SecondaryNormalTexBlend[Selected]; // Debug.Log(i); t.CallMaterialEdited(true); } @@ -746,10 +1103,12 @@ public override void OnInspectorGUI() { Obj.Specular[i] = t.Specular[Selected]; Obj.AlphaCutoff[i] = t.AlphaCutoff[Selected]; Obj.NormalStrength[i] = t.NormalStrength[Selected]; + Obj.DetailNormalStrength[i] = t.DetailNormalStrength[Selected]; Obj.BlendColor[i] = t.BlendColor[Selected]; Obj.BlendFactor[i] = t.BlendFactor[Selected]; Obj.MainTexScaleOffset[i] = t.MainTexScaleOffset[Selected]; Obj.SecondaryAlbedoTexScaleOffset[i] = t.SecondaryAlbedoTexScaleOffset[Selected]; + Obj.SecondaryNormalTexScaleOffset[i] = t.SecondaryNormalTexScaleOffset[Selected]; Obj.SecondaryTextureScale[i] = t.SecondaryTextureScale[Selected]; Obj.Rotation[i] = t.Rotation[Selected]; Obj.Flags[i] = Flag; @@ -757,6 +1116,7 @@ public override void OnInspectorGUI() { Obj.KelvinTemp[i] = t.KelvinTemp[Selected]; Obj.ColorBleed[i] = t.ColorBleed[Selected]; Obj.AlbedoBlendFactor[i] = t.AlbedoBlendFactor[Selected]; + Obj.SecondaryNormalTexBlend[i] = t.SecondaryNormalTexBlend[Selected]; Obj.CallMaterialEdited(true); } } diff --git a/TrueTrace/Models/1sponza (2)/Materials/fabric_f.mat b/TrueTrace/Models/1sponza (2)/Materials/fabric_f.mat index 39dd0098..17408961 100644 --- a/TrueTrace/Models/1sponza (2)/Materials/fabric_f.mat +++ b/TrueTrace/Models/1sponza (2)/Materials/fabric_f.mat @@ -41,7 +41,7 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MainTex: - m_Texture: {fileID: 2800000, guid: b73406b81b6cd484181dedc3f25e648f, type: 3} + m_Texture: {fileID: 2800000, guid: 2fd9297c087b1334195e475b89ed03cf, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MetallicGlossMap: diff --git a/TrueTrace/Models/1sponza (2)/Materials/fabric_g.mat b/TrueTrace/Models/1sponza (2)/Materials/fabric_g.mat index ec013d22..05b4b7de 100644 --- a/TrueTrace/Models/1sponza (2)/Materials/fabric_g.mat +++ b/TrueTrace/Models/1sponza (2)/Materials/fabric_g.mat @@ -41,7 +41,7 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MainTex: - m_Texture: {fileID: 2800000, guid: 2fd9297c087b1334195e475b89ed03cf, type: 3} + m_Texture: {fileID: 2800000, guid: b73406b81b6cd484181dedc3f25e648f, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MetallicGlossMap: diff --git a/TrueTrace/Resources/AssetManager.cs b/TrueTrace/Resources/AssetManager.cs index 9df75ab3..d415e34a 100644 --- a/TrueTrace/Resources/AssetManager.cs +++ b/TrueTrace/Resources/AssetManager.cs @@ -24,7 +24,7 @@ public class AssetManager : MonoBehaviour public int BindlessTextureCount; [HideInInspector] public Texture2D IESAtlas; [HideInInspector] public Texture2D AlbedoAtlas; - [HideInInspector] public Texture2D NormalAtlas; + public Texture2D NormalAtlas; [HideInInspector] public Texture2D SingleComponentAtlas; [HideInInspector] public Texture2D EmissiveAtlas; [HideInInspector] public Texture2D AlphaAtlas; @@ -40,10 +40,12 @@ public class AssetManager : MonoBehaviour private int NodeInitializerKernel; private int LightTLASRefitKernel; - + private float luminance(float r, float g, float b) { return 0.299f * r + 0.587f * g + 0.114f * b; } [HideInInspector] public int AlbedoAtlasSize; [HideInInspector] public int IESAtlasSize; + [HideInInspector] public LightBVHTransform[] LightBVHTransforms; + [HideInInspector] public GaussianTreeNode[] SGTree; [HideInInspector] public List MaterialsChanged; @@ -51,7 +53,8 @@ public class AssetManager : MonoBehaviour [HideInInspector] public ComputeBuffer BVH8AggregatedBuffer; [HideInInspector] public ComputeBuffer AggTriBuffer; [HideInInspector] public ComputeBuffer LightTriBuffer; - [HideInInspector] public ComputeBuffer LightNodeBuffer; + [HideInInspector] public ComputeBuffer LightTreeBufferA; + [HideInInspector] public ComputeBuffer LightTreeBufferB; [HideInInspector] public List MyMeshesCompacted; [HideInInspector] public List UnityLights; [HideInInspector] public InstancedManager InstanceData; @@ -64,7 +67,8 @@ public class AssetManager : MonoBehaviour [HideInInspector] public bool DoHeightmap; [HideInInspector] public ComputeBuffer MaterialBuffer; - [HideInInspector] public ComputeBuffer MeshDataBuffer; + [HideInInspector] public ComputeBuffer MeshDataBufferA; + [HideInInspector] public ComputeBuffer MeshDataBufferB; [HideInInspector] public ComputeBuffer LightMeshBuffer; [HideInInspector] public ComputeBuffer UnityLightBuffer; @@ -77,7 +81,8 @@ public void SetMeshTraceBuffers(ComputeShader ThisShader, int Kernel) { ThisShader.SetComputeBuffer(Kernel, "TLASBVH8Indices", TLASCWBVHIndexes); ThisShader.SetComputeBuffer(Kernel, "AggTris", AggTriBuffer); ThisShader.SetComputeBuffer(Kernel, "cwbvh_nodes", BVH8AggregatedBuffer); - ThisShader.SetComputeBuffer(Kernel, "_MeshData", MeshDataBuffer); + ThisShader.SetComputeBuffer(Kernel, "_MeshData", RayMaster.FramesSinceStart2 % 2 == 0 ? MeshDataBufferA : MeshDataBufferB); + ThisShader.SetComputeBuffer(Kernel, "_MeshDataPrev", RayMaster.FramesSinceStart2 % 2 == 1 ? MeshDataBufferA : MeshDataBufferB); ThisShader.SetComputeBuffer(Kernel, "_Materials", MaterialBuffer); ThisShader.SetTexture(Kernel, "_AlphaAtlas", AlphaAtlas); ThisShader.SetTexture(Kernel, "_IESAtlas", IESAtlas); @@ -99,9 +104,10 @@ public void SetHeightmapTraceBuffers(ComputeShader ThisShader, int Kernel) { public void SetLightData(ComputeShader ThisShader, int Kernel) { ThisShader.SetComputeBuffer(Kernel, "_UnityLights", UnityLightBuffer); - ThisShader.SetComputeBuffer(Kernel, "LightNodes", LightNodeBuffer); ThisShader.SetComputeBuffer(Kernel, "LightTriangles", LightTriBuffer); ThisShader.SetComputeBuffer(Kernel, "_LightMeshes", LightMeshBuffer); + ThisShader.SetComputeBuffer(Kernel, "SGTree", RayMaster.FramesSinceStart2 % 2 == 0 ? LightTreeBufferA : LightTreeBufferB); + ThisShader.SetComputeBuffer(Kernel, "SGTreePrev", RayMaster.FramesSinceStart2 % 2 == 1 ? LightTreeBufferA : LightTreeBufferB); ThisShader.SetTexture(Kernel, "Heightmap", HeightmapAtlas); } @@ -109,7 +115,7 @@ public void SetLightData(ComputeShader ThisShader, int Kernel) { private int TriangleBufferKernel; private int NodeBufferKernel; private int LightBufferKernel; - private int LightNodeBufferKernel; + private int LightTreeNodeBufferKernel; [HideInInspector] public List RenderTransforms; [HideInInspector] public List RenderQue; @@ -135,6 +141,7 @@ public void SetLightData(ComputeShader ThisShader, int Kernel) { [HideInInspector] public AABB[] MeshAABBs; [HideInInspector] public LightBounds[] LightAABBs; + [HideInInspector] public GaussianTreeNode[] SGTreeNodes; [HideInInspector] public bool ParentCountHasChanged; @@ -165,11 +172,12 @@ public void SetLightData(ComputeShader ThisShader, int Kernel) { #endif public void ClearAll() {//My attempt at clearing memory - RunningTasks = 0; + // RunningTasks = 0; ParentObject[] ChildrenObjects = this.GetComponentsInChildren(); foreach (ParentObject obj in ChildrenObjects) obj.ClearAll(); CommonFunctions.DeepClean(ref _Materials); + CommonFunctions.DeepClean(ref SGTreeNodes); CommonFunctions.DeepClean(ref LightTransforms); CommonFunctions.DeepClean(ref LightMeshes); CommonFunctions.DeepClean(ref MyMeshesCompacted); @@ -186,12 +194,14 @@ public void ClearAll() TerrainBuffer.ReleaseSafe(); LightTriBuffer.ReleaseSafe(); - LightNodeBuffer.ReleaseSafe(); + LightTreeBufferA.ReleaseSafe(); + LightTreeBufferB.ReleaseSafe(); BVH8AggregatedBuffer.ReleaseSafe(); AggTriBuffer.ReleaseSafe(); MaterialBuffer.ReleaseSafe(); - MeshDataBuffer.ReleaseSafe(); + MeshDataBufferA.ReleaseSafe(); + MeshDataBufferB.ReleaseSafe(); LightMeshBuffer.ReleaseSafe(); UnityLightBuffer.ReleaseSafe(); @@ -234,6 +244,7 @@ private void PackAndCompactBindless(Dictionary DictTex, PackingRect case 7: _Materials[SelectedTex.TexObjList[j].x].MatCapTex = VectoredTexIndex; break; case 9: _Materials[SelectedTex.TexObjList[j].x].SecondaryAlbedoTex = VectoredTexIndex; break; case 10: _Materials[SelectedTex.TexObjList[j].x].SecondaryAlbedoMask = VectoredTexIndex; break; + case 11: _Materials[SelectedTex.TexObjList[j].x].SecondaryNormalTex = VectoredTexIndex; break; default: break; } } @@ -351,7 +362,8 @@ private void PackAndCompact(Dictionary DictTex, ref RenderTexture A for(int j = 0; j < ListLength; j++) { switch (TexIndex) { case 2: - _Materials[SelectedTex.TexObjList[j].x].NormalTex = PackRect(RectSelect); + if(TempRect.TexType == 1) _Materials[SelectedTex.TexObjList[j].x].NormalTex = PackRect(RectSelect); + else if(TempRect.TexType == 11) _Materials[SelectedTex.TexObjList[j].x].SecondaryNormalTex = PackRect(RectSelect); break; case 4: if(TempRect.TexType == 4) _Materials[SelectedTex.TexObjList[j].x].MetallicTex = PackRect(RectSelect); @@ -545,6 +557,7 @@ private void CreateAtlas(int TotalMatCount, CommandBuffer cmd) {//Creates textur #if !DX11Only && !UseAtlas if(TempMat.AlbedoTex.x != 0) KeyCheck(MatCount, Obj.AlbedoTexs[(int)TempMat.AlbedoTex.x-1], ref BindlessDict, ref BindlessRect, 4, 0); if(TempMat.NormalTex.x != 0) KeyCheck(MatCount, Obj.NormalTexs[(int)TempMat.NormalTex.x-1], ref BindlessDict, ref BindlessRect, 4, 1); + if(TempMat.SecondaryNormalTex.x != 0) KeyCheck(MatCount, Obj.SecondaryNormalTexs[(int)TempMat.SecondaryNormalTex.x-1], ref BindlessDict, ref BindlessRect, 4, 11); if(TempMat.EmissiveTex.x != 0) KeyCheck(MatCount, Obj.EmissionTexs[(int)TempMat.EmissiveTex.x-1], ref BindlessDict, ref BindlessRect, 4, 2); if(TempMat.AlphaTex.x != 0) KeyCheck(MatCount, Obj.AlphaTexs[(int)TempMat.AlphaTex.x-1], ref BindlessDict, ref BindlessRect, Obj.AlphaTexChannelIndex[(int)TempMat.AlphaTex.x-1], 3); if(TempMat.MetallicTex.x != 0) KeyCheck(MatCount, Obj.MetallicTexs[(int)TempMat.MetallicTex.x-1], ref BindlessDict, ref BindlessRect, Obj.MetallicTexChannelIndex[(int)TempMat.MetallicTex.x-1], 4); @@ -556,6 +569,7 @@ private void CreateAtlas(int TotalMatCount, CommandBuffer cmd) {//Creates textur #else if(TempMat.AlbedoTex.x != 0) KeyCheck(MatCount, Obj.AlbedoTexs[(int)TempMat.AlbedoTex.x-1], ref AlbTextures, ref AlbRect, 0, 0); if(TempMat.NormalTex.x != 0) KeyCheck(MatCount, Obj.NormalTexs[(int)TempMat.NormalTex.x-1], ref NormTextures, ref NormRect, 0, 1); + if(TempMat.SecondaryNormalTex.x != 0) KeyCheck(MatCount, Obj.SecondaryNormalTexs[(int)TempMat.SecondaryNormalTex.x-1], ref NormTextures, ref NormRect, 0, 11); if(TempMat.EmissiveTex.x != 0) KeyCheck(MatCount, Obj.EmissionTexs[(int)TempMat.EmissiveTex.x-1], ref EmisTextures, ref EmisRect, 0, 2); if(TempMat.AlphaTex.x != 0) KeyCheck(MatCount, Obj.AlphaTexs[(int)TempMat.AlphaTex.x-1], ref AlphTextures, ref AlphRect, Obj.AlphaTexChannelIndex[(int)TempMat.AlphaTex.x-1], 3); if(TempMat.MetallicTex.x != 0) KeyCheck(MatCount, Obj.MetallicTexs[(int)TempMat.MetallicTex.x-1], ref SingleComponentTexture, ref SingleComponentRect, Obj.MetallicTexChannelIndex[(int)TempMat.MetallicTex.x-1], 4); @@ -580,6 +594,7 @@ private void CreateAtlas(int TotalMatCount, CommandBuffer cmd) {//Creates textur #if !DX11Only && !UseAtlas if(TempMat.AlbedoTex.x != 0) KeyCheck(MatCount, Obj.AlbedoTexs[(int)TempMat.AlbedoTex.x-1], ref BindlessDict, ref BindlessRect, 4, 0); if(TempMat.NormalTex.x != 0) KeyCheck(MatCount, Obj.NormalTexs[(int)TempMat.NormalTex.x-1], ref BindlessDict, ref BindlessRect, 4, 1); + if(TempMat.SecondaryNormalTex.x != 0) KeyCheck(MatCount, Obj.SecondaryNormalTexs[(int)TempMat.SecondaryNormalTex.x-1], ref BindlessDict, ref BindlessRect, 4, 11); if(TempMat.EmissiveTex.x != 0) KeyCheck(MatCount, Obj.EmissionTexs[(int)TempMat.EmissiveTex.x-1], ref BindlessDict, ref BindlessRect, 4, 2); if(TempMat.AlphaTex.x != 0) KeyCheck(MatCount, Obj.AlphaTexs[(int)TempMat.AlphaTex.x-1], ref BindlessDict, ref BindlessRect, Obj.AlphaTexChannelIndex[(int)TempMat.AlphaTex.x-1], 3); if(TempMat.MetallicTex.x != 0) KeyCheck(MatCount, Obj.MetallicTexs[(int)TempMat.MetallicTex.x-1], ref BindlessDict, ref BindlessRect, Obj.MetallicTexChannelIndex[(int)TempMat.MetallicTex.x-1], 4); @@ -591,6 +606,7 @@ private void CreateAtlas(int TotalMatCount, CommandBuffer cmd) {//Creates textur #else if(TempMat.AlbedoTex.x != 0) KeyCheck(MatCount, Obj.AlbedoTexs[(int)TempMat.AlbedoTex.x-1], ref AlbTextures, ref AlbRect, 0, 0); if(TempMat.NormalTex.x != 0) KeyCheck(MatCount, Obj.NormalTexs[(int)TempMat.NormalTex.x-1], ref NormTextures, ref NormRect, 0, 1); + if(TempMat.SecondaryNormalTex.x != 0) KeyCheck(MatCount, Obj.SecondaryNormalTexs[(int)TempMat.SecondaryNormalTex.x-1], ref NormTextures, ref NormRect, 0, 11); if(TempMat.EmissiveTex.x != 0) KeyCheck(MatCount, Obj.EmissionTexs[(int)TempMat.EmissiveTex.x-1], ref EmisTextures, ref EmisRect, 0, 2); if(TempMat.AlphaTex.x != 0) KeyCheck(MatCount, Obj.AlphaTexs[(int)TempMat.AlphaTex.x-1], ref AlphTextures, ref AlphRect, Obj.AlphaTexChannelIndex[(int)TempMat.AlphaTex.x-1], 3); if(TempMat.MetallicTex.x != 0) KeyCheck(MatCount, Obj.MetallicTexs[(int)TempMat.MetallicTex.x-1], ref SingleComponentTexture, ref SingleComponentRect, Obj.MetallicTexChannelIndex[(int)TempMat.MetallicTex.x-1], 4); @@ -769,8 +785,12 @@ void OnSceneLoaded(Scene scene, LoadSceneMode mode) { public void ForceUpdateAtlas() { int throwaway = 0; - // for(int i = 0; i < RenderQue.Count; i++) RenderQue[i].CreateAtlas(ref throwaway); - // CreateAtlas(throwaway); + CommandBuffer tempcmd = new CommandBuffer(); + for(int i = 0; i < RenderQue.Count; i++) RenderQue[i].CreateAtlas(ref throwaway); + CreateAtlas(throwaway, tempcmd); + Graphics.ExecuteCommandBuffer(tempcmd); + tempcmd.Clear(); + tempcmd.Release(); } public void OnApplicationQuit() { @@ -780,7 +800,8 @@ public void OnApplicationQuit() { #endif LightTriBuffer.ReleaseSafe(); - LightNodeBuffer.ReleaseSafe(); + LightTreeBufferA.ReleaseSafe(); + LightTreeBufferB.ReleaseSafe(); BVH8AggregatedBuffer.ReleaseSafe(); AggTriBuffer.ReleaseSafe(); @@ -868,7 +889,11 @@ private void init() { UpdateMaterialDefinition(); Refitter = Resources.Load("Utility/BVHRefitter"); - LightTLASRefitKernel = Refitter.FindKernel("TLASLightRefitKernel"); +#if !DontUseSGTree + LightTLASRefitKernel = Refitter.FindKernel("TLASSGTreeRefitKernel"); +#else + LightTLASRefitKernel = Refitter.FindKernel("TLASLightBVHRefitKernel"); +#endif RefitLayer = Refitter.FindKernel("RefitBVHLayer"); NodeUpdater = Refitter.FindKernel("NodeUpdate"); NodeCompress = Refitter.FindKernel("NodeCompress"); @@ -902,14 +927,19 @@ private void init() { UnityLightCount = 0; TerrainInfos = new List(); LightTriBuffer.ReleaseSafe(); - LightNodeBuffer.ReleaseSafe(); + LightTreeBufferA.ReleaseSafe(); + LightTreeBufferB.ReleaseSafe(); BVH8AggregatedBuffer.ReleaseSafe(); AggTriBuffer.ReleaseSafe(); MeshFunctions = Resources.Load("Utility/GeneralMeshFunctions"); TriangleBufferKernel = MeshFunctions.FindKernel("CombineTriBuffers"); NodeBufferKernel = MeshFunctions.FindKernel("CombineNodeBuffers"); LightBufferKernel = MeshFunctions.FindKernel("CombineLightBuffers"); - LightNodeBufferKernel = MeshFunctions.FindKernel("CombineLightNodes"); +#if !DontUseSGTree + LightTreeNodeBufferKernel = MeshFunctions.FindKernel("CombineSGTreeNodes"); +#else + LightTreeNodeBufferKernel = MeshFunctions.FindKernel("CombineLightNodes"); +#endif if (Terrains.Count != 0) for (int i = 0; i < Terrains.Count; i++) Terrains[i].Load(); } @@ -1093,6 +1123,7 @@ public void EditorBuild() { var CurrentRep = i; BuildQue[CurrentRep].LoadData(); + // BuildQue[CurrentRep].BuildTotal(); BuildQue[CurrentRep].AsyncTask = Task.Run(() => { BuildQue[CurrentRep].BuildTotal(); RunningTasks--; }); BuildQue[CurrentRep].ExistsInQue = 1; BuildQue[CurrentRep].QueInProgress = 1; @@ -1157,14 +1188,18 @@ private void AccumulateData(CommandBuffer cmd) int LightTriCount = 0; int CurTriOffset = 0; int CurLightTriOffset = 0; - int CurLightNodeOffset = 0; + int CurSGNodeOffset = 0; TotalParentObjectSize = 0; LightMeshCount = 0; LightMeshes.Clear(); LightTransforms.Clear(); int TotalMatCount = 0; - int AggLightNodeCount = 0; - for(int i = 0; i < ParentsLength; i++) if (RenderQue[i].LightTriangles.Count != 0) {LightMeshCount++; AggLightNodeCount += RenderQue[i].LBVH.nodes.Length;} + int AggSGTreeNodeCount = 0; +#if !DontUseSGTree + for(int i = 0; i < ParentsLength; i++) if (RenderQue[i].LightTriangles.Count != 0) {LightMeshCount++; AggSGTreeNodeCount += RenderQue[i].LBVH.SGTree.Length;} +#else + for(int i = 0; i < ParentsLength; i++) if (RenderQue[i].LightTriangles.Count != 0) {LightMeshCount++; AggSGTreeNodeCount += RenderQue[i].LBVH.nodes.Length;} +#endif for (int i = 0; i < InstanceRenderQue.Count; i++) {if (InstanceRenderQue[i].InstanceParent.LightTriangles.Count != 0) LightMeshCount++;} @@ -1174,7 +1209,8 @@ private void AccumulateData(CommandBuffer cmd) BVH8AggregatedBuffer.Release(); AggTriBuffer.Release(); LightTriBuffer.Release(); - if(LightNodeBuffer == null) LightNodeBuffer.Release(); + if(LightTreeBufferA != null) LightTreeBufferA.Release(); + if(LightTreeBufferB != null) LightTreeBufferB.Release(); } for (int i = 0; i < ParentsLength; i++) { @@ -1189,31 +1225,50 @@ private void AccumulateData(CommandBuffer cmd) AggNodeCount += InstanceData.RenderQue[i].AggNodes.Length; AggTriCount += InstanceData.RenderQue[i].AggTriangles.Length; LightTriCount += InstanceData.RenderQue[i].LightTriangles.Count; - if (InstanceData.RenderQue[i].LightTriangles.Count != 0) AggLightNodeCount += InstanceData.RenderQue[i].LBVH.nodes.Length; +#if !DontUseSGTree + if (InstanceData.RenderQue[i].LightTriangles.Count != 0) AggSGTreeNodeCount += InstanceData.RenderQue[i].LBVH.SGTree.Length; +#else + if (InstanceData.RenderQue[i].LightTriangles.Count != 0) AggSGTreeNodeCount += InstanceData.RenderQue[i].LBVH.nodes.Length; +#endif } - CurLightNodeOffset = 2 * (LightMeshCount); - AggLightNodeCount += CurLightNodeOffset; + CurSGNodeOffset = 2 * (LightMeshCount); + AggSGTreeNodeCount += CurSGNodeOffset; Debug.Log("Light Tri Count: " + LightTriCount); Debug.Log("Total Tri Count: " + AggTriCount); - if(LightTriCount == 0) {LightTriCount++; AggLightNodeCount++;} + if(LightTriCount == 0) {LightTriCount++; AggSGTreeNodeCount++;} if (AggNodeCount != 0) {//Accumulate the BVH nodes and triangles for all normal models LightAABBs = new LightBounds[LightMeshCount]; + SGTreeNodes = new GaussianTreeNode[LightMeshCount]; + SGTree = new GaussianTreeNode[LightMeshCount * 2]; CommonFunctions.CreateDynamicBuffer(ref BVH8AggregatedBuffer, AggNodeCount, 80); CommonFunctions.CreateDynamicBuffer(ref AggTriBuffer, AggTriCount, 88); - CommonFunctions.CreateDynamicBuffer(ref LightTriBuffer, LightTriCount, 44); - CommonFunctions.CreateDynamicBuffer(ref LightNodeBuffer, AggLightNodeCount, 40); + CommonFunctions.CreateDynamicBuffer(ref LightTriBuffer, LightTriCount, CommonFunctions.GetStride()); +#if !DontUseSGTree + CommonFunctions.CreateDynamicBuffer(ref LightTreeBufferA, AggSGTreeNodeCount, CommonFunctions.GetStride()); + CommonFunctions.CreateDynamicBuffer(ref LightTreeBufferB, AggSGTreeNodeCount, CommonFunctions.GetStride()); +#else + CommonFunctions.CreateDynamicBuffer(ref LightTreeBufferA, AggSGTreeNodeCount, CommonFunctions.GetStride()); + CommonFunctions.CreateDynamicBuffer(ref LightTreeBufferB, AggSGTreeNodeCount, CommonFunctions.GetStride()); +#endif MeshFunctions.SetBuffer(TriangleBufferKernel, "OutCudaTriArray", AggTriBuffer); MeshFunctions.SetBuffer(NodeBufferKernel, "OutAggNodes", BVH8AggregatedBuffer); MeshFunctions.SetBuffer(LightBufferKernel, "LightTrianglesOut", LightTriBuffer); - MeshFunctions.SetBuffer(LightNodeBufferKernel, "LightNodesOut", LightNodeBuffer); +#if !DontUseSGTree + MeshFunctions.SetBuffer(LightTreeNodeBufferKernel, "SGNodesOut", LightTreeBufferA); + MeshFunctions.SetBuffer(LightTreeNodeBufferKernel, "SGNodesOut2", LightTreeBufferB); +#else + MeshFunctions.SetBuffer(LightTreeNodeBufferKernel, "LightNodesOut", LightTreeBufferA); + MeshFunctions.SetBuffer(LightTreeNodeBufferKernel, "LightNodesOut2", LightTreeBufferB); +#endif int MatOffset = 0; int CurLightMesh = 0; for (int i = 0; i < ParentsLength; i++) { RenderQue[i].UpdateData(); + // cmd.BeginSample("AccumBufferTri"); cmd.SetComputeIntParam(MeshFunctions, "Offset", CurTriOffset); cmd.SetComputeIntParam(MeshFunctions, "Count", RenderQue[i].TriBuffer.count); @@ -1235,11 +1290,16 @@ private void AccumulateData(CommandBuffer cmd) cmd.SetComputeBufferParam(MeshFunctions, LightBufferKernel, "LightTrianglesIn", RenderQue[i].LightTriBuffer); cmd.DispatchCompute(MeshFunctions, LightBufferKernel, (int)Mathf.Ceil(RenderQue[i].LightTriBuffer.count / 372.0f), 1, 1); - cmd.SetComputeIntParam(MeshFunctions, "Offset", CurLightNodeOffset); - cmd.SetComputeIntParam(MeshFunctions, "Count", RenderQue[i].LightNodeBuffer.count); - cmd.SetComputeBufferParam(MeshFunctions, LightNodeBufferKernel, "LightNodesIn", RenderQue[i].LightNodeBuffer); - cmd.DispatchCompute(MeshFunctions, LightNodeBufferKernel, (int)Mathf.Ceil(RenderQue[i].LightNodeBuffer.count / 372.0f), 1, 1); - + cmd.SetComputeIntParam(MeshFunctions, "Offset", CurSGNodeOffset); + cmd.SetComputeIntParam(MeshFunctions, "Count", RenderQue[i].LightTreeBuffer.count); +#if !DontUseSGTree + cmd.SetComputeBufferParam(MeshFunctions, LightTreeNodeBufferKernel, "SGNodesIn", RenderQue[i].LightTreeBuffer); +#else + cmd.SetComputeBufferParam(MeshFunctions, LightTreeNodeBufferKernel, "LightNodesIn", RenderQue[i].LightTreeBuffer); +#endif + cmd.DispatchCompute(MeshFunctions, LightTreeNodeBufferKernel, (int)Mathf.Ceil(RenderQue[i].LightTreeBuffer.count / 372.0f), 1, 1); + + LightTransforms.Add(RenderTransforms[i]); LightMeshes.Add(new LightMeshData() { @@ -1250,6 +1310,11 @@ private void AccumulateData(CommandBuffer cmd) }); try { +#if !DontUseSGTree + SGTreeNodes[CurLightMesh] = RenderQue[i].LBVH.SGTree[0]; +#endif + + LightAABBs[CurLightMesh].LightCount = RenderQue[i].LBVH.ParentBound.aabb.LightCount; LightAABBs[CurLightMesh].phi = RenderQue[i].LBVH.ParentBound.aabb.phi; LightAABBs[CurLightMesh].cosTheta_o = RenderQue[i].LBVH.ParentBound.aabb.cosTheta_o; LightAABBs[CurLightMesh].cosTheta_e = RenderQue[i].LBVH.ParentBound.aabb.cosTheta_e; @@ -1257,8 +1322,12 @@ private void AccumulateData(CommandBuffer cmd) RenderQue[i].LightTriOffset = CurLightTriOffset; - RenderQue[i].LightNodeOffset = CurLightNodeOffset; - CurLightNodeOffset += RenderQue[i].LBVH.nodes.Length; + RenderQue[i].LightNodeOffset = CurSGNodeOffset; +#if !DontUseSGTree + CurSGNodeOffset += RenderQue[i].LBVH.SGTree.Length; +#else + CurSGNodeOffset += RenderQue[i].LBVH.nodes.Length; +#endif CurLightTriOffset += RenderQue[i].LightTriangles.Count; TotalParentObjectSize += RenderQue[i].LightTriBuffer.count * RenderQue[i].LightTriBuffer.stride; CurLightMesh++; @@ -1296,18 +1365,26 @@ private void AccumulateData(CommandBuffer cmd) cmd.SetComputeIntParam(MeshFunctions, "Count", InstanceData.RenderQue[i].LightTriBuffer.count); cmd.SetComputeBufferParam(MeshFunctions, LightBufferKernel, "LightTrianglesIn", InstanceData.RenderQue[i].LightTriBuffer); cmd.DispatchCompute(MeshFunctions, LightBufferKernel, (int)Mathf.Ceil(InstanceData.RenderQue[i].LightTriBuffer.count / 372.0f), 1, 1); - - cmd.SetComputeIntParam(MeshFunctions, "Offset", CurLightNodeOffset); - cmd.SetComputeIntParam(MeshFunctions, "Count", InstanceData.RenderQue[i].LightNodeBuffer.count); - cmd.SetComputeBufferParam(MeshFunctions, LightNodeBufferKernel, "LightNodesIn", InstanceData.RenderQue[i].LightNodeBuffer); - cmd.DispatchCompute(MeshFunctions, LightNodeBufferKernel, (int)Mathf.Ceil(InstanceData.RenderQue[i].LightNodeBuffer.count / 372.0f), 1, 1); + + cmd.SetComputeIntParam(MeshFunctions, "Offset", CurSGNodeOffset); + cmd.SetComputeIntParam(MeshFunctions, "Count", InstanceData.RenderQue[i].LightTreeBuffer.count); +#if !DontUseSGTree + cmd.SetComputeBufferParam(MeshFunctions, LightTreeNodeBufferKernel, "SGNodesIn", InstanceData.RenderQue[i].LightTreeBuffer); +#else + cmd.SetComputeBufferParam(MeshFunctions, LightTreeNodeBufferKernel, "LightNodesIn", InstanceData.RenderQue[i].LightTreeBuffer); +#endif + cmd.DispatchCompute(MeshFunctions, LightTreeNodeBufferKernel, (int)Mathf.Ceil(InstanceData.RenderQue[i].LightTreeBuffer.count / 372.0f), 1, 1); InstanceData.RenderQue[i].LightTriOffset = CurLightTriOffset; CurLightTriOffset += InstanceData.RenderQue[i].LightTriangles.Count; InstanceData.RenderQue[i].LightEndIndex = CurLightTriOffset; - InstanceData.RenderQue[i].LightNodeOffset = CurLightNodeOffset; - CurLightNodeOffset += InstanceData.RenderQue[i].LBVH.nodes.Length; + InstanceData.RenderQue[i].LightNodeOffset = CurSGNodeOffset; +#if !DontUseSGTree + CurSGNodeOffset += InstanceData.RenderQue[i].LBVH.SGTree.Length; +#else + CurSGNodeOffset += InstanceData.RenderQue[i].LBVH.nodes.Length; +#endif } InstanceData.RenderQue[i].NodeOffset = CurNodeOffset; @@ -1328,6 +1405,11 @@ private void AccumulateData(CommandBuffer cmd) IndexEnd = InstanceRenderQue[i].InstanceParent.LightEndIndex }); +#if !DontUseSGTree + SGTreeNodes[CurLightMesh] = InstanceRenderQue[i].InstanceParent.LBVH.SGTree[0]; +#endif + + LightAABBs[CurLightMesh].LightCount = InstanceRenderQue[i].InstanceParent.LBVH.ParentBound.aabb.LightCount; LightAABBs[CurLightMesh].phi = InstanceRenderQue[i].InstanceParent.LBVH.ParentBound.aabb.phi; LightAABBs[CurLightMesh].cosTheta_o = InstanceRenderQue[i].InstanceParent.LBVH.ParentBound.aabb.cosTheta_o; LightAABBs[CurLightMesh].cosTheta_e = InstanceRenderQue[i].InstanceParent.LBVH.ParentBound.aabb.cosTheta_e; @@ -1349,7 +1431,7 @@ private void AccumulateData(CommandBuffer cmd) if (UseSkinning && didstart) { for (int i = 0; i < ParentsLength; i++) {//Refit BVH's of skinned meshes if (RenderQue[i].IsSkinnedGroup || RenderQue[i].IsDeformable) { - RenderQue[i].RefitMesh(ref BVH8AggregatedBuffer, ref AggTriBuffer, ref LightTriBuffer, ref LightNodeBuffer, cmd); + RenderQue[i].RefitMesh(ref BVH8AggregatedBuffer, ref AggTriBuffer, ref LightTriBuffer, RayMaster.FramesSinceStart2 % 2 == 0 ? LightTreeBufferA : LightTreeBufferB, cmd); if(i < MyMeshesCompacted.Count) { MyMeshDataCompacted TempMesh2 = MyMeshesCompacted[i]; TempMesh2.Transform = RenderTransforms[i].worldToLocalMatrix; @@ -1449,12 +1531,7 @@ unsafe public void DocumentNodes(int CurrentNode, int ParentNode, int NextNode, ComputeBuffer BVHDataBuffer; ComputeBuffer LightBVHTransformsBuffer; - [System.Serializable] - public struct LightBVHTransform { - public Matrix4x4 Transform; - public int SolidOffset; - } - [HideInInspector] public LightBVHTransform[] LightBVHTransforms; + unsafe public void ConstructNewTLAS() { #if HardwareRT @@ -1464,11 +1541,10 @@ unsafe public void ConstructNewTLAS() { MeshOffsets = new List(); AccelStruct.ClearInstances(); for(int i = 0; i < RenderQue.Count; i++) { - RenderQue[i].HWRTIndex = new List(); foreach(var A in RenderQue[i].Renderers) { MeshOffsets.Add(new Vector2(SubMeshOffsets.Count, i)); var B2 = A.gameObject; - Mesh mesh = new Mesh(); + Mesh mesh = null; if(B2.TryGetComponent(out MeshFilter TempFilter)) mesh = TempFilter.sharedMesh; else if(B2.TryGetComponent(out SkinnedMeshRenderer TempSkin)) mesh = TempSkin.sharedMesh; int SubMeshCount = mesh.subMeshCount; @@ -1607,7 +1683,6 @@ unsafe async void CorrectRefit(AABB[] Boxes) { return; } ComputeBuffer BoxesBuffer; - ComputeBuffer LightBoxesBuffer; int CurFrame = 0; int BVHNodeCount = 0; LightBVHBuilder LBVH; @@ -1627,9 +1702,16 @@ public unsafe void RefitTLAS(AABB[] Boxes, CommandBuffer cmd) LBVH.WorkingSet[i].ReleaseSafe(); } } - LBVH = new LightBVHBuilder(LightAABBs); - LightNodeBuffer.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); + LBVH = new LightBVHBuilder(LightAABBs, ref SGTree, LightBVHTransforms, SGTreeNodes); +#if !DontUseSGTree + LightTreeBufferA.SetData(SGTree, 0, 0, SGTree.Length); + LightTreeBufferB.SetData(SGTree, 0, 0, SGTree.Length); +#else + LightTreeBufferA.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); + LightTreeBufferB.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); +#endif } + if(WorkingBuffer != null) for(int i = 0; i < WorkingBuffer.Length; i++) WorkingBuffer[i]?.Release(); if (NodeBuffer != null) NodeBuffer.Release(); if (StackBuffer != null) StackBuffer.Release(); @@ -1713,8 +1795,14 @@ public unsafe void RefitTLAS(AABB[] Boxes, CommandBuffer cmd) if(CurFrame % 25 == 24) { if(LightMeshCount > 0) { - LBVH = new LightBVHBuilder(LightAABBs); - LightNodeBuffer.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); + LBVH = new LightBVHBuilder(LightAABBs, ref SGTree, LightBVHTransforms, SGTreeNodes); +#if !DontUseSGTree + LightTreeBufferA.SetData(SGTree, 0, 0, SGTree.Length); + LightTreeBufferB.SetData(SGTree, 0, 0, SGTree.Length); +#else + LightTreeBufferA.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); + LightTreeBufferB.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); +#endif } LightBVHTransformsBuffer.ReleaseSafe(); if(LightBVHTransforms.Length != 0) { @@ -1726,12 +1814,13 @@ public unsafe void RefitTLAS(AABB[] Boxes, CommandBuffer cmd) #endif if(LightAABBs != null && LightAABBs.Length != 0) { LightBVHTransformsBuffer.SetData(LightBVHTransforms); - if(LightBoxesBuffer == null || LightBoxesBuffer.count != LightAABBs.Length) LightBoxesBuffer = new ComputeBuffer(LightAABBs.Length, 56); - LightBoxesBuffer.SetData(LightAABBs); cmd.BeginSample("LightRefitter"); cmd.SetComputeBufferParam(Refitter, LightTLASRefitKernel, "Transfers", LightBVHTransformsBuffer); - cmd.SetComputeBufferParam(Refitter, LightTLASRefitKernel, "LightNodesWrite", LightNodeBuffer); - cmd.SetComputeBufferParam(Refitter, LightTLASRefitKernel, "LightBounds", LightBoxesBuffer); +#if !DontUseSGTree + cmd.SetComputeBufferParam(Refitter, LightTLASRefitKernel, "SGTreeWrite", RayMaster.FramesSinceStart2 % 2 == 0 ? LightTreeBufferA : LightTreeBufferB); +#else + cmd.SetComputeBufferParam(Refitter, LightTLASRefitKernel, "LightNodesWrite", RayMaster.FramesSinceStart2 % 2 == 0 ? LightTreeBufferA : LightTreeBufferB); +#endif int ObjectOffset = 0; for(int i = LBVH.WorkingSet.Length - 1; i >= 0; i--) { var ObjOffVar = ObjectOffset; @@ -1836,6 +1925,7 @@ public int UpdateTLAS(CommandBuffer cmd) LightAABBs[i].b.BBMin = new_center - new_extent; LightAABBs[i].b.BBMax = new_center + new_extent; LightAABBs[i].w = (Mat * RenderQue[Index].LBVH.ParentBound.aabb.w).normalized; + } else { Index -= RendQueCount; LightBVHTransforms[i].SolidOffset = InstanceRenderQue[Index].InstanceParent.LightNodeOffset; @@ -1845,11 +1935,19 @@ public int UpdateTLAS(CommandBuffer cmd) LightAABBs[i].b.BBMin = new_center - new_extent; LightAABBs[i].b.BBMax = new_center + new_extent; LightAABBs[i].w = (Mat * InstanceRenderQue[Index].InstanceParent.LBVH.ParentBound.aabb.w).normalized; + + } } if(LightMeshCount > 0) { - LBVH = new LightBVHBuilder(LightAABBs); - LightNodeBuffer.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); + LBVH = new LightBVHBuilder(LightAABBs, ref SGTree, LightBVHTransforms, SGTreeNodes); +#if !DontUseSGTree + LightTreeBufferA.SetData(SGTree, 0, 0, SGTree.Length); + LightTreeBufferB.SetData(SGTree, 0, 0, SGTree.Length); +#else + LightTreeBufferA.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); + LightTreeBufferB.SetData(LBVH.nodes, 0, 0, LBVH.nodes.Length); +#endif } // UnityEngine.Profiling.Profiler.EndSample(); @@ -1903,7 +2001,8 @@ public int UpdateTLAS(CommandBuffer cmd) #if !HardwareRT BVH8AggregatedBuffer.SetData(TempBVHArray, 0, 0, TempBVHArray.Length); #endif - CommonFunctions.CreateComputeBuffer(ref MeshDataBuffer, MyMeshesCompacted); + CommonFunctions.CreateComputeBuffer(ref MeshDataBufferA, MyMeshesCompacted); + CommonFunctions.CreateComputeBuffer(ref MeshDataBufferB, MyMeshesCompacted); #if HardwareRT CommonFunctions.CreateComputeBuffer(ref MeshIndexOffsets, MeshOffsets); CommonFunctions.CreateComputeBuffer(ref SubMeshOffsetsBuffer, SubMeshOffsets); @@ -1966,7 +2065,8 @@ public int UpdateTLAS(CommandBuffer cmd) RefitTLAS(MeshAABBs, cmd); cmd.EndSample("TLAS Refitting"); HasChangedMaterials = UpdateMaterials(); - MeshDataBuffer.SetData(MyMeshesCompacted); + if(RayMaster.FramesSinceStart2 % 2 == 0) MeshDataBufferA.SetData(MyMeshesCompacted); + else MeshDataBufferB.SetData(MyMeshesCompacted); } if(HasChangedMaterials) MaterialBuffer.SetData(_Materials); LightMeshData CurLightMesh; @@ -2028,6 +2128,8 @@ public bool UpdateMaterials() TempMat.scatterDistance = CurrentMaterial.ScatterDist[Index]; TempMat.AlphaCutoff = CurrentMaterial.AlphaCutoff[Index]; TempMat.NormalStrength = CurrentMaterial.NormalStrength[Index]; + TempMat.DetailNormalStrength = CurrentMaterial.DetailNormalStrength[Index]; + TempMat.SecondaryNormalTexBlend = CurrentMaterial.SecondaryNormalTexBlend[Index]; TempMat.MetallicRemap = CurrentMaterial.MetallicRemap[Index]; TempMat.RoughnessRemap = CurrentMaterial.RoughnessRemap[Index]; TempMat.Hue = CurrentMaterial.Hue[Index]; @@ -2037,6 +2139,7 @@ public bool UpdateMaterials() TempMat.BlendColor = CurrentMaterial.BlendColor[Index]; TempMat.BlendFactor = CurrentMaterial.BlendFactor[Index]; TempMat.AlbedoTextureScale = CurrentMaterial.MainTexScaleOffset[Index]; + TempMat.SecondaryNormalTexScaleOffset = CurrentMaterial.SecondaryNormalTexScaleOffset[Index]; TempMat.SecondaryAlbedoTexScaleOffset = CurrentMaterial.SecondaryAlbedoTexScaleOffset[Index]; TempMat.SecondaryTextureScale = CurrentMaterial.SecondaryTextureScale[Index]; TempMat.Rotation = CurrentMaterial.Rotation[Index] * 3.14159f; @@ -2068,6 +2171,55 @@ public bool UpdateMaterials() } + // private int DrawCount; + // public GaussianTreeNode[] LightTree; + // private void Refit(int Depth, int CurrentIndex, bool HasHitTLAS, int node_offset, Matrix4x4 Transform) { + // if((HasHitTLAS && LightTree[CurrentIndex].left < 0) || Depth > 20 || LightTree[CurrentIndex].intensity == 0) return; + + // int LeftIndex = LightTree[CurrentIndex].left; + // HasHitTLAS = HasHitTLAS || LeftIndex < 0; + + // Vector3 Pos = CommonFunctions.ToVector3(Transform * CommonFunctions.ToVector4(LightTree[CurrentIndex].S.Center, 1)); + // float Radius = Vector3.Distance(Pos, CommonFunctions.ToVector3(Transform * CommonFunctions.ToVector4(LightTree[CurrentIndex].S.Center + new Vector3(LightTree[CurrentIndex].S.Radius, 0, 0), 1))); + // Gizmos.DrawWireSphere(Pos, Radius); + // if(LeftIndex < 0) { + // int MeshIndex = -(LeftIndex+1); + // node_offset = MyMeshesCompacted[LightMeshes[MeshIndex].LockedMeshIndex].LightNodeOffset; + // Transform = MyMeshesCompacted[LightMeshes[MeshIndex].LockedMeshIndex].Transform.inverse; + // LeftIndex = 0; + // return; + // } else { + // DrawCount++; + // // if(CurrentIndex >= node_offset + LeftIndex) Debug.Log("EEE " + LeftIndex + ", " + node_offset); + // } + + + // Refit(Depth + 1, LeftIndex + node_offset, HasHitTLAS, node_offset, Transform); + // Refit(Depth + 1, LeftIndex + node_offset + 1, HasHitTLAS, node_offset, Transform); + // } + + // public float VarTest = 1.0f; + // // public GaussianTreeNode[] LightTree2; + // public void OnDrawGizmos() { + // if(Application.isPlaying) { + // DrawCount = 0; + // int Count = LightTreeBuffer.count; + // LightTree = new GaussianTreeNode[Count]; + // // LightTree2 = new GaussianTreeNode[Count]; + // // LightTreeBuffer2.GetData(LightTree); + // LightTreeBuffer.GetData(LightTree); + // Refit(0, 0, false, 0, Matrix4x4.identity); + // Debug.Log(DrawCount); + // // for(int i = 2; i < Count; i++) { + // // Vector3 Pos = CommonFunctions.ToVector3(LightBVHTransforms[0].Transform * CommonFunctions.ToVector4(LightTree[i].S.Center, 1)); + // // float Radius = Vector3.Distance(Pos, CommonFunctions.ToVector3(LightBVHTransforms[0].Transform * CommonFunctions.ToVector4(LightTree[i].S.Center + new Vector3(LightTree[i].S.Radius, 0, 0), 1))); + // // // if(LightTree[i].variance < LightTree[i].S.Radius * VarTest) Gizmos.DrawWireSphere(Pos, Radius); + // // Gizmos.DrawWireSphere(Pos, Radius); + + // // } + // } + // } + } } \ No newline at end of file diff --git a/TrueTrace/Resources/Builders/CommonVars.cs b/TrueTrace/Resources/Builders/CommonVars.cs index 848e8815..c630f7a3 100644 --- a/TrueTrace/Resources/Builders/CommonVars.cs +++ b/TrueTrace/Resources/Builders/CommonVars.cs @@ -6,6 +6,41 @@ namespace CommonVars { #pragma warning disable 4014 + [System.Serializable] + public struct BoundingSphere { + public Vector3 Center; + public float Radius; + + public void init() { + Center = Vector3.zero; + Radius = 0.0f; + } + public void Validate(float padding) { + Radius = Mathf.Max(Radius, padding); + } + + public void Extend(Vector3 A) { + Radius = Mathf.Max(Radius, Vector3.Distance(Center, A)); + } + } + + [System.Serializable] + public struct LightBVHTransform { + public Matrix4x4 Transform; + public int SolidOffset; + } + + [System.Serializable] + public struct GaussianTreeNode { + public BoundingSphere S; + public Vector3 axis; + public float variance; + public float sharpness; + public float intensity; + public int left; + } + + [System.Serializable] public struct LightData { @@ -48,6 +83,7 @@ public struct MeshDat public List Normals; public List Tangents; public List UVs; + public List Colors; #if TTLightMapping public List LightmapUVs; #endif @@ -56,6 +92,10 @@ public struct MeshDat public void SetUvZero(int Count) { for (int i = 0; i < Count; i++) UVs.Add(new Vector2(0.0f, 0.0f)); } + public void SetColorsZero(int Count) { + Color TempCol = new Color(1,1,1,1); + for (int i = 0; i < Count; i++) Colors.Add(TempCol); + } #if TTLightMapping public void AddLightmapUVs(Vector2[] LightUVs, Vector4 ScaleOffset) { int Count = LightUVs.Length; @@ -75,6 +115,7 @@ public void init(int StartingSize) { this.Verticies = new List(StartingSize); this.Normals = new List(StartingSize); this.Indices = new List(StartingSize); + this.Colors = new List(StartingSize); } public void Clear() { if (Tangents != null) { @@ -87,6 +128,7 @@ public void Clear() { CommonFunctions.DeepClean(ref Verticies); CommonFunctions.DeepClean(ref Normals); CommonFunctions.DeepClean(ref Indices); + CommonFunctions.DeepClean(ref Colors); } } } @@ -104,6 +146,7 @@ public struct MaterialData public Vector2Int MatCapTex; public Vector2Int SecondaryAlbedoTex; public Vector2Int SecondaryAlbedoMask; + public Vector2Int SecondaryNormalTex; public Vector3 BaseColor; public float emission; public Vector3 EmissionColor; @@ -140,6 +183,9 @@ public struct MaterialData public float Rotation; public float ColorBleed; public float AlbedoBlendFactor; + public Vector4 SecondaryNormalTexScaleOffset; + public float SecondaryNormalTexBlend; + public float DetailNormalStrength; } [System.Serializable] @@ -507,9 +553,13 @@ public struct CudaTriangle public uint tan1; public uint tan2; - public Vector2 tex0; - public Vector2 texedge1; - public Vector2 texedge2; + public uint tex0; + public uint texedge1; + public uint texedge2; + + public uint VertColA; + public uint VertColB; + public uint VertColC; public uint MatDat; } @@ -557,7 +607,7 @@ public class TexObj public int ReadIndex; public List TexObjList = new List(); } - public enum TexturePurpose {Albedo, Alpha, Normal, Emission, Metallic, Roughness, MatCapTex, MatCapMask, SecondaryAlbedoTexture, SecondaryAlbedoTextureMask}; + public enum TexturePurpose {Albedo, Alpha, Normal, Emission, Metallic, Roughness, MatCapTex, MatCapMask, SecondaryAlbedoTexture, SecondaryAlbedoTextureMask, SecondaryNormalTexture}; [System.Serializable] public class TexturePairs { @@ -634,6 +684,23 @@ public class RayObjectDatas public float KelvinTemp; public float ColorBleed; public float AlbedoBlendFactor; + public Vector4 SecondaryNormalTexScaleOffset; + public float SecondaryNormalTexBlend; + public float DetailNormalStrength; + + + + public string AlbedoGUID; + public string MetallicGUID; + public string RoughnessGUID; + public string EmissionGUID; + public string AlphaGUID; + public string MatCapGUID; + public string MatcapMaskGUID; + public string SecondaryAlbedoGUID; + public string SecondaryAlbedoMaskGUID; + public string NormalGUID; + public string ShaderName; } [System.Serializable] public class RayObjs @@ -641,6 +708,20 @@ public class RayObjs [System.Xml.Serialization.XmlElement("RayObjectDatas")] public List RayObj = new List(); } + [System.Serializable] + public class RayObjFolder + { + public string FolderName = ""; + public List ContainedPresets = new List(); + } + + [System.Serializable] + public class RayObjFolderMaster + { + [System.Xml.Serialization.XmlElement("RayObjFolder")] + public List PresetFolders = new List(); + } + public struct TTStopWatch {//stopwatch stuff @@ -680,6 +761,13 @@ public void Stop(string OptionalString = "") { public static class CommonFunctions { + public static Vector4 ToVector4(Vector3 A, float B) { + return new Vector4(A.x, A.y, A.z, B); + } + public static Vector3 ToVector3(Vector4 A) { + return new Vector3(A.x, A.y, A.z); + } + public static void DeepClean(ref List A) { if(A != null) { A.Clear(); @@ -909,6 +997,18 @@ public static uint PackOctahedral(Vector3 nor) return (uint)(halfMaxUInt16 + temp.x * halfMaxUInt16 * sign.x) | ((uint)(halfMaxUInt16 + temp.y * halfMaxUInt16 * sign.y) << 16); } + + public static Vector3 UnpackOctahedral(uint data) { + uint ivx = (uint)(data) & 65535u; + uint ivy = (uint)(data>>16 ) & 65535u; + Vector2 v = new Vector2(ivx/32767.5f, ivy/32767.5f) - Vector2.one; + Vector3 nor = new Vector3(v.x, v.y, 1.0f - Mathf.Abs(v.x) - Mathf.Abs(v.y)); // Rune Stubbe's version, + float t = Mathf.Max(-nor.z,0.0f); // much faster than original + nor.x += (nor.x >= 0) ? -t : t; + nor.y += (nor.y >= 0) ? -t : t; + return nor.normalized; + } + public static readonly RenderTextureFormat RTFull4 = RenderTextureFormat.ARGBFloat; public static readonly RenderTextureFormat RTInt1 = RenderTextureFormat.RInt; public static readonly RenderTextureFormat RTInt2 = RenderTextureFormat.RGInt; @@ -986,6 +1086,11 @@ public static void CreateRenderTextureArray(ref RenderTexture ThisTexArray, ThisTexArray.Create(); } + public static int GetStride() + where T : struct + { + return System.Runtime.InteropServices.Marshal.SizeOf(); + } public static void CreateComputeBuffer(ref ComputeBuffer buffer, List data) where T : struct @@ -1024,8 +1129,8 @@ public static void CreateComputeBuffer(ref ComputeBuffer buffer, T[] data) } - public enum Flags {IsEmissionMask, BaseIsMap, ReplaceBase, UseSmoothness, InvertSmoothnessTexture, IsBackground, ShadowCaster, Invisible, BackgroundBleed, Thin}; - //0-9 Flags + public enum Flags {IsEmissionMask, BaseIsMap, ReplaceBase, UseSmoothness, InvertSmoothnessTexture, IsBackground, ShadowCaster, Invisible, BackgroundBleed, Thin, UseVertexColors}; + //0-10 Flags //28-30 SecondaryAlbedoStride public static int SetFlagStretch(this int FlagVar, int LeftOffset, int Stride, int Setter) { @@ -1048,5 +1153,110 @@ public static bool GetFlag(this int FlagVar, Flags flag) { return (((int)FlagVar >> (int)flag) & (int)1) == 1; } + public static uint packRGBE(Color v) + { + Vector3 va = new Vector3(Mathf.Max(0, v.r), Mathf.Max(0, v.g), Mathf.Max(0, v.b)); + float max_abs = Mathf.Max(va.x, Mathf.Max(va.y, va.z)); + if (max_abs == 0) return 0; + + float exponent = Mathf.Floor(Mathf.Log(max_abs, 2)); + + uint result = (uint)(Mathf.Clamp(exponent + 20, 0, 31)) << 27; + + float scale = Mathf.Pow(2.0f, -exponent) * 256.0f; + result |= (uint)(Mathf.Min(511, Mathf.Round(va.x * scale))); + result |= (uint)(Mathf.Min(511, Mathf.Round(va.y * scale))) << 9; + result |= (uint)(Mathf.Min(511, Mathf.Round(va.z * scale))) << 18; + + return result; + } + + + public static uint encodeQTangentUI32(Vector3 T, Vector3 B, Vector3 N){ + float determinant = T.x * ((B.y * N.z) - (N.y * B.z)) - B.x * ((T.y * N.z) - (N.y * T.z)) + N.x * ((T.y * B.z) - (B.y * T.z)); + + float r = (determinant < 0.0f) ? -1.0f : 1.0f; // Reflection matrix handling + N *= r; + // #if 0 + // // When the input matrix is always a valid orthogonal tangent space matrix, we can simplify the quaternion calculation to just this: + // vec4 q = vec4(B.z - T.y, N.x - T.z, T.y - B.x, 1.0 + T.x + B.y + N.z); + // #else + // Otherwise we have to handle all other possible cases as well. + float t = T.x + (B.y + N.z); + Vector4 q; + if(t > 2.9999999f){ + q = new Vector4(0.0f, 0.0f, 0.0f, 1.0f); + }else if(t > 0.0000001f){ + float s = Mathf.Sqrt(1.0f + t) * 2.0f; + q = new Vector4((B.z - N.y) / s, (N.x - T.z) / s, (T.y - B.x) / s, s * 0.25f); + }else if((T.x > B.y) && (T.x > N.z)){ + float s = Mathf.Sqrt(1.0f + (T.x - (B.y + N.z))) * 2.0f; + q = new Vector4(s * 0.25f, (B.x + T.y) / s, (N.x + T.z) / s, (B.z - T.y) / s); + }else if(B.y > N.z){ + float s = Mathf.Sqrt(1.0f + (B.y - (T.x + N.z))) * 2.0f; + q = new Vector4((B.x + T.y) / s, (T.y + B.z) / s, (N.x - T.z) / s, s * 0.25f); + q = new Vector4(q.x, q.w, q.y, q.z); + }else{ + float s = Mathf.Sqrt(1.0f + (N.z - (T.x + B.y))) * 2.0f; + q = new Vector4((N.x + T.z) / s, (T.y + B.z) / s, (T.y - B.x) / s, s * 0.25f); + q = new Vector4(q.x, q.y, q.w, q.z); + } + // #endif + q = q.normalized; + Vector4 qAbs = new Vector4(Mathf.Abs(q.x), Mathf.Abs(q.y), Mathf.Abs(q.z), Mathf.Abs(q.w)); + int maxComponentIndex = (qAbs.x > qAbs.y) ? ((qAbs.x > qAbs.z) ? ((qAbs.x > qAbs.w) ? 0 : 3) : ((qAbs.z > qAbs.w) ? 2 : 3)) : ((qAbs.y > qAbs.z) ? ((qAbs.y > qAbs.w) ? 1 : 3) : ((qAbs.z > qAbs.w) ? 2 : 3)); + float Mult = ((q[maxComponentIndex] < 0.0f) ? -1.0f : 1.0f) * 1.4142135623730951f; + switch(maxComponentIndex) { + case 0: + q = new Vector4(q.y, q.z, q.w, q.w); + break; + case 1: + q = new Vector4(q.x, q.z, q.w, q.w); + break; + case 2: + q = new Vector4(q.x, q.y, q.w, q.w); + break; + case 3: + break; + } + q = new Vector4(q.x * Mult, q.y * Mult, q.z * Mult, q.w); + return (((uint)(Mathf.Round(Mathf.Clamp(q.x * 511.0f, -511.0f, 511.0f) + 512.0f)) & 0x3ffu) << 0) | + (((uint)(Mathf.Round(Mathf.Clamp(q.y * 511.0f, -511.0f, 511.0f) + 512.0f)) & 0x3ffu) << 10) | + (((uint)(Mathf.Round(Mathf.Clamp(q.z * 255.0f, -255.0f, 255.0f) + 256.0f)) & 0x1ffu) << 20) | + (((uint)(((Vector3.Dot(Vector3.Cross(T, N), B) * r) < 0.0f) ? 1u : 0u) & 0x1u) << 29) | + (((uint)(maxComponentIndex) & 0x3u) << 30); + } + + public static void decodeQTangentUI32(uint v, ref Vector3 T, ref Vector3 N){ + Vector4 q = new Vector4( + (((int)((v >> 0) & 0x3ffu) - 512) / 511.0f) * 0.7071067811865475f, + (((int)((v >> 10) & 0x3ffu) - 512) / 511.0f) * 0.7071067811865475f, + (((int)((v >> 20) & 0x1ffu) - 256) / 255.0f) * 0.7071067811865475f, + 0 + ); + q.w = Mathf.Sqrt(1.0f - Mathf.Clamp(Vector3.Dot(new Vector3(q.x, q.y, q.z), new Vector3(q.x, q.y, q.z)), 0.0f, 1.0f)); + switch((uint)((v >> 30) & 0x3u)) { + case 0: + q = new Vector4(q.w, q.x, q.y, q.z); + break; + case 1: + q = new Vector4(q.x, q.w, q.y, q.z); + break; + case 2: + q = new Vector4(q.x, q.y, q.w, q.z); + break; + case 3: + break; + } + q = q.normalized; + Vector3 t2 = new Vector3(q.x * 2.0f, q.y * 2.0f, q.z * 2.0f); + Vector3 tx = t2 * q.x; + Vector3 ty = t2 * q.y; + Vector3 tz = t2 * q.w; + T = (new Vector3(1.0f - (ty.y + (q.z * t2.z)), tx.y + tz.z, tx.z - tz.y)).normalized; + N = (new Vector3(tx.z + tz.y, ty.z - tz.x, 1.0f - (tx.x + ty.y))).normalized; + return; + } + } } diff --git a/TrueTrace/Resources/Builders/LightBVHBuilder.cs b/TrueTrace/Resources/Builders/LightBVHBuilder.cs index 5a709083..b53b2ddf 100644 --- a/TrueTrace/Resources/Builders/LightBVHBuilder.cs +++ b/TrueTrace/Resources/Builders/LightBVHBuilder.cs @@ -2,10 +2,13 @@ using System.Collections.Generic; using UnityEngine; using CommonVars; +using System; +using Unity.Collections; +using Unity.Collections.LowLevel.Unsafe; namespace TrueTrace { [System.Serializable] - public class LightBVHBuilder { + public unsafe class LightBVHBuilder { void OnDestroy() { Debug.Log("EEE"); } @@ -19,29 +22,15 @@ public DirectionCone(Vector3 w, float cosTheta) { this.cosTheta = cosTheta; } } - float Dot(ref Vector3 A, ref Vector3 B) { - return A.x * B.x + A.y * B.y + A.z * B.z; - } - float Dot(Vector3 A) { - return A.x * A.x + A.y * A.y + A.z * A.z; - } - float Length(Vector3 A) { - return (float)System.Math.Sqrt(Dot(A)); - } - public bool IsEmpty(DirectionCone Cone) {return Cone.cosTheta == float.MaxValue;} + private float luminance(float r, float g, float b) { return 0.299f * r + 0.587f * g + 0.114f * b; } + + float Dot(ref Vector3 A, ref Vector3 B) {return A.x * B.x + A.y * B.y + A.z * B.z;} + float Dot(Vector3 A) {return A.x * A.x + A.y * A.y + A.z * A.z;} + float Length(Vector3 A) {return (float)System.Math.Sqrt(Dot(A));} + public bool IsEmpty(ref LightBounds Cone) {return Cone.w == Vector3.zero;} - public DirectionCone EntireSphere() {return new DirectionCone(new Vector3(0,0,1), -1);} - public DirectionCone BoundSubtendedDirections(AABB aabb, Vector3 p) { - float diameter = aabb.IsInside(p) ? Dot(aabb.BBMax - p) : 0; - Vector3 pCenter = (aabb.BBMax + aabb.BBMin) / 2.0f; - float sin2ThetaMax = Dot(p - pCenter); - if(sin2ThetaMax < diameter) return EntireSphere(); - Vector3 w = (pCenter - p).normalized; - sin2ThetaMax = diameter / sin2ThetaMax; - float cosThetaMax = Mathf.Sqrt(1.0f - sin2ThetaMax); - return new DirectionCone(w, cosThetaMax); - } + private float AngleBetween(Vector3 v1, Vector3 v2) { if(Dot(ref v1, ref v2) < 0) return 3.14159f - 2.0f * (float)System.Math.Asin(Length(v1 + v2) / 2.0f); @@ -123,16 +112,36 @@ private float EvaluateCost(ref LightBounds b, float Kr, int dim) { (2.0f * theta_w * sinTheta_o -(float)System.Math.Cos(theta_o - 2.0f * theta_w) - 2.0f * theta_o * sinTheta_o + b.cosTheta_o); - + float Radius = Vector3.Distance((b.b.BBMax + b.b.BBMin) / 2.0f, b.b.BBMax); + float SA = 4.0f * Mathf.PI * Radius * Radius; + return b.phi * M_omega * Kr * surface_area(b.b) / (float)Mathf.Max(b.LightCount, 1); } - private LightBounds[] LightTris; - private NodeBounds[] nodes2; + private LightBounds* LightTris; + private NodeBounds* nodes2; +#if DontUseSGTree public CompactLightBVHData[] nodes; +#else + private CompactLightBVHData[] nodes; + public GaussianTreeNode[] SGTree; +#endif + private int* DimensionedIndices; + public int PrimCount; + private float* SAH; + private bool* indices_going_left; + private int* temp; + public int[] FinalIndices; - - private int[] DimensionedIndices; + public NativeArray LightTrisArray; + public NativeArray nodes2Array; + public NativeArray DimensionedIndicesArray; + public NativeArray tempArray; + public NativeArray indices_going_left_array; + public NativeArray CentersX; + public NativeArray CentersY; + public NativeArray CentersZ; + public NativeArray SAHArray; public struct ObjectSplit { public int index; @@ -143,11 +152,6 @@ public struct ObjectSplit { } private ObjectSplit split = new ObjectSplit(); - public int PrimCount; - private float[] SAH; - private bool[] indices_going_left; - private int[] temp; - public int[] FinalIndices; ObjectSplit partition_sah(int first_index, int index_count, AABB parentBounds) { split.cost = float.MaxValue; @@ -235,7 +239,7 @@ void BuildRecursive(int nodesi, ref int node_index, int first_index, int index_c temp[indices_going_left[index] ? (left++) : (right++)] = index; } - System.Array.Copy(temp, 0, DimensionedIndices, Offset + first_index, index_count); + NativeArray.Copy(tempArray, 0, DimensionedIndicesArray, Offset + first_index, index_count); } nodes2[nodesi].left = node_index; @@ -247,14 +251,7 @@ void BuildRecursive(int nodesi, ref int node_index, int first_index, int index_c BuildRecursive(nodes2[nodesi].left + 1, ref node_index,first_index + split.index - first_index,first_index + index_count - split.index, Depth + 1); } public ComputeBuffer[] WorkingSet; - private List[] Set; - void Refit(int Depth, int CurrentIndex) { - if(nodes2[CurrentIndex].aabb.cosTheta_e == 0) return; - Set[Depth].Add(CurrentIndex); - if(nodes2[CurrentIndex].isLeaf == 1) return; - Refit(Depth + 1, nodes2[CurrentIndex].left); - Refit(Depth + 1, nodes2[CurrentIndex].left + 1); - } + private float AreaOfTriangle(Vector3 pt1, Vector3 pt2, Vector3 pt3) { @@ -264,21 +261,75 @@ private float AreaOfTriangle(Vector3 pt1, Vector3 pt2, Vector3 pt3) float s = (a + b + c) / 2.0f; return Mathf.Sqrt(s * (s - a) * (s - b) * (s - c)); } - - public LightBVHBuilder(List Tris, List Norms, float phi, List LuminanceWeights) {//need to make sure incomming is transformed to world space already + + public List[] Set; + void Refit(int Depth, int CurrentIndex) { + if(nodes2[CurrentIndex].aabb.cosTheta_e == 0) return; + Set[Depth].Add(CurrentIndex); + if(nodes2[CurrentIndex].isLeaf == 1) return; + Refit(Depth + 1, nodes2[CurrentIndex].left); + Refit(Depth + 1, nodes2[CurrentIndex].left + 1); + } + + private void Refit2(int Depth, int CurrentIndex) { + if((2.0f * ((float)(nodes[CurrentIndex].cosTheta_oe >> 16) / 32767.0f) - 1.0f) == 0) return; + Set[Depth].Add(CurrentIndex); + if(nodes[CurrentIndex].left < 0) return; + Refit2(Depth + 1, nodes[CurrentIndex].left); + Refit2(Depth + 1, nodes[CurrentIndex].left + 1); + } + + float expm1_over_x(float x) + { + float u = Mathf.Exp(x); + + if (u == 1.0f) + { + return 1.0f; + } + + float y = u - 1.0f; + + if (Mathf.Abs(x) < 1.0f) + { + return y / Mathf.Log(u); + } + + return y / x; + } + + float SGIntegral(float sharpness) + { + return 4.0f * Mathf.PI * expm1_over_x(-2.0f * sharpness); + } + + + public unsafe LightBVHBuilder(List Tris, List Norms, float phi, List LuminanceWeights) {//need to make sure incomming is transformed to world space already PrimCount = Tris.Count; MaxDepth = 0; - LightTris = new LightBounds[PrimCount]; - nodes2 = new NodeBounds[PrimCount * 2]; - SAH = new float[PrimCount]; - indices_going_left = new bool[PrimCount]; - temp = new int[PrimCount]; - DimensionedIndices = new int[PrimCount * 3]; + tempArray = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.ClearMemory); + SAHArray = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.ClearMemory); + indices_going_left_array = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.ClearMemory); + DimensionedIndicesArray = new NativeArray(PrimCount * 3, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + CentersX = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + CentersY = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + CentersZ = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + nodes2Array = new NativeArray(PrimCount * 2, Unity.Collections.Allocator.TempJob, NativeArrayOptions.ClearMemory); + LightTrisArray = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + + + nodes2 = (NodeBounds*)NativeArrayUnsafeUtility.GetUnsafePtr(nodes2Array); + LightTris = (LightBounds*)NativeArrayUnsafeUtility.GetUnsafePtr(LightTrisArray); + float* ptr = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(CentersX); + float* ptr1 = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(CentersY); + float* ptr2 = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(CentersZ); + indices_going_left = (bool*)NativeArrayUnsafeUtility.GetUnsafePtr(indices_going_left_array); + DimensionedIndices = (int*)NativeArrayUnsafeUtility.GetUnsafePtr(DimensionedIndicesArray); + temp = (int*)NativeArrayUnsafeUtility.GetUnsafePtr(tempArray); + SAH = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(SAHArray); + FinalIndices = new int[PrimCount]; - float[] CentersX = new float[PrimCount]; - float[] CentersY = new float[PrimCount]; - float[] CentersZ = new float[PrimCount]; - for(int i = 0; i < PrimCount * 2; i++) nodes2[i] = new NodeBounds(); + for(int i = 0; i < PrimCount; i++) { AABB TriAABB = new AABB(); TriAABB.init(); @@ -291,23 +342,31 @@ public LightBVHBuilder(List Tris, List Norms, float phi, LightBounds TempBound = new LightBounds(TriAABB, tricone.W, ThisPhi, tricone.cosTheta,(float)System.Math.Cos(3.14159f / 2.0f), 1, 0); LightTris[i] = TempBound; FinalIndices[i] = i; - CentersX[i] = (TriAABB.BBMax.x - TriAABB.BBMin.x) / 2.0f + TriAABB.BBMin.x; - CentersY[i] = (TriAABB.BBMax.y - TriAABB.BBMin.y) / 2.0f + TriAABB.BBMin.y; - CentersZ[i] = (TriAABB.BBMax.z - TriAABB.BBMin.z) / 2.0f + TriAABB.BBMin.z; + ptr[i] = (TriAABB.BBMax.x - TriAABB.BBMin.x) / 2.0f + TriAABB.BBMin.x; + ptr1[i] = (TriAABB.BBMax.y - TriAABB.BBMin.y) / 2.0f + TriAABB.BBMin.y; + ptr2[i] = (TriAABB.BBMax.z - TriAABB.BBMin.z) / 2.0f + TriAABB.BBMin.z; Union(ref nodes2[0].aabb, TempBound); } - System.Array.Sort(FinalIndices, (s1,s2) => {var sign = CentersX[s1] - CentersX[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); - System.Array.Copy(FinalIndices, 0, DimensionedIndices, 0, PrimCount); + System.Array.Sort(FinalIndices, (s1,s2) => {var sign = ptr[s1] - ptr[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); + CentersX.Dispose(); + NativeArray.Copy(FinalIndices, 0, DimensionedIndicesArray, 0, PrimCount); for(int i = 0; i < PrimCount; i++) FinalIndices[i] = i; - System.Array.Sort(FinalIndices, (s1,s2) => {var sign = CentersY[s1] - CentersY[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); - System.Array.Copy(FinalIndices, 0, DimensionedIndices, PrimCount, PrimCount); + System.Array.Sort(FinalIndices, (s1,s2) => {var sign = ptr1[s1] - ptr1[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); + CentersY.Dispose(); + NativeArray.Copy(FinalIndices, 0, DimensionedIndicesArray, PrimCount, PrimCount); for(int i = 0; i < PrimCount; i++) FinalIndices[i] = i; - System.Array.Sort(FinalIndices, (s1,s2) => {var sign = CentersZ[s1] - CentersZ[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); - System.Array.Copy(FinalIndices, 0, DimensionedIndices, PrimCount * 2, PrimCount); + System.Array.Sort(FinalIndices, (s1,s2) => {var sign = ptr2[s1] - ptr2[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); + CentersZ.Dispose(); + NativeArray.Copy(FinalIndices, 0, DimensionedIndicesArray, PrimCount * 2, PrimCount); + CommonFunctions.DeepClean(ref FinalIndices); int nodeIndex = 2; BuildRecursive(0, ref nodeIndex,0,PrimCount, 1); + indices_going_left_array.Dispose(); + tempArray.Dispose(); + SAHArray.Dispose(); + // NodeBounds[] TempNodes = new NodeBounds[nodeIndex]; // for(int i = 0; i < nodeIndex; i++) { // TempNodes[i] = nodes2[i]; @@ -319,7 +378,8 @@ public LightBVHBuilder(List Tris, List Norms, float phi, nodes2[i].left = DimensionedIndices[nodes2[i].left]; } } - nodes = new CompactLightBVHData[nodes2.Length]; + DimensionedIndicesArray.Dispose(); + nodes = new CompactLightBVHData[PrimCount * 2]; for(int i = 0; i < PrimCount * 2; i++) { CompactLightBVHData TempNode = new CompactLightBVHData(); TempNode.BBMax = nodes2[i].aabb.b.BBMax; @@ -335,44 +395,128 @@ public LightBVHBuilder(List Tris, List Norms, float phi, nodes[i] = TempNode; } ParentBound = nodes2[0]; - CommonFunctions.DeepClean(ref nodes2); - CommonFunctions.DeepClean(ref LightTris); + // ParentBound.aabb.phi /= (float)Mathf.Max(ParentBound.aabb.LightCount, 1); + nodes2Array.Dispose(); + LightTrisArray.Dispose(); +#if !DontUseSGTree + { + SGTree = new GaussianTreeNode[nodes.Length]; + Set = new List[MaxDepth]; + for(int i = 0; i < MaxDepth; i++) Set[i] = new List(); + Refit2(0, 0); + for(int i = MaxDepth - 1; i >= 0; i--) { + int SetCount = Set[i].Count; + for(int j = 0; j < SetCount; j++) { + GaussianTreeNode TempNode = new GaussianTreeNode(); + int WriteIndex = Set[i][j]; + CompactLightBVHData LBVHNode = nodes[WriteIndex]; + Vector3 V; + Vector3 mean; + float variance; + float intensity; + float radius; + if(LBVHNode.left < 0) { + LightTriData ThisLight = Tris[-(LBVHNode.left+1)]; + + float area = AreaOfTriangle(ThisLight.pos0, ThisLight.pos0 + ThisLight.posedge1, ThisLight.pos0 + ThisLight.posedge2); + + intensity = ThisLight.SourceEnergy * area; + V = 0.5f * -Norms[-(LBVHNode.left+1)];//(Vector3.Cross(ThisLight.posedge1.normalized, ThisLight.posedge2.normalized).normalized); + mean = (ThisLight.pos0 + (ThisLight.pos0 + ThisLight.posedge1) + (ThisLight.pos0 + ThisLight.posedge2)) / 3.0f; + variance = (Vector3.Dot(ThisLight.posedge1, ThisLight.posedge1) + Vector3.Dot(ThisLight.posedge2, ThisLight.posedge2) - Vector3.Dot(ThisLight.posedge1, ThisLight.posedge2)) / 18.0f; + radius = Mathf.Max(Mathf.Max(Vector3.Distance(mean, ThisLight.pos0), Vector3.Distance(mean, ThisLight.pos0 + ThisLight.posedge1)), Vector3.Distance(mean, ThisLight.pos0 + ThisLight.posedge2)); + } else { + GaussianTreeNode LeftNode = SGTree[nodes[WriteIndex].left]; + GaussianTreeNode RightNode = SGTree[nodes[WriteIndex].left + 1]; + + float phi_left = LeftNode.intensity; + float phi_right = RightNode.intensity; + float w_left = phi_left / (phi_left + phi_right); + float w_right = phi_right / (phi_left + phi_right); + + V = w_left * LeftNode.axis + w_right * RightNode.axis; + + mean = w_left * LeftNode.S.Center + w_right * RightNode.S.Center; + variance = w_left * LeftNode.variance + w_right * RightNode.variance + w_left * w_right * Vector3.Dot(LeftNode.S.Center - RightNode.S.Center, LeftNode.S.Center - RightNode.S.Center); + + intensity = LeftNode.intensity + RightNode.intensity; + radius = Mathf.Max(Vector3.Distance(mean, LeftNode.S.Center) + LeftNode.S.Radius, Vector3.Distance(mean, RightNode.S.Center) + RightNode.S.Radius); + } + TempNode.sharpness = ((3.0f * Vector3.Distance(Vector3.zero, V) - Mathf.Pow(Vector3.Distance(Vector3.zero, V), 3))) / (1.0f - Mathf.Pow(Vector3.Distance(Vector3.zero, V), 2)); + TempNode.axis = V; + TempNode.S.Center = mean; + TempNode.variance = variance; + TempNode.intensity = intensity; + TempNode.S.Radius = radius; + + TempNode.left = LBVHNode.left; + SGTree[WriteIndex] = TempNode; + } + } + } + + // SGTree[0].intensity /= (float)Mathf.Max(ParentBound.aabb.LightCount, 1); + CommonFunctions.DeepClean(ref nodes); +#endif } - public LightBVHBuilder(LightBounds[] Tris) {//need to make sure incomming is transformed to world space already + + public LightBVHBuilder(LightBounds[] Tris,ref GaussianTreeNode[] SGTree, LightBVHTransform[] LightBVHTransforms, GaussianTreeNode[] SGTreeNodes) {//need to make sure incomming is transformed to world space already PrimCount = Tris.Length; MaxDepth = 0; - LightTris = Tris; - nodes2 = new NodeBounds[PrimCount * 2]; - SAH = new float[PrimCount]; - indices_going_left = new bool[PrimCount]; - temp = new int[PrimCount]; - DimensionedIndices = new int[PrimCount * 3]; + + LightTrisArray = new NativeArray(Tris, Unity.Collections.Allocator.TempJob); + LightTris = (LightBounds*)NativeArrayUnsafeUtility.GetUnsafePtr(LightTrisArray); + tempArray = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.ClearMemory); + SAHArray = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.ClearMemory); + indices_going_left_array = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.ClearMemory); + DimensionedIndicesArray = new NativeArray(PrimCount * 3, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + CentersX = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + CentersY = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + CentersZ = new NativeArray(PrimCount, Unity.Collections.Allocator.TempJob, NativeArrayOptions.UninitializedMemory); + + + nodes2Array = new NativeArray(PrimCount * 2, Unity.Collections.Allocator.TempJob, NativeArrayOptions.ClearMemory); + nodes2 = (NodeBounds*)NativeArrayUnsafeUtility.GetUnsafePtr(nodes2Array); + float* ptr = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(CentersX); + float* ptr1 = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(CentersY); + float* ptr2 = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(CentersZ); + indices_going_left = (bool*)NativeArrayUnsafeUtility.GetUnsafePtr(indices_going_left_array); + DimensionedIndices = (int*)NativeArrayUnsafeUtility.GetUnsafePtr(DimensionedIndicesArray); + temp = (int*)NativeArrayUnsafeUtility.GetUnsafePtr(tempArray); + SAH = (float*)NativeArrayUnsafeUtility.GetUnsafePtr(SAHArray); + + FinalIndices = new int[PrimCount]; - float[] CentersX = new float[PrimCount]; - float[] CentersY = new float[PrimCount]; - float[] CentersZ = new float[PrimCount]; - for(int i = 0; i < PrimCount * 2; i++) nodes2[i] = new NodeBounds(); + for(int i = 0; i < PrimCount; i++) { FinalIndices[i] = i; - CentersX[i] = (Tris[i].b.BBMax.x - Tris[i].b.BBMin.x) / 2.0f + Tris[i].b.BBMin.x; - CentersY[i] = (Tris[i].b.BBMax.y - Tris[i].b.BBMin.y) / 2.0f + Tris[i].b.BBMin.y; - CentersZ[i] = (Tris[i].b.BBMax.z - Tris[i].b.BBMin.z) / 2.0f + Tris[i].b.BBMin.z; + ptr[i] = (Tris[i].b.BBMax.x - Tris[i].b.BBMin.x) / 2.0f + Tris[i].b.BBMin.x; + ptr1[i] = (Tris[i].b.BBMax.y - Tris[i].b.BBMin.y) / 2.0f + Tris[i].b.BBMin.y; + ptr2[i] = (Tris[i].b.BBMax.z - Tris[i].b.BBMin.z) / 2.0f + Tris[i].b.BBMin.z; Union(ref nodes2[0].aabb, Tris[i]); } - System.Array.Sort(FinalIndices, (s1,s2) => {var sign = CentersX[s1] - CentersX[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); - System.Array.Copy(FinalIndices, 0, DimensionedIndices, 0, PrimCount); + System.Array.Sort(FinalIndices, (s1,s2) => {var sign = ptr[s1] - ptr[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); + CentersX.Dispose(); + NativeArray.Copy(FinalIndices, 0, DimensionedIndicesArray, 0, PrimCount); for(int i = 0; i < PrimCount; i++) FinalIndices[i] = i; - System.Array.Sort(FinalIndices, (s1,s2) => {var sign = CentersY[s1] - CentersY[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); - System.Array.Copy(FinalIndices, 0, DimensionedIndices, PrimCount, PrimCount); + System.Array.Sort(FinalIndices, (s1,s2) => {var sign = ptr1[s1] - ptr1[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); + CentersY.Dispose(); + NativeArray.Copy(FinalIndices, 0, DimensionedIndicesArray, PrimCount, PrimCount); for(int i = 0; i < PrimCount; i++) FinalIndices[i] = i; - System.Array.Sort(FinalIndices, (s1,s2) => {var sign = CentersZ[s1] - CentersZ[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); - System.Array.Copy(FinalIndices, 0, DimensionedIndices, PrimCount * 2, PrimCount); + System.Array.Sort(FinalIndices, (s1,s2) => {var sign = ptr2[s1] - ptr2[s2]; return sign < 0 ? -1 : (sign == 0 ? 0 : 1);}); + CentersZ.Dispose(); + NativeArray.Copy(FinalIndices, 0, DimensionedIndicesArray, PrimCount * 2, PrimCount); + CommonFunctions.DeepClean(ref FinalIndices); int nodeIndex = 2; BuildRecursive(0, ref nodeIndex,0,PrimCount, 1); + indices_going_left_array.Dispose(); + tempArray.Dispose(); + SAHArray.Dispose(); + for(int i = 0; i < PrimCount * 2; i++) { if(nodes2[i].isLeaf == 1) { nodes2[i].left = DimensionedIndices[nodes2[i].left]; @@ -387,7 +531,7 @@ public LightBVHBuilder(LightBounds[] Tris) {//need to make sure incomming is tra WorkingSet[i] = new ComputeBuffer(Set[i].Count, 4); WorkingSet[i].SetData(Set[i]); } - nodes = new CompactLightBVHData[nodes2.Length]; + nodes = new CompactLightBVHData[PrimCount * 2]; for(int i = 0; i < PrimCount * 2; i++) { CompactLightBVHData TempNode = new CompactLightBVHData(); TempNode.BBMax = nodes2[i].aabb.b.BBMax; @@ -402,19 +546,83 @@ public LightBVHBuilder(LightBounds[] Tris) {//need to make sure incomming is tra } nodes[i] = TempNode; } - ParentBound = nodes2[0]; - CommonFunctions.DeepClean(ref nodes2); + DimensionedIndicesArray.Dispose(); + LightTrisArray.Dispose(); + nodes2Array.Dispose(); + +#if !DontUseSGTree + { + for(int i = 0; i < MaxDepth; i++) Set[i] = new List(); + Refit2(0, 0); + for(int i = MaxDepth - 1; i >= 0; i--) { + int SetCount = Set[i].Count; + for(int j = 0; j < SetCount; j++) { + GaussianTreeNode TempNode = new GaussianTreeNode(); + int WriteIndex = Set[i][j]; + CompactLightBVHData LBVHNode = nodes[WriteIndex]; + Vector3 V; + Vector3 mean; + float variance; + float intensity; + float radius; + if(LBVHNode.left < 0) { + TempNode = SGTreeNodes[-(LBVHNode.left+1)]; + Vector3 ExtendedCenter = CommonFunctions.ToVector3(LightBVHTransforms[-(LBVHNode.left+1)].Transform * CommonFunctions.ToVector4(TempNode.S.Center + new Vector3(TempNode.S.Radius, 0, 0), 1)); + Vector3 center = CommonFunctions.ToVector3(LightBVHTransforms[-(LBVHNode.left+1)].Transform * CommonFunctions.ToVector4(TempNode.S.Center, 1)); + Vector3 Axis = CommonFunctions.ToVector3(LightBVHTransforms[-(LBVHNode.left+1)].Transform * CommonFunctions.ToVector4(TempNode.axis, 0)); + float Scale = Vector3.Distance(center, ExtendedCenter) / TempNode.S.Radius; + TempNode.axis = Axis; + TempNode.S.Center = center; + TempNode.variance *= Scale; + TempNode.S.Radius *= Scale; + TempNode.intensity *= Scale; + } else { + GaussianTreeNode LeftNode = SGTree[nodes[WriteIndex].left]; + GaussianTreeNode RightNode = SGTree[nodes[WriteIndex].left + 1]; + + float phi_left = LeftNode.intensity; + float phi_right = RightNode.intensity; + float w_left = phi_left / (phi_left + phi_right); + float w_right = phi_right / (phi_left + phi_right); + + V = w_left * LeftNode.axis + w_right * RightNode.axis;//may be wrong, paper uses BAR_V(BAR_axis here), not just normalized V/axis + + mean = w_left * LeftNode.S.Center + w_right * RightNode.S.Center; + variance = w_left * LeftNode.variance + w_right * RightNode.variance + w_left * w_right * Vector3.Dot(LeftNode.S.Center - RightNode.S.Center, LeftNode.S.Center - RightNode.S.Center); + + intensity = LeftNode.intensity + RightNode.intensity; + radius = Mathf.Max(Vector3.Distance(mean, LeftNode.S.Center) + LeftNode.S.Radius, Vector3.Distance(mean, RightNode.S.Center) + RightNode.S.Radius); + TempNode.sharpness = ((3.0f * Vector3.Distance(Vector3.zero, V) - Mathf.Pow(Vector3.Distance(Vector3.zero, V), 3))) / (1.0f - Mathf.Pow(Vector3.Distance(Vector3.zero, V), 2)); + TempNode.axis = V; + TempNode.S.Center = mean; + TempNode.variance = variance; + TempNode.intensity = intensity; + TempNode.S.Radius = radius; + } + + TempNode.left = LBVHNode.left; + SGTree[WriteIndex] = TempNode; + } + } + } + CommonFunctions.DeepClean(ref nodes); +#endif + } public void ClearAll() { - CommonFunctions.DeepClean(ref LightTris); - CommonFunctions.DeepClean(ref nodes2); - CommonFunctions.DeepClean(ref nodes); - CommonFunctions.DeepClean(ref SAH); - CommonFunctions.DeepClean(ref indices_going_left); - CommonFunctions.DeepClean(ref temp); - CommonFunctions.DeepClean(ref DimensionedIndices); + // LightTrisArray.Dispose(); + // nodes2Array.Dispose(); + // // nodesArray.Dispose(); + // SAHArray.Dispose(); + // indices_going_left_array.Dispose(); + // tempArray.Dispose(); + // DimensionedIndicesArray.Dispose(); CommonFunctions.DeepClean(ref FinalIndices); + CommonFunctions.DeepClean(ref nodes); +#if !DontUseSGTree + CommonFunctions.DeepClean(ref SGTree); +#endif } } } \ No newline at end of file diff --git a/TrueTrace/Resources/GlobalDefines.cginc b/TrueTrace/Resources/GlobalDefines.cginc index 67d650ab..8f5b9526 100644 --- a/TrueTrace/Resources/GlobalDefines.cginc +++ b/TrueTrace/Resources/GlobalDefines.cginc @@ -2,6 +2,7 @@ // #define HDRP // #define DX11 #define UseBindless +#define UseSGTree //Dont modify above, CPU code will do automatically #define AdvancedAlphaMapped #define ExtraSampleValidation @@ -23,6 +24,10 @@ // #define AdvancedRadCacheAlt // #define UseTextureLOD // #define vMFDiffuse +#define EONDiffuse +// #define AdvancedBackground +#define UseBRDFLights + //END OF DEFINES //DEBUG VIEW DEFINES @@ -50,7 +55,11 @@ #define AREALIGHTDISK 4 #define TRILIGHT 5 + #define NormalOffset 0.0001f +#define ShadowDistanceFudgeFactor 0.0001f + + #define IsEmissionMask 0 #define BaseIsMap 1 @@ -62,6 +71,7 @@ #define Invisible 7 #define BackgrounBleed 8 #define Thin 9 +#define VertexColors 10 #define SampleAlbedo 0 #define SampleMetallic 1 @@ -75,6 +85,7 @@ #define SampleTerrainAlbedo 9 #define SampleSecondaryAlbedo 10 #define SampleSecondaryAlbedoMask 11 +#define SampleDetailNormal 12 #define BlendModeLerp 0 #define BlendModeAdd 1 @@ -89,3 +100,4 @@ int GetFlagStretch(int FlagVar, int LeftOffset, int Stride) { } #define MaxTraversalSamples 1000 +#define ShadowDistanceFudgeFactor 0.0001f diff --git a/TrueTrace/Resources/MainCompute/CommonData.cginc b/TrueTrace/Resources/MainCompute/CommonData.cginc index d62fa5a4..25995d55 100644 --- a/TrueTrace/Resources/MainCompute/CommonData.cginc +++ b/TrueTrace/Resources/MainCompute/CommonData.cginc @@ -3,7 +3,7 @@ #define EPSILON 1e-8 #include "CommonStructs.cginc" - +#define TOHALF(x) float2(f16tof32(x >> 16), f16tof32(x & 0xFFFF)) bool OIDNGuideWrite; @@ -134,9 +134,9 @@ inline TrianglePos triangle_get_positions(const int ID) { inline TriangleUvs triangle_get_positions2(const int ID) { TriangleUvs tri; - tri.pos0 = AggTris.Load(ID).tex0; - tri.posedge1 = AggTris.Load(ID).texedge1; - tri.posedge2 = AggTris.Load(ID).texedge2; + tri.pos0 = TOHALF(AggTris.Load(ID).tex0); + tri.posedge1 = TOHALF(AggTris.Load(ID).texedge1); + tri.posedge2 = TOHALF(AggTris.Load(ID).texedge2); return tri; } @@ -235,6 +235,9 @@ inline float4 SampleTexture(float2 UV, int TextureType, const MaterialData MatTe case SampleSecondaryAlbedoMask: FinalCol = SingleComponentAtlas.SampleLevel(my_linear_clamp_sampler, AlignUV(UV, MatTex.AlbedoTexScale, MatTex.SecondaryAlbedoMask, MatTex.Rotation), 0); break; + case SampleDetailNormal: + FinalCol = _NormalAtlas.SampleLevel(sampler_NormalAtlas, AlignUV(UV, MatTex.SecondaryNormalTexScaleOffset, MatTex.SecondaryNormalTex, MatTex.Rotation), 0).xyxy; + break; } #else//BINDLESS //AlbedoTexScale, AlbedoTex, and Rotation dont worry about, thats just for transforming to the atlas @@ -260,6 +263,7 @@ inline float4 SampleTexture(float2 UV, int TextureType, const MaterialData MatTe case SampleTerrainAlbedo: TextureIndexAndChannel = MatTex.AlbedoTex; UV = (UV * MatTex.surfaceColor.xy + MatTex.transmittanceColor.xy) * MatTex.AlbedoTexScale.xy + MatTex.AlbedoTexScale.zw; break; case SampleSecondaryAlbedo: TextureIndexAndChannel = MatTex.SecondaryAlbedoTex; UV = UV * MatTex.SecondaryAlbedoTexScaleOffset.xy + MatTex.SecondaryAlbedoTexScaleOffset.zw; break; case SampleSecondaryAlbedoMask: TextureIndexAndChannel = MatTex.SecondaryAlbedoMask; UV = UV * MatTex.AlbedoTexScale.xy + MatTex.AlbedoTexScale.zw; break; + case SampleDetailNormal: TextureIndexAndChannel = MatTex.SecondaryNormalTex; UV = UV * MatTex.SecondaryNormalTexScaleOffset.xy + MatTex.SecondaryNormalTexScaleOffset.zw; break; } int TextureIndex = TextureIndexAndChannel.x - 1; int TextureReadChannel = TextureIndexAndChannel.y;//0-3 is rgba, 4 is to just read all @@ -278,7 +282,7 @@ inline float4 SampleTexture(float2 UV, int TextureType, const MaterialData MatTe #endif #endif if(TextureReadChannel != 4) FinalCol = FinalCol[TextureReadChannel]; - if(TextureType == SampleNormal) { + if(TextureType == SampleNormal || TextureType == SampleDetailNormal) { FinalCol.g = 1.0f - FinalCol.g; FinalCol = (FinalCol.r >= 0.99f) ? FinalCol.agag : FinalCol.rgrg; @@ -474,6 +478,81 @@ float3 unpackRGBE(uint x) return v; } +float encode_diamond(float2 p) +{ + // Project to the unit diamond, then to the x-axis. + float x = p.x / (abs(p.x) + abs(p.y)); + + // Contract the x coordinate by a factor of 4 to represent all 4 quadrants in + // the unit range and remap + float py_sign = sign(p.y); + return -py_sign * 0.25f * x + 0.5f + py_sign * 0.25f; +} + +float2 decode_diamond(float p) +{ + float2 v; + + // Remap p to the appropriate segment on the diamond + float p_sign = sign(p - 0.5f); + v.x = -p_sign * 4.f * p + 1.f + p_sign * 2.f; + v.y = p_sign * (1.f - abs(v.x)); + + // Normalization extends the point on the diamond back to the unit circle + return normalize(v); +} + +// Given a normal and tangent vector, encode the tangent as a single float that can be +// subsequently quantized. +float encode_tangent(float3 normal, float3 tangent) +{ + // First, find a canonical direction in the tangent plane + float3 t1; + if (abs(normal.y) > abs(normal.z)) + { + // Pick a canonical direction orthogonal to n with z = 0 + t1 = float3(normal.y, -normal.x, 0.f); + } + else + { + // Pick a canonical direction orthogonal to n with y = 0 + t1 = float3(normal.z, 0.f, -normal.x); + } + t1 = normalize(t1); + + // Construct t2 such that t1 and t2 span the plane + float3 t2 = cross(t1, normal); + + // Decompose the tangent into two coordinates in the canonical basis + float2 packed_tangent = float2(dot(tangent, t1), dot(tangent, t2)); + + // Apply our diamond encoding to our two coordinates + return encode_diamond(packed_tangent); +} + +float3 decode_tangent(float3 normal, float diamond_tangent) +{ + // As in the encode step, find our canonical tangent basis span(t1, t2) + float3 t1; + if (abs(normal.y) > abs(normal.z)) + { + t1 = float3(normal.y, -normal.x, 0.f); + } + else + { + t1 = float3(normal.z, 0.f, -normal.x); + } + t1 = normalize(t1); + + float3 t2 = cross(t1, normal); + + // Recover the coordinates used with t1 and t2 + float2 packed_tangent = decode_diamond(diamond_tangent); + + return packed_tangent.x * t1 + packed_tangent.y * t2; +} + + SmallerRay CreateCameraRay(float2 uv, uint pixel_index) { // Transform the camera origin to world space float3 origin = mul(CamToWorld, float4(0.0f, 0.0f, 0.0f, 1.0f)).xyz; @@ -554,7 +633,57 @@ static float3 CalculateExtinction2(float3 apparantColor, float scatterDistance) return 1.0f / (s * scatterDistance); } //shadow_triangle -inline bool triangle_intersect_shadow(int tri_id, const SmallerRay ray, float max_distance, int mesh_id, inout float3 throughput, const int MatOffset) { +//triangle_shadow +//putting these^ here cuz I ALWAYS ctrl + f for the WRONG term when trying to find this function... +inline bool triangle_intersect_shadow(int tri_id, const SmallerRay ray, const float max_distance, inout float3 throughput, const int MatOffset) { + TrianglePos tri = triangle_get_positions(tri_id); + TriangleUvs tri2 = triangle_get_positions2(tri_id); + int MaterialIndex = (MatOffset + AggTris[tri_id].MatDat); + + float3 h = cross(ray.direction, tri.posedge2); + float a = dot(tri.posedge1, h); + + float f = rcp(a); + float3 s = ray.origin - tri.pos0; + float u = f * dot(s, h); + + if (u >= 0.0f && u <= 1.0f) { + float3 q = cross(s, tri.posedge1); + float v = f * dot(ray.direction, q); + + if (v >= 0.0f && u + v <= 1.0f) { + float t = f * dot(tri.posedge2, q); + [branch] if (t > 0.0f && t < max_distance) { + #if defined(AdvancedAlphaMapped) || defined(AdvancedBackground) || defined(IgnoreGlassShadow) + if(GetFlag(_Materials[MaterialIndex].Tag, IsBackground) || GetFlag(_Materials[MaterialIndex].Tag, ShadowCaster)) return false; + if(_Materials[MaterialIndex].MatType == CutoutIndex || _Materials[MaterialIndex].specTrans == 1) { + float2 BaseUv = tri2.pos0 * (1.0f - u - v) + tri2.posedge1 * u + tri2.posedge2 * v; + if(_Materials[MaterialIndex].MatType == CutoutIndex && _Materials[MaterialIndex].AlphaTex.x > 0) + if( SampleTexture(BaseUv, SampleAlpha, _Materials[MaterialIndex]).x < _Materials[MaterialIndex].AlphaCutoff) return false; + + #ifdef IgnoreGlassShadow + if(_Materials[MaterialIndex].specTrans == 1) { + #ifdef StainedGlassShadows + float3 MatCol = _Materials[MaterialIndex].surfaceColor; + if(_Materials[MaterialIndex].AlbedoTex.x > 0) MatCol *= SampleTexture(BaseUv, SampleAlbedo, _Materials[MaterialIndex]) / 3.0f; + MatCol = lerp(MatCol, _Materials[MaterialIndex].BlendColor, _Materials[MaterialIndex].BlendFactor); + //float Dotter = abs(dot(normalize(cross(normalize(tri.posedge1), normalize(tri.posedge2))), ray.direction)); + + throughput *= sqrt(exp(-CalculateExtinction2(1.0f - MatCol, _Materials[MaterialIndex].scatterDistance == 0.0f ? 1.0f : _Materials[MaterialIndex].scatterDistance))); + #endif + return false; + } + #endif + } + #endif + return true; + } + } + } + + return false; +} +inline void triangle_intersect_dist(int tri_id, const SmallerRay ray, inout float max_distance, int mesh_id, const int MatOffset) { TrianglePos tri = triangle_get_positions(tri_id); TriangleUvs tri2 = triangle_get_positions2(tri_id); int MaterialIndex = (MatOffset + AggTris[tri_id].MatDat); @@ -572,12 +701,12 @@ inline bool triangle_intersect_shadow(int tri_id, const SmallerRay ray, float ma if (v >= 0.0f && u + v <= 1.0f) { float t = f * dot(tri.posedge2, q); - #ifdef AdvancedAlphaMapped - if(GetFlag(_Materials[MaterialIndex].Tag, IsBackground) || GetFlag(_Materials[MaterialIndex].Tag, ShadowCaster)) return false; + #if defined(AdvancedAlphaMapped) || defined(AdvancedBackground) || defined(IgnoreGlassShadow) + if(GetFlag(_Materials[MaterialIndex].Tag, IsBackground) || GetFlag(_Materials[MaterialIndex].Tag, ShadowCaster)) return; if(_Materials[MaterialIndex].MatType == CutoutIndex || _Materials[MaterialIndex].specTrans == 1) { float2 BaseUv = tri2.pos0 * (1.0f - u - v) + tri2.posedge1 * u + tri2.posedge2 * v; if(_Materials[MaterialIndex].MatType == CutoutIndex && _Materials[MaterialIndex].AlphaTex.x > 0) - if( SampleTexture(BaseUv, SampleAlpha, _Materials[MaterialIndex]).x < _Materials[MaterialIndex].AlphaCutoff) return false; + if( SampleTexture(BaseUv, SampleAlpha, _Materials[MaterialIndex]).x < _Materials[MaterialIndex].AlphaCutoff) return; #ifdef IgnoreGlassShadow if(_Materials[MaterialIndex].specTrans == 1) { @@ -585,19 +714,24 @@ inline bool triangle_intersect_shadow(int tri_id, const SmallerRay ray, float ma float3 MatCol = _Materials[MaterialIndex].surfaceColor; if(_Materials[MaterialIndex].AlbedoTex.x > 0) MatCol *= SampleTexture(BaseUv, SampleAlbedo, _Materials[MaterialIndex]) / 3.0f; MatCol = lerp(MatCol, _Materials[MaterialIndex].BlendColor, _Materials[MaterialIndex].BlendFactor); - throughput *= sqrt(exp(-CalculateExtinction2(1.0f - MatCol, _Materials[MaterialIndex].scatterDistance == 0.0f ? 1.0f : _Materials[MaterialIndex].scatterDistance))); #endif - return false; + return; } #endif } #endif - if (t > 0.0f && t < max_distance) return true; + if (t > 0.0f && t < max_distance) { + max_distance = t; + return; + } } } - return false; + return; } + + + inline uint ray_get_octant_inv4(const float3 ray_direction) { return (ray_direction.x < 0.0f ? 0 : 0x04040404) | @@ -686,6 +820,106 @@ inline uint cwbvh_node_intersect(const SmallerRay ray, int oct_inv4, float max_d } + +inline void Closest_Hit_Compute(SmallerRay ray, inout float MinDist) { + uint2 stack[16]; + int stack_size = 0; + uint2 current_group; + + uint oct_inv4; + int tlas_stack_size = -1; + int mesh_id = -1; + SmallerRay ray2; + int TriOffset = 0; + int NodeOffset = 0; + + ray2 = ray; + + oct_inv4 = ray_get_octant_inv4(ray.direction); + + current_group.x = (uint)0; + current_group.y = (uint)0x80000000; + int MatOffset = 0; + int Reps = 0; + [loop] while (Reps < MaxTraversalSamples) {//Traverse Accelleration Structure(Compressed Wide Bounding Volume Hierarchy) + uint2 triangle_group; + [branch]if (current_group.y & 0xff000000) { + uint child_index_offset = firstbithigh(current_group.y); + + uint slot_index = (child_index_offset - 24) ^ (oct_inv4 & 0xff); + uint relative_index = countbits(current_group.y & ~(0xffffffff << slot_index)); + uint child_node_index = current_group.x + relative_index; + const BVHNode8Data TempNode = cwbvh_nodes[child_node_index]; + + current_group.y &= ~(1 << child_index_offset); + + if (current_group.y & 0xff000000) stack[stack_size++] = current_group; + + uint hitmask = cwbvh_node_intersect(ray, oct_inv4, MinDist, TempNode); + + current_group.y = (hitmask & 0xff000000) | ((TempNode.nodes[0].w >> 24) & 0xff); + triangle_group.y = (hitmask & 0x00ffffff); + + current_group.x = (TempNode.nodes[1].x) + NodeOffset; + triangle_group.x = (TempNode.nodes[1].y) + TriOffset; + Reps++; + } else { + triangle_group = current_group; + current_group = (uint2)0; + } + + if(triangle_group.y != 0) { + [branch]if (tlas_stack_size == -1) {//Transfer from Top Level Accelleration Structure to Bottom Level Accelleration Structure + uint mesh_offset = firstbithigh(triangle_group.y); + triangle_group.y &= ~(1 << mesh_offset); + mesh_id = TLASBVH8Indices[triangle_group.x + mesh_offset]; + NodeOffset = _MeshData[mesh_id].NodeOffset; + TriOffset = _MeshData[mesh_id].TriOffset; + + if (triangle_group.y != 0) stack[stack_size++] = triangle_group; + + if (current_group.y & 0xff000000) stack[stack_size++] = current_group; + + tlas_stack_size = stack_size; + + int root_index = (_MeshData[mesh_id].mesh_data_bvh_offsets & 0x7fffffff); + + MatOffset = _MeshData[mesh_id].MaterialOffset; + ray.direction = (mul((float3x3)_MeshData[mesh_id].W2L, ray.direction)).xyz; + ray.origin = (mul(_MeshData[mesh_id].W2L, float4(ray.origin, 1))).xyz; + + oct_inv4 = ray_get_octant_inv4(ray.direction); + + current_group.x = (uint)root_index; + current_group.y = (uint)0x80000000; + } else { + while (triangle_group.y != 0) { + uint triangle_index = firstbithigh(triangle_group.y); + triangle_group.y &= ~(1 << triangle_index); + triangle_intersect_dist(triangle_group.x + triangle_index, ray, MinDist, mesh_id, MatOffset); + } + } + } + + if ((current_group.y & 0xff000000) == 0) { + if (stack_size == 0) {//thread has finished traversing + break; + } + + if (stack_size == tlas_stack_size) { + NodeOffset = 0; + TriOffset = 0; + tlas_stack_size = -1; + ray = ray2; + oct_inv4 = ray_get_octant_inv4(ray.direction); + } + current_group = stack[--stack_size]; + } + } + return; +} + + inline bool VisabilityCheckCompute(SmallerRay ray, float dist) { uint2 stack[16]; int stack_size = 0; @@ -762,7 +996,7 @@ inline bool VisabilityCheckCompute(SmallerRay ray, float dist) { while (triangle_group.y != 0) { uint triangle_index = firstbithigh(triangle_group.y); triangle_group.y &= ~(1 << triangle_index); - if (triangle_intersect_shadow(triangle_group.x + triangle_index, ray, dist, mesh_id, through, MatOffset)) { + if (triangle_intersect_shadow(triangle_group.x + triangle_index, ray, dist, through, MatOffset)) { return false; } } @@ -956,6 +1190,358 @@ inline float AreaOfTriangle(float3 pt1, float3 pt2, float3 pt3) { return sqrt(s * (s - a) * (s - b) * (s - c)); } +static const float FLT_EPSILON = 1.192092896e-07f; + + + +inline float2 mulsign(const float2 x, const float2 y) +{ + return asfloat((asuint(y) & 0x80000000) ^ asuint(x)); +} + +inline float expm1(const float x) { + const float u = exp(x); + const float y = u - 1.0f; + return (u == 1.0f) ? x : (abs(x) < 1.0f ? y * x / log(u) : y); +} + + + +float erf2(const float x) +{ + // Early return for large |x|. + if (abs(x) >= 4.0) + { + return mulsign(1.0, x); + } + + // Polynomial approximation based on the approximation posted in https://forums.developer.nvidia.com/t/optimized-version-of-single-precision-error-function-erff/40977 + [branch]if (abs(x) > 1.0) + { + // The maximum error is smaller than the approximation described in Abramowitz and Stegun [1964 "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables", 7.1.26, p.299]. + const float A1 = 1.628459513; + const float A2 = 9.15674746e-1; + const float A3 = 1.54329389e-1; + const float A4 = -3.51759829e-2; + const float A5 = 5.66795561e-3; + const float A6 = -5.64874616e-4; + const float A7 = 2.58907676e-5; + const float a = abs(x); + const float y = 1.0 - exp2(-(((((((A7 * a + A6) * a + A5) * a + A4) * a + A3) * a + A2) * a + A1) * a)); + + return mulsign(y, x); + } else { + + // The maximum error is smaller than the 6th order Taylor polynomial. + const float A1 = 1.128379121; + const float A2 = -3.76123011e-1; + const float A3 = 1.12799220e-1; + const float A4 = -2.67030653e-2; + const float A5 = 4.90735564e-3; + const float A6 = -5.58853149e-4; + const float x2 = x * x; + + return (((((A6 * x2 + A5) * x2 + A4) * x2 + A3) * x2 + A2) * x2 + A1) * x; + } +} + +float erfc(const float x) +{ + return 1.0 - erf2(x); +} + + +inline float vmf_hemispherical_integral ( float cosine , float sharpness ) { + // Interpolation factor [ Tokuyoshi 2022]. + float steepness = sharpness * sqrt ((0.5 * sharpness + 0.65173288269070562) / (( sharpness + 1.3418280033141288) * + sharpness + 7.2216687798956709) ) ; + float v = saturate (0.5 + 0.5 * ( erf2( steepness * clamp ( cosine , -1.0 , 1.0) ) / erf2( steepness ) ) ) ; + // Interpolation between upper and lower hemispherical integrals . + float e = exp( - sharpness ) ; + return lerp (e , 1.0 , v ) / ( e + 1.0) ; +} + +inline float VMFHemisphericalIntegral(const float cosine, const float sharpness) +{ + // Interpolation factor [Tokuyoshi 2022]. + const float A = 0.6517328826907056171791055021459f; + const float B = 1.3418280033141287699294252888649f; + const float C = 7.2216687798956709087860872386955f; + const float steepness = sharpness * sqrt((0.5 * sharpness + A) / ((sharpness + B) * sharpness + C)); + const float lerpFactor = saturate(0.5 + 0.5 * (erf2(steepness * clamp(cosine, -1.0, 1.0)) / erf2(steepness))); + + // Interpolation between upper and lower hemispherical integrals . + const float e = exp(-sharpness); + + return lerp(e, 1.0, lerpFactor) / (e + 1.0); +} + +struct SGLobe { + float3 axis ; + float sharpness ; + float logAmplitude ; +}; +inline SGLobe sg_product ( float3 axis1 , float sharpness1 , float3 axis2 , float sharpness2 ) { + float3 axis = axis1 * sharpness1 + axis2 * sharpness2 ; + float sharpness = length ( axis ) ; + float cosine = clamp (dot( axis1 , axis2 ) , -1.0 , 1.0) ; + float sharpnessMin = min( sharpness1 , sharpness2 ) ; + float sharpnessRatio = sharpnessMin / max( sharpness1 , sharpness2 ) ; + float logAmplitude = 2.0 * sharpnessMin * ( cosine - 1.0) / (1.0 + sharpnessRatio + sqrt (2.0 * sharpnessRatio * cosine + + sharpnessRatio * sharpnessRatio + 1.0) ) ; + SGLobe result = { axis / max( sharpness , EPSILON ) , sharpness , logAmplitude }; + return result ; +} +static const float FLT_MAX = 3.402823466e+38f; + + +// [Tokuyoshi et al. 2024 "Hierarchical Light Sampling with Accurate Spherical Gaussian Lighting (Supplementary Document)" Listing. 5] +inline float UpperSGClampedCosineIntegralOverTwoPi(const float sharpness) +{ + [branch]if (sharpness <= 0.5) + { + // Taylor-series approximation for the numerical stability. + // TODO: Derive a faster polynomial approximation. + return (((((((-1.0 / 362880.0) * sharpness + 1.0 / 40320.0) * sharpness - 1.0 / 5040.0) * sharpness + 1.0 / 720.0) * sharpness - 1.0 / 120.0) * sharpness + 1.0 / 24.0) * sharpness - 1.0 / 6.0) * sharpness + 0.5; + } + + return (expm1(-sharpness) + sharpness) * rcp(sharpness * sharpness); +} + +// [Tokuyoshi et al. 2024 "Hierarchical Light Sampling with Accurate Spherical Gaussian Lighting (Supplementary Document)" Listing. 6] +inline float LowerSGClampedCosineIntegralOverTwoPi(const float sharpness) +{ + const float e = exp(-sharpness); + + [branch]if (sharpness <= 0.5) + { + // Taylor-series approximation for the numerical stability. + // TODO: Derive a faster polynomial approximation. + return e * (((((((((1.0 / 403200.0) * sharpness - 1.0 / 45360.0) * sharpness + 1.0 / 5760.0) * sharpness - 1.0 / 840.0) * sharpness + 1.0 / 144.0) * sharpness - 1.0 / 30.0) * sharpness + 1.0 / 8.0) * sharpness - 1.0 / 3.0) * sharpness + 0.5); + } + + return e * (-expm1(-sharpness) - sharpness * e) * rcp(sharpness * sharpness); +} + +// Approximate product integral of an SG and clamped cosine / pi. +// [Tokuyoshi et al. 2024 "Hierarchical Light Sampling with Accurate Spherical Gaussian Lighting (Supplementary Document)" Listing. 7] +inline float SGClampedCosineProductIntegralOverPi2024(const float cosine, const float sharpness) +{ + const float t = sharpness * sqrt(0.5 * ((sharpness + 2.7360831611272558028247203765204f) * sharpness + 17.02129778174187535455530451145f) / (((sharpness + 4.0100826728510421403939290030394f) * sharpness + 15.219156263147210594866010069381f) * sharpness + 76.087896272360737270901154261082f)); + const float tz = t * cosine;//can these EVER GET NEGATIVE + + // In this HLSL implementation, we roughly implement erfc(x) = 1 - erf2(x) which can have a numerical error for large x. + // Therefore, unlike the original impelemntation [Tokuyoshi et al. 2024], we clamp the lerp factor with the machine epsilon / 2 for a conservative approximation. + // This clamping is unnecessary for languages that have a precise erfc function (e.g., C++). + // The original implementation [Tokuyoshi et al. 2024] uses a precise erfc function and does not clamp the lerp factor. + const float INV_SQRTPI = 0.56418958354775628694807945156077f; // = 1/sqrt(pi). + const float CLAMPING_THRESHOLD = 0.5 * FLT_EPSILON; // Set zero if a precise erfc function is available. + + float ERFCTZ = 1.0f; + float ERFCT = 1.0f; + { + const float A1 = 1.628459513; + const float A2 = 9.15674746e-1; + const float A3 = 1.54329389e-1; + const float A4 = -3.51759829e-2; + const float A5 = 5.66795561e-3; + const float A6 = -5.64874616e-4; + const float A7 = 2.58907676e-5; + + const float B1 = 1.128379121; + const float B2 = -3.76123011e-1; + const float B3 = 1.12799220e-1; + const float B4 = -2.67030653e-2; + const float B5 = 4.90735564e-3; + const float B6 = -5.58853149e-4; + + float a; + if (abs(tz) >= 4.0) { + ERFCTZ = mulsign(1.0, -tz); + } else if (abs(tz) > 1.0) { + a = abs(tz); + a = 1.0 - exp2(-(((((((A7 * a + A6) * a + A5) * a + A4) * a + A3) * a + A2) * a + A1) * a)); + + ERFCTZ = mulsign(a, -tz); + } else { + a = tz * tz; + ERFCTZ = (((((B6 * a + B5) * a + B4) * a + B3) * a + B2) * a + B1) * -tz; + } + + [branch]if (t >= 4.0) { + ERFCT = mulsign(1.0, t); + } else if (t > 1.0) { + a = 1.0 - exp2(-(((((((A7 * t + A6) * t + A5) * t + A4) * t + A3) * t + A2) * t + A1) * t)); + + ERFCT = mulsign(a, t); + } else { + a = t * t; + ERFCT = (((((B6 * a + B5) * a + B4) * a + B3) * a + B2) * a + B1) * t; + } + ERFCT = 1.0f - ERFCT; + ERFCTZ = 1.0f - ERFCTZ; + + + + } + + + + const float lerpFactor = saturate(max(0.5f * (cosine * ERFCTZ + ERFCT) - 0.5f * INV_SQRTPI * exp(-tz * tz) * expm1(t * t * (cosine * cosine - 1.0)) * rcp(t), CLAMPING_THRESHOLD)); + + // Interpolation between lower and upper hemispherical integrals. + const float lowerIntegral = LowerSGClampedCosineIntegralOverTwoPi(sharpness); + const float upperIntegral = UpperSGClampedCosineIntegralOverTwoPi(sharpness); + + return 2.0 * lerp(lowerIntegral, upperIntegral, lerpFactor); +} + + +// Symmetry GGX using a 2x2 roughness matrix (i.e., Non-axis-aligned GGX w/o the Heaviside function). +inline float SGGX(const float3 m, const float2x2 roughnessMat) +{ + const float det = max(determinant(roughnessMat), EPSILON); // TODO: Use Kahan's algorithm for precise determinant. [https://pharr.org/matt/blog/2019/11/03/difference-of-floats] + const float2x2 roughnessMatAdj = { roughnessMat._22, -roughnessMat._12, -roughnessMat._21, roughnessMat._11 }; + const float length2 = dot(m.xz, mul(roughnessMatAdj, m.xz)) / det + m.y * m.y; // TODO: Use Kahan's algorithm for precise mul and dot. [https://pharr.org/matt/blog/2019/11/03/difference-of-floatshttps://pharr.org/matt/blog/2019/11/03/difference-of-floats] + + return 1.0 / (PI * sqrt(det) * (length2 * length2)); +} + +// Reflection lobe based the symmetric GGX VNDF. +// [Tokuyoshi et al. 2024 "Hierarchical Light Sampling with Accurate Spherical Gaussian Lighting", Section 5.2] +inline float SGGXReflectionPDF(const float3 wi, const float3 m, const float2x2 roughnessMat) +{ + return SGGX(m, roughnessMat) * rcp(max(4.0 * sqrt(dot(wi.xz, mul(roughnessMat, wi.xz)) + wi.y * wi.y), EPSILON)); // TODO: Use Kahan's algorithm for precise mul and dot. [https://pharr.org/matt/blog/2019/11/03/difference-of-floats] +} + + +inline float expm1_over_x(const float x) +{ + const float u = exp(x); + + if (u == 1.0) + { + return 1.0; + } + + const float y = u - 1.0; + + if (abs(x) < 1.0) + { + return y * rcp(log(u)); + } + + return y * rcp(x); +} + + +inline float SGIntegral(const float sharpness) +{ + return 4.0 * PI * expm1_over_x(-2.0 * sharpness); +} + + + /* + is cross(B,N) = T? + if so, origional actually constructs the frame as TBN, so the swap between .y and .z should hold up well + I really need to bite the bullet and convert my materials and thus their tangent frames to use TBN instead of TNB, since everyone uses TBN + but Z->Up is just weird + if cross(B,N) = T, why do they use that to add the tangent to the frame? why not just use the tangent thats already in the function? is it a handedness or sign issue? + + + Unrelated: see if I can use the hypothesis tests for firefly detection... + + Thank god the code snippets from the paper and for the determinant were in HLSL + i do NOT want to deal with re-swizzling the matrices....(side note, look into this to make sure I actually dont) + + */ + +bool IsFinite(float x) +{ + return (asuint(x) & 0x7F800000) != 0x7F800000; +} + +inline float SGImportance(const GaussianTreeNode TargetNode, const float3 viewDirTS, const float3 p, const float3 n, const float2 projRoughness2, const float3 reflecVec, const float3x3 tangentFrame) { + // if(TargetNode.intensity <= 0) return 0; + float3 to_light = TargetNode.position - p; + const float squareddist = dot(to_light, to_light); + + // const float c = clamp(dot(n, -(to_light)) / sqrt(squareddist), 0, 1); + + // Compute the Jacobian J for the transformation between halfvetors and reflection vectors at halfvector = normal. + // const float3 viewDirTS = mul(tangentFrame, viewDir);//their origional one constructs the tangent frame from N,T,BT, whereas mine constructs it from T,N,BT; problem? I converted all .y to .z and vice versa, but... + + const float vlen = length(viewDirTS.xz); + const float2 v = (vlen != 0.0) ? (viewDirTS.xz / vlen) : float2(1.0, 0.0); + const float2x2 reflecJacobianMat = mul(float2x2(v.x, -v.y, v.y, v.x), float2x2(0.5, 0.0, 0.0, 0.5f / viewDirTS.y)); + + // Compute JJ^T matrix. + const float2x2 jjMat = mul(reflecJacobianMat, transpose(reflecJacobianMat)); + const float detJJ4 = rcp(4.0 * viewDirTS.y * viewDirTS.y); // = 4 * determiant(JJ^T). + + + // TargetNode.variance = 0.5f * TargetNode.radius * TargetNode.radius; + const float Variance = max(TargetNode.variance, (1.0f / pow(2, 31)) * squareddist);// * (1.0f - c) + 0.5f * (TargetNode.radius * TargetNode.radius) * c; + // Variance = Variance * (1.0f - c) + 0.5f * (TargetNode.radius * TargetNode.radius) * c; + // float Variance = max(TargetNode.variance, squareddist); + + + to_light = normalize(to_light); + const SGLobe LightLobe = sg_product((TargetNode.axis), TargetNode.sharpness, to_light, squareddist / Variance); + + + const float emissive = (TargetNode.intensity) / (Variance * SGIntegral(TargetNode.sharpness)); + + const float amplitude = exp(LightLobe.logAmplitude); + const float cosine = clamp(dot(LightLobe.axis, n), -1.0, 1.0); + const float diffuseIllumination = amplitude * SGClampedCosineProductIntegralOverPi2024(cosine, LightLobe.sharpness); + + + const float3 prodVec = reflecVec + LightLobe.axis * LightLobe.sharpness; // Axis of the SG product lobe. + const float prodSharpness = length(prodVec); + const float3 prodDir = prodVec / prodSharpness; + const float LightLobeVariance = rcp(LightLobe.sharpness); + // if(id.y > screen_height / 2 + screen_height / 4) LightLobeVariance = LightLobeVariance * (1.0f - c) + 0.5f * (TargetNode.radius * TargetNode.radius) * c; + + const float2x2 filteredProjRoughnessMat = float2x2(projRoughness2.x, 0.0, 0.0, projRoughness2.y) + 2.0 * LightLobeVariance * jjMat; + + + + // Compute determinant(filteredProjRoughnessMat) in a numerically stable manner. + // See the supplementary document (Section 5.2) of the paper for the derivation. + const float det = projRoughness2.x * projRoughness2.y + 2.0 * LightLobeVariance * (projRoughness2.x * jjMat._11 + projRoughness2.y * jjMat._22) + LightLobeVariance * LightLobeVariance * detJJ4; + + // NDF filtering in a numerically stable manner. + // See the supplementary document (Section 5.2) of the paper for the derivation. + const float tr = filteredProjRoughnessMat._11 + filteredProjRoughnessMat._22; + const float2x2 filteredRoughnessMat = min(filteredProjRoughnessMat + float2x2(det, 0.0, 0.0, det), FLT_MAX) * rcp(1.0 + tr + det);//IsFinite(1.0 + tr + det) ? min(filteredProjRoughnessMat + float2x2(det, 0.0, 0.0, det), FLT_MAX) / (1.0 + tr + det) : (float2x2(min(filteredProjRoughnessMat._11, FLT_MAX) / min(filteredProjRoughnessMat._11 + 1.0, FLT_MAX), 0.0, 0.0, min(filteredProjRoughnessMat._22, FLT_MAX) / min(filteredProjRoughnessMat._22 + 1.0, FLT_MAX))); + + // Evaluate the filtered distribution. + const float3 halfvecUnormalized = viewDirTS + mul(tangentFrame, LightLobe.axis); + const float3 halfvec = halfvecUnormalized * rsqrt(max(dot(halfvecUnormalized, halfvecUnormalized), EPSILON)); + const float pdf = SGGXReflectionPDF(viewDirTS, halfvec, filteredRoughnessMat); + + // Visibility of the SG light in the upper hemisphere. + const float visibility = VMFHemisphericalIntegral(dot(prodDir, n), prodSharpness);// * (dot(n, to_light) >= 0 || TargetNode.radius >= sqrt(squareddist)); + + // Eq. 12 of the paper. + const float specularIllumination = amplitude * visibility * pdf * SGIntegral(LightLobe.sharpness); + + + return max(emissive * (diffuseIllumination + specularIllumination), 0.f); +} + + + + + + + + + + + + inline float cosSubClamped(float sinTheta_a, float cosTheta_a, float sinTheta_b, float cosTheta_b) { if(cosTheta_a > cosTheta_b) return 1; @@ -1004,9 +1590,15 @@ float Importance(const float3 p, const float3 n, LightBVHData node, bool HasHitT return max(importance, 0.f); // / (float) max(node.LightCount, 1); } +#ifdef UseSGTree +int CalcInside(GaussianTreeNode A, GaussianTreeNode B, float3 p, int Index) { + bool Residency0 = dot(p - A.position, p - A.position) <= A.radius * A.radius; + bool Residency1 = dot(p - B.position, p - B.position) <= B.radius * B.radius; +#else int CalcInside(LightBVHData A, LightBVHData B, float3 p, int Index) { bool Residency0 = all(p <= A.BBMax) && all(p >= A.BBMin); bool Residency1 = all(p <= B.BBMax) && all(p >= B.BBMin); +#endif if(Residency0 && Residency1) { return Index + 2; } else if(Residency0) { @@ -1016,7 +1608,11 @@ int CalcInside(LightBVHData A, LightBVHData B, float3 p, int Index) { } else return -1; } -void CalcLightPDF(inout float lightPDF, float3 p, float3 p2, float3 n, int pixel_index, int MeshIndex) { +#ifdef UseSGTree +void CalcLightPDF(inout float lightPDF, float3 p, float3 p2, float3 n, const int pixel_index, const int MeshIndex, const float2 sharpness, float3 viewDir, const float metallic, StructuredBuffer NodeBuffer, StructuredBuffer MeshBuffer) { +#else +void CalcLightPDF(inout float lightPDF, float3 p, float3 p2, float3 n, const int pixel_index, const int MeshIndex, const float2 sharpness, float3 viewDir, const float metallic, StructuredBuffer NodeBuffer, StructuredBuffer MeshBuffer) { +#endif int node_index = 0; int Reps = 0; bool HasHitTLAS = false; @@ -1025,14 +1621,33 @@ void CalcLightPDF(inout float lightPDF, float3 p, float3 p2, float3 n, int pixel int stacksize = 0; float RandNum = random(264, pixel_index).x; + + float3x3 tangentFrame = GetTangentSpace2(n); + const float2 roughness2 = sharpness * sharpness; + const float2 ProjRoughness2 = roughness2 / max(1.0 - roughness2, EPSILON); + const float reflecSharpness = (1.0 - max(roughness2.x, roughness2.y)) / max(2.0f * max(roughness2.x, roughness2.y), EPSILON); + float3 viewDirTS = mul(tangentFrame, viewDir);//their origional one constructs the tangent frame from N,T,BT, whereas mine constructs it from T,N,BT; problem? I converted all .y to .z and vice versa, but... + float3 reflecVec = reflect(-viewDir, n) * reflecSharpness; + while(Reps < 100) { Reps++; - LightBVHData node = LightNodes[node_index]; - if(node.left >= 0) { - float2 ci = float2( - Importance(p, n, LightNodes[node.left + NodeOffset], HasHitTLAS), - Importance(p, n, LightNodes[node.left + 1 + NodeOffset], HasHitTLAS) +#ifdef UseSGTree + GaussianTreeNode node = NodeBuffer[node_index]; +#else + LightBVHData node = SGTree[node_index]; +#endif + [branch]if(node.left >= 0) { +#ifdef UseSGTree + const float2 ci = float2( + SGImportance(NodeBuffer[node.left + NodeOffset], viewDirTS, p, n, ProjRoughness2, reflecVec, tangentFrame), + SGImportance(NodeBuffer[node.left + 1 + NodeOffset], viewDirTS, p, n, ProjRoughness2, reflecVec, tangentFrame) ); +#else + const float2 ci = float2( + Importance(p, n, SGTree[node.left + NodeOffset], HasHitTLAS), + Importance(p, n, SGTree[node.left + 1 + NodeOffset], HasHitTLAS) + ); +#endif // if(ci.x == 0 && ci.y == 0) {pmf = -1; return;} float sumweights = (ci.x + ci.y); @@ -1047,7 +1662,7 @@ void CalcLightPDF(inout float lightPDF, float3 p, float3 p2, float3 n, int pixel if(sum + ci[offset] <= up) sum += ci[offset++]; - int Index = CalcInside(LightNodes[node.left + NodeOffset], LightNodes[node.left + NodeOffset + 1], p2, offset); + int Index = CalcInside(SGTree[node.left + NodeOffset], SGTree[node.left + NodeOffset + 1], p2, offset); if(Index == -1) { if(stacksize == 0) {return;} float3 tempstack = stack[--stacksize]; @@ -1067,17 +1682,25 @@ void CalcLightPDF(inout float lightPDF, float3 p, float3 p2, float3 n, int pixel if(HasHitTLAS) { return; } else { - p = mul(_MeshData[MeshIndex].W2L, float4(p,1)); - p2 = mul(_MeshData[MeshIndex].W2L, float4(p2,1)); - float3x3 Inverse = (float3x3)inverse(_MeshData[MeshIndex].W2L); + p = mul(MeshBuffer[MeshIndex].W2L, float4(p,1)); + p2 = mul(MeshBuffer[MeshIndex].W2L, float4(p2,1)); + float3x3 Inverse = (float3x3)inverse(MeshBuffer[MeshIndex].W2L); float scalex = length(mul(Inverse, float3(1,0,0))); float scaley = length(mul(Inverse, float3(0,1,0))); float scalez = length(mul(Inverse, float3(0,0,1))); float3 Scale = pow(rcp(float3(scalex, scaley, scalez)),2); - n = normalize(mul(_MeshData[MeshIndex].W2L, float4(n,0)).xyz / Scale); - NodeOffset = _MeshData[MeshIndex].LightNodeOffset; + n = normalize(mul(MeshBuffer[MeshIndex].W2L, float4(n,0)).xyz / Scale); + viewDir = normalize(mul(MeshBuffer[MeshIndex].W2L, float4(viewDir,0)).xyz / Scale); + tangentFrame = GetTangentSpace2(n);//Need to maybe check to see if this holds up when the traversal backtracks due to dead end + viewDirTS = mul(tangentFrame, viewDir); + reflecVec = reflect(-viewDir, n) * reflecSharpness; + NodeOffset = MeshBuffer[MeshIndex].LightNodeOffset; node_index = NodeOffset; HasHitTLAS = true; + if(MeshIndex != _LightMeshes[-(node.left+1)].LockedMeshIndex) { + lightPDF = 1; + return; + } } } } @@ -1085,39 +1708,85 @@ void CalcLightPDF(inout float lightPDF, float3 p, float3 p2, float3 n, int pixel return; } -int SampleLightBVH(float3 p, float3 n, inout float pmf, int pixel_index, inout int MeshIndex) { + + + + +#ifdef UseSGTree +int SampleLightBVH(float3 p, float3 n, inout float pmf, const int pixel_index, inout int MeshIndex, const float2 sharpness, float3 viewDir, const float metallic, StructuredBuffer NodeBuffer, StructuredBuffer MeshBuffer) { +#else +int SampleLightBVH(float3 p, float3 n, inout float pmf, const int pixel_index, inout int MeshIndex, const float2 sharpness, float3 viewDir, const float metallic, StructuredBuffer NodeBuffer, StructuredBuffer MeshBuffer) { +#endif int node_index = 0; int Reps = 0; bool HasHitTLAS = false; int NodeOffset = 0; int StartIndex = 0; - while(Reps < 322) { + + float3x3 tangentFrame = GetTangentSpace2(n); + const float2 roughness2 = sharpness * sharpness; + const float2 ProjRoughness2 = roughness2 / max(1.0 - roughness2, EPSILON); + const float reflecSharpness = (1.0 - max(roughness2.x, roughness2.y)) / max(2.0f * max(roughness2.x, roughness2.y), EPSILON); + float3 viewDirTS = mul(tangentFrame, viewDir);//their origional one constructs the tangent frame from N,T,BT, whereas mine constructs it from T,N,BT; problem? I converted all .y to .z and vice versa, but... + float3 reflecVec = reflect(-viewDir, n) * reflecSharpness; + float RandNum = random(264 + Reps, pixel_index).x; + while(Reps < 222) { Reps++; - LightBVHData node = LightNodes[node_index]; +#ifdef UseSGTree + GaussianTreeNode node = NodeBuffer[node_index]; +#else + LightBVHData node = NodeBuffer[node_index]; +#endif [branch]if(node.left >= 0) { +#ifdef UseSGTree + const float2 ci = float2( + SGImportance(NodeBuffer[node.left + NodeOffset], viewDirTS, p, n, ProjRoughness2, reflecVec, tangentFrame), + SGImportance(NodeBuffer[node.left + 1 + NodeOffset], viewDirTS, p, n, ProjRoughness2, reflecVec, tangentFrame) + ); +#else const float2 ci = float2( - Importance(p, n, LightNodes[node.left + NodeOffset], HasHitTLAS), - Importance(p, n, LightNodes[node.left + 1 + NodeOffset], HasHitTLAS) + Importance(p, n, SGTree[node.left + NodeOffset], HasHitTLAS), + Importance(p, n, SGTree[node.left + 1 + NodeOffset], HasHitTLAS) ); +#endif if(ci.x == 0 && ci.y == 0) break; - bool Index = random(264 + Reps, pixel_index).x >= (ci.x / (ci.x + ci.y)); - pmf /= ((ci[Index] / (ci.x + ci.y))); + + float sumweights = (ci.x + ci.y); + float up = RandNum * sumweights; + if (up == sumweights) + { + up = asfloat(asuint(up) - 1); + } + int offset = 0; + float sum = 0; + if(sum + ci[offset] <= up) sum += ci[offset++]; + if(sum + ci[offset] <= up) sum += ci[offset++]; + + bool Index = RandNum >= (ci.x / sumweights); + RandNum = min((up - sum) / ci[Index], 1.0f - (1e-6)); + + pmf /= ((ci[Index] / sumweights)); node_index = node.left + Index + NodeOffset; + } else { [branch]if(HasHitTLAS) { return -(node.left+1) + StartIndex; } else { StartIndex = _LightMeshes[-(node.left+1)].StartIndex; MeshIndex = _LightMeshes[-(node.left+1)].LockedMeshIndex; - p = mul(_MeshData[MeshIndex].W2L, float4(p,1)); - float3x3 Inverse = (float3x3)inverse(_MeshData[MeshIndex].W2L); + float3x3 Inverse = (float3x3)inverse(MeshBuffer[MeshIndex].W2L); float scalex = length(mul(Inverse, float3(1,0,0))); float scaley = length(mul(Inverse, float3(0,1,0))); float scalez = length(mul(Inverse, float3(0,0,1))); float3 Scale = pow(rcp(float3(scalex, scaley, scalez)),2); - n = normalize(mul(_MeshData[MeshIndex].W2L, float4(n,0)).xyz / Scale); - NodeOffset = _MeshData[MeshIndex].LightNodeOffset; + p = mul(MeshBuffer[MeshIndex].W2L, float4(p,1)); + n = normalize(mul(MeshBuffer[MeshIndex].W2L, float4(n,0)).xyz / Scale); + viewDir = normalize(mul(MeshBuffer[MeshIndex].W2L, float4(viewDir,0)).xyz / Scale); + tangentFrame = GetTangentSpace2(n); + viewDirTS = mul(tangentFrame, viewDir); + reflecVec = reflect(-viewDir, n) * reflecSharpness; + NodeOffset = MeshBuffer[MeshIndex].LightNodeOffset; node_index = NodeOffset; HasHitTLAS = true; } @@ -1168,9 +1837,9 @@ void Unity_Saturation_float(float3 In, float Saturation, out float3 Out) { Out = luma.xxx + Saturation.xxx * (In - luma.xxx); } -void Unity_Contrast_float(float3 In, float Contrast, out float3 Out) { +void Unity_Contrast_float(inout float3 A, float Contrast) { float midpoint = pow(0.5, 2.2); - Out = (In - midpoint) * Contrast + midpoint; + A = (A - midpoint) * Contrast + midpoint; } float3 DeSat(float3 In, float Saturation) { @@ -1771,7 +2440,7 @@ inline int SelectUnityLight(int pixel_index, inout float lightWeight, float3 Nor if(PDF > 0) p_hat = max(luminance(light.Radiance) / (LengthSquared * max(PDF, 0.1f)),0); else p_hat = 0; } else { - p_hat = max(luminance(light.Radiance) / ((light.Type == DIRECTIONALLIGHT) ? 12.0f : LengthSquared) * ((light.Type == SPOTLIGHT) ? saturate(saturate(dot(to_light, -light.Direction)) * light.SpotAngle.x + light.SpotAngle.y) : 1)* (dot(to_light, Norm) > 0),0); + p_hat = max(luminance(light.Radiance) / ((light.Type == DIRECTIONALLIGHT) ? 12.0f : LengthSquared) * ((light.Type == SPOTLIGHT) ? saturate((light.Softness * light.Softness) + saturate(dot(to_light, -light.Direction)) * light.SpotAngle.x + light.SpotAngle.y) : 1)* (dot(to_light, Norm) > 0),0); // float PDF = (((light.Type == DIRECTIONALLIGHT) ? 10.0f : LengthSquared) * ((light.Type == SPOTLIGHT) ? saturate(saturate(dot(to_light, -light.Direction)) * light.SpotAngle.x + light.SpotAngle.y) : 1)* (dot(to_light, Norm) > 0)); // if(PDF > 0.01f) p_hat = max(luminance(light.Radiance) / PDF,0); // else p_hat = 0; @@ -1787,7 +2456,7 @@ inline int SelectUnityLight(int pixel_index, inout float lightWeight, float3 Nor return MinIndex; } -inline int SelectLight(const uint pixel_index, inout uint MeshIndex, inout float lightWeight, float3 Norm, float3 Position, float4x4 Transform, inout float3 Radiance, inout float3 FinalPos) {//Need to check these to make sure they arnt simply doing uniform sampling +inline int SelectLight(const uint pixel_index, inout uint MeshIndex, inout float lightWeight, float3 Norm, float3 Position, float4x4 Transform, inout float3 Radiance, inout float3 FinalPos, float2 sharpness, float3 viewDir, float metallic) {//Need to check these to make sure they arnt simply doing uniform sampling float2 TriangleUV; int MeshTriOffset = _MeshData[_LightMeshes[MeshIndex].LockedMeshIndex].TriOffset; @@ -1836,7 +2505,11 @@ inline int SelectLight(const uint pixel_index, inout uint MeshIndex, inout float FinalPos += Position; lightWeight *= (wsum / max((CounCoun) * MinP_Hat, 0.000001f) * LightCount); #else - MinIndex = SampleLightBVH(Position, Norm, lightWeight, pixel_index, MeshIndex); + [branch]if(UseASVGF && RandomNums[uint2(pixel_index % screen_width, pixel_index / screen_width)].w == 1) { + MinIndex = SampleLightBVH(Position, Norm, lightWeight, pixel_index, MeshIndex, sharpness, viewDir, metallic, SGTreePrev, _MeshDataPrev); + } else { + MinIndex = SampleLightBVH(Position, Norm, lightWeight, pixel_index, MeshIndex, sharpness, viewDir, metallic, SGTree, _MeshData); + } if(MinIndex == -1) return -1; MeshTriOffset = _MeshData[MeshIndex].TriOffset; MatOffset =_MeshData[MeshIndex].MaterialOffset; @@ -1848,10 +2521,13 @@ inline int SelectLight(const uint pixel_index, inout uint MeshIndex, inout float int AggTriIndex = LightTriangles[MinIndex].TriTarget + MeshTriOffset; int MaterialIndex = AggTris[AggTriIndex].MatDat + MatOffset; MaterialData MatDat = _Materials[MaterialIndex]; + #ifdef AdvancedBackground + if(GetFlag(MatDat.Tag, IsBackground)) return -1; + #endif #ifdef WhiteLights MatDat.surfaceColor = 0.5f; #else - float2 BaseUv = AggTris[AggTriIndex].tex0 * (1.0f - FinalUV.x - FinalUV.y) + AggTris[AggTriIndex].texedge1 * FinalUV.x + AggTris[AggTriIndex].texedge2 * FinalUV.y; + float2 BaseUv = TOHALF(AggTris[AggTriIndex].tex0) * (1.0f - FinalUV.x - FinalUV.y) + TOHALF(AggTris[AggTriIndex].texedge1) * FinalUV.x + TOHALF(AggTris[AggTriIndex].texedge2) * FinalUV.y; if(MatDat.AlbedoTex.x > 0) MatDat.surfaceColor *= SampleTexture(BaseUv, SampleAlbedo, MatDat); @@ -1862,8 +2538,7 @@ inline int SelectLight(const uint pixel_index, inout uint MeshIndex, inout float MatDat.surfaceColor *= MatDat.Brightness; TempCol = MatDat.surfaceColor; Unity_Saturation_float(TempCol, MatDat.Saturation, MatDat.surfaceColor); - TempCol = MatDat.surfaceColor; - Unity_Contrast_float(TempCol, MatDat.Contrast, MatDat.surfaceColor); + Unity_Contrast_float(MatDat.surfaceColor, MatDat.Contrast); MatDat.surfaceColor = saturate(MatDat.surfaceColor); if ((MatDat.EmissiveTex.x > 0 && MatDat.emission >= 0)) { @@ -1931,4 +2606,20 @@ inline float3 temperature(float t) float LinearIndex = hash_with(Index, hash) * one_over_max_unsigned; return float4(pal(LinearIndex), 1); } -#endif \ No newline at end of file +#endif + + +float3 applyFog( in float3 col, // color of pixel + in float t, // distance to point + in float3 rd, // camera to point + in float3 lig) // sun direction +{ + float3 b = 0.0001f;//float3(0.1f, 0.1f, 0.1f); + float fogAmount = 1.0 - exp(-t*b); + float sunAmount = max( dot(rd, lig), 0.0 ); + float3 fogColor = lerp( float3(0.5,0.6,0.7), // blue + float3(1.0,0.9,0.7), // yellow + pow(sunAmount,8.0) ); + return lerp( col, fogColor, fogAmount ); + // return col*exp(-t*b) + fogColor*(1.0-exp(-t*b)); +} \ No newline at end of file diff --git a/TrueTrace/Resources/MainCompute/CommonStructs.cginc b/TrueTrace/Resources/MainCompute/CommonStructs.cginc index eccde5e5..9baf9505 100644 --- a/TrueTrace/Resources/MainCompute/CommonStructs.cginc +++ b/TrueTrace/Resources/MainCompute/CommonStructs.cginc @@ -7,15 +7,46 @@ struct CudaTriangle { uint3 tans; - float2 tex0; - float2 texedge1; - float2 texedge2; + uint tex0; + uint texedge1; + uint texedge2; + + uint VertColA; + uint VertColB; + uint VertColC; uint MatDat; }; StructuredBuffer AggTris; +struct GaussianTreeNode { + float3 position; + float radius; + float3 axis; + float variance; + float sharpness; + float intensity; + int left; +}; + +struct LightBVHData { + float3 BBMax; + float3 BBMin; + uint w; + float phi; + uint cosTheta_oe; + int left; +}; + +#ifdef UseSGTree + StructuredBuffer SGTree; + StructuredBuffer SGTreePrev; +#else + StructuredBuffer SGTree; + StructuredBuffer SGTreePrev; +#endif + struct MyMeshDataCompacted { float4x4 W2L; int TriOffset; @@ -27,6 +58,7 @@ struct MyMeshDataCompacted { }; StructuredBuffer _MeshData; +StructuredBuffer _MeshDataPrev; struct TerrainData { float3 PositionOffset; @@ -45,6 +77,7 @@ struct LightTriData { float3 posedge2; uint TriTarget; float SourceEnergy; + // uint NormalizedColor; }; StructuredBuffer LightTriangles; @@ -58,16 +91,7 @@ struct LightMeshData {//remove 74 bytes }; StructuredBuffer _LightMeshes; -struct LightBVHData { - float3 BBMax; - float3 BBMin; - uint w; - float phi; - uint cosTheta_oe; - int left; -}; -StructuredBuffer LightNodes; struct LightData { @@ -103,6 +127,7 @@ struct MaterialData {//56 int2 MatCapTex; int2 SecondaryAlbedoTex; int2 SecondaryAlbedoMask; + int2 SecondaryNormalTex; float3 surfaceColor; float emission; float3 EmissionColor; @@ -139,6 +164,9 @@ struct MaterialData {//56 float Rotation; float ColorBleed; float AlbedoBlendFactor; + float4 SecondaryNormalTexScaleOffset; + float SecondaryNormalTexBlend; + float DetailNormalStrength; }; StructuredBuffer _Materials; @@ -193,4 +221,16 @@ struct ColData { RWStructuredBuffer GlobalColors; StructuredBuffer PrevGlobalColorsA; -RWStructuredBuffer PrevGlobalColorsB; \ No newline at end of file +RWStructuredBuffer PrevGlobalColorsB; + + +struct SDFData { + float3 A; + float3 B; + int Type; + int Operation; + float Smoothness; + float4 Transform; +}; + +StructuredBuffer SDFs; diff --git a/TrueTrace/Resources/MainCompute/IntersectionKernels.compute b/TrueTrace/Resources/MainCompute/IntersectionKernels.compute index e042bb96..53a65564 100644 --- a/TrueTrace/Resources/MainCompute/IntersectionKernels.compute +++ b/TrueTrace/Resources/MainCompute/IntersectionKernels.compute @@ -87,6 +87,7 @@ void IntersectBVH(int ray_index) { [branch]if(CurBounce % 2 == 1) ray_index += screen_width * screen_height; RayData GlobalRay = GlobalRays[ray_index]; bestHit = CreateRayHit(); + if(CurBounce == 0) bestHit.t = asfloat(GlobalRay.hits.z); float RandNum = random(43, GlobalRay.PixelIndex).x; #ifdef HardwareRT const uint rayFlags = RAY_FLAG_FORCE_OPAQUE ; @@ -97,8 +98,8 @@ void IntersectBVH(int ray_index) { ray.origin = myRay.Origin; ray.direction = myRay.Direction; myRay.TMin = 0; - myRay.TMax = FarPlane; - bestHit.t = FarPlane; + myRay.TMax = bestHit.t; + // bestHit.t = FarPlane; while(true) { q.TraceRayInline(myAccelerationStructure, rayFlags, 0xff, myRay); while(q.Proceed()){} @@ -119,7 +120,7 @@ void IntersectBVH(int ray_index) { #ifdef AdvancedAlphaMapped if(CurBounce == 0 && GetFlag(_Materials[MaterialIndex].Tag, Invisible)) {myRay.TMin = bestHit.t + 0.0001f; bestHit.t = FarPlane; continue;} if(_Materials[MaterialIndex].MatType == CutoutIndex) { - float2 BaseUv = AggTris[tri_id].tex0 * (1.0f - bestHit.u - bestHit.v) + AggTris[tri_id].texedge1 * bestHit.u + AggTris[tri_id].texedge2 * bestHit.v; + float2 BaseUv = TOHALF(AggTris[tri_id].tex0) * (1.0f - bestHit.u - bestHit.v) + TOHALF(AggTris[tri_id].texedge1) * bestHit.u + TOHALF(AggTris[tri_id].texedge2) * bestHit.v; if(_Materials[MaterialIndex].AlphaTex.x > 0) if(SampleTexture(BaseUv, SampleAlpha, _Materials[MaterialIndex]).x < _Materials[MaterialIndex].AlphaCutoff) {myRay.TMin = bestHit.t + 0.0001f; bestHit.t = FarPlane; continue;} } @@ -130,7 +131,7 @@ void IntersectBVH(int ray_index) { #endif #ifdef FadeMapping if(_Materials[MaterialIndex].MatType == FadeIndex) { - float2 BaseUv = AggTris[tri_id].tex0 * (1.0f - bestHit.u - bestHit.v) + AggTris[tri_id].texedge1 * bestHit.u + AggTris[tri_id].texedge2 * bestHit.v; + float2 BaseUv = TOHALF(AggTris[tri_id].tex0) * (1.0f - bestHit.u - bestHit.v) + TOHALF(AggTris[tri_id].texedge1) * bestHit.u + TOHALF(AggTris[tri_id].texedge2) * bestHit.v; if(_Materials[MaterialIndex].AlphaTex.x > 0) if(SampleTexture(BaseUv, SampleAlpha, _Materials[MaterialIndex]).x - _Materials[MaterialIndex].AlphaCutoff <= RandNum) {myRay.TMin = bestHit.t + 0.0001f; bestHit.t = FarPlane; continue;} } @@ -149,6 +150,7 @@ void IntersectBVH(int ray_index) { _PrimaryTriangleInfo[TempUv] = uint4((UseReSTIRGI && bestHit.t != FarPlane) ? uint3(MeshOffsets[Indexes.x].y, bestHit.triangle_id + SubMeshOffsets[MeshOffsets[Indexes.x].x + Indexes.y] - _MeshData[MeshOffsets[Indexes.x].y].TriOffset, ((uint)(bestHit.u * 65535.0f) | ((uint)(bestHit.v * 65535.0f) << 16))) : ((UseASVGF || bestHit.t != FarPlane) ? asuint(ray.direction) : asuint(ray.direction * bestHit.t + ray.origin)), bestHit.t == FarPlane); } + if(CurBounce == 0 && bestHit.t == asfloat(GlobalRay.hits.z)) bestHit.t = FarPlane; set(ray_index, bestHit); #else ray.origin = GlobalRay.origin; @@ -232,6 +234,7 @@ void IntersectBVH(int ray_index) { } else if(GetBounceData(GlobalColors[PixIndex].MetRoughIsSpec) == 0 || CurBounce + 1 == GetBounceData(GlobalColors[PixIndex].MetRoughIsSpec)) { _PrimaryTriangleInfo[TempUv] = uint4((UseReSTIRGI && bestHit.t != FarPlane) ? uint3(bestHit.mesh_id, bestHit.triangle_id - _MeshData[bestHit.mesh_id].TriOffset, ((uint)(bestHit.u * 65535.0f) | ((uint)(bestHit.v * 65535.0f) << 16))) : ((UseASVGF || bestHit.t != FarPlane) ? asuint(ray2.direction) : asuint(ray2.direction * bestHit.t + ray2.origin)), bestHit.t == FarPlane); } + if(CurBounce == 0 && bestHit.t == asfloat(GlobalRay.hits.z)) bestHit.t = FarPlane; set(ray_index, bestHit); return; } @@ -262,6 +265,7 @@ void kernel_trace(uint3 id : SV_DispatchThreadID) {//If I move the function cont #pragma kernel kernel_shadow void IntersectBVHShadow(int ray_index) { + if(ray_index >= BufferSizes[CurBounce].shadow_rays) return; SmallerRay ray; #ifndef HardwareRT @@ -274,13 +278,12 @@ void IntersectBVHShadow(int ray_index) { uint oct_inv4; int tlas_stack_size; SmallerRay ray2; - float max_distance; int Reps = 0; + bool Hit = false; #endif int mesh_id = -1; - if(ray_index >= BufferSizes[CurBounce].shadow_rays) return; ShadowRayData ShadowRay = ShadowRaysBuffer[ray_index]; float3 throughput = 1; @@ -304,7 +307,7 @@ void IntersectBVHShadow(int ray_index) { float v = q.CommittedTriangleBarycentrics().x; int2 Indexes = int2(q.CommittedInstanceID(), q.CommittedGeometryIndex()); int triangle_id = q.CommittedPrimitiveIndex(); - #if defined(IgnoreBackfacing) || defined(AdvancedAlphaMapped) || defined(IgnoreGlassShadow) + #if defined(IgnoreBackfacing) || defined(AdvancedAlphaMapped) || defined(IgnoreGlassShadow) || defined(AdvancedBackground) int triangleOffset = SubMeshOffsets[MeshOffsets[Indexes.x].x + Indexes.y]; triangle_id += triangleOffset; mesh_id = MeshOffsets[Indexes.x].y; @@ -313,7 +316,7 @@ void IntersectBVHShadow(int ray_index) { #endif #ifdef AdvancedAlphaMapped if(_Materials[MaterialIndex].MatType == CutoutIndex) { - float2 BaseUv = AggTris[triangle_id].tex0 * (1.0f - u - v) + AggTris[triangle_id].texedge1 * u + AggTris[triangle_id].texedge2 * v; + float2 BaseUv = TOHALF(AggTris[triangle_id].tex0) * (1.0f - u - v) + TOHALF(AggTris[triangle_id].texedge1) * u + TOHALF(AggTris[triangle_id].texedge2) * v; if(_Materials[MaterialIndex].AlphaTex.x > 0) if(SampleTexture(BaseUv, SampleAlpha, _Materials[MaterialIndex]).x < _Materials[MaterialIndex].AlphaCutoff) {myRay.TMin = q.CommittedRayT() + 0.0001f; continue;} } @@ -325,7 +328,7 @@ void IntersectBVHShadow(int ray_index) { #ifdef IgnoreGlassShadow if(_Materials[MaterialIndex].specTrans == 1) { #ifdef StainedGlassShadows - float2 BaseUv = AggTris[triangle_id].tex0 * (1.0f - u - v) + AggTris[triangle_id].texedge1 * u + AggTris[triangle_id].texedge2 * v; + float2 BaseUv = TOHALF(AggTris[triangle_id].tex0) * (1.0f - u - v) + TOHALF(AggTris[triangle_id].texedge1) * u + TOHALF(AggTris[triangle_id].texedge2) * v; float3 MatCol = _Materials[MaterialIndex].surfaceColor; if(_Materials[MaterialIndex].AlbedoTex.x > 0) MatCol *= SampleTexture(BaseUv, SampleAlbedo, _Materials[MaterialIndex]) / 3.0f; MatCol = lerp(MatCol, _Materials[MaterialIndex].BlendColor, _Materials[MaterialIndex].BlendFactor); @@ -366,7 +369,7 @@ void IntersectBVHShadow(int ray_index) { break; } #else - max_distance = abs(ShadowRay.t); + const float max_distance = abs(ShadowRay.t); ray.origin = ShadowRay.origin; ray.direction = (ShadowRay.direction == 0 ? EPSILON : ShadowRay.direction); ray2 = ray; @@ -440,12 +443,17 @@ void IntersectBVHShadow(int ray_index) { uint triangle_index = firstbithigh(triangle_group.y); triangle_group.y &= ~(1 << triangle_index); - if (triangle_intersect_shadow(triangle_group.x + triangle_index, ray, max_distance, mesh_id, throughput, MatOffset)) return; + if (triangle_intersect_shadow(triangle_group.x + triangle_index, ray, max_distance, throughput, MatOffset)) { + ShadowRaysBuffer[ray_index].t = 0; + return; + } } } } + + if ((current_group.y & 0xff000000) == 0) { if (stack_size == 0) {//thread has finished traversing if(!TerrainExists) { @@ -474,7 +482,7 @@ void IntersectBVHShadow(int ray_index) { ShadowRaysBuffer[ray_index].illumination *= throughput; ShadowRaysBuffer[ray_index].DiffuseIlluminance = packRGBE(unpackRGBE(ShadowRaysBuffer[ray_index].DiffuseIlluminance) * throughput); } - break; + return; } if (stack_size == tlas_stack_size) { diff --git a/TrueTrace/Resources/MainCompute/Materials.cginc b/TrueTrace/Resources/MainCompute/Materials.cginc index 41bdb6f1..84c82064 100644 --- a/TrueTrace/Resources/MainCompute/Materials.cginc +++ b/TrueTrace/Resources/MainCompute/Materials.cginc @@ -644,55 +644,123 @@ float3 vMFDiffuseAlbedoMapping(float3 kd, float roughness) } + +static const float constant1_FON = 0.5f - 2.0f / (3.0f * PI); +static const float constant2_FON = 2.0f / 3.0f - 28.0f / (15.0f * PI); +float E_FON_exact(float mu, float r) +{ +float AF = 1.0f / (1.0f + constant1_FON * r); // FON A coeff. +float BF = r * AF; // FON B coeff. +float Si = sqrt(1.0f - (mu * mu)); +float G = Si * (acos(mu) - Si * mu) ++ (2.0f / 3.0f) * ((Si / mu) * (1.0f - (Si * Si * Si)) - Si); +return AF + (BF/PI) * G; +} +float E_FON_approx(float mu, float r) +{ +float mucomp = 1.0f - mu; +float mucomp2 = mucomp * mucomp; +const float2x2 Gcoeffs = float2x2(0.0571085289f, -0.332181442f, 0.491881867f, 0.0714429953f); +float GoverPi = dot(mul(Gcoeffs, float2(mucomp, mucomp2)), float2(1.0f, mucomp2)); +return (1.0f + r * GoverPi) / (1.0f + constant1_FON * r); +} +// Evaluates EON BRDF value, given inputs: +// rho = single-scattering albedo parameter +// r = roughness in [0, 1] +// wi_local = direction of incident ray (directed away from vertex) +// wo_local = direction of outgoing ray (directed away from vertex) +// exact = flag to select exact or fast approx. version +// +// Note that this implementation assumes throughout that the directions are +// specified in a local space where the z-direction aligns with the surface normal. +float3 f_EON(float3 rho, float r, float3 wi_local, float3 wo_local, bool exact) +{ +float mu_i = wi_local.y; // input angle cos +float mu_o = wo_local.y; // output angle cos +float s = dot(wi_local, wo_local) - mu_i * mu_o; // QON s term +float sovertF = s > 0.0f ? s / max(mu_i, mu_o) : s; // FON s/t +float AF = 1.0f / (1.0f + constant1_FON * r); // FON A coeff. +float3 f_ss = (rho/PI) * AF * (1.0f + r * sovertF); // single-scatter +float EFo = exact ? E_FON_exact(mu_o, r): // FON wo albedo (exact) +E_FON_approx(mu_o, r); // FON wo albedo (approx) +float EFi = exact ? E_FON_exact(mu_i, r): // FON wi albedo (exact) +E_FON_approx(mu_i, r); // FON wi albedo (approx) +float avgEF = AF * (1.0f + constant2_FON * r); // avg. albedo +float3 rho_ms = (rho * rho) * avgEF / ((1.0f) - rho * (1.0f - avgEF)); +const float eps = 1.0e-7f; +float3 f_ms = (rho_ms/PI) * max(eps, 1.0f - EFo) // multi-scatter lobe +* max(eps, 1.0f - EFi) +/ max(eps, 1.0f - avgEF); +return f_ss + f_ms; +} +// Computes EON directional albedo: +float3 E_EON(float3 rho, float r, float3 wi_local, bool exact) +{ +float mu_i = wi_local.y; // input angle cos +float AF = 1.0f / (1.0f + constant1_FON * r); // FON A coeff. +float EF = exact ? E_FON_exact(mu_i, r): // FON wi albedo (exact) +E_FON_approx(mu_i, r); // FON wi albedo (approx) +float avgEF = AF * (1.0f + constant2_FON * r); // average albedo +float3 rho_ms = (rho * rho) * avgEF / (1.0f - rho * (1.0f - avgEF)); +return rho * EF + rho_ms * (1.0f - EF); +} + + + static float3 EvaluateDisneyDiffuse(const MaterialData hitDat, const float3 wo, const float3 wm, const float3 wi, bool thin, int pixel_index) { float dotNL = AbsCosTheta(wi); float dotNV = AbsCosTheta(wo); - #ifdef vMFDiffuse - float cosThetaI = wi.y, sinThetaI = sqrt(1.0 - cosThetaI * cosThetaI); - float cosThetaO = wo.y, sinThetaO = sqrt(1.0 - cosThetaO * cosThetaO); - - float cosPhiDiff = 0.0; - if (sinThetaI > 0.0 && sinThetaO > 0.0) { - /* Compute cos(phiO-phiI) using the half-angle formulae */ - float sinPhiI = clamp(wi.z / sinThetaI, -1.0, 1.0), - cosPhiI = clamp(wi.x / sinThetaI, -1.0, 1.0), - sinPhiO = clamp(wo.z / sinThetaO, -1.0, 1.0), - cosPhiO = clamp(wo.x / sinThetaO, -1.0, 1.0); - cosPhiDiff = cosPhiI * cosPhiO + sinPhiI * sinPhiO; - } - float phi = safeacos(cosPhiDiff); - - float r = clamp(hitDat.roughness, 0.0, .9999); - float3 c = vMFDiffuseAlbedoMapping(hitDat.surfaceColor / PI, r); - return vMFdiffuseBRDF(dotNV, dotNL, phi, r, c) * PI; + #if defined(EONDiffuse) + return f_EON(hitDat.surfaceColor / PI, hitDat.roughness, wi, wo, true) * PI; #else + #if defined(vMFDiffuse) + float cosThetaI = wi.y, sinThetaI = sqrt(1.0 - cosThetaI * cosThetaI); + float cosThetaO = wo.y, sinThetaO = sqrt(1.0 - cosThetaO * cosThetaO); + + float cosPhiDiff = 0.0; + if (sinThetaI > 0.0 && sinThetaO > 0.0) { + /* Compute cos(phiO-phiI) using the half-angle formulae */ + float sinPhiI = clamp(wi.z / sinThetaI, -1.0, 1.0), + cosPhiI = clamp(wi.x / sinThetaI, -1.0, 1.0), + sinPhiO = clamp(wo.z / sinThetaO, -1.0, 1.0), + cosPhiO = clamp(wo.x / sinThetaO, -1.0, 1.0); + cosPhiDiff = cosPhiI * cosPhiO + sinPhiI * sinPhiO; + } + float phi = safeacos(cosPhiDiff); + float r = clamp(hitDat.roughness, 0.0, .9999); + float3 c = vMFDiffuseAlbedoMapping(hitDat.surfaceColor / PI, r); + return vMFdiffuseBRDF(dotNV, dotNL, phi, r, c) * PI; - float fl = SchlickWeight(dotNL); - float fv = SchlickWeight(dotNV); + #else - float hanrahanKrueger = 0.0f; - if (thin && hitDat.flatness > 0.0f) { - float roughness = hitDat.roughness * hitDat.roughness; + float fl = SchlickWeight(dotNL); + float fv = SchlickWeight(dotNV); - float dotHL = dot(wm, wi); - float fss90 = dotHL * dotHL * roughness; - float fss = lerp(1.0f, fss90, fl) * lerp(1.0f, fss90, fv); + float hanrahanKrueger = 0.0f; - float ss = 1.25f * (fss * (1.0f / (dotNL + dotNV) - 0.5f) + 0.5f); - hanrahanKrueger = ss; - } + if (thin && hitDat.flatness > 0.0f) { + float roughness = hitDat.roughness * hitDat.roughness; - float lambert = 1.0f; - float retro = EvaluateDisneyRetroDiffuse(hitDat, wo, wm, wi); - float subsurfaceApprox = lerp(lambert, hanrahanKrueger, thin ? hitDat.flatness : 0.0f); + float dotHL = dot(wm, wi); + float fss90 = dotHL * dotHL * roughness; + float fss = lerp(1.0f, fss90, fl) * lerp(1.0f, fss90, fv); + float ss = 1.25f * (fss * (1.0f / (dotNL + dotNV) - 0.5f) + 0.5f); + hanrahanKrueger = ss; + } + + float lambert = 1.0f; + float retro = EvaluateDisneyRetroDiffuse(hitDat, wo, wm, wi); + float subsurfaceApprox = lerp(lambert, hanrahanKrueger, thin ? hitDat.flatness : 0.0f); - return hitDat.surfaceColor * rcp(PI) * (retro + subsurfaceApprox * (1.0f - 0.5f * fl) * (1.0f - 0.5f * fv)) * (1.0f - hitDat.metallic); + + return hitDat.surfaceColor * rcp(PI) * (retro + subsurfaceApprox * (1.0f - 0.5f * fl) * (1.0f - 0.5f * fv)) * (1.0f - hitDat.metallic); + #endif #endif } @@ -788,7 +856,7 @@ static float3 SampleDisneySpecTransmission(const MaterialData hitDat, float3 wo, forwardPdfW *= pdf; // -- convert wi back to world space - return G1v;// * exp(-CalculateExtinction(1.0f - hitDat.surfaceColor, hitDat.scatterDistance == 0 ? 1 : hitDat.scatterDistance) * (hitDat.scatterDistance)); + return G1v * 0.99f;// * exp(-CalculateExtinction(1.0f - hitDat.surfaceColor, hitDat.scatterDistance == 0 ? 1 : hitDat.scatterDistance) * (hitDat.scatterDistance)); } static float3 SampleDisneyDiffuse(const MaterialData hitDat, float3 wo, bool thin, out float forwardPdfW, out float3 wi, inout bool refracted, uint pixel_index) @@ -1191,7 +1259,9 @@ bool SampleDisney(MaterialData hitDat, inout float3 v, bool thin, out float PDF, Case = 1; } else if(p <= P.x + P.y + P.z) { Case = 2; - } else Case = 3; + } else if(p <= P.x + P.y + P.z + P.w) { + Case = 3; + } switch(Case) { case 0: Reflection = SampleDisneyBRDF(hitDat, v, PDF, wi, pixel_index); @@ -1201,7 +1271,7 @@ bool SampleDisney(MaterialData hitDat, inout float3 v, bool thin, out float PDF, break; case 2: hitDat.surfaceColor *= PI; - Reflection = SampleDisneyDiffuse(hitDat, v, thin, PDF, wi, Refracted, pixel_index);// * P[2]; + Reflection = SampleDisneyDiffuse(hitDat, v, thin, PDF, wi, Refracted, pixel_index) * (1.0f - P[3]); break; case 3: Reflection = SampleDisneySpecTransmission(hitDat, v, thin, PDF, wi, Refracted, pixel_index, GotFlipped); @@ -1209,8 +1279,9 @@ bool SampleDisney(MaterialData hitDat, inout float3 v, bool thin, out float PDF, } v = normalize(ToWorld(TruTanMat, wi)); - throughput = clamp(Reflection / P[Case], 0, 4.0f); - if(Case == 3) throughput = saturate(throughput); + if(Case != 3) throughput = clamp(Reflection / P[Case], 0, 4); + else Reflection = throughput; + // if(Case == 3) throughput = saturate(throughput); PDF *= P[Case]; return Reflection.x != -1 && PDF > 0; diff --git a/TrueTrace/Resources/MainCompute/RayTracingShader.compute b/TrueTrace/Resources/MainCompute/RayTracingShader.compute index 70d270ff..4d2c8a58 100644 --- a/TrueTrace/Resources/MainCompute/RayTracingShader.compute +++ b/TrueTrace/Resources/MainCompute/RayTracingShader.compute @@ -98,9 +98,9 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit [branch]if(CurBounce == 0 && UseReSTIRGI && ReSTIRGIUpdateRate != 0 && RandomNums[id].z != 0 && hitDat.specTrans == 0 && hitDat.diffTrans == 0) { norm = i_octahedral_32(asuint(RandomNums[id].w)); #ifdef UseTextureLOD - } else if (CurBounce == 0 && !ClayMode && hitDat.NormalTex.x > 0) {//Handle Normal Maps + } else if (CurBounce == 0 && !ClayMode && (hitDat.NormalTex.x > 0 || hitDat.SecondaryNormalTex.x > 0)) {//Handle Normal Maps #else - } else if (!ClayMode && hitDat.NormalTex.x > 0) {//Handle Normal Maps + } else if (!ClayMode && (hitDat.NormalTex.x > 0 || hitDat.SecondaryNormalTex.x > 0)) {//Handle Normal Maps #endif float3 LocalTan = GetTriangleTangent(hit.triangle_id, float2(hit.u, hit.v), Inverse); float3 LocalBinorm = normalize(cross(Geomnorm, LocalTan)); @@ -108,6 +108,14 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit float3 LocalNormIN = float3((hitDat.NormalStrength * Norm - (hitDat.NormalStrength / 2.0f)), 0.0f); LocalNormIN.z = 1.0 - 0.5 * dot(LocalNormIN, LocalNormIN); + + if(hitDat.SecondaryNormalTex.x > 0) { + float2 DetailNorm = SampleTexture(BaseUv, SampleDetailNormal, hitDat); + float3 DetailLocalNormIN = float3((hitDat.DetailNormalStrength * DetailNorm - (hitDat.DetailNormalStrength / 2.0f)), 0.0f); + DetailLocalNormIN.z = 1.0 - 0.5 * dot(DetailLocalNormIN, DetailLocalNormIN); + LocalNormIN = lerp(LocalNormIN, DetailLocalNormIN, hitDat.SecondaryNormalTexBlend); + } + norm = clamp(normalize(mul(normalize(LocalNormIN), float3x3(LocalTan, LocalBinorm, Geomnorm)).xyz),-1,1); if (abs(norm.x) == abs(norm.y) == abs(norm.z)) norm = Geomnorm; norm = i_octahedral_32(octahedral_32(norm)); @@ -116,6 +124,7 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit Geomnorm = i_octahedral_32(asuint(PrevScreenData.x)); norm = i_octahedral_32(asuint(PrevScreenData.y)); } + // if(CurBounce == 0) _DebugTex[id.xy] = float4(GetTriangleTangent(hit.triangle_id, float2(hit.u, hit.v), Inverse) * 0.5f + 0.5f, 1.0f); { @@ -153,23 +162,29 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit float SA = abs(dot(norm, ray.direction)) * a / (hit.t * hit.t); float light_pdf = 1.0f / (SA * LightMeshCount); #if defined(LBVH) && !defined(FasterLightSampling) - CalcLightPDF(light_pdf, ray.origin, pos, ray.direction, pixel_index, hit.mesh_id); + [branch]if(UseASVGF && RandomNums[uint2(pixel_index % screen_width, pixel_index / screen_width)].w == 1) { + CalcLightPDF(light_pdf, ray.origin, pos, ray.direction, pixel_index, hit.mesh_id, 1.0, -ray.direction, 0.0f, SGTreePrev, _MeshDataPrev); + } else { + CalcLightPDF(light_pdf, ray.origin, pos, ray.direction, pixel_index, hit.mesh_id, 1.0, -ray.direction, 0.0f, SGTree, _MeshData); + } #else light_pdf *= rcp(_MeshData[hit.mesh_id].LightTriCount); #endif float w = power_heuristic(max(last_pdf,0), light_pdf); if (CurBounce == 0) Color.Direct += EmissCol; - else if (CurBounce == 1) Color.Direct += EmissCol * w; - #ifndef RadianceCache - else Color.Indirect += Color.throughput * EmissCol * w; - #else - else { - if(!((CacheInstance.pathLength >> 7) & 0x1)) Color.Indirect += Color.throughput * EmissCol * w; - else CacheInstance.CurrentIlluminance = EncodeRGB(DecodeRGB(CacheInstance.CurrentIlluminance) + EmissCol * w); - } + #ifdef UseBRDFLights + else if (CurBounce == 1) Color.Direct += EmissCol * w; + #ifndef RadianceCache + else Color.Indirect += Color.throughput * EmissCol * w; + #else + else { + if(!((CacheInstance.pathLength >> 7) & 0x1)) Color.Indirect += Color.throughput * EmissCol * w; + else CacheInstance.CurrentIlluminance = EncodeRGB(DecodeRGB(CacheInstance.CurrentIlluminance) + EmissCol * w); + } + #endif #endif } - if(CurBounce == 0 && !(id.x == screen_width / 2 && id.y == screen_height / 2)) PrevScreenData.z = -10000.0f; + if(UseASVGF && CurBounce == 0 && !(id.x == screen_width / 2 && id.y == screen_height / 2)) PrevScreenData.z = -10000.0f; if(luminance(EmissCol) > 12.0f) { if(CurBounce == 0) { Color.Data = EmissCol; @@ -187,7 +202,7 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit } [branch]if(ClayMode) { - if(hitDat.specTrans == 0) + // if(hitDat.specTrans == 0) hitDat.surfaceColor = ClayColor; hitDat.metallic = 0; hitDat.clearcoat = 0; @@ -238,7 +253,9 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit int WaterStageFlag = (Color.MetRoughIsSpec & 0x3800000) >> 23; if(GotFlipped) { if((MaterialLobe == 2 && Refracted) || MaterialLobe == 3 || (WaterStageFlag == 2 || WaterStageFlag == 4)) { - bsdfmodifier *= exp(-Color.InWaterDistance * CalculateExtinction((MaterialLobe == 2 && Refracted) ? (hitDat.transmittanceColor) : (1.0f - hitDat.surfaceColor), hitDat.scatterDistance == 0.0f ? 1.0f : hitDat.scatterDistance)); + bsdf *= exp(-Color.InWaterDistance * CalculateExtinction((MaterialLobe == 2 && Refracted) ? (hitDat.transmittanceColor) : (1.0f - (bsdf * hitDat.surfaceColor)), hitDat.scatterDistance == 0.0f ? 1.0f : hitDat.scatterDistance)); + //MAY WANNA CHANGE THE MATLOBE == 2 TO MATLOBE == 3 AS WELL^^ + bsdfmodifier = bsdf; if(!(WaterStageFlag == 2 || WaterStageFlag == 4)) WaterStageFlag = 3 + !Refracted; Color.InWaterDistance = 0; } @@ -252,7 +269,7 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit Color.MetRoughIsSpec = (Color.MetRoughIsSpec & ~(0x3800000)) | (WaterStageFlag << 23); } - bsdf *= bsdfmodifier; + // bsdf *= bsdfmodifier; throughput *= bsdf; } @@ -313,7 +330,7 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit #endif if (!validBSDFSample) return;//If the ray failed, we have no choice but to terminate this path pos = ray.origin; - [branch] if (hitDat.specTrans == 0 && (UseNEE) && CurBounce < MaxBounce && (SecondaryBackgroundType == 1 || unitylightcount + LightMeshCount != 0)) {//Next event estimation + [branch] if ((UseNEE) && CurBounce < MaxBounce && (SecondaryBackgroundType == 1 || unitylightcount + LightMeshCount != 0)) {//Next event estimation float3 LightNorm; float3 LightPosition; int LightFormat = TRILIGHT; @@ -331,14 +348,14 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit RunningWeight = selectionoptions; SelectedLightGroup = selections[min(floor(random(114, pixel_index).x * (float)selectionoptions), selectionoptions - 1)]; - if (SelectedLightGroup == 1) { + if (SelectedLightGroup == 1) {//we only really need to precompute this, right? maybe we can do a similar optimization as ReSTIR DI? AggTriIndex = SelectUnityLight(pixel_index, RunningWeight, norm, pos, PrevDirection); LightData Light = _UnityLights[AggTriIndex]; float sinPhi, cosPhi; LightPosition = Light.Position; LightNorm = Light.Direction; LightFormat = Light.Type; - Radiance = Light.Radiance; + Radiance = Light.Radiance / PI; float3 RandVec = float3(random(115, pixel_index), random(116, pixel_index).x); MiscInfo = float3(Light.Softness * 120.0f + 1, Light.SpotAngle); if(LightFormat == AREALIGHTQUAD || LightFormat == AREALIGHTDISK) { @@ -360,14 +377,16 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit if(UseTransmittanceInNEE) Radiance *= GetSkyTransmittance(pos, -LightNorm, 0, -LightNorm); break; case SPOTLIGHT: + Radiance *= ((1.0f - MiscInfo.z * 0.0174533) + (MiscInfo.y * 0.0174533 - MiscInfo.z * 0.0174533) / 2.0f); LightPosition += normalize(RandVec - 0.5f) * random(116, pixel_index).y * Light.Softness * 0.1f;//Soft Shadows break; case AREALIGHTQUAD: RandVec.xy = RandVec.xy * Light.SpotAngle - Light.SpotAngle / 2.0f; RandVec.xy = mul(float2x2(cosPhi, -sinPhi, sinPhi, cosPhi), RandVec.xy); LightPosition += ToWorld(GetTangentSpace2(LightNorm), normalize(float3(RandVec.x,0,RandVec.y))) * length(RandVec.xy); - area = (Light.SpotAngle.x * Light.SpotAngle.y) / 2.0f; + area = (Light.SpotAngle.x * Light.SpotAngle.y); if(hitDat.MatType == 3) Radiance = 0; + Radiance *= PI; break; case AREALIGHTDISK: sincos(RandVec.x * 2.0f * PI, RandVec.x, RandVec.y); @@ -384,16 +403,19 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit int MeshIndex = SelectLightMeshSmart(pixel_index, RunningWeight, pos); float4x4 MeshTransformInverse = _MeshData[_LightMeshes[MeshIndex].LockedMeshIndex].W2L; #endif - AggTriIndex = SelectLight(pixel_index, MeshIndex, RunningWeight, norm, pos, MeshTransformInverse, Radiance, LightPosition); + float ax, ay; + CalculateAnisotropicParams(hitDat.roughness, hitDat.anisotropic, ax, ay); + AggTriIndex = SelectLight(pixel_index, MeshIndex, RunningWeight, norm, pos, MeshTransformInverse, Radiance, LightPosition, float2(ax, ay), -PrevDirection, (saturate(hitDat.metallic + hitDat.Specular + hitDat.clearcoat))); #ifdef LBVH MeshTransformInverse = _MeshData[MeshIndex].W2L; #endif Radiance *= LEMEnergyScale; TrianglePos CurTri = triangle_get_positions(AggTriIndex); MeshTransformInverse = inverse(MeshTransformInverse); - float3 a1 = mul((float3x3)MeshTransformInverse, CurTri.posedge1).xyz; - float3 a2 = mul((float3x3)MeshTransformInverse, CurTri.posedge2).xyz; - area = AreaOfTriangle(float3(0,0,0), a1, a2); + float3 a0 = mul(MeshTransformInverse, float4(CurTri.pos0, 1)).xyz; + float3 a1 = mul(MeshTransformInverse, float4(CurTri.pos0 + CurTri.posedge1, 1)).xyz; + float3 a2 = mul(MeshTransformInverse, float4(CurTri.pos0 + CurTri.posedge2, 1)).xyz; + area = AreaOfTriangle(a0, a1, a2); LightPosition = mul(MeshTransformInverse, float4(LightPosition,1)); LightNorm = normalize(mul((float3x3)MeshTransformInverse, normalize(cross(CurTri.posedge1, CurTri.posedge2))).xyz); } else { @@ -450,17 +472,21 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit float NEE_pdf; float3 Illum; [branch]if (SelectedLightGroup == 1) { - NEE_pdf = distance_to_light_squared * abs(dot(to_light, LightNorm)) / area; - Illum = (Radiance * bsdf_value) / NEE_pdf * RunningWeight * ((LightFormat == AREALIGHTQUAD || LightFormat == AREALIGHTDISK) ? (MiscInfo.x) : 1.0f); - bsdf_diffuse = (Radiance * bsdf_diffuse) / NEE_pdf * RunningWeight * ((LightFormat == AREALIGHTQUAD || LightFormat == AREALIGHTDISK) ? (MiscInfo.x) : 1.0f); + NEE_pdf = 1.0f / (abs(dot(to_light, LightNorm)) * area / distance_to_light_squared); + Illum = (Radiance * bsdf_value) / NEE_pdf * RunningWeight; + bsdf_diffuse = (Radiance * bsdf_diffuse) / NEE_pdf * RunningWeight; } else if(SelectedLightGroup == 0) { NEE_pdf = (1.0f / ((abs(dot(to_light, LightNorm)) * area) / distance_to_light_squared)) / RunningWeight; #ifndef LBVH NEE_pdf /= LightMeshCount; #endif float NEEMISWeight = power_heuristic(NEE_pdf, bsdf_pdf); - Illum = (Radiance * bsdf_value) / NEE_pdf * NEEMISWeight; - bsdf_diffuse = (Radiance * bsdf_diffuse) / NEE_pdf * NEEMISWeight; + Illum = (Radiance * bsdf_value) / NEE_pdf; + bsdf_diffuse = (Radiance * bsdf_diffuse) / NEE_pdf; + #ifdef UseBRDFLights + Illum *= NEEMISWeight; + bsdf_diffuse *= NEEMISWeight; + #endif } else { NEE_pdf = HDRIParams.x * HDRIParams.y * equirectDirectionPdf(to_light) * (luminance(Radiance) / TotSum[0]); float NEEMISWeight = power_heuristic(NEE_pdf, bsdf_pdf); @@ -469,8 +495,8 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit } #ifndef RadianceCache #endif - Illum *= Color.throughput; - bsdf_diffuse *= Color.throughput; + Illum *= Color.throughput * bsdfmodifier; + bsdf_diffuse *= Color.throughput * bsdfmodifier; if(LightFormat == AREALIGHTQUAD || LightFormat == AREALIGHTDISK) { Illum *= pow(saturate(dot(to_light, -LightNorm)), MiscInfo.x); @@ -480,6 +506,7 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit bsdf_diffuse *= saturate(saturate(dot(to_light, -LightNorm)) * MiscInfo.y + MiscInfo.z); Illum *= saturate(saturate(dot(to_light, -LightNorm)) * MiscInfo.y + MiscInfo.z); } + // if(id.x > screen_width / 2) Illum *= applyFog(1, 10000.0f, to_light, SunDir); float maxillum = max(max(Illum.x, Illum.y), Illum.z); if(DoExposure) maxillum *= Exposure[0]; if(!UseRussianRoulette || (CurBounce == 0 && ImprovedPrimaryHit)) maxillum = 1; @@ -503,7 +530,7 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit ShadowRayData ShadRay = {pos, packRGBE(bsdf_diffuse), to_light, - (LightFormat == DIRECTIONALLIGHT ? 10000.0f : distance_to_light - 0.01f) * (TempTemp ? 1 : -1), + (LightFormat == DIRECTIONALLIGHT ? 10000.0f : distance_to_light - ShadowDistanceFudgeFactor) * (TempTemp ? 1 : -1), Illum, pixel_index}; if(abs(ShadRay.t) > 0.001f) { @@ -558,6 +585,10 @@ inline void calcFinalColor(SmallerRay ray, inout ColData Color, MaterialData hit } static const ColData InitCol = { 1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0}; +float3 PrimaryBackgroundTintColor; +float PrimaryBackgroundTint; +float PrimaryBackgroundContrast; + #ifdef DX11 [numthreads(64, 1, 1)] #else @@ -594,9 +625,17 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { - - +int MaterialIndex; +#ifdef AdvancedBackground + bool BackgroundCheck = false; + if(bestHit.t != FarPlane && !(TerrainExists && (bestHit.mesh_id == 9999999))) { + MaterialIndex = _MeshData[bestHit.mesh_id].MaterialOffset + AggTris[bestHit.triangle_id].MatDat; + if(GetFlag(_Materials[MaterialIndex].Tag, IsBackground) && (Color.MetRoughIsSpec >> 31)) BackgroundCheck = true; + } + if (bestHit.t == FarPlane || BackgroundCheck) {//if ray goes into the void, sample skybox +#else if (bestHit.t == FarPlane) {//if ray goes into the void, sample skybox +#endif float3 Radiance, transmittance, debug = 0; float Stars; float2 uv; @@ -617,17 +656,24 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { Stars *= max(12.0f * pow(1.0f - saturate(pow(RayleighPhaseFunction(dot(ray.direction, SunDir)) * MiePhaseFunction(0.8f, dot(ray.direction, SunDir)),0.1f)),2.0f) * transmittance * -dot(rayorig2, SunDir) / length(rayorig2), 0); Stars = pow(saturate(Stars), 2.0f); if(GetBounceData(Color.MetRoughIsSpec) <= 1) Radiance += Stars; + // if(id.x > screen_width / 2) Radiance = applyFog(Radiance, 500.0f, ray.direction, SunDir); if (all(Radiance < 10000.0f)) { - if (CurBounce == 0) Color.Direct = Color.throughput * DeSat(Radiance, 1.0f - TrueDeSat) * Intensity; - else if (CurBounce == 1) Color.Direct += Color.throughput * DeSat(Radiance, 1.0f - TrueDeSat) * Intensity; + Radiance = DeSat(Radiance, 1.0f - TrueDeSat); + if(DoSecondary) { + Unity_Contrast_float(Radiance, PrimaryBackgroundContrast); + Radiance = lerp(Radiance, PrimaryBackgroundTintColor, PrimaryBackgroundTint); + } + Radiance *= Intensity; + if (CurBounce == 0) Color.Direct = Color.throughput * Radiance; + else if (CurBounce == 1) Color.Direct += Color.throughput * Radiance; #ifdef RadianceCache else if(!((CacheBuffer[pixel_index].pathLength >> 7) & 0x1) || (((Color.MetRoughIsSpec & 0x3800000) >> 23) >= 3)) Color.Indirect += Color.throughput * DeSat(Radiance, 1.0f - TrueDeSat) * Intensity; else if(!UseReSTIRGI || ReSTIRGIUpdateRate == 0 || RandomNums[id.xy].z == 0) { - AddMissToCache(CacheBuffer[pixel_index], DeSat(Radiance, 1.0f - TrueDeSat) * Intensity); + AddMissToCache(CacheBuffer[pixel_index], Radiance); } #else - else Color.Indirect += Color.throughput * DeSat(Radiance, 1.0f - TrueDeSat) * Intensity; + else Color.Indirect += Color.throughput * Radiance; #endif } break; @@ -636,19 +682,31 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { uv = fmod(uv * HDRIScale + HDRILongLat / 360.0f, 1.0f); if(UseNEE && CurBounce > 0) mis = power_heuristic(GlobRay.last_pdf, HDRIParams.x * HDRIParams.y * equirectDirectionPdf(ray.direction) * (luminance(_SkyboxTexture.SampleLevel(my_linear_clamp_sampler, uv, 0).xyz) / TotSum[0])); - if (CurBounce == 0) Color.Direct = DeSat(_SkyboxTexture.SampleLevel(my_linear_clamp_sampler, uv, 0).xyz,1.0f - TrueDeSat) * Intensity; - if (CurBounce == 1) Color.Direct += DeSat(_SkyboxTexture.SampleLevel(my_linear_clamp_sampler, uv, 0).xyz,1.0f - TrueDeSat) * Intensity * mis; - else Color.Direct += Color.throughput * DeSat(_SkyboxTexture.SampleLevel(my_linear_clamp_sampler, uv, 0).xyz,1.0f - TrueDeSat) * Intensity * mis; + Radiance = DeSat(_SkyboxTexture.SampleLevel(my_linear_clamp_sampler, uv, 0).xyz,1.0f - TrueDeSat); + if(DoSecondary) { + Unity_Contrast_float(Radiance, PrimaryBackgroundContrast); + Radiance = lerp(Radiance, PrimaryBackgroundTintColor, PrimaryBackgroundTint); + } + Radiance *= Intensity; + if (CurBounce == 0) Color.Direct = Radiance; + else if (CurBounce == 1) Color.Direct += Radiance * mis; + else Color.Direct += Color.throughput * Radiance * mis; #ifdef RadianceCache - AddMissToCache(CacheBuffer[pixel_index], DeSat(_SkyboxTexture.SampleLevel(my_linear_clamp_sampler, uv, 0).xyz,1.0f - TrueDeSat) * Intensity * mis); + AddMissToCache(CacheBuffer[pixel_index], Radiance * mis); #endif break; case 2: - if (CurBounce == 0) Color.Direct = DeSat(BackgroundColor * Intensity, 1.0f - TrueDeSat); - else if (CurBounce == 1) Color.Direct += DeSat((DoSecondary ? BackgroundColor : SecondaryBackgroundColor) * Intensity, 1.0f - TrueDeSat); - else Color.Indirect += Color.throughput * DeSat((DoSecondary ? BackgroundColor : SecondaryBackgroundColor) * Intensity, 1.0f - TrueDeSat); + Radiance = DeSat((DoSecondary ? BackgroundColor : SecondaryBackgroundColor), 1.0f - TrueDeSat); + if(DoSecondary) { + Unity_Contrast_float(Radiance, PrimaryBackgroundContrast); + Radiance = lerp(Radiance, PrimaryBackgroundTintColor, PrimaryBackgroundTint); + } + Radiance *= Intensity; + if (CurBounce == 0) Color.Direct = Radiance; + else if (CurBounce == 1) Color.Direct += Radiance; + else Color.Indirect += Color.throughput * Radiance; #ifdef RadianceCache - AddMissToCache(CacheBuffer[pixel_index], (DoSecondary ? BackgroundColor : SecondaryBackgroundColor) * Intensity); + AddMissToCache(CacheBuffer[pixel_index], Radiance); #endif break; } @@ -668,8 +726,10 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { } return; } + + + float2 BaseUv; - int MaterialIndex; bool HitTerrain = false; MaterialData TempMat; [branch]if (TerrainExists && (bestHit.mesh_id == 9999999)) {//if hit terrain @@ -703,8 +763,10 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { TempMat.surfaceColor = BaseCol; HitTerrain = true; } else { - BaseUv = AggTris[bestHit.triangle_id].tex0 * (1.0f - bestHit.u - bestHit.v) + AggTris[bestHit.triangle_id].texedge1 * bestHit.u + AggTris[bestHit.triangle_id].texedge2 * bestHit.v; + BaseUv = TOHALF(AggTris[bestHit.triangle_id].tex0) * (1.0f - bestHit.u - bestHit.v) + TOHALF(AggTris[bestHit.triangle_id].texedge1) * bestHit.u + TOHALF(AggTris[bestHit.triangle_id].texedge2) * bestHit.v; +#ifndef AdvancedBackground MaterialIndex = _MeshData[bestHit.mesh_id].MaterialOffset + AggTris[bestHit.triangle_id].MatDat; +#endif TempMat = _Materials[MaterialIndex]; float3 TempCol = 1; @@ -729,8 +791,8 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { break; } } - - TempMat.surfaceColor *= TempCol; + if(GetFlag(TempMat.Tag, VertexColors)) TempCol *= unpackRGBE(AggTris[bestHit.triangle_id].VertColA) * (1.0f - bestHit.u - bestHit.v) + unpackRGBE(AggTris[bestHit.triangle_id].VertColB) * bestHit.u + unpackRGBE(AggTris[bestHit.triangle_id].VertColC) * bestHit.v; + TempMat.surfaceColor *= TempCol; TempCol = TempMat.surfaceColor; #ifndef DX11 @@ -739,12 +801,13 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { TempMat.surfaceColor *= TempMat.Brightness; TempCol = TempMat.surfaceColor; Unity_Saturation_float(TempCol, TempMat.Saturation, TempMat.surfaceColor); - TempCol = TempMat.surfaceColor; - Unity_Contrast_float(TempCol, TempMat.Contrast, TempMat.surfaceColor); + Unity_Contrast_float(TempMat.surfaceColor, TempMat.Contrast); TempMat.surfaceColor = saturate(TempMat.surfaceColor); TempMat.surfaceColor = lerp(TempMat.surfaceColor, TempMat.BlendColor, TempMat.BlendFactor); } - + { + // if(id.x > screen_width / 2) TempMat.surfaceColor = applyFog(TempMat.surfaceColor, bestHit.t, ray.direction, SunDir); + } #if DebugView != -1 #if DebugView == DVMatID @@ -805,7 +868,6 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { - #ifdef HDRP Texture2DArray DiffuseGBuffer; Texture2DArray SpecularGBuffer; @@ -817,14 +879,14 @@ void kernel_shade(uint3 id : SV_DispatchThreadID) { #endif #pragma kernel kernel_finalize - +int UpscalerMethod; [numthreads(16, 16, 1)] void kernel_finalize(uint3 id : SV_DispatchThreadID) {//Moved final accumulation into its own kernel, improves performance if (id.x >= screen_width || id.y >= screen_height) return; int final_pixel_index = id.y * screen_width + id.x; float3 GBufferCol = 1; - [branch]if(DiffRes) { + [branch]if(DiffRes && UpscalerMethod != 0) { float2 UV = id.xy / float2(screen_width, screen_height); #ifdef HDRP float3 SpecularAlbedo = 0; diff --git a/TrueTrace/Resources/MainCompute/RayTracingShader.compute.meta b/TrueTrace/Resources/MainCompute/RayTracingShader.compute.meta index 53a3f309..77967da4 100644 --- a/TrueTrace/Resources/MainCompute/RayTracingShader.compute.meta +++ b/TrueTrace/Resources/MainCompute/RayTracingShader.compute.meta @@ -2,7 +2,7 @@ fileFormatVersion: 2 guid: a6e6e3016e50d0042835edd81fa9e84e ComputeShaderImporter: externalObjects: {} - preprocessorOverride: 0 + preprocessorOverride: 1 userData: assetBundleName: assetBundleVariant: diff --git a/TrueTrace/Resources/MainCompute/ReSTIRGI.compute.meta b/TrueTrace/Resources/MainCompute/ReSTIRGI.compute.meta index 179ca91b..0146ac4d 100644 --- a/TrueTrace/Resources/MainCompute/ReSTIRGI.compute.meta +++ b/TrueTrace/Resources/MainCompute/ReSTIRGI.compute.meta @@ -2,7 +2,7 @@ fileFormatVersion: 2 guid: e9c5efd1f81f9294caeeb0387b0c2eda ComputeShaderImporter: externalObjects: {} - preprocessorOverride: 0 + preprocessorOverride: 1 userData: assetBundleName: assetBundleVariant: diff --git a/TrueTrace/Resources/Objects/ParentObject.cs b/TrueTrace/Resources/Objects/ParentObject.cs index 0805d7ba..9094c5e0 100644 --- a/TrueTrace/Resources/Objects/ParentObject.cs +++ b/TrueTrace/Resources/Objects/ParentObject.cs @@ -14,13 +14,15 @@ namespace TrueTrace { [System.Serializable] public class ParentObject : MonoBehaviour { + + public LightBVHBuilder LBVH; public Task AsyncTask; public int ExistsInQue = -1; public int QueInProgress = -1; public bool IsDeformable = false; [HideInInspector] public ComputeBuffer LightTriBuffer; - [HideInInspector] public ComputeBuffer LightNodeBuffer; + [HideInInspector] public ComputeBuffer LightTreeBuffer; [HideInInspector] public ComputeBuffer TriBuffer; [HideInInspector] public ComputeBuffer BVHBuffer; public string Name; @@ -34,7 +36,7 @@ public class ParentObject : MonoBehaviour [HideInInspector] public CudaTriangle[] AggTriangles; [HideInInspector] public Vector3 ParentScale; [HideInInspector] public List LightTriangles; - [HideInInspector] public List LightTriNorms; + [HideInInspector] private List LightTriNorms;//Test to see if I can get rrid of this alltogether and just calculate the normal based off cross... [HideInInspector] public BVH8Builder BVH; [HideInInspector] public SkinnedMeshRenderer[] SkinnedMeshes; [HideInInspector] public MeshFilter[] DeformableMeshes; @@ -44,15 +46,15 @@ public class ParentObject : MonoBehaviour [HideInInspector] public BVHNode8DataCompressed[] AggNodes; [HideInInspector] public int InstanceMeshIndex; [HideInInspector] public int LightEndIndex; - public AABB aabb_untransformed; - public AABB aabb; + [HideInInspector] public AABB aabb_untransformed; + [HideInInspector] public AABB aabb; [HideInInspector] public bool AllFull; [HideInInspector] public int AggIndexCount; [HideInInspector] public int AggBVHNodeCount; - public List _Materials; + [HideInInspector] public List _Materials; [HideInInspector] public int MatOffset; [HideInInspector] public StorableTransform[] CachedTransforms; - [HideInInspector] public MeshDat CurMeshData; + [HideInInspector] private MeshDat CurMeshData; public int TotalObjects; [HideInInspector] public List TransformIndexes; [HideInInspector] public bool HasCompleted; @@ -65,7 +67,6 @@ public class ParentObject : MonoBehaviour [HideInInspector] public int NodeUpdateKernel; [HideInInspector] public int NodeCompressKernel; [HideInInspector] public int NodeInitializerKernel; - [HideInInspector] public int LightTLASRefitKernel; [HideInInspector] public int LightBLASRefitKernel; [HideInInspector] public int CompactedMeshData; @@ -89,18 +90,12 @@ public class ParentObject : MonoBehaviour private ComputeBuffer CWBVHIndicesBuffer; private ComputeBuffer[] WorkingBuffer; private ComputeBuffer[] WorkingSet; - public BVH2Builder BVH2; - - #if TTLightMapping - public List[] LightMapTris; - public List LightMapTexIndex; - public List PerRendererIndex; - #endif + private BVH2Builder BVH2; [HideInInspector] public Layer[] ForwardStack; [HideInInspector] public Layer2[] LayerStack; [HideInInspector] public List NodePair; - [HideInInspector] public List LuminanceWeights; + [HideInInspector] private List LuminanceWeights; [HideInInspector] public int MaxRecur = 0; [HideInInspector] public int[] ToBVHIndex; @@ -114,7 +109,6 @@ public class ParentObject : MonoBehaviour [HideInInspector] public List SplitNodes; #if HardwareRT - public List HWRTIndex; public Renderer[] Renderers; #endif @@ -147,7 +141,6 @@ public void ClearAll() { CommonFunctions.DeepClean(ref ForwardStack); CommonFunctions.DeepClean(ref LightTriNorms); CommonFunctions.DeepClean(ref CWBVHIndicesBufferInverted); - CommonFunctions.DeepClean(ref CWBVHIndicesBufferInverted); CommonFunctions.DeepClean(ref LuminanceWeights); if(TrianglesArray.IsCreated) TrianglesArray.Dispose(); if(BVH2 != null) { @@ -187,7 +180,7 @@ public void ClearAll() { if (TriBuffer != null) { LightTriBuffer?.Release(); - LightNodeBuffer?.Release(); + LightTreeBuffer?.ReleaseSafe(); TriBuffer?.Release(); BVHBuffer?.Release(); } @@ -221,7 +214,7 @@ public void OnApplicationQuit() } if (TriBuffer != null) { LightTriBuffer.Release(); - LightNodeBuffer.Release(); + LightTreeBuffer.ReleaseSafe(); TriBuffer.Release(); BVHBuffer.Release(); } @@ -248,8 +241,11 @@ public void init() NodeUpdateKernel = MeshRefit.FindKernel("NodeUpdate"); NodeCompressKernel = MeshRefit.FindKernel("NodeCompress"); NodeInitializerKernel = MeshRefit.FindKernel("NodeInitializer"); - LightTLASRefitKernel = MeshRefit.FindKernel("TLASLightRefitKernel"); +#if !DontUseSGTree + LightBLASRefitKernel = MeshRefit.FindKernel("BLASSGTreeRefitKernel"); +#else LightBLASRefitKernel = MeshRefit.FindKernel("BLASLightRefitKernel"); +#endif } private bool NeedsToResetBuffers = true; public void SetUpBuffers() @@ -257,22 +253,35 @@ public void SetUpBuffers() if (NeedsToResetBuffers) { if (LightTriBuffer != null) LightTriBuffer.Release(); - if (LightNodeBuffer != null) LightNodeBuffer.Release(); if (TriBuffer != null) TriBuffer.Release(); if (BVHBuffer != null) BVHBuffer.Release(); + if (LightTreeBuffer != null) LightTreeBuffer.Release(); if(AggTriangles != null) { if(LightTriangles.Count == 0) { - LightTriBuffer = new ComputeBuffer(1, 44); - LightNodeBuffer = new ComputeBuffer(1, 40); + LightTriBuffer = new ComputeBuffer(1, CommonFunctions.GetStride()); +#if !DontUseSGTree + LightTreeBuffer = new ComputeBuffer(1, CommonFunctions.GetStride()); +#else + LightTreeBuffer = new ComputeBuffer(1, CommonFunctions.GetStride()); +#endif } else { - LightTriBuffer = new ComputeBuffer(Mathf.Max(LightTriangles.Count,1), 44); - LightNodeBuffer = new ComputeBuffer(Mathf.Max(LBVH.nodes.Length,1), 40); + LightTriBuffer = new ComputeBuffer(Mathf.Max(LightTriangles.Count,1), CommonFunctions.GetStride()); +#if !DontUseSGTree + LightTreeBuffer = new ComputeBuffer(Mathf.Max(LBVH.SGTree.Length,1), CommonFunctions.GetStride()); +#else + LightTreeBuffer = new ComputeBuffer(Mathf.Max(LBVH.nodes.Length,1), CommonFunctions.GetStride()); +#endif } TriBuffer = new ComputeBuffer(AggTriangles.Length, 88); BVHBuffer = new ComputeBuffer(AggNodes.Length, 80); if(HasLightTriangles) { LightTriBuffer.SetData(LightTriangles); - LightNodeBuffer.SetData(LBVH.nodes); +#if !DontUseSGTree + LightTreeBuffer.SetData(LBVH.SGTree); +#else + LightTreeBuffer.SetData(LBVH.nodes); +#endif + } TriBuffer.SetData(AggTriangles); BVHBuffer.SetData(AggNodes); @@ -282,6 +291,7 @@ public void SetUpBuffers() public List AlbedoTexs; public List NormalTexs; + public List SecondaryNormalTexs; public List MetallicTexs; public List MetallicTexChannelIndex; public List RoughnessTexs; @@ -352,6 +362,7 @@ public void CreateAtlas(ref int VertCount) _Materials.Clear(); AlbedoTexs = new List(); NormalTexs = new List(); + SecondaryNormalTexs = new List(); MetallicTexs = new List(); RoughnessTexs = new List(); EmissionTexs = new List(); @@ -426,6 +437,10 @@ public void CreateAtlas(ref int VertCount) for(int i2 = 0; i2 < TexCount; i2++) { string TexName = RelevantMat.AvailableTextures[i2].TextureName; switch((TexturePurpose)RelevantMat.AvailableTextures[i2].Purpose) { + case(TexturePurpose.SecondaryNormalTexture): + Result = TextureParse(ref TempScale, SharedMaterials[i], TexName, ref SecondaryNormalTexs, ref TempIndex); + CurMat.SecondaryNormalTex.x = TempIndex; + break; case(TexturePurpose.SecondaryAlbedoTextureMask): Result = TextureParse(ref TempScale, SharedMaterials[i], TexName, ref SecondaryAlbedoTexMasks, ref TempIndex); CurMat.SecondaryAlbedoMask.x = TempIndex; @@ -476,6 +491,7 @@ public void CreateAtlas(ref int VertCount) } if(JustCreated) { + CurMat.SecondaryNormalTexScaleOffset = TempScale; CurMat.SecondaryAlbedoTexScaleOffset = TempScale; CurMat.AlbedoTextureScale = TempScale; CurMat.SecondaryTextureScale = new Vector2(TempScale.x, TempScale.y); @@ -633,7 +649,7 @@ public void LoadData() { if(IsDeformable) DeformableMeshes[i] = TempFilter; } else if(CurrentObject.TryGetComponent(out SkinnedMeshRenderer TempRend)) { - TempRend.BakeMesh(mesh); + mesh = TempRend.sharedMesh; if (IsSkinnedGroup) SkinnedMeshes[i] = TempRend; } @@ -650,6 +666,11 @@ public void LoadData() { if (Tans.Count != 0) CurMeshData.Tangents.AddRange(Tans); else CurMeshData.SetTansZero(mesh.vertexCount); + var Colors = new List(); + mesh.GetColors(Colors); + if (Colors.Count != 0) CurMeshData.Colors.AddRange(Colors); + else CurMeshData.SetColorsZero(mesh.vertexCount); + var Norms = new List(); mesh.GetNormals(Norms); CurMeshData.Normals.AddRange(Norms); @@ -796,21 +817,35 @@ unsafe public void Construct() LT.TriTarget = (uint)CWBVHIndicesBufferInverted[LT.TriTarget]; LightTriangles[i] = LT; } - if(LightTriangles.Count > 0) LBVH = new LightBVHBuilder(LightTriangles, LightTriNorms, 0.1f, LuminanceWeights); + if(LightTriangles.Count > 0) { + LBVH = new LightBVHBuilder(LightTriangles, LightTriNorms, 0.1f, LuminanceWeights); + + } } + public List[] Set; private void Refit(int Depth, int CurrentIndex) { +#if DontUseSGTree if((2.0f * ((float)(LBVH.nodes[CurrentIndex].cosTheta_oe >> 16) / 32767.0f) - 1.0f) == 0) return; +#endif Set[Depth].Add(CurrentIndex); +#if !DontUseSGTree + if(LBVH.SGTree[CurrentIndex].left < 0) return; + Refit(Depth + 1, LBVH.SGTree[CurrentIndex].left); + Refit(Depth + 1, LBVH.SGTree[CurrentIndex].left + 1); +#else if(LBVH.nodes[CurrentIndex].left < 0) return; Refit(Depth + 1, LBVH.nodes[CurrentIndex].left); Refit(Depth + 1, LBVH.nodes[CurrentIndex].left + 1); +#endif } - public void RefitMesh(ref ComputeBuffer RealizedAggNodes, ref ComputeBuffer RealizedTriBuffer, ref ComputeBuffer RealizedLightTriBuffer, ref ComputeBuffer RealizedLightNodeBuffer, CommandBuffer cmd) + + + public void RefitMesh(ref ComputeBuffer RealizedAggNodes, ref ComputeBuffer RealizedTriBuffer, ref ComputeBuffer RealizedLightTriBuffer, ComputeBuffer RealizedLightNodeBuffer, CommandBuffer cmd) { #if HardwareRT for(int i = 0; i < Renderers.Length; i++) AssetManager.Assets.AccelStruct.UpdateInstanceTransform(Renderers[i]); @@ -948,7 +983,11 @@ public void RefitMesh(ref ComputeBuffer RealizedAggNodes, ref ComputeBuffer Real cmd.BeginSample("LightRefitter"); cmd.SetComputeIntParam(MeshRefit, "TotalNodeOffset", LightNodeOffset); cmd.SetComputeMatrixParam(MeshRefit, "ToWorld", transform.localToWorldMatrix); +#if !DontUseSGTree + cmd.SetComputeBufferParam(MeshRefit, LightBLASRefitKernel, "SGTreeWrite", RealizedLightNodeBuffer); +#else cmd.SetComputeBufferParam(MeshRefit, LightBLASRefitKernel, "LightNodesWrite", RealizedLightNodeBuffer); +#endif cmd.SetComputeFloatParam(MeshRefit, "FloatMax", float.MaxValue); int ObjectOffset = LightNodeOffset; for(int i = WorkingSet.Length - 1; i >= 0; i--) { @@ -964,8 +1003,7 @@ public void RefitMesh(ref ComputeBuffer RealizedAggNodes, ref ComputeBuffer Real cmd.EndSample("LightRefitter"); } - #if HardwareRT - #else + #if !HardwareRT cmd.BeginSample("ReMesh Init"); cmd.SetComputeIntParam(MeshRefit, "NodeCount", NodePair.Count); cmd.DispatchCompute(MeshRefit, NodeInitializerKernel, (int)Mathf.Ceil(NodePair.Count / (float)KernelRatio), 1, 1); @@ -1019,6 +1057,7 @@ private float AreaOfTriangle(Vector3 pt1, Vector3 pt2, Vector3 pt3) return Mathf.Sqrt(s * (s - a) * (s - b) * (s - c)); } private float luminance(float r, float g, float b) { return 0.299f * r + 0.587f * g + 0.114f * b; } + private float luminance(Vector3 A) { return Vector3.Dot(new Vector3(0.299f, 0.587f, 0.114f), A);} // Calculate the width and height of a triangle in 3D space public Vector2 CalculateTriangleWidthAndHeight(Vector3 pointA, Vector3 pointB, Vector3 pointC) { @@ -1030,7 +1069,7 @@ public Vector2 CalculateTriangleWidthAndHeight(Vector3 pointA, Vector3 pointB, V return new Vector2(width, height); } - public unsafe async Task BuildTotal() { + public unsafe void BuildTotal() { int IllumTriCount = 0; CudaTriangle TempTri = new CudaTriangle(); Matrix4x4 ParentMatInv = CachedTransforms[0].WTL; @@ -1079,6 +1118,9 @@ public unsafe async Task BuildTotal() { Norm2 = TransMat * Vector3.Scale(Scale, CurMeshData.Normals[Index2]); Norm3 = TransMat * Vector3.Scale(Scale, CurMeshData.Normals[Index3]); + + + #if TTLightMapping LightMapTris[LightMapRendererIndex].Add(new LightMapTriData() { pos0 = ParentMat * V1, @@ -1094,9 +1136,9 @@ public unsafe async Task BuildTotal() { #endif - TempTri.tex0 = CurMeshData.UVs[Index1]; - TempTri.texedge1 = CurMeshData.UVs[Index2]; - TempTri.texedge2 = CurMeshData.UVs[Index3]; + TempTri.tex0 = ((uint)Mathf.FloatToHalf(CurMeshData.UVs[Index1].x) << 16) | Mathf.FloatToHalf(CurMeshData.UVs[Index1].y); + TempTri.texedge1 = ((uint)Mathf.FloatToHalf(CurMeshData.UVs[Index2].x) << 16) | Mathf.FloatToHalf(CurMeshData.UVs[Index2].y); + TempTri.texedge2 = ((uint)Mathf.FloatToHalf(CurMeshData.UVs[Index3].x) << 16) | Mathf.FloatToHalf(CurMeshData.UVs[Index3].y); TempTri.pos0 = V1; TempTri.posedge1 = V2 - V1; @@ -1108,6 +1150,25 @@ public unsafe async Task BuildTotal() { TempTri.tan0 = CommonFunctions.PackOctahedral(Tan1.normalized); TempTri.tan1 = CommonFunctions.PackOctahedral(Tan2.normalized); TempTri.tan2 = CommonFunctions.PackOctahedral(Tan3.normalized); + + TempTri.VertColA = CommonFunctions.packRGBE(CurMeshData.Colors[Index1]); + TempTri.VertColB = CommonFunctions.packRGBE(CurMeshData.Colors[Index2]); + TempTri.VertColC = CommonFunctions.packRGBE(CurMeshData.Colors[Index3]); + + // { + // Vector3 N = Norm1.normalized; + // Vector3 T = Tan1.normalized; + // Vector3 B = Vector3.Cross(N, T); + + // uint EncodedQ = CommonFunctions.encodeQTangentUI32(T, B, N); + // Vector3 N2 = Vector3.zero; + // Vector3 T2 = Vector3.zero; + + // CommonFunctions.decodeQTangentUI32(EncodedQ, ref T2, ref N2); + // if(Mathf.Abs(N.x - N2.x) > 0.01f || Mathf.Abs(N.y - N2.y) > 0.01f || Mathf.Abs(N.z - N2.z) > 0.01f) { + // Debug.Log("AAAA: " + N.normalized + "; " + N2.normalized); + // } + // } TempTri.MatDat = (uint)CurMeshData.MatDat[OffsetReal]; AggTriangles[OffsetReal] = TempTri; @@ -1117,19 +1178,43 @@ public unsafe async Task BuildTotal() { if (_Materials[(int)TempTri.MatDat].emission > 0.0f) { bool IsValid = true; + Vector3 SecondaryBaseCol = Vector3.one; #if AccurateLightTris if(_Materials[(int)TempTri.MatDat].EmissiveTex.x != 0) { int ThisIndex = _Materials[(int)TempTri.MatDat].EmissiveTex.x - 1; - Vector2 UVV = (TempTri.tex0 + TempTri.texedge1 + TempTri.texedge2) / 3.0f; + Vector2 UVV = (new Vector2(Mathf.HalfToFloat((ushort)(TempTri.tex0 >> 16)), Mathf.HalfToFloat((ushort)(TempTri.tex0 & 0xFFFF))) + + new Vector2(Mathf.HalfToFloat((ushort)(TempTri.texedge1 >> 16)), Mathf.HalfToFloat((ushort)(TempTri.texedge1 & 0xFFFF))) + + new Vector2(Mathf.HalfToFloat((ushort)(TempTri.texedge2 >> 16)), Mathf.HalfToFloat((ushort)(TempTri.texedge2 & 0xFFFF)))) / 3.0f; int UVIndex3 = (int)Mathf.Max((Mathf.Floor(UVV.y * (EmissionTexWidthHeight[ThisIndex].y)) * EmissionTexWidthHeight[ThisIndex].x + Mathf.Floor(UVV.x * EmissionTexWidthHeight[ThisIndex].x)),0); - if(UVIndex3 < EmissionTexWidthHeight[ThisIndex].y * EmissionTexWidthHeight[ThisIndex].x) - if(EmissionTexPixels[ThisIndex][UVIndex3].r < 0.1f && EmissionTexPixels[ThisIndex][UVIndex3].g < 0.1f && EmissionTexPixels[ThisIndex][UVIndex3].b < 0.1f) IsValid = false; + UVV = new Vector2(Mathf.HalfToFloat((ushort)(TempTri.tex0 >> 16)), Mathf.HalfToFloat((ushort)(TempTri.tex0 & 0xFFFF))); + int UVIndex2 = (int)Mathf.Max((Mathf.Floor(UVV.y * (EmissionTexWidthHeight[ThisIndex].y)) * EmissionTexWidthHeight[ThisIndex].x + Mathf.Floor(UVV.x * EmissionTexWidthHeight[ThisIndex].x)),0); + UVV = new Vector2(Mathf.HalfToFloat((ushort)(TempTri.texedge1 >> 16)), Mathf.HalfToFloat((ushort)(TempTri.texedge1 & 0xFFFF))); + int UVIndex1 = (int)Mathf.Max((Mathf.Floor(UVV.y * (EmissionTexWidthHeight[ThisIndex].y)) * EmissionTexWidthHeight[ThisIndex].x + Mathf.Floor(UVV.x * EmissionTexWidthHeight[ThisIndex].x)),0); + UVV = new Vector2(Mathf.HalfToFloat((ushort)(TempTri.texedge2 >> 16)), Mathf.HalfToFloat((ushort)(TempTri.texedge2 & 0xFFFF))); + int UVIndex0 = (int)Mathf.Max((Mathf.Floor(UVV.y * (EmissionTexWidthHeight[ThisIndex].y)) * EmissionTexWidthHeight[ThisIndex].x + Mathf.Floor(UVV.x * EmissionTexWidthHeight[ThisIndex].x)),0); + bool FoundTrue = false; + if(UVIndex3 < EmissionTexWidthHeight[ThisIndex].y * EmissionTexWidthHeight[ThisIndex].x){ + if(!(EmissionTexPixels[ThisIndex][UVIndex3].r < 0.01f && EmissionTexPixels[ThisIndex][UVIndex3].g < 0.01f && EmissionTexPixels[ThisIndex][UVIndex3].b < 0.01f)) FoundTrue = true; + // else SecondaryBaseCol = new Vector3(EmissionTexPixels[ThisIndex][UVIndex3].r, EmissionTexPixels[ThisIndex][UVIndex3].g, EmissionTexPixels[ThisIndex][UVIndex3].b); + } + if(UVIndex2 < EmissionTexWidthHeight[ThisIndex].y * EmissionTexWidthHeight[ThisIndex].x){ + if(!(EmissionTexPixels[ThisIndex][UVIndex2].r < 0.01f && EmissionTexPixels[ThisIndex][UVIndex2].g < 0.01f && EmissionTexPixels[ThisIndex][UVIndex2].b < 0.01f)) FoundTrue = true; + // else SecondaryBaseCol = new Vector3(EmissionTexPixels[ThisIndex][UVIndex3].r, EmissionTexPixels[ThisIndex][UVIndex3].g, EmissionTexPixels[ThisIndex][UVIndex3].b); + } + if(UVIndex1 < EmissionTexWidthHeight[ThisIndex].y * EmissionTexWidthHeight[ThisIndex].x){ + if(!(EmissionTexPixels[ThisIndex][UVIndex1].r < 0.01f && EmissionTexPixels[ThisIndex][UVIndex1].g < 0.01f && EmissionTexPixels[ThisIndex][UVIndex1].b < 0.01f)) FoundTrue = true; + // else SecondaryBaseCol = new Vector3(EmissionTexPixels[ThisIndex][UVIndex3].r, EmissionTexPixels[ThisIndex][UVIndex3].g, EmissionTexPixels[ThisIndex][UVIndex3].b); + } + if(UVIndex0 < EmissionTexWidthHeight[ThisIndex].y * EmissionTexWidthHeight[ThisIndex].x){ + if(!(EmissionTexPixels[ThisIndex][UVIndex0].r < 0.01f && EmissionTexPixels[ThisIndex][UVIndex0].g < 0.01f && EmissionTexPixels[ThisIndex][UVIndex0].b < 0.01f)) FoundTrue = true; + // else SecondaryBaseCol = new Vector3(EmissionTexPixels[ThisIndex][UVIndex3].r, EmissionTexPixels[ThisIndex][UVIndex3].g, EmissionTexPixels[ThisIndex][UVIndex3].b); + } + IsValid = FoundTrue; } #endif if(IsValid) { HasLightTriangles = true; - LuminanceWeights.Add(_Materials[(int)TempTri.MatDat].emission); Vector3 Radiance = _Materials[(int)TempTri.MatDat].emission * _Materials[(int)TempTri.MatDat].BaseColor; float radiance = luminance(Radiance.x, Radiance.y, Radiance.z); float area = AreaOfTriangle(ParentMat * V1, ParentMat * V2, ParentMat * V3); @@ -1142,8 +1227,9 @@ public unsafe async Task BuildTotal() { posedge1 = TempTri.posedge1, posedge2 = TempTri.posedge2, TriTarget = (uint)(OffsetReal), - SourceEnergy = radiance + SourceEnergy = Vector3.Distance(Vector3.zero, _Materials[(int)TempTri.MatDat].emission * Vector3.Scale(_Materials[(int)TempTri.MatDat].BaseColor, SecondaryBaseCol)) }); + LuminanceWeights.Add(Vector3.Distance(Vector3.zero, _Materials[(int)TempTri.MatDat].emission * Vector3.Scale(_Materials[(int)TempTri.MatDat].BaseColor, SecondaryBaseCol))); IllumTriCount++; } } @@ -1268,26 +1354,36 @@ private void OnDisable() { HasCompleted = false; } } - // Vector4 ToVector4(Vector3 A, float B) { - // return new Vector4(A.x, A.y, A.z, B); - // } - // Vector3 ToVector3(Vector4 A) { - // return new Vector3(A.x, A.y, A.z); - // } // public void OnDrawGizmos() { - // int LightTriCount = LightTriangles.Count; - // for(int i = 0; i < LightTriCount; i++) { - // Vector3 Pos0 = ToVector3(this.transform.localToWorldMatrix * ToVector4(LightTriangles[i].pos0, 1)); - // Vector3 Pos1 = ToVector3(this.transform.localToWorldMatrix * ToVector4(LightTriangles[i].pos0 + LightTriangles[i].posedge1, 1)); - // Vector3 Pos2 = ToVector3(this.transform.localToWorldMatrix * ToVector4(LightTriangles[i].pos0 + LightTriangles[i].posedge2, 1)); - // Gizmos.DrawLine(Pos0, Pos1); - // Gizmos.DrawLine(Pos0, Pos2); - // Gizmos.DrawLine(Pos2, Pos1); + // if(LightTriangles != null) { + // int LightTriCount = LightTriangles.Count; + // for(int i = 0; i < LightTriCount; i++) { + // Vector3 Pos0 = CommonFunctions.ToVector3(this.transform.localToWorldMatrix * CommonFunctions.ToVector4(LightTriangles[i].pos0, 1)); + // Vector3 Pos1 = CommonFunctions.ToVector3(this.transform.localToWorldMatrix * CommonFunctions.ToVector4(LightTriangles[i].pos0 + LightTriangles[i].posedge1, 1)); + // Vector3 Pos2 = CommonFunctions.ToVector3(this.transform.localToWorldMatrix * CommonFunctions.ToVector4(LightTriangles[i].pos0 + LightTriangles[i].posedge2, 1)); + // Gizmos.DrawLine(Pos0, Pos1); + // Gizmos.DrawLine(Pos0, Pos2); + // Gizmos.DrawLine(Pos2, Pos1); + // } // } // } + + + // public void OnDrawGizmos() { + // if(LBVH != null && LBVH.SGTree != null) { + // int Count = LBVH.SGTree.Length; + // for(int i = 0; i < Count; i++) { + // Vector3 Pos = CommonFunctions.ToVector3(this.transform.localToWorldMatrix * CommonFunctions.ToVector4(LBVH.SGTree[i].S.Center, 1)); + // float Radius = Vector3.Distance(Pos, CommonFunctions.ToVector3(this.transform.localToWorldMatrix * CommonFunctions.ToVector4(LBVH.SGTree[i].S.Center + new Vector3(LBVH.SGTree[i].S.Radius, 0, 0), 1))); + // // if(LightTree[i].variance < LightTree[i].S.Radius * VarTest) Gizmos.DrawWireSphere(Pos, Radius); + // Gizmos.DrawWireSphere(Pos, Radius); + + // } + // } + // } } diff --git a/TrueTrace/Resources/Objects/RayTracingObject.cs b/TrueTrace/Resources/Objects/RayTracingObject.cs index 96ea4aaa..c3967dd8 100644 --- a/TrueTrace/Resources/Objects/RayTracingObject.cs +++ b/TrueTrace/Resources/Objects/RayTracingObject.cs @@ -48,6 +48,9 @@ public enum BlendModes {Lerp, Add, Multiply}; [SerializeField] public Material[] SharedMaterials; [SerializeField] public string[] Names; [SerializeField] public int Selected; + [SerializeField] public float[] SecondaryNormalTexBlend; + [SerializeField] public float[] DetailNormalStrength; + [SerializeField] public Vector4[] SecondaryNormalTexScaleOffset; public int[] Indexes; public bool NeedsToUpdate; [SerializeField] public bool IsReady = false; @@ -183,7 +186,7 @@ public void matfill() { SubMeshCount = (MeshRend.sharedMaterials).Length; if(TryGetComponent(out Renderer Rend)) SharedMaterials = Rend.sharedMaterials; } else if(TryGetComponent(out SkinnedMeshRenderer SkinnedRend)) { - SkinnedRend.BakeMesh(mesh); + mesh = SkinnedRend.sharedMesh; if(!SkinnedRend.enabled) mesh = null; SubMeshCount = (SkinnedRend.sharedMaterials).Length; SharedMaterials = SkinnedRend.sharedMaterials; @@ -223,6 +226,7 @@ public void matfill() { InitializeArray(ref SecondaryTextureScale, new Vector2(1,1), Index, NeedsRedo); InitializeArray(ref MainTexScaleOffset, new Vector4(1,1,0,0), Index, NeedsRedo); InitializeArray(ref SecondaryAlbedoTexScaleOffset, new Vector4(1,1,0,0), Index, NeedsRedo); + InitializeArray(ref SecondaryNormalTexScaleOffset, new Vector4(1,1,0,0), Index, NeedsRedo); InitializeArray(ref BlendColor, new Vector3(1,1,1), Index, NeedsRedo); InitializeArray(ref BlendFactor, 0, Index, NeedsRedo); InitializeArray(ref Hue, 0, Index, NeedsRedo); @@ -260,6 +264,8 @@ public void matfill() { InitializeArray(ref KelvinTemp, 0, Index, NeedsRedo); InitializeArray(ref ColorBleed, 1, Index, NeedsRedo); InitializeArray(ref AlbedoBlendFactor, 1, Index, NeedsRedo); + InitializeArray(ref SecondaryNormalTexBlend, 0, Index, NeedsRedo); + InitializeArray(ref DetailNormalStrength, 1, Index, NeedsRedo); IsReady = true; mesh = null; diff --git a/TrueTrace/Resources/PostProcess/ASVGF/ASVGF.compute b/TrueTrace/Resources/PostProcess/ASVGF/ASVGF.compute index 655fa11b..c65d52da 100644 --- a/TrueTrace/Resources/PostProcess/ASVGF/ASVGF.compute +++ b/TrueTrace/Resources/PostProcess/ASVGF/ASVGF.compute @@ -479,8 +479,8 @@ void Reproject(uint3 gl_GlobalInvocationID : SV_DispatchThreadID, uint3 gl_WorkG } } - GlobalRaysMini[ipos.x + ipos.y * screen_width].origin -= CamDiff; - GlobalRaysMini[ipos.x + ipos.y * screen_width].direction = normalize(Pos - GlobalRaysMini[ipos.x + ipos.y * screen_width].origin); + // GlobalRaysMini[ipos.x + ipos.y * screen_width].origin -= CamDiff; + // GlobalRaysMini[ipos.x + ipos.y * screen_width].direction = normalize(Pos - GlobalRaysMini[ipos.x + ipos.y * screen_width].origin); MetallicAWrite[ipos] = MetallicB[found_pos_prev]; ScreenSpaceInfoWrite[ipos] = float4(asfloat(TEX_PT_NORMALS_B[found_pos_prev].xy),0,0); @@ -1426,7 +1426,6 @@ inline SH interpolate_lf(Texture2D img_lf_shY, Texture2D img_lf_ return sum_lf; } -bool DiffRes; #ifdef HDRP Texture2DArray DiffuseGBuffer; @@ -1479,14 +1478,14 @@ void Atrous(uint3 gl_GlobalInvocationID : SV_DispatchThreadID, uint3 gl_WorkGrou float3 normal = i_octahedral_32(TEX_PT_NORMALS_A[ipos].y); float4 base_color = float4(unpackRGBE(AlbedoColorB[ipos].x),(ReflRefracA[ipos] << 1) >> 30);// TEX_PT_BASE_COLOR_A.SampleLevel(sampler_trilinear_clamp, ipos / float2(screen_width, screen_height), 0); - if(DiffRes && base_color.w <= 2) base_color.xyz = 1; + if(UpscalerMethod != 0 && DiffRes && base_color.w <= 2) base_color.xyz = 1; if(base_color.w == 1) base_color = float4(unpackRGBE(AlbedoColorB[ipos].x),1); // Project the spherical harmonics lighting onto the actual surface normal float3 projected_lf = project_SH_irradiance(filtered_lf, normal); projected_lf *= 1024.0f; - float3 final_color = composite_color(base_color, projected_lf, filtered_hf, filtered_spec, (DiffRes && base_color.w <= 2) ? 1 : unpackRGBE(AlbedoColorB[ipos].y), ipos); + float3 final_color = composite_color(base_color, projected_lf, filtered_hf, filtered_spec, (UpscalerMethod != 0 && DiffRes && base_color.w <= 2) ? 1 : unpackRGBE(AlbedoColorB[ipos].y), ipos); // SH TempSH = irradiance_to_SH(final_color, i_octahedral_32(TEX_PT_NORMALS_A[ipos].x)); // final_color = project_SH_irradiance(TempSH, normal); IMG_ASVGF_COLOR[ipos] = float4(final_color, 0); diff --git a/TrueTrace/Resources/PostProcess/ASVGF/ASVGF.cs b/TrueTrace/Resources/PostProcess/ASVGF/ASVGF.cs index f33944fc..a6c2cf02 100644 --- a/TrueTrace/Resources/PostProcess/ASVGF/ASVGF.cs +++ b/TrueTrace/Resources/PostProcess/ASVGF/ASVGF.cs @@ -256,7 +256,19 @@ public void DoRNG(ref RenderTexture RNGTex, ref RenderTexture RNGTexB, int CurFr } - public void Do(ref ComputeBuffer _ColorBuffer, ref RenderTexture Output, float ResolutionRatio, RenderTexture ScreenSpaceInfo, CommandBuffer cmd, int CurFrame, ref RenderTexture WorldPosData, int PartialRenderingFactor, ComputeBuffer ExposureModifier, bool DoExposure, float IndirectBoost, RenderTexture RNGTex) + public void Do(ref ComputeBuffer _ColorBuffer, + ref RenderTexture Output, + float ResolutionRatio, + RenderTexture ScreenSpaceInfo, + CommandBuffer cmd, + int CurFrame, + ref RenderTexture WorldPosData, + int PartialRenderingFactor, + ComputeBuffer ExposureModifier, + bool DoExposure, + float IndirectBoost, + RenderTexture RNGTex, + int UpscalerMethod) { camera = RayTracingMaster._camera; @@ -264,6 +276,7 @@ public void Do(ref ComputeBuffer _ColorBuffer, ref RenderTexture Output, float R cmd.BeginSample("ASVGF Copy Data Kernel"); int MaxIterations = 4; cmd.SetComputeIntParam(shader, "MaxIterations", MaxIterations); + cmd.SetComputeIntParam(shader, "UpscalerMethod", UpscalerMethod); cmd.SetComputeFloatParam(shader, "ResRatio", ResolutionRatio); shader.SetBool("UseExposure", DoExposure); shader.SetFloat("IndirectBoost", IndirectBoost); diff --git a/TrueTrace/Resources/PostProcess/DenoisersCommon.cginc b/TrueTrace/Resources/PostProcess/DenoisersCommon.cginc index 70e3d7eb..704edd5d 100644 --- a/TrueTrace/Resources/PostProcess/DenoisersCommon.cginc +++ b/TrueTrace/Resources/PostProcess/DenoisersCommon.cginc @@ -1,6 +1,8 @@ #include "../MainCompute/CommonStructs.cginc" int screen_width; int screen_height; +int UpscalerMethod; +bool DiffRes; float4x4 CamToWorld; float4x4 CamInvProj; float4x4 CamToWorldPrev; diff --git a/TrueTrace/Resources/PostProcess/ReSTIRASVGF/ReSTIRASVGF.compute b/TrueTrace/Resources/PostProcess/ReSTIRASVGF/ReSTIRASVGF.compute index ed582ae2..f99284d4 100644 --- a/TrueTrace/Resources/PostProcess/ReSTIRASVGF/ReSTIRASVGF.compute +++ b/TrueTrace/Resources/PostProcess/ReSTIRASVGF/ReSTIRASVGF.compute @@ -1314,7 +1314,6 @@ inline SH interpolate_lf(Texture2D img_lf_shY, Texture2D img_lf_ return sum_lf; } -bool DiffRes; #ifdef HDRP Texture2DArray DiffuseGBuffer; @@ -1366,13 +1365,13 @@ void Atrous(uint3 gl_GlobalInvocationID : SV_DispatchThreadID, uint3 gl_WorkGrou float3 normal = i_octahedral_32(TEX_PT_NORMALS_A[ipos].y); float4 base_color = float4(unpackRGBE(AlbedoColorB[ipos].x),GetBounceData(GlobalColorsRead[ipos.x + ipos.y * screen_width].MetRoughIsSpec));// TEX_PT_BASE_COLOR_A.SampleLevel(sampler_trilinear_clamp, ipos / float2(screen_width, screen_height), 0); - if(DiffRes && base_color.w <= 2) base_color.xyz = 1; + if(UpscalerMethod != 0 && DiffRes && base_color.w <= 2) base_color.xyz = 1; if(base_color.w == 1) base_color = float4(GlobalColorsRead[ipos.x + ipos.y * screen_width].Data,1); // Project the spherical harmonics lighting onto the actual surface normal float3 projected_lf = project_SH_irradiance(filtered_lf, normal); projected_lf *= 1024.0f; - float3 final_color = composite_color(base_color, projected_lf, filtered_hf, filtered_spec, (DiffRes && base_color.w <= 2) ? 1 : unpackRGBE(AlbedoColorB[ipos].y), ipos); + float3 final_color = composite_color(base_color, projected_lf, filtered_hf, filtered_spec, (UpscalerMethod != 0 && DiffRes && base_color.w <= 2) ? 1 : unpackRGBE(AlbedoColorB[ipos].y), ipos); IMG_ASVGF_COLOR[ipos] = float4(final_color, 0); diff --git a/TrueTrace/Resources/PostProcess/ReSTIRASVGF/ReSTIRASVGF.cs b/TrueTrace/Resources/PostProcess/ReSTIRASVGF/ReSTIRASVGF.cs index 30eae1ec..010ccce4 100644 --- a/TrueTrace/Resources/PostProcess/ReSTIRASVGF/ReSTIRASVGF.cs +++ b/TrueTrace/Resources/PostProcess/ReSTIRASVGF/ReSTIRASVGF.cs @@ -190,12 +190,14 @@ public void Do(ref ComputeBuffer _ColorBuffer, RenderTexture Gradients, RenderTexture PrimaryTriData, ComputeBuffer MeshData, - ComputeBuffer TriData) + ComputeBuffer TriData, + int UpscalerMethod) { camera = RayTracingMaster._camera; bool EvenFrame = CurFrame % 2 == 0; cmd.BeginSample("Dist Correct Kernel"); + cmd.SetComputeIntParam(shader, "UpscalerMethod", UpscalerMethod); Vector3 Euler = camera.transform.eulerAngles; shader.SetMatrix("viewprojection", camera.projectionMatrix * camera.worldToCameraMatrix); camera.transform.eulerAngles = prevEuler; diff --git a/TrueTrace/Resources/RayTracingMaster.cs b/TrueTrace/Resources/RayTracingMaster.cs index 270a07e5..8d915ac2 100644 --- a/TrueTrace/Resources/RayTracingMaster.cs +++ b/TrueTrace/Resources/RayTracingMaster.cs @@ -57,6 +57,7 @@ public static void WriteString(RayTracingObject OBJtoWrite, string NameIndex) { Spec = OBJtoWrite.Specular[Index], AlphaCutoff = OBJtoWrite.AlphaCutoff[Index], NormStrength = OBJtoWrite.NormalStrength[Index], + DetailNormalStrength = OBJtoWrite.DetailNormalStrength[Index], Hue = OBJtoWrite.Hue[Index], Brightness = OBJtoWrite.Brightness[Index], Contrast = OBJtoWrite.Contrast[Index], @@ -71,6 +72,8 @@ public static void WriteString(RayTracingObject OBJtoWrite, string NameIndex) { UseKelvin = OBJtoWrite.UseKelvin[Index], KelvinTemp = OBJtoWrite.KelvinTemp[Index], ColorBleed = OBJtoWrite.ColorBleed[Index], + SecondaryNormalTexBlend = OBJtoWrite.SecondaryNormalTexBlend[Index], + SecondaryNormalTexScaleOffset = OBJtoWrite.SecondaryNormalTexScaleOffset[Index], AlbedoBlendFactor = OBJtoWrite.AlbedoBlendFactor[Index] }; if(WriteID == -1) { @@ -109,6 +112,8 @@ public static void WriteString(RayTracingObject OBJtoWrite, string NameIndex) { private RenderTexture CDFY; private RenderTexture Gradients; + public static TTSDFHandler OptionalSDFHandler; + private bool HasSDFHandler = false; private bool OIDNGuideWrite; @@ -434,6 +439,7 @@ private void SetMatrix(string Name, Matrix4x4 Mat) { IntersectionShader.SetMatrix(Name, Mat); GenerateShader.SetMatrix(Name, Mat); ReSTIRGI.SetMatrix(Name, Mat); + if(HasSDFHandler) OptionalSDFHandler.GenShader.SetMatrix(Name, Mat); } private void SetVector(string Name, Vector3 IN, CommandBuffer cmd) { @@ -441,6 +447,7 @@ private void SetVector(string Name, Vector3 IN, CommandBuffer cmd) { cmd.SetComputeVectorParam(IntersectionShader, Name, IN); cmd.SetComputeVectorParam(GenerateShader, Name, IN); cmd.SetComputeVectorParam(ReSTIRGI, Name, IN); + if(HasSDFHandler) cmd.SetComputeVectorParam(OptionalSDFHandler.GenShader, Name, IN); } private void SetInt(string Name, int IN, CommandBuffer cmd) { @@ -448,6 +455,7 @@ private void SetInt(string Name, int IN, CommandBuffer cmd) { cmd.SetComputeIntParam(IntersectionShader, Name, IN); cmd.SetComputeIntParam(GenerateShader, Name, IN); cmd.SetComputeIntParam(ReSTIRGI, Name, IN); + if(HasSDFHandler) cmd.SetComputeIntParam(OptionalSDFHandler.GenShader, Name, IN); } private void SetFloat(string Name, float IN, CommandBuffer cmd) { @@ -455,6 +463,7 @@ private void SetFloat(string Name, float IN, CommandBuffer cmd) { cmd.SetComputeFloatParam(IntersectionShader, Name, IN); cmd.SetComputeFloatParam(GenerateShader, Name, IN); cmd.SetComputeFloatParam(ReSTIRGI, Name, IN); + if(HasSDFHandler) cmd.SetComputeFloatParam(OptionalSDFHandler.GenShader, Name, IN); } private void SetBool(string Name, bool IN) { @@ -462,19 +471,20 @@ private void SetBool(string Name, bool IN) { IntersectionShader.SetBool(Name, IN); GenerateShader.SetBool(Name, IN); ReSTIRGI.SetBool(Name, IN); + if(HasSDFHandler) OptionalSDFHandler.GenShader.SetBool(Name, IN); } Matrix4x4 CamInvProjPrev; Matrix4x4 CamToWorldPrev; Vector3 PrevPos; private Vector2 HDRIParams = Vector2.zero; - private void SetShaderParameters(CommandBuffer cmd) - { + private void SetShaderParameters(CommandBuffer cmd) { + HasSDFHandler = (OptionalSDFHandler != null); if(LocalTTSettings.RenderScale != 1.0f) _camera.renderingPath = RenderingPath.DeferredShading; _camera.depthTextureMode |= DepthTextureMode.Depth | DepthTextureMode.MotionVectors; - if(LocalTTSettings.UseReSTIRGI && LocalTTSettings.UseASVGF && !ReSTIRASVGFCode.Initialized) ReSTIRASVGFCode.init(SourceWidth, SourceHeight); - else if ((!LocalTTSettings.UseASVGF || !LocalTTSettings.UseReSTIRGI) && ReSTIRASVGFCode.Initialized) ReSTIRASVGFCode.ClearAll(); - if (!LocalTTSettings.UseReSTIRGI && LocalTTSettings.UseASVGF && !ASVGFCode.Initialized) ASVGFCode.init(SourceWidth, SourceHeight); - else if ((!LocalTTSettings.UseASVGF || LocalTTSettings.UseReSTIRGI) && ASVGFCode.Initialized) ASVGFCode.ClearAll(); + if(LocalTTSettings.UseReSTIRGI && LocalTTSettings.DenoiserMethod == 1 && !ReSTIRASVGFCode.Initialized) ReSTIRASVGFCode.init(SourceWidth, SourceHeight); + else if ((LocalTTSettings.DenoiserMethod != 1 || !LocalTTSettings.UseReSTIRGI) && ReSTIRASVGFCode.Initialized) ReSTIRASVGFCode.ClearAll(); + if (!LocalTTSettings.UseReSTIRGI && LocalTTSettings.DenoiserMethod == 1 && !ASVGFCode.Initialized) ASVGFCode.init(SourceWidth, SourceHeight); + else if ((LocalTTSettings.DenoiserMethod != 1 || LocalTTSettings.UseReSTIRGI) && ASVGFCode.Initialized) ASVGFCode.ClearAll(); if(TTPostProc.Initialized == false) TTPostProc.init(SourceWidth, SourceHeight); BufferSizes = new BufferSizeData[LocalTTSettings.bouncecount + 1]; @@ -515,6 +525,7 @@ private void SetShaderParameters(CommandBuffer cmd) PrevPos = _camera.transform.position; SetVector("PrevCamPos", Temp22, cmd); SetVector("CamDelta", E, cmd); + SetVector("PrimaryBackgroundTintColor", LocalTTSettings.PrimaryBackgroundTintColor, cmd); SetVector("BackgroundColor", LocalTTSettings.SceneBackgroundColor, cmd); SetVector("SecondaryBackgroundColor", LocalTTSettings.SecondarySceneBackgroundColor, cmd); SetVector("ClayColor", LocalTTSettings.ClayColor, cmd); @@ -523,12 +534,14 @@ private void SetShaderParameters(CommandBuffer cmd) SetVector("HDRILongLat", LocalTTSettings.HDRILongLat, cmd); SetVector("HDRIScale", LocalTTSettings.HDRIScale, cmd); SetVector("MousePos", Input.mousePosition, cmd); - if(LocalTTSettings.UseASVGF && !LocalTTSettings.UseReSTIRGI) ASVGFCode.shader.SetVector("CamDelta", E); - if(LocalTTSettings.UseASVGF && LocalTTSettings.UseReSTIRGI) ReSTIRASVGFCode.shader.SetVector("CamDelta", E); + if(LocalTTSettings.DenoiserMethod == 1 && !LocalTTSettings.UseReSTIRGI) ASVGFCode.shader.SetVector("CamDelta", E); + if(LocalTTSettings.DenoiserMethod == 1 && LocalTTSettings.UseReSTIRGI) ReSTIRASVGFCode.shader.SetVector("CamDelta", E); Shader.SetGlobalInt("PartialRenderingFactor", LocalTTSettings.PartialRenderingFactor); SetFloat("FarPlane", _camera.farClipPlane, cmd); SetFloat("NearPlane", _camera.nearClipPlane, cmd); + SetFloat("PrimaryBackgroundTint", LocalTTSettings.PrimaryBackgroundTint, cmd); + SetFloat("PrimaryBackgroundContrast", LocalTTSettings.PrimaryBackgroundContrast, cmd); SetFloat("focal_distance", LocalTTSettings.DoFFocal, cmd); SetFloat("AperatureRadius", LocalTTSettings.DoFAperature * LocalTTSettings.DoFAperatureScale, cmd); SetFloat("IndirectBoost", LocalTTSettings.IndirectBoost, cmd); @@ -557,6 +570,7 @@ private void SetShaderParameters(CommandBuffer cmd) SetInt("SecondaryBackgroundType", LocalTTSettings.SecondaryBackgroundType, cmd); SetInt("MaterialCount", Assets.MatCount, cmd); SetInt("PartialRenderingFactor", LocalTTSettings.DoPartialRendering ? LocalTTSettings.PartialRenderingFactor : 1, cmd); + SetInt("UpscalerMethod", LocalTTSettings.UpscalerMethod, cmd); SetBool("IsFocusing", IsFocusing); SetBool("DoPanorama", DoPanorama); @@ -569,12 +583,12 @@ private void SetShaderParameters(CommandBuffer cmd) SetBool("UseReSTIRGITemporal", LocalTTSettings.UseReSTIRGITemporal); SetBool("UseReSTIRGISpatial", LocalTTSettings.UseReSTIRGISpatial); SetBool("DoReSTIRGIConnectionValidation", LocalTTSettings.DoReSTIRGIConnectionValidation); - SetBool("UseASVGF", LocalTTSettings.UseASVGF && !LocalTTSettings.UseReSTIRGI); + SetBool("UseASVGF", LocalTTSettings.DenoiserMethod == 1 && !LocalTTSettings.UseReSTIRGI); SetBool("TerrainExists", Assets.Terrains.Count != 0); SetBool("DoPartialRendering", LocalTTSettings.DoPartialRendering); SetBool("UseTransmittanceInNEE", LocalTTSettings.UseTransmittanceInNEE); OIDNGuideWrite = (FramesSinceStart == LocalTTSettings.OIDNFrameCount); - SetBool("OIDNGuideWrite", OIDNGuideWrite && LocalTTSettings.UseOIDN); + SetBool("OIDNGuideWrite", OIDNGuideWrite && LocalTTSettings.DenoiserMethod == 2); SetBool("DiffRes", LocalTTSettings.RenderScale != 1.0f); SetBool("DoPartialRendering", LocalTTSettings.DoPartialRendering); SetBool("DoExposure", LocalTTSettings.PPExposure); @@ -636,21 +650,13 @@ private void SetShaderParameters(CommandBuffer cmd) SetVector("HDRIParams", HDRIParams, cmd); GenerateShader.SetBuffer(GenASVGFKernel, "Rays", (FramesSinceStart2 % 2 == 0) ? RaysBuffer : RaysBufferB); - GenerateShader.SetTexture(GenASVGFKernel, "RandomNums", FlipFrame ? _RandomNums : _RandomNumsB); - GenerateShader.SetComputeBuffer(GenASVGFKernel, "GlobalRays", _RayBuffer); - GenerateShader.SetComputeBuffer(GenASVGFKernel, "GlobalColors", LightingBuffer); - GenerateShader.SetTexture(GenASVGFKernel, "WorldPosA", GIWorldPosA); - GenerateShader.SetTexture(GenASVGFKernel, "NEEPosA", FlipFrame ? GINEEPosA : GINEEPosB); GenerateShader.SetComputeBuffer(GenASVGFKernel, "GlobalRays", _RayBuffer); - GenerateShader.SetComputeBuffer(GenASVGFKernel, "GlobalColors", LightingBuffer); GenerateShader.SetTexture(GenKernel, "RandomNums", (FramesSinceStart2 % 2 == 0) ? _RandomNums : _RandomNumsB); GenerateShader.SetComputeBuffer(GenKernel, "GlobalRays", _RayBuffer); - GenerateShader.SetComputeBuffer(GenKernel, "GlobalColors", LightingBuffer); GenerateShader.SetTexture(GenPanoramaKernel, "RandomNums", (FramesSinceStart2 % 2 == 0) ? _RandomNums : _RandomNumsB); GenerateShader.SetComputeBuffer(GenPanoramaKernel, "GlobalRays", _RayBuffer); - GenerateShader.SetComputeBuffer(GenPanoramaKernel, "GlobalColors", LightingBuffer); AssetManager.Assets.SetMeshTraceBuffers(IntersectionShader, TraceKernel); IntersectionShader.SetComputeBuffer(TraceKernel, "GlobalRays", _RayBuffer); @@ -683,20 +689,10 @@ private void SetShaderParameters(CommandBuffer cmd) GenerateShader.SetComputeBuffer(ResolveKernel + 1, "HashEntriesBuffer", HashBuffer); GenerateShader.SetComputeBuffer(ResolveKernel + 1, "HashEntriesBufferA2", HashBufferB); GenerateShader.SetComputeBuffer(ResolveKernel + 2, "VoxelDataBufferA", FlipFrame ? VoxelDataBufferA : VoxelDataBufferB); - // GenerateShader.SetComputeBuffer(ResolveKernel + 2, "HashEntriesBufferB", HashBuffer); - // GenerateShader.SetComputeBuffer(ResolveKernel + 2, "HashEntriesBuffer", HashBufferB); IntersectionShader.SetComputeBuffer(ShadowKernel, "CacheBuffer", CacheBuffer); IntersectionShader.SetComputeBuffer(HeightmapShadowKernel, "CacheBuffer", CacheBuffer); - GenerateShader.SetComputeBuffer(GIReTraceKernel, "CacheBuffer", CacheBuffer); - GenerateShader.SetComputeBuffer(GenASVGFKernel, "CacheBuffer", CacheBuffer); - GenerateShader.SetComputeBuffer(GenASVGFKernel, "VoxelDataBufferA", FlipFrame ? VoxelDataBufferA : VoxelDataBufferB); - GenerateShader.SetComputeBuffer(GenKernel, "CacheBuffer", CacheBuffer); - GenerateShader.SetComputeBuffer(GenKernel, "VoxelDataBufferA", FlipFrame ? VoxelDataBufferA : VoxelDataBufferB); - - GenerateShader.SetComputeBuffer(GenPanoramaKernel, "CacheBuffer", CacheBuffer); - GenerateShader.SetComputeBuffer(GenPanoramaKernel, "VoxelDataBufferA", FlipFrame ? VoxelDataBufferA : VoxelDataBufferB); ShadingShader.SetComputeBuffer(ShadeKernel, "CacheBuffer", CacheBuffer); ShadingShader.SetComputeBuffer(ShadeKernel, "HashEntriesBuffer", HashBuffer); @@ -740,15 +736,10 @@ private void SetShaderParameters(CommandBuffer cmd) #endif GenerateShader.SetComputeBuffer(GIReTraceKernel, "GlobalRays", _RayBuffer); - GenerateShader.SetComputeBuffer(GIReTraceKernel, "GlobalColors", LightingBuffer); - GenerateShader.SetTexture(GIReTraceKernel, "WorldPosA", GIWorldPosA); - GenerateShader.SetTexture(GIReTraceKernel, "NEEPosA", FlipFrame ? GINEEPosA : GINEEPosB); GenerateShader.SetComputeBuffer(GIReTraceKernel, "PrevGlobalColorsA", FlipFrame ? PrevLightingBufferA : PrevLightingBufferB); - GenerateShader.SetBuffer(GIReTraceKernel, "Rays", FlipFrame ? RaysBuffer : RaysBufferB); GenerateShader.SetTexture(GIReTraceKernel, "RandomNumsWrite", FlipFrame ? _RandomNums : _RandomNumsB); GenerateShader.SetTexture(GIReTraceKernel, "ReservoirA", !FlipFrame ? GIReservoirB : GIReservoirA); GenerateShader.SetTexture(GIReTraceKernel, "RandomNums", !FlipFrame ? _RandomNums : _RandomNumsB); - GenerateShader.SetTexture(GIReTraceKernel, "ScreenSpaceInfo", !FlipFrame ? ScreenSpaceInfo : ScreenSpaceInfoPrev); AssetManager.Assets.SetMeshTraceBuffers(ReSTIRGI, ReSTIRGIKernel); @@ -801,8 +792,8 @@ private void ResetAllTextures() { LocalTTSettings.RenderScale = 1; } PrevResFactor = LocalTTSettings.RenderScale; - if(LocalTTSettings.UseASVGF && LocalTTSettings.UseReSTIRGI) {ReSTIRASVGFCode.ClearAll(); ReSTIRASVGFCode.init(SourceWidth, SourceHeight);} - if (LocalTTSettings.UseASVGF && !LocalTTSettings.UseReSTIRGI) {ASVGFCode.ClearAll(); ASVGFCode.init(SourceWidth, SourceHeight);} + if(LocalTTSettings.DenoiserMethod == 1 && LocalTTSettings.UseReSTIRGI) {ReSTIRASVGFCode.ClearAll(); ReSTIRASVGFCode.init(SourceWidth, SourceHeight);} + if(LocalTTSettings.DenoiserMethod == 1 && !LocalTTSettings.UseReSTIRGI) {ASVGFCode.ClearAll(); ASVGFCode.init(SourceWidth, SourceHeight);} if(TTPostProc.Initialized) TTPostProc.ClearAll(); TTPostProc.init(SourceWidth, SourceHeight); @@ -923,10 +914,10 @@ public void ClearOutRenderTexture(RenderTexture renderTexture) private void GenerateRays(CommandBuffer cmd) { - if (LocalTTSettings.UseASVGF && !LocalTTSettings.UseReSTIRGI) { + if (LocalTTSettings.DenoiserMethod == 1 && !LocalTTSettings.UseReSTIRGI) { cmd.BeginSample("ASVGF Reproject Pass"); - ASVGFCode.shader.SetTexture(1, "ScreenSpaceInfoWrite", (FramesSinceStart2 % 2 == 0) ? ScreenSpaceInfo : ScreenSpaceInfoPrev); - ASVGFCode.DoRNG(ref _RandomNums, ref _RandomNumsB, FramesSinceStart2, ref RaysBuffer, ref RaysBufferB, cmd, _PrimaryTriangleInfo, AssetManager.Assets.MeshDataBuffer, Assets.AggTriBuffer, MeshOrderChanged, Assets.TLASCWBVHIndexes); + ASVGFCode.shader.SetTexture(1, "ScreenSpaceInfoWrite", (FramesSinceStart2 % 2 == 0) ? ScreenSpaceInfo : ScreenSpaceInfoPrev); + ASVGFCode.DoRNG(ref _RandomNums, ref _RandomNumsB, FramesSinceStart2, ref RaysBuffer, ref RaysBufferB, cmd, _PrimaryTriangleInfo, FramesSinceStart2 % 2 == 0 ? AssetManager.Assets.MeshDataBufferA : AssetManager.Assets.MeshDataBufferB, Assets.AggTriBuffer, MeshOrderChanged, Assets.TLASCWBVHIndexes); cmd.EndSample("ASVGF Reproject Pass"); } @@ -936,9 +927,13 @@ private void GenerateRays(CommandBuffer cmd) { cmd.DispatchCompute(GenerateShader, GIReTraceKernel, Mathf.CeilToInt(SourceWidth / 16.0f), Mathf.CeilToInt(SourceHeight / 16.0f), 1); cmd.EndSample("ReSTIR GI Reproject"); } else { - cmd.BeginSample("Primary Ray Generation"); - cmd.DispatchCompute(GenerateShader, (DoChainedImages ? GenPanoramaKernel : ((LocalTTSettings.UseASVGF && !LocalTTSettings.UseReSTIRGI) ? GenASVGFKernel : GenKernel)), Mathf.CeilToInt(SourceWidth / 16.0f), Mathf.CeilToInt(SourceHeight / 16.0f), 1); - cmd.EndSample("Primary Ray Generation"); + if(HasSDFHandler) { + OptionalSDFHandler.Run(cmd, (FramesSinceStart2 % 2 == 0) ? _RandomNums : _RandomNumsB, _RayBuffer, SourceWidth, SourceHeight, DoChainedImages, LocalTTSettings.DenoiserMethod == 1 && !LocalTTSettings.UseReSTIRGI, (FramesSinceStart2 % 2 == 0) ? RaysBuffer : RaysBufferB); + } else { + cmd.BeginSample("Primary Ray Generation"); + cmd.DispatchCompute(GenerateShader, (DoChainedImages ? GenPanoramaKernel : ((LocalTTSettings.DenoiserMethod == 1 && !LocalTTSettings.UseReSTIRGI) ? GenASVGFKernel : GenKernel)), Mathf.CeilToInt(SourceWidth / 16.0f), Mathf.CeilToInt(SourceHeight / 16.0f), 1); + cmd.EndSample("Primary Ray Generation"); + } } } @@ -949,7 +944,7 @@ private void Render(RenderTexture destination, CommandBuffer cmd) cmd.DispatchCompute(GenerateShader, ResolveKernel + 2, Mathf.CeilToInt((4.0f * 1024.0f * 1024.0f) / 256.0f), 1, 1); cmd.EndSample("RadCacheClear"); #endif - TTPostProc.ValidateInit(LocalTTSettings.PPBloom, LocalTTSettings.PPTAA, SourceWidth != TargetWidth, LocalTTSettings.UseTAAU, LocalTTSettings.DoSharpen, LocalTTSettings.PPFXAA); + TTPostProc.ValidateInit(LocalTTSettings.PPBloom, LocalTTSettings.PPTAA, SourceWidth != TargetWidth, LocalTTSettings.UpscalerMethod == 2, LocalTTSettings.DoSharpen, LocalTTSettings.PPFXAA); float CurrentSample; GenerateRays(cmd); @@ -1046,7 +1041,7 @@ private void Render(RenderTexture destination, CommandBuffer cmd) cmd.EndSample("ReSTIRGI Extra Spatial Kernel"); } - if (!(!LocalTTSettings.UseReSTIRGI && LocalTTSettings.UseASVGF) && !(LocalTTSettings.UseReSTIRGI && LocalTTSettings.UseASVGF)) + if (!(!LocalTTSettings.UseReSTIRGI && LocalTTSettings.DenoiserMethod == 1) && !(LocalTTSettings.UseReSTIRGI && LocalTTSettings.DenoiserMethod == 1)) { cmd.BeginSample("Finalize Kernel"); cmd.DispatchCompute(ShadingShader, FinalizeKernel, Mathf.CeilToInt(SourceWidth / 16.0f), Mathf.CeilToInt(SourceHeight / 16.0f), 1); @@ -1058,13 +1053,25 @@ private void Render(RenderTexture destination, CommandBuffer cmd) _addMaterial.SetFloat("_Sample", CurrentSample); cmd.Blit(_target, _converged, _addMaterial); cmd.EndSample("Finalize Kernel"); - } else if(!(LocalTTSettings.UseReSTIRGI && LocalTTSettings.UseASVGF)) { + } else if(!(LocalTTSettings.UseReSTIRGI && LocalTTSettings.DenoiserMethod == 1)) { cmd.BeginSample("ASVGF"); SampleCount = 0; - ASVGFCode.Do(ref LightingBuffer, ref _converged, LocalTTSettings.RenderScale, ((FramesSinceStart2 % 2 == 0) ? ScreenSpaceInfo : ScreenSpaceInfoPrev), cmd, FramesSinceStart2, ref GIWorldPosA, LocalTTSettings.DoPartialRendering ? LocalTTSettings.PartialRenderingFactor : 1, TTPostProc.ExposureBuffer, LocalTTSettings.PPExposure, LocalTTSettings.IndirectBoost, (FramesSinceStart2 % 2 == 0) ? _RandomNums : _RandomNumsB); + ASVGFCode.Do(ref LightingBuffer, + ref _converged, + LocalTTSettings.RenderScale, + ((FramesSinceStart2 % 2 == 0) ? ScreenSpaceInfo : ScreenSpaceInfoPrev), + cmd, + FramesSinceStart2, + ref GIWorldPosA, + LocalTTSettings.DoPartialRendering ? LocalTTSettings.PartialRenderingFactor : 1, + TTPostProc.ExposureBuffer, + LocalTTSettings.PPExposure, + LocalTTSettings.IndirectBoost, + (FramesSinceStart2 % 2 == 0) ? _RandomNums : _RandomNumsB, + LocalTTSettings.UpscalerMethod); CurrentSample = 1; cmd.EndSample("ASVGF"); - } else if(LocalTTSettings.UseReSTIRGI && LocalTTSettings.UseASVGF) { + } else if(LocalTTSettings.UseReSTIRGI && LocalTTSettings.DenoiserMethod == 1) { cmd.BeginSample("ReSTIR ASVGF"); SampleCount = 0; ReSTIRASVGFCode.Do(ref LightingBuffer, @@ -1081,8 +1088,9 @@ private void Render(RenderTexture destination, CommandBuffer cmd) LocalTTSettings.IndirectBoost, Gradients, _PrimaryTriangleInfo, - AssetManager.Assets.MeshDataBuffer, - Assets.AggTriBuffer); + FramesSinceStart2 % 2 == 0 ? AssetManager.Assets.MeshDataBufferA : AssetManager.Assets.MeshDataBufferB, + Assets.AggTriBuffer, + LocalTTSettings.UpscalerMethod); CurrentSample = 1; cmd.EndSample("ReSTIR ASVGF"); } @@ -1101,8 +1109,17 @@ private void Render(RenderTexture destination, CommandBuffer cmd) cmd.BeginSample("Post Processing"); if (SourceWidth != TargetWidth) { - if (LocalTTSettings.UseTAAU) TTPostProc.ExecuteTAAU(ref _FinalTex, ref _converged, cmd, FramesSinceStart2); - else TTPostProc.ExecuteUpsample(ref _converged, ref _FinalTex, FramesSinceStart2, _currentSample, cmd, ((FramesSinceStart2 % 2 == 0) ? ScreenSpaceInfo : ScreenSpaceInfoPrev));//This is a postprocessing pass, but im treating it like its not one, need to move it to after the accumulation + switch(LocalTTSettings.UpscalerMethod) { + case 0://Bilinear + cmd.Blit(_converged, _FinalTex); + break; + case 1://GSR + TTPostProc.ExecuteUpsample(ref _converged, ref _FinalTex, FramesSinceStart2, _currentSample, cmd, ((FramesSinceStart2 % 2 == 0) ? ScreenSpaceInfo : ScreenSpaceInfoPrev)); + break; + case 2://TAAU + TTPostProc.ExecuteTAAU(ref _FinalTex, ref _converged, cmd, FramesSinceStart2); + break; + } } else cmd.CopyTexture(_converged, 0, 0, _FinalTex, 0, 0); @@ -1112,7 +1129,7 @@ private void Render(RenderTexture destination, CommandBuffer cmd) } #if UseOIDN - if(LocalTTSettings.UseOIDN && SampleCount > LocalTTSettings.OIDNFrameCount) { + if(LocalTTSettings.DenoiserMethod == 2 && SampleCount > LocalTTSettings.OIDNFrameCount) { if(DoChainedImages) { cmd.SetComputeBufferParam(ShadingShader, TTtoOIDNKernelPanorama, "OutputBuffer", ColorBuffer); ShadingShader.SetTexture(TTtoOIDNKernelPanorama, "Result", _FinalTex); @@ -1146,7 +1163,7 @@ private void Render(RenderTexture destination, CommandBuffer cmd) FramesSinceStart++; FramesSinceStart2++; PrevCamPosition = _camera.transform.position; - PrevASVGF = LocalTTSettings.UseASVGF; + PrevASVGF = LocalTTSettings.DenoiserMethod == 1; PrevReSTIRGI = LocalTTSettings.UseReSTIRGI; } diff --git a/TrueTrace/Resources/Utility/BVHRefitter.compute b/TrueTrace/Resources/Utility/BVHRefitter.compute index 9377ae44..da29a068 100644 --- a/TrueTrace/Resources/Utility/BVHRefitter.compute +++ b/TrueTrace/Resources/Utility/BVHRefitter.compute @@ -1,4 +1,5 @@ #define KernelRatio 256 +#include "../GlobalDefines.cginc" #include "../MainCompute/CommonStructs.cginc" #pragma warning( disable : 3556) @@ -336,7 +337,7 @@ void NodeInitializer(uint3 id : SV_DispatchThreadID) // ---------------------------------------------------------------------- // //Light BVH refits -#pragma kernel TLASLightRefitKernel +#pragma kernel TLASSGTreeRefitKernel @@ -351,12 +352,19 @@ float3 i_octahedral_32( uint data ) { +RWStructuredBuffer SGTreeWrite; RWStructuredBuffer LightNodesWrite; StructuredBuffer WorkingSet; int SetCount; int ObjectOffset; +inline float luminance(const float3 a) { + return dot(float3(0.299f, 0.587f, 0.114f), a); +} + + + float AngleBetween(float3 v1, float3 v2) { if(dot(v1, v2) < 0) return 3.14159f - 2.0f * asin(length(v1 + v2) / 2.0f); else return 2.0f * asin(length(v2 - v1) / 2.0f); @@ -431,6 +439,57 @@ inline LightBVHData Union(const LightBVHData A, const LightBVHData B, int Left) return Dat; } + +inline float expm1_over_x(const float x) +{ + const float u = exp(x); + + if (u == 1.0) + { + return 1.0; + } + + const float y = u - 1.0; + + if (abs(x) < 1.0) + { + return y / log(u); + } + + return y / x; +} + + +inline float SGIntegral(const float sharpness) +{ + return 4.0 * 3.14159f * expm1_over_x(-2.0 * sharpness); +} + + +inline GaussianTreeNode UnionSG(const GaussianTreeNode LeftNode, const GaussianTreeNode RightNode, int Left) { + + float phi_left = LeftNode.intensity; + float phi_right = RightNode.intensity; + float w_left = phi_left / (phi_left + phi_right); + float w_right = phi_right / (phi_left + phi_right); + + float3 V = w_left * LeftNode.axis + w_right * RightNode.axis;//may be wrong, paper uses BAR_V(BAR_axis here), not just normalized V/axis + + float3 mean = w_left * LeftNode.position + w_right * RightNode.position; + float variance = w_left * LeftNode.variance + w_right * RightNode.variance + w_left * w_right * dot(LeftNode.position - RightNode.position, LeftNode.position - RightNode.position); + + float intensity = LeftNode.intensity + RightNode.intensity; + + float radius = max(distance(mean, LeftNode.position) + LeftNode.radius, distance(mean, RightNode.position) + RightNode.radius); + + float VLength = length(V); + float sharpness = ((3.0f * VLength - VLength * VLength * VLength)) / (1.0f - VLength * VLength); + + + GaussianTreeNode Dat = {mean, radius, V, variance, sharpness, intensity, Left}; + return Dat; +} + struct Transfer { float4x4 Transf2; int SolidOffset; @@ -455,7 +514,42 @@ float3 transform_direction(float4x4 mat, float3 direction) } [numthreads(256,1,1)] -void TLASLightRefitKernel (uint3 id : SV_DispatchThreadID) +void TLASSGTreeRefitKernel (uint3 id : SV_DispatchThreadID) +{ + if(id.x > (uint)SetCount) return; + const int Index = WorkingSet[id.x]; + GaussianTreeNode Node = SGTreeWrite[Index]; + if(Node.left < 0) { + Transfer Transf = Transfers[-(Node.left+1)]; + float3 ExtendedCenter = transform_position(Transf.Transf2, SGTreeWrite[Transf.SolidOffset].position + float3(SGTreeWrite[Transf.SolidOffset].radius, 0, 0)); + float3 center = transform_position(Transf.Transf2, SGTreeWrite[Transf.SolidOffset].position); + float3 axis = transform_direction(Transf.Transf2, SGTreeWrite[Transf.SolidOffset].axis); + float Scale = length(center - ExtendedCenter) / SGTreeWrite[Transf.SolidOffset].radius; + + SGTreeWrite[Index].position = center; + SGTreeWrite[Index].axis = axis; + SGTreeWrite[Index].variance = SGTreeWrite[Transf.SolidOffset].variance; + SGTreeWrite[Index].sharpness = SGTreeWrite[Transf.SolidOffset].sharpness; + + + SGTreeWrite[Index].radius = SGTreeWrite[Transf.SolidOffset].radius * Scale; + SGTreeWrite[Index].intensity = SGTreeWrite[Transf.SolidOffset].intensity * Scale; + return; + } + GaussianTreeNode LeftNode = SGTreeWrite[Node.left]; + + SGTreeWrite[Index] = UnionSG(LeftNode, SGTreeWrite[Node.left + 1], Node.left); + +} + + + + + +#pragma kernel TLASLightBVHRefitKernel + +[numthreads(256,1,1)] +void TLASLightBVHRefitKernel (uint3 id : SV_DispatchThreadID) { if(id.x > (uint)SetCount) return; const int Index = WorkingSet[id.x]; @@ -479,7 +573,22 @@ void TLASLightRefitKernel (uint3 id : SV_DispatchThreadID) -#pragma kernel BLASLightRefitKernel + +float3 unpackRGBE(uint x) +{ + int exponent = int(x >> 27) - 20; + float scale = pow(2, exponent) / 256.0; + + float3 v; + v.r = float(x & 0x1ff) * scale; + v.g = float((x >> 9) & 0x1ff) * scale; + v.b = float((x >> 18) & 0x1ff) * scale; + + return v; +} + + +#pragma kernel BLASSGTreeRefitKernel int TotalNodeOffset; @@ -492,6 +601,39 @@ inline float AreaOfTriangle(float3 pt1, float3 pt2, float3 pt3) { } float4x4 ToWorld; +[numthreads(256,1,1)] +void BLASSGTreeRefitKernel (uint3 id : SV_DispatchThreadID) +{ + if(id.x > (uint)SetCount) return; + const int Index = WorkingSet[id.x] + TotalNodeOffset; + GaussianTreeNode Node = SGTreeWrite[Index]; + if(Node.left < 0) { + LightTriData LightTri = LightTriangles[-(Node.left+1) + LightTriBuffOffset]; + float3 mean = (LightTri.pos0 + (LightTri.pos0 + LightTri.posedge1) + (LightTri.pos0 + LightTri.posedge2)) / 3.0f; + float radius = max(max(distance(mean, LightTri.pos0), distance(mean, LightTri.pos0 + LightTri.posedge1)), distance(mean, LightTri.pos0 + LightTri.posedge2)); + + + float area = AreaOfTriangle(LightTri.pos0, LightTri.pos0 + LightTri.posedge1, LightTri.pos0 + LightTri.posedge2); + + if(area == 0) area = 0.000000001f; + float intensity = LightTri.SourceEnergy * area; + float3 V = 0.5f * normalize(cross(normalize(LightTri.posedge1), normalize(LightTri.posedge2))); + float variance = (dot(LightTri.posedge1, LightTri.posedge1) + dot(LightTri.posedge2, LightTri.posedge2) - dot(LightTri.posedge1, LightTri.posedge2)) / 18.0f; + + SGTreeWrite[Index].position = mean; + SGTreeWrite[Index].radius = radius; + SGTreeWrite[Index].intensity = intensity; + SGTreeWrite[Index].variance = variance; + return; + } + GaussianTreeNode LeftNode = SGTreeWrite[Node.left + TotalNodeOffset]; + + SGTreeWrite[Index] = UnionSG(LeftNode, SGTreeWrite[Node.left + 1 + TotalNodeOffset], Node.left); + +} + +#pragma kernel BLASLightRefitKernel + [numthreads(256,1,1)] void BLASLightRefitKernel (uint3 id : SV_DispatchThreadID) { @@ -518,5 +660,4 @@ void BLASLightRefitKernel (uint3 id : SV_DispatchThreadID) LightBVHData LeftNode = LightNodesWrite[Node.left + TotalNodeOffset]; LightNodesWrite[Index] = Union(LeftNode, LightNodesWrite[Node.left + 1 + TotalNodeOffset], Node.left); - -} +} \ No newline at end of file diff --git a/TrueTrace/Resources/Utility/GeneralMeshFunctions.compute b/TrueTrace/Resources/Utility/GeneralMeshFunctions.compute index 4a7cccd4..ef3bcf01 100644 --- a/TrueTrace/Resources/Utility/GeneralMeshFunctions.compute +++ b/TrueTrace/Resources/Utility/GeneralMeshFunctions.compute @@ -1,3 +1,4 @@ +#include "../GlobalDefines.cginc" #include "../MainCompute/CommonStructs.cginc" #pragma kernel CombineTriBuffers @@ -58,6 +59,7 @@ void CombineLightBuffers(uint3 id : SV_DispatchThreadID) StructuredBuffer LightNodesIn; RWStructuredBuffer LightNodesOut; +RWStructuredBuffer LightNodesOut2; [numthreads(372, 1, 1)] void CombineLightNodes(uint3 id : SV_DispatchThreadID) @@ -66,5 +68,23 @@ void CombineLightNodes(uint3 id : SV_DispatchThreadID) return; LightNodesOut[id.x + Offset] = LightNodesIn[id.x]; + LightNodesOut2[id.x + Offset] = LightNodesIn[id.x]; + +} + +#pragma kernel CombineSGTreeNodes + +StructuredBuffer SGNodesIn; +RWStructuredBuffer SGNodesOut; +RWStructuredBuffer SGNodesOut2; + +[numthreads(372, 1, 1)] +void CombineSGTreeNodes(uint3 id : SV_DispatchThreadID) +{ + if (id.x >= Count) + return; + + SGNodesOut[id.x + Offset] = SGNodesIn[id.x]; + SGNodesOut2[id.x + Offset] = SGNodesIn[id.x]; } \ No newline at end of file diff --git a/TrueTrace/Resources/Utility/MaterialMappings.xml b/TrueTrace/Resources/Utility/MaterialMappings.xml index 89061c84..178ad57f 100644 --- a/TrueTrace/Resources/Utility/MaterialMappings.xml +++ b/TrueTrace/Resources/Utility/MaterialMappings.xml @@ -33,6 +33,21 @@ 3 _MainTex + + 8 + -4 + _DetailAlbedoMap + + + 9 + 0 + _DetailMask + + + 10 + -3 + _DetailNormalMap + _Metallic _Glossiness @@ -6475,12 +6490,7 @@ 3 -4 - _EmissionMask - - - 4 - 0 - _EmissionMask1 + _EmissionMap null @@ -7634,8 +7644,8 @@ 1 - 0 - _AlphaMask + 3 + _MainTex null @@ -7744,4 +7754,69 @@ null null + + .poiyomi/Old Versions/8.1/Poiyomi Toon + + + 0 + -4 + _MainTex + + + 2 + -3 + _BumpMap + + + 3 + -4 + _MatcapMask + + + 1 + 3 + _MainTex + + + null + null + false + false + false + null + null + null + null + null + + + Hidden/.poiyomi/• Poiyomi Toon •/Sports_dingus_2D_View-Sports_dingus_2D_View + + + 0 + -4 + _MainTex + + + 2 + -3 + _BumpMap + + + 1 + 3 + _MainTex + + + null + null + false + false + false + null + null + null + null + null + \ No newline at end of file diff --git a/TrueTrace/Resources/Utility/MaterialPresets.xml b/TrueTrace/Resources/Utility/MaterialPresets.xml index a5ecd492..6d408dff 100644 --- a/TrueTrace/Resources/Utility/MaterialPresets.xml +++ b/TrueTrace/Resources/Utility/MaterialPresets.xml @@ -1,713 +1,702 @@ - - - 0 - Default - 0 - - 0 - 0 - 0 - - - 1 - 1 - 1 - - - 0 - 1 - - - 0 - 1 - - 0 - - 1 - 1 - 1 - - 0 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - true - 0 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 0 - false - 0 - 0 - - - 0 - GlassFull - 0 - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - 0 - 1 - - - 0 - 1 - - 0 - - 1 - 1 - 1 - - 0 - 1.33 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - false - 0.1 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 0 - false - 0 - 0 - - - 0 - GlassThin - 0 - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - 0 - 1 - - - 0 - 1 - - 0 - - 1 - 1 - 1 - - 0 - 1.33 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - false - 0.1 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 512 - false - 0 - 0 - - - 0 - BodyA - 0 - - 0 - 0 - 0 - - - 1 - 1 - 1 - - - 0 - 1 - - - 0 - 1 - - 12 - - 0.105882347 - 1 - 0.8368656 - - 1 - 1 - 0 - 0 - 3.47 - 0 - 0.075 - 0 - 0 - 1 - 0 - 0 - false - 0 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 512 - false - 0 - 0 - - - 0 - Purple - 0 - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - 0 - 1 - - - 0 - 1 - - 12 - - 0.419607878 - 0 - 0.9725491 - - 0 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - false - 0.1 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 4 - false - 0 - 0 - - - 0 - Water - 0 - - 1 - 1 - 1 - - - 0.409433961 - 0.9000582 - 1 - - - 0 - 1 - - - 0 - 1 - - 0 - - 1 - 1 - 1 - - 0 - 1.33 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - false - 0.86 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 0 - false - 0 - 0 - - - 0 - Water2 - 0 - - 0 - 0 - 0 - - - 0.513207555 - 0.570612252 - 1 - - - 0 - 1 - - - 0 - 1 - - 0 - - 1 - 1 - 1 - - 0 - 1.3 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - false - 2.54 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 0.56078434 - 0.7579309 - 1 - - 1 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 0 - false - 0 - 0 - - - 0 - Water3 - 0 - - 1 - 1 - 1 - - - 0.4171709 - 0.8396226 - 0.764596641 - - - 0 - 1 - - - 0 - 1 - - 0 - - 1 - 1 - 1 - - 0 - 1.39 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 1 - false - 0.53 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 0 - false - 0 - 0 - - - 0 - Leaf1 - 1 - - 1 - 1 - 1 - - - 1 - 1 - 1 - - - 0 - 1 - - - 0 - 1 - - 0 - - 1 - 1 - 1 - - 0 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0.219 - 0 - false - 0.29 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 8 - false - 0 - 0 - - - 0 - COPYPASTEBUFFER - 0 - - 0 - 0 - 0 - - - 1 - 1 - 1 - - - 0 - 1 - - - 0 - 1 - - 0 - - 1 - 1 - 1 - - 0 - 1 - 1 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - false - 0 - 0 - 0.1 - 1 - 0 - 1 - 1 - 1 - - 1 - 1 - 1 - - 0 - - 1 - 1 - 0 - 0 - - - 1 - 1 - - 0 - 0 - false - 0 - 1 - - \ No newline at end of file + + + Glass + + + 0 + Glass 1 + 0 + + 0 + 0 + 0 + + + 1 + 1 + 1 + + + 0 + 1 + + + 0 + 1 + + 0 + + 1 + 1 + 1 + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + true + 0 + 0 + 0.1 + 1 + 0 + 1 + 1 + 1 + + 1 + 1 + 1 + + 0 + + 1 + 1 + 0 + 0 + + + 1 + 1 + 0 + 0 + + + 1 + 1 + + 0 + 0 + false + 0 + 1 + 1 + + 0 + 0 + 0 + 0 + + 0 + 0 + a0012119388d8ef48b08851ee2d5bac5 + null + null + null + a0012119388d8ef48b08851ee2d5bac5 + null + null + null + null + null + Standard + + + 0 + WaterA + 0 + + 1 + 1 + 1 + + + 0.3816601 + 0.571424 + 0.7830189 + + + 0 + 1 + + + 0 + 1 + + 0 + + 1 + 1 + 1 + + 0.06 + 1.33 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + false + 1.99 + 0 + 0.1 + 1 + 0 + 1 + 1 + 1 + + 1 + 1 + 1 + + 0 + + 1 + 1 + 0 + 0 + + + 1 + 1 + 0 + 0 + + + 1 + 1 + + 0 + 0 + false + 0 + 1 + 1 + + 1 + 1 + 0 + 0 + + 0 + 1 + null + null + null + null + null + null + null + null + null + null + Standard + + + + + Emission + + + 0 + Emiss Red + 0 + + 0 + 0 + 0 + + + 1 + 1 + 1 + + + 0 + 1 + + + 0 + 1 + + 120 + + 1 + 0 + 0 + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + false + 0 + 0 + 0.1 + 1 + 0 + 1 + 1 + 1 + + 1 + 1 + 1 + + 0 + + 1 + 1 + 0 + 0 + + + 1 + 1 + 0 + 0 + + + 1 + 1 + + 0 + 0 + false + 0 + 1 + 1 + + 0 + 0 + 0 + 0 + + 0 + 0 + a0012119388d8ef48b08851ee2d5bac5 + null + null + null + a0012119388d8ef48b08851ee2d5bac5 + null + null + null + null + null + Standard + + + 0 + Emiss Green + 0 + + 0 + 0 + 0 + + + 1 + 1 + 1 + + + 0 + 1 + + + 0 + 1 + + 120 + + 0 + 0.08712435 + 1 + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + false + 0 + 0 + 0.1 + 1 + 0 + 1 + 1 + 1 + + 1 + 1 + 1 + + 0 + + 1 + 1 + 0 + 0 + + + 1 + 1 + 0 + 0 + + + 1 + 1 + + 0 + 0 + false + 0 + 1 + 1 + + 0 + 0 + 0 + 0 + + 0 + 0 + a0012119388d8ef48b08851ee2d5bac5 + null + null + null + a0012119388d8ef48b08851ee2d5bac5 + null + null + null + null + null + Standard + + + + + COPYPASTEBUFFER + + + 0 + COPYPASTEBUFFER + 0 + + 0 + 0 + 0 + + + 0.513207555 + 0.570612252 + 1 + + + 0 + 1 + + + 0 + 1 + + 0 + + 1 + 1 + 1 + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + false + 0.04 + 0 + 0.1 + 1 + 0 + 1 + 1 + 1 + + 0.56078434 + 0.7579309 + 1 + + 1 + + 1 + 1 + 0 + 0 + + + 1 + 1 + 0 + 0 + + + 1 + 1 + + 0 + 0 + false + 0 + 1 + 1 + + 0 + 0 + 0 + 0 + + 0 + 0 + d7ba42597aa599e43a1ec146acd8cf46 + null + null + null + d7ba42597aa599e43a1ec146acd8cf46 + null + null + null + null + null + Standard + + + + + TESTING + + + 0 + GREEN TEXT TEST + 0 + + 0 + 0 + 0 + + + 1 + 1 + 1 + + + 0 + 1 + + + 0 + 1 + + 0 + + 1 + 1 + 1 + + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + true + 0 + 0 + 0.1 + 1 + 0 + 1 + 1 + 1 + + 1 + 1 + 1 + + 0 + + 1 + 1 + 0 + 0 + + + 1 + 1 + 0 + 0 + + + 1 + 1 + + 0 + 0 + false + 0 + 1 + 1 + + 0 + 0 + 0 + 0 + + 0 + 0 + b73406b81b6cd484181dedc3f25e648f + null + null + null + b73406b81b6cd484181dedc3f25e648f + null + null + null + null + null + Standard + + + 0 + TEST2 + 0 + + 0 + 0 + 0 + + + 1 + 1 + 1 + + + 0 + 1 + + + 0 + 1 + + 0 + + 1 + 1 + 1 + + 0.484 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + false + 0 + 0 + 0.1 + 1 + 0 + 1 + 1 + 1 + + 1 + 1 + 1 + + 0 + + 32 + 4 + 2 + 0 + + + 54 + 3 + 1 + 0 + + + 2 + 4 + + 0 + 0 + false + 0 + 1 + 1 + + 0 + 0 + 0 + 0 + + 0 + 0 + 29609964099711e45a99687857e420f5 + null + null + null + 29609964099711e45a99687857e420f5 + null + null + null + null + null + Standard + + + + \ No newline at end of file diff --git a/TrueTrace/Resources/Utility/PanoramaDoer.cs b/TrueTrace/Resources/Utility/PanoramaDoer.cs index a31d7926..9faaece0 100644 --- a/TrueTrace/Resources/Utility/PanoramaDoer.cs +++ b/TrueTrace/Resources/Utility/PanoramaDoer.cs @@ -26,6 +26,16 @@ public class PanoramaDoer : MonoBehaviour private int CurrentSegment = 0; private Texture2D[] TexArray; + Matrix4x4 CalcProj(Camera cam) { + float Aspect = FinalAtlasSize.x / (float)FinalAtlasSize.y; + float YFOV = 1.0f / Mathf.Tan(cam.fieldOfView / (2.0f * (360.0f / (2.0f * 3.14159f)))); + float XFOV = YFOV / Aspect; + Matrix4x4 TempProj = cam.projectionMatrix; + TempProj[0,0] = XFOV; + TempProj[1,1] = YFOV; + return TempProj; + } + void AddResolution(int width, int height, string label) { Type gameViewSize = typeof(Editor).Assembly.GetType("UnityEditor.GameViewSize"); @@ -86,9 +96,8 @@ public void Start() { AddResolution(Mathf.CeilToInt((float)FinalAtlasSize.x / (float)HorizontalSegments) + Padding, FinalAtlasSize.y, "TempPanoramaSize"); SetResolution(GetCount() - 1); } else { - AddResolution(FinalAtlasSize.x, FinalAtlasSize.y, "TempPanoramaSize"); + AddResolution(Mathf.CeilToInt((float)FinalAtlasSize.x / (float)HorizontalSegments) + Padding, FinalAtlasSize.y, "TempPanoramaSize"); SetResolution(GetCount() - 1); - HorizontalSegments = 1; } Init(); RayMaster.DoPanorama = DoPanorama; @@ -145,7 +154,13 @@ public void Init() { Cameras[0].gameObject.SetActive(true); for(int i = 1; i < Cameras.Length; i++) Cameras[i].gameObject.SetActive(false); Camera[] AllCameras = GameObject.FindObjectsOfType(); - for(int i = 0; i < AllCameras.Length; i++) if(!Cameras[0].Equals(AllCameras[i])) AllCameras[i].gameObject.SetActive(false); + for(int i = 0; i < AllCameras.Length; i++) { + if(!DoPanorama) { + Cameras[i].projectionMatrix = CalcProj(Cameras[i]); + } + if(!Cameras[0].Equals(AllCameras[i])) AllCameras[i].gameObject.SetActive(false); + + } } } diff --git a/TrueTrace/Resources/Utility/SimpleUI/SimpleGUIControls.cs b/TrueTrace/Resources/Utility/SimpleUI/SimpleGUIControls.cs index 3022621a..f868c065 100644 --- a/TrueTrace/Resources/Utility/SimpleUI/SimpleGUIControls.cs +++ b/TrueTrace/Resources/Utility/SimpleUI/SimpleGUIControls.cs @@ -9,8 +9,7 @@ public class SimpleGUIControls : MonoBehaviour RayTracingMaster RayMaster; public void Start() { RayMaster = GameObject.Find("Scene").GetComponent(); - RayMaster.LocalTTSettings.UseASVGF = true; - RayMaster.LocalTTSettings.UseOIDN = false; + RayMaster.LocalTTSettings.DenoiserMethod = 1; RayMaster.LocalTTSettings.Accumulate = true; RayMaster.LocalTTSettings.ClayMode = false; RayMaster.LocalTTSettings.OIDNFrameCount = 50; @@ -22,8 +21,7 @@ public void ToggleClay(bool BoolIn) { RayMaster.LocalTTSettings.ClayMode = BoolIn; } public void ToggleASVGF(bool BoolIn) { - RayMaster.LocalTTSettings.UseASVGF = BoolIn; - RayMaster.LocalTTSettings.UseOIDN = !BoolIn; + RayMaster.LocalTTSettings.DenoiserMethod = BoolIn ? 1 : 2; } public void SetOIDNFrameCount(string StringIn) { int IntResult = 0; diff --git a/TrueTrace/Resources/Utility/TTSDFs.meta b/TrueTrace/Resources/Utility/TTSDFs.meta new file mode 100644 index 00000000..9432bca7 --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e4313bb08344876409b71c7ca8dc908d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TrueTrace/Resources/Utility/TTSDFs/ReadMe.txt b/TrueTrace/Resources/Utility/TTSDFs/ReadMe.txt new file mode 100644 index 00000000..bf988e52 --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs/ReadMe.txt @@ -0,0 +1,6 @@ +To use the SDF Slicer: +Add a sphere object to the hierarchy and put it outside of TrueTrace's "Scene" Gameobject +Add the "TTSDFHandler" Component to the sphere + +DoBackfacing allows rays to travel infinitely after exiting the last SDF(hard to explain) +Max Step Count and Min Step Size are for tuning the "resolution" of the slices(since it uses sphere-tracing/ray-marching, intersections are more approximations) \ No newline at end of file diff --git a/TrueTrace/Resources/Utility/TTSDFs/ReadMe.txt.meta b/TrueTrace/Resources/Utility/TTSDFs/ReadMe.txt.meta new file mode 100644 index 00000000..188730e2 --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs/ReadMe.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2f996ad65126e5c40911d26786ab1ad8 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TrueTrace/Resources/Utility/TTSDFs/TTSDFHandler.cs b/TrueTrace/Resources/Utility/TTSDFs/TTSDFHandler.cs new file mode 100644 index 00000000..47ed12b7 --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs/TTSDFHandler.cs @@ -0,0 +1,424 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Rendering; +using CommonVars; + +#if UNITY_EDITOR +using UnityEditor; +using UnityEngine.UIElements; +using UnityEditor.UIElements; +#endif + + +namespace TrueTrace { + [ExecuteInEditMode][System.Serializable][RequireComponent(typeof(MeshRenderer))] + public class TTSDFHandler : MonoBehaviour + { + public enum SDFShapes {Sphere, Box}; + public enum SDFOperations {Union, Subtraction, Xor, Intersection}; + + [System.Serializable] + public struct SDFVar { + public Vector3 A; + public Vector3 B; + public int Type; + public int Operation; + public float Smoothness; + public Quaternion Transform; + + public SDFVar(SDFVar A2) { + this = A2; + } + } + [SerializeField] public SDFVar[] SDFs; + [SerializeField] public bool IntersectBackFacing = false; + [SerializeField] public int MaxStepCount = 1000; + [SerializeField] public float MinValidSize = 0.01f; + [SerializeField] public float FramesSinceStart = 0.0f; + + public ComputeShader GenShader; + public ComputeBuffer SDFBuffer; + public MeshRenderer Rend; + private Material SDFMat; + + private int GenKernel; + private int GenPanoramaKernel; + private int GenASVGFKernel; + + public void Start() { + Init(); + RayTracingMaster.OptionalSDFHandler = this; + // if(Rend == null) { + // if(TryGetComponent(out Rend)) { + // // Rend.enabled = false; + // } + // } + + } + + public void Init() { + if(SDFs != null) { + CommonFunctions.CreateComputeBuffer(ref SDFBuffer, SDFs); + } + if(SDFMat == null) { + SDFMat = new Material(Shader.Find("Unlit/TTSDFShader")); + if(TryGetComponent(out Rend)) { + Rend.materials = new Material[] {SDFMat}; + } + } + if(GenShader == null) {GenShader = Resources.Load("Utility/TTSDFs/TTSDFRayGen"); } + GenKernel = GenShader.FindKernel("Generate"); + GenPanoramaKernel = GenShader.FindKernel("GeneratePanorama"); + GenASVGFKernel = GenShader.FindKernel("GenerateASVGF"); + } + + public void Run(CommandBuffer cmd, RenderTexture _RandomNums, ComputeBuffer _RayBuffer, int SourceWidth, int SourceHeight, bool DoChainedImages, bool UseASVGF, ComputeBuffer ASVGFRaysBuffer) { + FramesSinceStart++; + if(GenShader != null && SDFs != null) { + CommonFunctions.CreateComputeBuffer(ref SDFBuffer, SDFs); + SDFMat.SetInteger("SDFCount", SDFs.Length); + SDFMat.SetBuffer("SDFs", SDFBuffer); + SDFMat.SetVector("Scale", transform.localScale); + + AssetManager.Assets.SetMeshTraceBuffers(GenShader, GenKernel); + AssetManager.Assets.SetMeshTraceBuffers(GenShader, GenPanoramaKernel); + AssetManager.Assets.SetMeshTraceBuffers(GenShader, GenASVGFKernel); + GenShader.SetTexture(GenKernel, "RandomNums", _RandomNums); + GenShader.SetTexture(GenPanoramaKernel, "RandomNums", _RandomNums); + GenShader.SetComputeBuffer(GenKernel, "GlobalRays", _RayBuffer); + GenShader.SetComputeBuffer(GenPanoramaKernel, "GlobalRays", _RayBuffer); + GenShader.SetComputeBuffer(GenASVGFKernel, "GlobalRays", _RayBuffer); + GenShader.SetComputeBuffer(GenASVGFKernel, "Rays", ASVGFRaysBuffer); + + GenShader.SetComputeBuffer(GenKernel, "SDFs", SDFBuffer); + GenShader.SetComputeBuffer(GenPanoramaKernel, "SDFs", SDFBuffer); + GenShader.SetComputeBuffer(GenASVGFKernel, "SDFs", SDFBuffer); + GenShader.SetInt("SDFCount", SDFBuffer.count); + GenShader.SetBool("DoBackfacing", IntersectBackFacing); + GenShader.SetFloat("Scale", Mathf.Max(Mathf.Max(transform.localScale.x, transform.localScale.y), transform.localScale.z)); + GenShader.SetInt("MaxStepCount", MaxStepCount); + GenShader.SetFloat("MinStepSize", MinValidSize); + GenShader.SetFloat("CustFramesSinceStart", FramesSinceStart); + + cmd.BeginSample("Primary Ray Generation"); + cmd.DispatchCompute(GenShader, (UseASVGF ? GenASVGFKernel : (DoChainedImages ? GenPanoramaKernel : GenKernel)), Mathf.CeilToInt(SourceWidth / 16.0f), Mathf.CeilToInt(SourceHeight / 16.0f), 1); + cmd.EndSample("Primary Ray Generation"); + } + } + public void OnEnable() { + if(SDFs == null) { + SDFs = new SDFVar[1]; + SDFs[0].Transform = Quaternion.identity; + SDFs[0].B = Vector3.one; + + } + this.transform.localScale = new Vector3(256.0f, 256.0f, 256.0f); + this.transform.position = Vector3.zero; + SDFMat = new Material(Shader.Find("Unlit/TTSDFShader")); + if(TryGetComponent(out Rend)) { + Rend.materials = new Material[] {SDFMat}; + } + } + public void UpdateDraw() { + if(SDFs != null && SDFMat != null) { + CommonFunctions.CreateComputeBuffer(ref SDFBuffer, SDFs); + SDFMat.SetInteger("SDFCount", SDFs.Length); + SDFMat.SetBuffer("SDFs", SDFBuffer); + SDFMat.SetVector("Scale", transform.localScale); + } + } + + public void OnDrawGizmos() { + if(Application.isPlaying) { + int Count = SDFs.Length; + for(int i = 0; i < Count; i++) { + if(SDFs[i].Type == 0) { + Gizmos.DrawWireSphere(SDFs[i].A, SDFs[i].B.x); + } else { + Gizmos.DrawWireCube(SDFs[i].A, SDFs[i].B * 2.0f); + } + } + } + } + } + +#if UNITY_EDITOR + // A tiny custom editor for ExampleScript component + [CustomEditor(typeof(TTSDFHandler))] + public class TTSDFHandlerEditor : Editor + { + + + private VisualElement CreateHorizontalBox(string Name) { + VisualElement HorizBox = new VisualElement(); + HorizBox.style.flexDirection = FlexDirection.Row; + return HorizBox; + } + ScrollView MatHierarchyView; + VisualElement SideWindow; + + private void Refresh(TTSDFHandler t) { + MatHierarchyView.Clear(); + int Count = t.SDFs.Length; + for(int i = 0; i < Count; i++) { + int Selected = i; + VisualElement SideBySideWindow = CreateHorizontalBox("SideBox " + i); + Button ThisButton = new Button(() => { + SideWindow.Clear(); + Vector3Field CenterField = new Vector3Field("Position: "); + CenterField.value = t.SDFs[Selected].A; + CenterField.RegisterValueChangedCallback(evt => {t.SDFs[Selected].A = evt.newValue;t.UpdateDraw();}); + + Vector3Field ScaleField = new Vector3Field("Scale: "); + ScaleField.value = t.SDFs[Selected].B; + ScaleField.RegisterValueChangedCallback(evt => {t.SDFs[Selected].B = evt.newValue;t.UpdateDraw();}); + + EnumField ShapeField = new EnumField("SDF Type: ", (TTSDFHandler.SDFShapes)t.SDFs[Selected].Type); + ShapeField.RegisterValueChangedCallback(evt => {t.SDFs[Selected].Type = (int)(TTSDFHandler.SDFShapes)(evt.newValue);t.UpdateDraw();}); + + EnumField OpField = new EnumField("SDF Operation: ", (TTSDFHandler.SDFOperations)t.SDFs[Selected].Operation); + OpField.RegisterValueChangedCallback(evt => {t.SDFs[Selected].Operation = (int)(TTSDFHandler.SDFOperations)(evt.newValue); t.UpdateDraw();}); + + + Slider SmoothnessSlider = new Slider() {label = "Smoothness: ", value = t.SDFs[Selected].Smoothness, highValue = 1.0f, lowValue = 0.0f}; + SmoothnessSlider.showInputField = true; + SmoothnessSlider.style.width = 200; + SmoothnessSlider.ElementAt(0).style.minWidth = 65; + SmoothnessSlider.RegisterValueChangedCallback(evt => {t.SDFs[Selected].Smoothness = evt.newValue;}); + + Button ResetRotationButton = new Button(() => { + t.SDFs[Selected].Transform = Quaternion.identity; + }); + ResetRotationButton.text = "Reset Rotation"; + + SideWindow.Add(CenterField); + SideWindow.Add(ScaleField); + SideWindow.Add(ShapeField); + SideWindow.Add(OpField); + SideWindow.Add(SmoothnessSlider); + SideWindow.Add(ResetRotationButton); + }); + + ThisButton.text = "SDF " + i; + + Button DeleteButton = new Button(() => { + SideWindow.Clear(); + List Temp = new List(t.SDFs); + Temp.RemoveAt(Selected); + t.SDFs = Temp.ToArray(); + Refresh(t); + }); + DeleteButton.text = "Delete"; + + Button ShiftUpButton = new Button(() => { + SideWindow.Clear(); + if(Selected != 0) { + TTSDFHandler.SDFVar Temp = new TTSDFHandler.SDFVar(t.SDFs[Selected]); + t.SDFs[Selected] = t.SDFs[Selected - 1]; + t.SDFs[Selected - 1] = Temp; + Refresh(t); + } + }); + ShiftUpButton.text = "Shift Up"; + + Button ShiftDownButton = new Button(() => { + SideWindow.Clear(); + if(Selected <= Count - 2) { + TTSDFHandler.SDFVar Temp = new TTSDFHandler.SDFVar(t.SDFs[Selected]); + t.SDFs[Selected] = t.SDFs[Selected + 1]; + t.SDFs[Selected + 1] = Temp; + Refresh(t); + } + }); + ShiftDownButton.text = "Shift Down"; + + + SideBySideWindow.Add(ThisButton); + SideBySideWindow.Add(DeleteButton); + SideBySideWindow.Add(ShiftUpButton); + SideBySideWindow.Add(ShiftDownButton); + + + MatHierarchyView.Add(SideBySideWindow); + } + + Button AddButton = new Button(() => { + List Temp = new List(t.SDFs); + Temp.Add(new TTSDFHandler.SDFVar() { + Transform = Quaternion.identity, + B = Vector3.one + }); + t.SDFs = Temp.ToArray(); + Refresh(t); + + }); + AddButton.text = "Add SDF"; + MatHierarchyView.Add(AddButton); + + } + + // int Selected = 0; + public override VisualElement CreateInspectorGUI() { + VisualElement rootVisualElement = new VisualElement(); + + + TwoPaneSplitView NewView = new TwoPaneSplitView(0, 250, TwoPaneSplitViewOrientation.Horizontal); + + NewView.style.minHeight = 1000; + + MatHierarchyView = new ScrollView(); + + SideWindow = new VisualElement(); + int ID = 0; + var t = target as TTSDFHandler; + int Count = t.SDFs.Length; + for(int i = 0; i < Count; i++) { + int Selected = i; + VisualElement SideBySideWindow = CreateHorizontalBox("SideBox " + i); + Button ThisButton = new Button(() => { + SideWindow.Clear(); + Vector3Field CenterField = new Vector3Field("Position: "); + CenterField.value = t.SDFs[Selected].A; + CenterField.RegisterValueChangedCallback(evt => {t.SDFs[Selected].A = evt.newValue;t.UpdateDraw();}); + + Vector3Field ScaleField = new Vector3Field("Scale: "); + ScaleField.value = t.SDFs[Selected].B; + ScaleField.RegisterValueChangedCallback(evt => {t.SDFs[Selected].B = evt.newValue;t.UpdateDraw();}); + + EnumField ShapeField = new EnumField("SDF Type: ", (TTSDFHandler.SDFShapes)t.SDFs[Selected].Type); + ShapeField.RegisterValueChangedCallback(evt => {t.SDFs[Selected].Type = (int)(TTSDFHandler.SDFShapes)(evt.newValue);t.UpdateDraw();}); + + EnumField OpField = new EnumField("SDF Operation: ", (TTSDFHandler.SDFOperations)t.SDFs[Selected].Operation); + OpField.RegisterValueChangedCallback(evt => {t.SDFs[Selected].Operation = (int)(TTSDFHandler.SDFOperations)(evt.newValue); t.UpdateDraw();}); + + Slider SmoothnessSlider = new Slider() {label = "Smoothness: ", value = t.SDFs[Selected].Smoothness, highValue = 1.0f, lowValue = 0.0f}; + SmoothnessSlider.showInputField = true; + SmoothnessSlider.style.width = 200; + SmoothnessSlider.ElementAt(0).style.minWidth = 65; + SmoothnessSlider.RegisterValueChangedCallback(evt => {t.SDFs[Selected].Smoothness = evt.newValue;}); + + Button ResetRotationButton = new Button(() => { + t.SDFs[Selected].Transform = Quaternion.identity; + }); + ResetRotationButton.text = "Reset Rotation"; + + SideWindow.Add(CenterField); + SideWindow.Add(ScaleField); + SideWindow.Add(ShapeField); + SideWindow.Add(OpField); + SideWindow.Add(SmoothnessSlider); + SideWindow.Add(ResetRotationButton); + }); + + ThisButton.text = "SDF " + i; + + Button DeleteButton = new Button(() => { + SideWindow.Clear(); + List Temp = new List(t.SDFs); + Temp.RemoveAt(Selected); + t.SDFs = Temp.ToArray(); + Refresh(t); + }); + DeleteButton.text = "Delete"; + + Button ShiftUpButton = new Button(() => { + SideWindow.Clear(); + if(Selected != 0) { + TTSDFHandler.SDFVar Temp = new TTSDFHandler.SDFVar(t.SDFs[Selected]); + t.SDFs[Selected] = t.SDFs[Selected - 1]; + t.SDFs[Selected - 1] = Temp; + } + Refresh(t); + }); + ShiftUpButton.text = "Shift Up"; + + Button ShiftDownButton = new Button(() => { + SideWindow.Clear(); + if(Selected <= Count - 2) { + TTSDFHandler.SDFVar Temp = new TTSDFHandler.SDFVar(t.SDFs[Selected]); + t.SDFs[Selected] = t.SDFs[Selected + 1]; + t.SDFs[Selected + 1] = Temp; + } + Refresh(t); + }); + ShiftDownButton.text = "Shift Down"; + + + SideBySideWindow.Add(ThisButton); + SideBySideWindow.Add(DeleteButton); + SideBySideWindow.Add(ShiftUpButton); + SideBySideWindow.Add(ShiftDownButton); + + + MatHierarchyView.Add(SideBySideWindow); + } + + Button AddButton = new Button(() => { + List Temp = new List(t.SDFs); + Temp.Add(new TTSDFHandler.SDFVar() { + Transform = Quaternion.identity, + B = Vector3.one + }); + t.SDFs = Temp.ToArray(); + Refresh(t); + + }); + AddButton.text = "Add SDF"; + MatHierarchyView.Add(AddButton); + + + NewView.Add(MatHierarchyView); + NewView.Add(SideWindow); + + + + + Button ResetSphereButton = new Button(() => { + t.FramesSinceStart = 0.0f; + }); + ResetSphereButton.text = "Reset Sphere"; + + + rootVisualElement.Add(ResetSphereButton); + rootVisualElement.Add(NewView); + Toggle IntersectBackFacingToggle = new Toggle() {value = t.IntersectBackFacing, text = "Do Backfacing"}; + IntersectBackFacingToggle.RegisterValueChangedCallback(evt => {t.IntersectBackFacing = evt.newValue;}); + rootVisualElement.Add(IntersectBackFacingToggle); + + IntegerField MaxStepCountField = new IntegerField() {value = t.MaxStepCount, label = "Max Step Count"}; + MaxStepCountField.RegisterValueChangedCallback(evt => {t.MaxStepCount = evt.newValue;}); + + Slider MinStepSizeSlider = new Slider() {label = "Min Step Size: ", value = t.MinValidSize, highValue = 0.01f, lowValue = 0.00001f}; + MinStepSizeSlider.showInputField = true; + MinStepSizeSlider.style.width = 200; + MinStepSizeSlider.ElementAt(0).style.minWidth = 65; + MinStepSizeSlider.RegisterValueChangedCallback(evt => {t.MinValidSize = evt.newValue;}); + + rootVisualElement.Add(MaxStepCountField); + rootVisualElement.Add(MinStepSizeSlider); + return rootVisualElement; + + } + // Custom in-scene UI for when ExampleScript + // component is selected. + public void OnSceneGUI() + { + var t = target as TTSDFHandler; + int Count = t.SDFs.Length; + Transform TempTransform = t.transform; + for(int i = 0; i < Count; i++) { + t.SDFs[i].Transform = Quaternion.Inverse(Handles.RotationHandle(Quaternion.Inverse(t.SDFs[i].Transform), t.SDFs[i].A)); + + t.SDFs[i].A = Handles.PositionHandle(t.SDFs[i].A + t.transform.position, Quaternion.identity); + t.SDFs[i].B = Handles.ScaleHandle(t.SDFs[i].B, t.SDFs[i].A, Quaternion.identity, 1.0f); + t.SDFs[i].A -= t.transform.position; + } + t.UpdateDraw(); + + } + } +#endif + + +} \ No newline at end of file diff --git a/TrueTrace/Resources/Utility/TTSDFs/TTSDFHandler.cs.meta b/TrueTrace/Resources/Utility/TTSDFs/TTSDFHandler.cs.meta new file mode 100644 index 00000000..2953836b --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs/TTSDFHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 341b72ef8b6d3254d952e77247ff4bd7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TrueTrace/Resources/Utility/TTSDFs/TTSDFRayGen.compute b/TrueTrace/Resources/Utility/TTSDFs/TTSDFRayGen.compute new file mode 100644 index 00000000..b316ae99 --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs/TTSDFRayGen.compute @@ -0,0 +1,269 @@ +#include "../../GlobalDefines.cginc" +#ifndef DX11 + #pragma use_dxc +#endif +#include "../../MainCompute/CommonData.cginc" +#ifdef HardwareRT + #include "UnityRayQuery.cginc" + #pragma require inlineraytracing + RaytracingAccelerationStructure myAccelerationStructure; +#endif + +int SDFCount; +float Scale; +float MinStepSize; +int MaxStepCount; + +inline float opXor(float d1, float d2 ){return max(min(d1,d2),-max(d1,d2));} +inline float opSubtraction( float d1, float d2 ) {return max(-d1,d2);} +inline float opIntersection( float d1, float d2 ){return max(d1,d2);} +inline float sdSphere( float3 p, float s ) {return length(p)-s;} +inline float opUnion( float d1, float d2 ) {return min(d1,d2);} +inline float opSmoothUnion( float d1, float d2, float k ) { + float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 ); + return lerp( d2, d1, h ) - k*h*(1.0-h); +} +inline float sdBox( float3 p, float3 b ) { + float3 q = abs(p) - b; + return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); +} +inline float4 qmul(float4 q1, float4 q2) { + return float4( + q2.xyz * q1.w + q1.xyz * q2.w + cross(q1.xyz, q2.xyz), + q1.w * q2.w - dot(q1.xyz, q2.xyz) + ); +} +inline float3 rotate_vector(float3 v, float4 r) { + float4 r_c = r * float4(-1, -1, -1, 1); + return qmul(r, qmul(float4(v, 0), r_c)).xyz; +} + +float CustFramesSinceStart; +inline float Map(float3 p) { + float MinDist = -sdSphere(p, Scale); + for(int i = 0; i < SDFCount; i++) { + float MinDist3; + SDFData TempSDF = SDFs[i]; + switch(SDFs[i].Type) { + case 0: MinDist3 = sdSphere(rotate_vector(p - TempSDF.A, TempSDF.Transform), 256.0f * saturate(CustFramesSinceStart / 260.0f)); break;//SDFs[i].B.x); break; + case 1: MinDist3 = sdBox(rotate_vector(p - TempSDF.A, TempSDF.Transform), TempSDF.B); break; + default: break; + } + switch(SDFs[i].Operation) { + case 0: MinDist = opSmoothUnion(MinDist, MinDist3, SDFs[i].Smoothness); break; + case 1: MinDist = opSubtraction(MinDist3, MinDist); break; + case 2: MinDist = opXor(MinDist3, MinDist); break; + case 3: MinDist = opIntersection(MinDist3, MinDist); break; + default: break; + } + } + return MinDist; +} + + +inline bool Traverse(float3 P, const float3 rayDir, float maxT, inout float TravT, inout float OuterT) { + bool HasHitNear = false; + bool HasHitFar = false; + float TempDist = 0; + int CurStep = 0; + float CurT = 0; + P = P - rayDir * 0.1f;// + (float3(0,0,6) * sin(curframe / 120.0f)); + + while(CurStep < MaxStepCount && TempDist < maxT && sdSphere(P, Scale) < 0.1f) { + CurT = Map(P); + + if(CurT < MinStepSize) HasHitNear = true; + if(HasHitNear) + if(CurT > MinStepSize) + HasHitFar = true; + + if(HasHitFar && CurT > MinStepSize) return true; + + if(!HasHitNear) TravT += abs(CurT); + if(!HasHitFar) OuterT += abs(CurT); + TempDist += abs(CurT); + P += rayDir * max(abs(CurT), MinStepSize); + CurStep++; + } + + return false; +} + + + +inline void VisabilityCheck(SmallerRay ray, inout float dist) { + #ifdef HardwareRT + const uint rayFlags = RAY_FLAG_FORCE_OPAQUE ; + UnityRayQuery q; + RayDesc myRay; + myRay.Origin = ray.origin; + myRay.Direction = ray.direction; + myRay.TMin = 0; + myRay.TMax = dist; + while(true) { + q.TraceRayInline(myAccelerationStructure, rayFlags, 0x1, myRay); + while(q.Proceed()){} + + if(q.CommittedStatus() == COMMITTED_TRIANGLE_HIT) { + + float u = q.CommittedTriangleBarycentrics().y; + float v = q.CommittedTriangleBarycentrics().x; + int2 Indexes = int2(q.CommittedInstanceID(), q.CommittedGeometryIndex()); + int triangle_id = q.CommittedPrimitiveIndex(); + #ifdef AdvancedAlphaMapped + int mesh_id; + + int triangleOffset = SubMeshOffsets[MeshOffsets[Indexes.x].x + Indexes.y]; + triangle_id += triangleOffset; + mesh_id = MeshOffsets[Indexes.x].y; + + int MaterialIndex = (_MeshData[mesh_id].MaterialOffset + AggTris[triangle_id].MatDat); + if(GetFlag(_Materials[MaterialIndex].Tag, IsBackground) || GetFlag(_Materials[MaterialIndex].Tag, ShadowCaster)) {myRay.TMin = q.CommittedRayT() + 0.001f; continue;} + if(_Materials[MaterialIndex].MatType == CutoutIndex) { + float2 BaseUv = AggTris[triangle_id].tex0 * (1.0f - u - v) + AggTris[triangle_id].texedge1 * u + AggTris[triangle_id].texedge2 * v; + float2 Uv = AlignUV(BaseUv, _Materials[MaterialIndex].AlbedoTexScale, _Materials[MaterialIndex].AlbedoTex); + if(_AlphaAtlas.SampleLevel(my_point_clamp_sampler, Uv, 0) < _Materials[MaterialIndex].AlphaCutoff) {myRay.TMin = q.CommittedRayT() + 0.001f; continue;} + } + #endif + dist = myRay.TMin; + return; + } + return; + } + #else + Closest_Hit_Compute(ray, dist); + #endif +} + +bool DoBackfacing; + +#pragma kernel Generate +[numthreads(16, 16, 1)] +void Generate(uint3 id : SV_DispatchThreadID) { + + if (id.x >= screen_width || id.y >= screen_height) return; + const uint pixel_index = id.y * screen_width + id.x; + float2 jitter = ((random(0, pixel_index) - 0.5)); + if(OIDNGuideWrite) jitter = 0; + float2 uv = float2((id.xy + jitter) / float2(screen_width, screen_height) * 2.0f - 1.0f); + SmallerRay ray = CreateCameraRay(uv, pixel_index); + + float3 P = ray.origin + NearPlane * ray.direction; + float TruMinDist = 0; + int Reps2 = 0; + float3 PrevP = P; + while(Reps2 < 100 && sdSphere(P, Scale) < 0.1f) { + float TempDist = 0; + float OuterT = 0; + bool TempVal = Traverse(P, ray.direction, 10000.0f, TempDist, OuterT); + P += TempDist * ray.direction; + SmallerRay TempRay = CreateRay(P, ray.direction); + OuterT = OuterT - TempDist; + float TempOuter = OuterT; + VisabilityCheck(TempRay, OuterT); + TruMinDist = TempOuter; + if(TempVal || Reps2 == 0) PrevP = P; + if(TempOuter == OuterT) P += (OuterT + 0.1f) * ray.direction; + else break; + Reps2++; + } + + P = PrevP; + if(DoBackfacing) TruMinDist = FarPlane; + + RayData globray = {P, pixel_index, ray.direction, 0, 0,0,asuint(TruMinDist),0}; + GlobalRays[pixel_index] = globray; +} + + +bool DoPanorama; +float2 Segment; +#pragma kernel GeneratePanorama +[numthreads(16, 16, 1)] +void GeneratePanorama(uint3 id : SV_DispatchThreadID) { + if (id.x >= screen_width || id.y >= screen_height) return; + const uint pixel_index = id.y * screen_width + id.x; + float2 jitter = ((random(0, pixel_index) - 0.5)); + if(OIDNGuideWrite) jitter = 0; + float2 uv = float2((id.xy + jitter) / float2(screen_width, screen_height)); + SmallerRay ray; + if(DoPanorama) { + uv.y = 1.0f - uv.y; + uv.x = (uv.x * (Segment.y - Segment.x)) + Segment.x; + uv.x = 1.0f - uv.x; + + ray = CreateRay(mul(CamToWorld, float4(0.0f, 0.0f, 0.0f, 1.0f)).xyz + NearPlane * normalize(equirectUvToDirection(uv)), normalize(equirectUvToDirection(uv))); + } else { + uv.x = ((uv.x * (Segment.y - Segment.x)) + Segment.x); + uv = (uv * 2.0f) - 1.0f; + + ray = CreateCameraRay(uv, pixel_index); + ray.origin = ray.origin + NearPlane * ray.direction; + } + + float3 P = ray.origin + NearPlane * ray.direction; + float TruMinDist = 0; + int Reps2 = 0; + float3 PrevP = P; + while(Reps2 < 100 && sdSphere(P, Scale) < 0.1f) { + float TempDist = 0; + float OuterT = 0; + bool TempVal = Traverse(P, ray.direction, 10000.0f, TempDist, OuterT); + P += TempDist * ray.direction; + SmallerRay TempRay = CreateRay(P, ray.direction); + OuterT = OuterT - TempDist; + float TempOuter = OuterT; + VisabilityCheck(TempRay, OuterT); + TruMinDist = TempOuter; + if(TempVal || Reps2 == 0) PrevP = P; + if(TempOuter == OuterT) P += (OuterT + 0.1f) * ray.direction; + else break; + Reps2++; + } + + P = PrevP; + if(DoBackfacing) TruMinDist = FarPlane; + + RayData globray = {P, pixel_index, ray.direction, 0, 0,0,asuint(TruMinDist),0}; + GlobalRays[pixel_index] = globray; +} + + +#pragma kernel GenerateASVGF + + +[numthreads(16, 16, 1)] +void GenerateASVGF(uint3 id : SV_DispatchThreadID) { + + if (id.x >= screen_width || id.y >= screen_height) return; + const uint pixel_index = id.y * screen_width + id.x; + + SmallerRay ray = Rays[pixel_index]; + + float3 P = ray.origin + NearPlane * ray.direction; + float TruMinDist = 0; + int Reps2 = 0; + float3 PrevP = P; + while(Reps2 < 100 && sdSphere(P, Scale) < 0.1f) { + float TempDist = 0; + float OuterT = 0; + bool TempVal = Traverse(P, ray.direction, 10000.0f, TempDist, OuterT); + P += TempDist * ray.direction; + SmallerRay TempRay = CreateRay(P, ray.direction); + OuterT = OuterT - TempDist; + float TempOuter = OuterT; + VisabilityCheck(TempRay, OuterT); + TruMinDist = TempOuter; + if(TempVal || Reps2 == 0) PrevP = P; + if(TempOuter == OuterT) P += (OuterT + 0.1f) * ray.direction; + else break; + Reps2++; + } + + P = PrevP; + if(DoBackfacing) TruMinDist = FarPlane; + + + RayData globray = {P, pixel_index, ray.direction, 0, 0,0,asuint(TruMinDist),0}; + GlobalRays[pixel_index] = globray; +} \ No newline at end of file diff --git a/TrueTrace/Resources/Utility/TTSDFs/TTSDFRayGen.compute.meta b/TrueTrace/Resources/Utility/TTSDFs/TTSDFRayGen.compute.meta new file mode 100644 index 00000000..f80404e3 --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs/TTSDFRayGen.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7981b89bc7490e249a79ecb4b0a63c8d +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/TrueTrace/Resources/Utility/TTSDFs/TTSDFShader.shader b/TrueTrace/Resources/Utility/TTSDFs/TTSDFShader.shader new file mode 100644 index 00000000..ed309424 --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs/TTSDFShader.shader @@ -0,0 +1,205 @@ +// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' +// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' + +Shader "Unlit/TTSDFShader" +{ + Properties + { + _MainTex ("Texture", 2D) = "white" {} + } + SubShader + { + Tags { "RenderType"="Opaque" } + LOD 100 + + + + Pass + { + Blend SrcAlpha OneMinusSrcAlpha + ZWrite On + ZTest LEqual + Cull Off // HERE IS WHERE YOU PUT CULL OFF + CGPROGRAM + #pragma vertex vert + #pragma fragment frag + + + #include "UnityCG.cginc" + #include "../../MainCompute/CommonStructs.cginc" + sampler2D _CameraDepthTexture; + + + + struct appdata + { + float4 vertex : POSITION; + float2 uv : TEXCOORD0; + }; + + struct v2f + { + float4 pos : SV_POSITION; + float3 wPos : TEXCOORD1; + }; + + sampler2D _MainTex; + float4 _MainTex_ST; + + + uint hash_with(uint seed, uint hash) { + // Wang hash + seed = (seed ^ 61) ^ hash; + seed += seed << 3; + seed ^= seed >> 4; + seed *= 0x27d4eb2d; + return seed; + } + uint pcg_hash(uint seed) { + uint state = seed * 747796405u + 2891336453u; + uint word = ((state >> ((state >> 28u) + 4u)) ^ state) * 277803737u; + return (word >> 22u) ^ word; + } + + float3 pal(float t) { + float3 a = float3(0.5f, 0.5f, 0.5f); + float3 b = float3(0.5f, 0.5f, 0.5f); + float3 c = float3(0.8f, 0.8f, 0.8f); + float3 d = float3(0.0f, 0.33f, 0.67f) + 0.21f; + return a + b*cos( 6.28318*(c*t+d) ); + } + + float4 HandleDebug(int Index) { + static const float one_over_max_unsigned = asfloat(0x2f7fffff); + uint hash = pcg_hash(32); + float LinearIndex = hash_with(Index, hash) * one_over_max_unsigned; + return float4(pal(LinearIndex), 1); + } + + + + + v2f vert (appdata v) + { + v2f o; + o.pos = UnityObjectToClipPos(v.vertex); + o.wPos = mul(unity_ObjectToWorld, v.vertex).xyz; + return o; + } + + int SDFCount; + + + +inline float opSubtraction( float d1, float d2 ){return max(-d1,d2);} + + +inline float sdSphere( float3 p, float s ) {return length(p)-s;} +inline float opUnion( float d1, float d2 ) {return min(d1,d2);} +inline float opSmoothUnion( float d1, float d2, float k ) { + float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 ); + return lerp( d2, d1, h ) - k*h*(1.0-h); +} + +inline float sdBox( float3 p, float3 b ) { + float3 q = abs(p) - b; + return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0); +} + +inline float opXor(float d1, float d2 ){return max(min(d1,d2),-max(d1,d2));} + + +inline float opIntersection( float d1, float d2 ){return max(d1,d2);} + + +inline float4 qmul(float4 q1, float4 q2) { + return float4( + q2.xyz * q1.w + q1.xyz * q2.w + cross(q1.xyz, q2.xyz), + q1.w * q2.w - dot(q1.xyz, q2.xyz) + ); +} + +inline float3 rotate_vector(float3 v, float4 r) { + float4 r_c = r * float4(-1, -1, -1, 1); + return qmul(r, qmul(float4(v, 0), r_c)).xyz; +} + + inline float Map(float3 p, inout int Color) { + float MinDist = 999999.0f; + for(int i = 0; i < SDFCount; i++) { + float MinDist2 = MinDist; + const SDFData TempSDF = SDFs[i]; + [branch]switch(SDFs[i].Type) { + case 0: MinDist = sdSphere(rotate_vector(p - TempSDF.A, TempSDF.Transform), SDFs[i].B.x); break; + case 1: MinDist = sdBox(rotate_vector(p - TempSDF.A, TempSDF.Transform), TempSDF.B); break; + default: break; + } + [branch]switch(SDFs[i].Operation) { + case 0: MinDist = opSmoothUnion(MinDist2, MinDist, SDFs[i].Smoothness); break; + case 1: MinDist = opSubtraction(MinDist, MinDist2); break; + case 2: MinDist = opXor(MinDist, MinDist2); break; + case 3: MinDist = opIntersection(MinDist, MinDist2); break; + default: break; + } + if(abs(MinDist2 - MinDist) > 0.0001f) { + Color = i; + } + } + return MinDist; + } + + inline bool Traverse(float3 P, const float3 rayDir, float maxT, inout float TravT, inout float3 Color) { + + int CurStep = 0; + float CurT; + int Col = 0; + [loop]while(CurStep++ < 100 && TravT < maxT) { + CurT = Map(P, Col); + if(CurT < 0.01f) { + P += rayDir * CurT * 2.0f; + CurT = Map(P, Col); + Color = HandleDebug(Col); + return true; + } + P += rayDir * max(CurT, 0.1f); + TravT += CurT; + } + return false; + } + + + float3 Scale; + float LinearDepthToRawDepth(float linearDepth) + { + return (1. - linearDepth * _ZBufferParams.y) / (linearDepth * _ZBufferParams.x); + } + + + fixed4 frag (v2f i, out float outputDepth : SV_Depth) : SV_Target + { + + float3 viewDirection = normalize(i.wPos - _WorldSpaceCameraPos); + + float TravT = 0; + + + + float4 Color = float4(1,1,1,0); + outputDepth = 0; + float3 Col = 0; + if(Traverse(_WorldSpaceCameraPos, viewDirection, 1000.0f, TravT, Col)) { + float linearDepth = (TravT - _ProjectionParams.y) / (_ProjectionParams.z - _ProjectionParams.y); + outputDepth = LinearDepthToRawDepth(linearDepth); + Color = float4(Col, 1); + } else { + // discard; + } + + + + return Color; + } + ENDCG + } + } +} diff --git a/TrueTrace/Resources/Utility/TTSDFs/TTSDFShader.shader.meta b/TrueTrace/Resources/Utility/TTSDFs/TTSDFShader.shader.meta new file mode 100644 index 00000000..570ceb5e --- /dev/null +++ b/TrueTrace/Resources/Utility/TTSDFs/TTSDFShader.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: eb7fd76a4d67a9542b324c9861b9cc66 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/TrueTrace/Resources/Utility/TTSettings.cs b/TrueTrace/Resources/Utility/TTSettings.cs index 8d03bc5c..ca50daa9 100644 --- a/TrueTrace/Resources/Utility/TTSettings.cs +++ b/TrueTrace/Resources/Utility/TTSettings.cs @@ -25,8 +25,8 @@ namespace TrueTrace { [SerializeField] public bool PPToneMap = true; [SerializeField] public bool PPTAA = false; [SerializeField] public float RenderScale = 1.0f; - [SerializeField] public bool UseASVGF = false; - [SerializeField] public bool UseTAAU = true; + [SerializeField] public int DenoiserMethod = 0; + [SerializeField] public int UpscalerMethod = 0; [SerializeField] public int ReSTIRGIUpdateRate = 7; [SerializeField] public bool UseReSTIRGITemporal = true; [SerializeField] public bool UseReSTIRGISpatial = true; @@ -50,7 +50,6 @@ namespace TrueTrace { [SerializeField] public float FireflyStrength = 1.0f; [SerializeField] public float FireflyOffset = 0.0f; [SerializeField] public int OIDNFrameCount = 0; - [SerializeField] public bool UseOIDN = false; [SerializeField] public bool DoSharpen = false; [SerializeField] public float Sharpness = 1.0f; [SerializeField] public int MainDesiredRes = 16384; @@ -76,5 +75,9 @@ namespace TrueTrace { [SerializeField] public float ConvBloomDistExp = 0; [SerializeField] public float ConvBloomDistExpClampMin = 1; [SerializeField] public float ConvBloomDistExpScale = 1; + [SerializeField] public Vector3 PrimaryBackgroundTintColor = new Vector3(1.0f, 1.0f, 1.0f); + [SerializeField] public float PrimaryBackgroundTint = 0; + [SerializeField] public float PrimaryBackgroundContrast = 1; + } } \ No newline at end of file diff --git a/TrueTrace/Resources/Utility/TurnTableScript.cs b/TrueTrace/Resources/Utility/TurnTableScript.cs index 76b90394..ca646504 100644 --- a/TrueTrace/Resources/Utility/TurnTableScript.cs +++ b/TrueTrace/Resources/Utility/TurnTableScript.cs @@ -47,7 +47,10 @@ public void Init() { if(CamSettings[0].Cam != null) CamSettings[0].Cam.gameObject.SetActive(true); for(int i = 1; i < CamSettings.Length; i++) if(CamSettings[i].Cam != null) CamSettings[i].Cam.gameObject.SetActive(false); Camera[] AllCameras = GameObject.FindObjectsOfType(); - for(int i = 0; i < AllCameras.Length; i++) if(!CamSettings[0].Cam.Equals(AllCameras[i])) AllCameras[i].gameObject.SetActive(false); + for(int i = 0; i < AllCameras.Length; i++) { + if(!CamSettings[0].Cam.Equals(AllCameras[i])) AllCameras[i].gameObject.SetActive(false); + // if(!AllCameras[i].gameObject.TryGetComponent(out RenderHandle ExistingHandle)) AllCameras[i].gameObject.AddComponent(); + } } } @@ -79,6 +82,9 @@ IEnumerator RecordFrame() SegmentNumber += "_"; } } + if(!System.IO.Directory.Exists(PlayerPrefs.GetString("TurnTablePath") + "/" + CamSettings[CurrentCamera].Cam.gameObject.name.Replace(" ", ""))) { + System.IO.Directory.CreateDirectory(PlayerPrefs.GetString("TurnTablePath") + "/" + CamSettings[CurrentCamera].Cam.gameObject.name.Replace(" ", "")); + } ScreenCapture.CaptureScreenshot(PlayerPrefs.GetString("TurnTablePath") + "/" + CamSettings[CurrentCamera].Cam.gameObject.name.Replace(" ", "") + "/" + CamSettings[CurrentCamera].Cam.gameObject.name + "." + SegmentNumber + ".png"); CurrentSegment++; CamSettings[CurrentCamera].Cam.gameObject.transform.RotateAround(CamSettings[CurrentCamera].Center, Vector3.up, (360.0f / (float)CamSettings[CurrentCamera].HorizontalResolution));