├── Documentation~
├── HowToUse.png
├── HowToUse_Settings.png
└── SSR.png
├── LICENSE.md
├── LICENSE.md.meta
├── README.md
├── README.md.meta
├── Runtime.meta
├── Runtime
├── MipGenerator.cs
├── MipGenerator.cs.meta
├── SSRUtils.cs
├── SSRUtils.cs.meta
├── ScreenSpaceReflection.cs
├── ScreenSpaceReflection.cs.meta
├── ScreenSpaceReflectionSettings.cs
├── ScreenSpaceReflectionSettings.cs.meta
├── ShaderIDs.cs
├── ShaderIDs.cs.meta
├── ShaderVariablesScreenSpaceReflection.cs
├── ShaderVariablesScreenSpaceReflection.cs.meta
├── Shaders.meta
└── Shaders
│ ├── Common.hlsl
│ ├── Common.hlsl.meta
│ ├── DepthPyramid.compute
│ ├── DepthPyramid.compute.meta
│ ├── NormalBuffer.hlsl
│ ├── NormalBuffer.hlsl.meta
│ ├── ScreenSpaceReflectionResolver.shader
│ ├── ScreenSpaceReflectionResolver.shader.meta
│ ├── ScreenSpaceReflections.compute
│ ├── ScreenSpaceReflections.compute.meta
│ ├── ShaderVariablesScreenSpaceReflection.hlsl
│ └── ShaderVariablesScreenSpaceReflection.hlsl.meta
├── Sample.meta
├── Sample
├── Deferred.meta
├── Deferred
│ ├── Deferred Rendering Sample.unity
│ ├── Deferred Rendering Sample.unity.meta
│ ├── M_Plane_SSRDeferred.mat
│ ├── M_Plane_SSRDeferred.mat.meta
│ ├── SSR Deferred Sample Asset.asset
│ ├── SSR Deferred Sample Asset.asset.meta
│ ├── SSR Deferred Sample Renderer.asset
│ └── SSR Deferred Sample Renderer.asset.meta
├── Forward.meta
└── Forward
│ ├── Forward Rendering Sample.unity
│ ├── Forward Rendering Sample.unity.meta
│ ├── M_Plane_SSRForwardLit.mat
│ ├── M_Plane_SSRForwardLit.mat.meta
│ ├── SSRForwardSample Asset.asset
│ ├── SSRForwardSample Asset.asset.meta
│ ├── SSRForwardSample Renderer.asset
│ ├── SSRForwardSample Renderer.asset.meta
│ ├── Shader.meta
│ └── Shader
│ ├── SSRForwardLit.shader
│ ├── SSRForwardLit.shader.meta
│ ├── SSRForwardLitDepthNormalsPass.hlsl
│ └── SSRForwardLitDepthNormalsPass.hlsl.meta
├── Setting.meta
├── Setting
├── Screen Space Reflection Settings.asset
└── Screen Space Reflection Settings.asset.meta
├── UniversalScreenSpaceReflection.asmdef
├── UniversalScreenSpaceReflection.asmdef.meta
├── package.json
└── package.json.meta
/Documentation~/HowToUse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mseonKim/URP-ScreenSpaceReflection/d75aaafbef8ba5486413dae8eec1678e993ac821/Documentation~/HowToUse.png
--------------------------------------------------------------------------------
/Documentation~/HowToUse_Settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mseonKim/URP-ScreenSpaceReflection/d75aaafbef8ba5486413dae8eec1678e993ac821/Documentation~/HowToUse_Settings.png
--------------------------------------------------------------------------------
/Documentation~/SSR.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mseonKim/URP-ScreenSpaceReflection/d75aaafbef8ba5486413dae8eec1678e993ac821/Documentation~/SSR.png
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Universal ScreenSpaceReflection © 2024 Unity Technologies
2 |
3 | Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
4 |
5 | Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions.
6 |
--------------------------------------------------------------------------------
/LICENSE.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a2664aa4e2fc6754f8e35e52d774b622
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Universal ScreenSpace Reflection
2 | 
3 |
4 | This repository is ported from Unity HDRP ScreenSpace Reflection.
5 |
6 | This package is available on URP from 2022.3.0f1 (2022 LTS) version.
7 | The RenderGraph path for Unity6 is also supported.
8 |
9 | ||2022 LTS|2023|Unity 6|
10 | |:---:|:---:|:---:|:---:|
11 | |URP Compatibility|O|O|O|
12 | |RenderGraph Implementation|X|X|O|
13 |
14 | ## How To Use
15 |
16 | 
17 |
18 | 1. Add `ScreenSpaceReflection` renderer feature to the `Renderer Data` asset. (Disable `Native RenderPass` in this asset if visible.)
19 | 2. Set the rendering path to your rendering mode.
20 | 3. Link the settings asset to the renderer feature.
21 | (You can create the settings asset via `Create/UniversalSSR/Settings`.)
22 |
23 | 
24 |
25 |
26 |
27 | ### In Forward(+) Rendering Mode
28 |
29 | Since the URP Default Lit shader does not save the smoothness value to the normal texture in Forward Rendering, we need to customize `DepthNormalsPass`. It also means that we need to customize all shaders that we want to draw the reflection for forward.
30 |
31 | However, it's pretty simple to handle this with a custom shader that stores the smoothness value into `_CameraNormalsTexture.a`.
32 | See the reference shader(`SSRForwardLit.shader`) in the sample project.
33 |
34 | Note) Unfortunately, shaders created with `ShaderGraph` are not supported as there's no way to customize the `DepthNormalsPass` without customizing the URP package.
35 |
36 |
37 | ## Limitations
38 |
39 | 1. XR Not supported.
40 | 2. Transparent Objects Not supported.
41 | 3. ShaderGraph shaders are not reflected in Forward(+) rendering.
42 |
43 | ## Differences from HDRP
44 |
45 | 1. Assume SSR_APPROX keyword is enabled. (No support PBR Accumulation mode due to performance.)
46 | 2. Stencil Check is excluded.
47 | 3. ClearCoatMask is excluded since it's only in HDRP.
48 | 4. Motion Vector is excluded.
49 |
--------------------------------------------------------------------------------
/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: eceda101b3d2f504bbebf8f36d0b8bdc
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e312383996965764393b8d273e07eb87
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/MipGenerator.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.Rendering;
3 | #if UNITY_6000_0_OR_NEWER
4 | using UnityEngine.Rendering.RenderGraphModule;
5 | #endif
6 |
7 | namespace UniversalScreenSpaceReflection
8 | {
9 | internal class MipGenerator
10 | {
11 | private ComputeShader m_DepthPyramidCS;
12 | private int m_CopyDepthToMip0Kernel;
13 | private int m_DepthDownsampleKernel;
14 |
15 | private int[] m_SrcOffset;
16 | private int[] m_DstOffset;
17 |
18 | public MipGenerator(ComputeShader depthPyramidCS)
19 | {
20 | m_DepthPyramidCS = depthPyramidCS;
21 | m_CopyDepthToMip0Kernel = m_DepthPyramidCS.FindKernel("KCopyDepthTextureToMipChain");
22 | m_DepthDownsampleKernel = m_DepthPyramidCS.FindKernel("KDepthDownsample8DualUav");
23 |
24 | m_SrcOffset = new int[4];
25 | m_DstOffset = new int[4];
26 | }
27 |
28 | // Generates an in-place depth pyramid
29 | // TODO: Mip-mapping depth is problematic for precision at lower mips, generate a packed atlas instead
30 | public void RenderMinDepthPyramid(CommandBuffer cmd, RenderTexture texture, SSRUtils.PackedMipChainInfo info, bool mip1AlreadyComputed)
31 | {
32 | SSRUtils.CheckRTCreated(texture);
33 |
34 | var cs = m_DepthPyramidCS;
35 | int kernel = m_CopyDepthToMip0Kernel;
36 |
37 | // Copy depth texture to mip0.
38 | {
39 | Vector2Int dstSize = info.mipLevelSizes[0];
40 | cmd.SetComputeIntParams(cs, ShaderIDs._SrcOffsetAndLimit, m_SrcOffset);
41 | cmd.SetComputeIntParams(cs, ShaderIDs._DstOffset, m_DstOffset);
42 | cmd.SetComputeTextureParam(cs, kernel, ShaderIDs._DepthMipChain, texture);
43 |
44 | cmd.DispatchCompute(cs, kernel, SSRUtils.DivRoundUp(dstSize.x, 8), SSRUtils.DivRoundUp(dstSize.y, 8), texture.volumeDepth);
45 | }
46 |
47 | kernel = m_DepthDownsampleKernel;
48 | // TODO: Do it 1x MIP at a time for now. In the future, do 4x MIPs per pass, or even use a single pass.
49 | // Note: Gather() doesn't take a LOD parameter and we cannot bind an SRV of a MIP level,
50 | // and we don't support Min samplers either. So we are forced to perform 4x loads.
51 | for (int i = 1; i < info.mipLevelCount; i++)
52 | {
53 | if (mip1AlreadyComputed && i == 1) continue;
54 |
55 | Vector2Int dstSize = info.mipLevelSizes[i];
56 | Vector2Int dstOffset = info.mipLevelOffsets[i];
57 | Vector2Int srcSize = info.mipLevelSizes[i - 1];
58 | Vector2Int srcOffset = info.mipLevelOffsets[i - 1];
59 | Vector2Int srcLimit = srcOffset + srcSize - Vector2Int.one;
60 |
61 | m_SrcOffset[0] = srcOffset.x;
62 | m_SrcOffset[1] = srcOffset.y;
63 | m_SrcOffset[2] = srcLimit.x;
64 | m_SrcOffset[3] = srcLimit.y;
65 |
66 | m_DstOffset[0] = dstOffset.x;
67 | m_DstOffset[1] = dstOffset.y;
68 | m_DstOffset[2] = 0;
69 | m_DstOffset[3] = 0;
70 |
71 | cmd.SetComputeIntParams(cs, ShaderIDs._SrcOffsetAndLimit, m_SrcOffset);
72 | cmd.SetComputeIntParams(cs, ShaderIDs._DstOffset, m_DstOffset);
73 | cmd.SetComputeTextureParam(cs, kernel, ShaderIDs._DepthMipChain, texture);
74 |
75 | cmd.DispatchCompute(cs, kernel, SSRUtils.DivRoundUp(dstSize.x, 8), SSRUtils.DivRoundUp(dstSize.y, 8), texture.volumeDepth);
76 | }
77 | }
78 |
79 | #if UNITY_6000_0_OR_NEWER
80 | #region RenderGraph
81 | public void RenderMinDepthPyramid(ComputeCommandBuffer cmd, TextureHandle texture, SSRUtils.PackedMipChainInfo info, int volumeDepth, bool mip1AlreadyComputed)
82 | {
83 | SSRUtils.CheckRTCreated(texture);
84 |
85 | var cs = m_DepthPyramidCS;
86 | int kernel = m_CopyDepthToMip0Kernel;
87 |
88 | // Copy depth texture to mip0.
89 | {
90 | Vector2Int dstSize = info.mipLevelSizes[0];
91 | cmd.SetComputeIntParams(cs, ShaderIDs._SrcOffsetAndLimit, m_SrcOffset);
92 | cmd.SetComputeIntParams(cs, ShaderIDs._DstOffset, m_DstOffset);
93 | cmd.SetComputeTextureParam(cs, kernel, ShaderIDs._DepthMipChain, texture);
94 |
95 | cmd.DispatchCompute(cs, kernel, SSRUtils.DivRoundUp(dstSize.x, 8), SSRUtils.DivRoundUp(dstSize.y, 8), volumeDepth);
96 | }
97 |
98 | kernel = m_DepthDownsampleKernel;
99 | // TODO: Do it 1x MIP at a time for now. In the future, do 4x MIPs per pass, or even use a single pass.
100 | // Note: Gather() doesn't take a LOD parameter and we cannot bind an SRV of a MIP level,
101 | // and we don't support Min samplers either. So we are forced to perform 4x loads.
102 | for (int i = 1; i < info.mipLevelCount; i++)
103 | {
104 | if (mip1AlreadyComputed && i == 1) continue;
105 |
106 | Vector2Int dstSize = info.mipLevelSizes[i];
107 | Vector2Int dstOffset = info.mipLevelOffsets[i];
108 | Vector2Int srcSize = info.mipLevelSizes[i - 1];
109 | Vector2Int srcOffset = info.mipLevelOffsets[i - 1];
110 | Vector2Int srcLimit = srcOffset + srcSize - Vector2Int.one;
111 |
112 | m_SrcOffset[0] = srcOffset.x;
113 | m_SrcOffset[1] = srcOffset.y;
114 | m_SrcOffset[2] = srcLimit.x;
115 | m_SrcOffset[3] = srcLimit.y;
116 |
117 | m_DstOffset[0] = dstOffset.x;
118 | m_DstOffset[1] = dstOffset.y;
119 | m_DstOffset[2] = 0;
120 | m_DstOffset[3] = 0;
121 |
122 | cmd.SetComputeIntParams(cs, ShaderIDs._SrcOffsetAndLimit, m_SrcOffset);
123 | cmd.SetComputeIntParams(cs, ShaderIDs._DstOffset, m_DstOffset);
124 | cmd.SetComputeTextureParam(cs, kernel, ShaderIDs._DepthMipChain, texture);
125 |
126 | cmd.DispatchCompute(cs, kernel, SSRUtils.DivRoundUp(dstSize.x, 8), SSRUtils.DivRoundUp(dstSize.y, 8), volumeDepth);
127 | }
128 | }
129 | #endregion
130 | #endif
131 | }
132 | }
--------------------------------------------------------------------------------
/Runtime/MipGenerator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 49b934ef275c3934e86d6af189663231
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/SSRUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.Rendering;
4 |
5 | namespace UniversalScreenSpaceReflection
6 | {
7 | public class SSRUtils
8 | {
9 | internal struct PackedMipChainInfo
10 | {
11 | public Vector2Int textureSize;
12 | public int mipLevelCount;
13 | public Vector2Int[] mipLevelSizes;
14 | public Vector2Int[] mipLevelOffsets;
15 |
16 | private Vector2 cachedTextureScale;
17 | private Vector2Int cachedHardwareTextureSize;
18 |
19 | private bool m_OffsetBufferWillNeedUpdate;
20 |
21 | public void Allocate()
22 | {
23 | mipLevelOffsets = new Vector2Int[15];
24 | mipLevelSizes = new Vector2Int[15];
25 | m_OffsetBufferWillNeedUpdate = true;
26 | }
27 |
28 | // We pack all MIP levels into the top MIP level to avoid the Pow2 MIP chain restriction.
29 | // We compute the required size iteratively.
30 | // This function is NOT fast, but it is illustrative, and can be optimized later.
31 | public void ComputePackedMipChainInfo(Vector2Int viewportSize)
32 | {
33 | bool isHardwareDrsOn = DynamicResolutionHandler.instance.HardwareDynamicResIsEnabled();
34 | Vector2Int hardwareTextureSize = isHardwareDrsOn ? DynamicResolutionHandler.instance.ApplyScalesOnSize(viewportSize) : viewportSize;
35 | Vector2 textureScale = isHardwareDrsOn ? new Vector2((float)viewportSize.x / (float)hardwareTextureSize.x, (float)viewportSize.y / (float)hardwareTextureSize.y) : new Vector2(1.0f, 1.0f);
36 |
37 | // No work needed.
38 | if (cachedHardwareTextureSize == hardwareTextureSize && cachedTextureScale == textureScale)
39 | return;
40 |
41 | cachedHardwareTextureSize = hardwareTextureSize;
42 | cachedTextureScale = textureScale;
43 |
44 | mipLevelSizes[0] = hardwareTextureSize;
45 | mipLevelOffsets[0] = Vector2Int.zero;
46 |
47 | int mipLevel = 0;
48 | Vector2Int mipSize = hardwareTextureSize;
49 |
50 | do
51 | {
52 | mipLevel++;
53 |
54 | // Round up.
55 | mipSize.x = Math.Max(1, (mipSize.x + 1) >> 1);
56 | mipSize.y = Math.Max(1, (mipSize.y + 1) >> 1);
57 |
58 | mipLevelSizes[mipLevel] = mipSize;
59 |
60 | Vector2Int prevMipBegin = mipLevelOffsets[mipLevel - 1];
61 | Vector2Int prevMipEnd = prevMipBegin + mipLevelSizes[mipLevel - 1];
62 |
63 | Vector2Int mipBegin = new Vector2Int();
64 |
65 | if ((mipLevel & 1) != 0) // Odd
66 | {
67 | mipBegin.x = prevMipBegin.x;
68 | mipBegin.y = prevMipEnd.y;
69 | }
70 | else // Even
71 | {
72 | mipBegin.x = prevMipEnd.x;
73 | mipBegin.y = prevMipBegin.y;
74 | }
75 |
76 | mipLevelOffsets[mipLevel] = mipBegin;
77 |
78 | hardwareTextureSize.x = Math.Max(hardwareTextureSize.x, mipBegin.x + mipSize.x);
79 | hardwareTextureSize.y = Math.Max(hardwareTextureSize.y, mipBegin.y + mipSize.y);
80 | }
81 | while ((mipSize.x > 1) || (mipSize.y > 1));
82 |
83 | textureSize = new Vector2Int(
84 | (int)Mathf.Ceil((float)hardwareTextureSize.x * textureScale.x), (int)Mathf.Ceil((float)hardwareTextureSize.y * textureScale.y));
85 |
86 | mipLevelCount = mipLevel + 1;
87 | m_OffsetBufferWillNeedUpdate = true;
88 | }
89 |
90 | public GraphicsBuffer GetOffsetBufferData(GraphicsBuffer mipLevelOffsetsBuffer)
91 | {
92 | if (m_OffsetBufferWillNeedUpdate)
93 | {
94 | mipLevelOffsetsBuffer.SetData(mipLevelOffsets);
95 | m_OffsetBufferWillNeedUpdate = false;
96 | }
97 |
98 | return mipLevelOffsetsBuffer;
99 | }
100 | }
101 |
102 | internal static int DivRoundUp(int x, int y) => (x + y - 1) / y;
103 |
104 | internal static void CheckRTCreated(RenderTexture rt)
105 | {
106 | // In some cases when loading a project for the first time in the editor, the internal resource is destroyed.
107 | // When used as render target, the C++ code will re-create the resource automatically. Since here it's used directly as an UAV, we need to check manually
108 | if (!rt.IsCreated())
109 | rt.Create();
110 | }
111 |
112 | internal static float ComputeViewportScale(int viewportSize, int bufferSize)
113 | {
114 | float rcpBufferSize = 1.0f / bufferSize;
115 |
116 | // Scale by (vp_dim / buf_dim).
117 | return viewportSize * rcpBufferSize;
118 | }
119 |
120 | internal static float ComputeViewportLimit(int viewportSize, int bufferSize)
121 | {
122 | float rcpBufferSize = 1.0f / bufferSize;
123 |
124 | // Clamp to (vp_dim - 0.5) / buf_dim.
125 | return (viewportSize - 0.5f) * rcpBufferSize;
126 | }
127 |
128 | internal static Vector4 ComputeViewportScaleAndLimit(Vector2Int viewportSize, Vector2Int bufferSize)
129 | {
130 | return new Vector4(ComputeViewportScale(viewportSize.x, bufferSize.x), // Scale(x)
131 | ComputeViewportScale(viewportSize.y, bufferSize.y), // Scale(y)
132 | ComputeViewportLimit(viewportSize.x, bufferSize.x), // Limit(x)
133 | ComputeViewportLimit(viewportSize.y, bufferSize.y)); // Limit(y)
134 | }
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/Runtime/SSRUtils.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: edb710335e3269b4bb8e7789695265bd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/ScreenSpaceReflection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.Rendering;
4 | using UnityEngine.Rendering.Universal;
5 | #if UNITY_6000_0_OR_NEWER
6 | using UnityEngine.Rendering.RenderGraphModule;
7 | using UnityEngine.Rendering.RenderGraphModule.Util;
8 | #endif
9 |
10 | namespace UniversalScreenSpaceReflection
11 | {
12 | public class ScreenSpaceReflection : ScriptableRendererFeature
13 | {
14 | public ScreenSpaceReflectionSettings settings;
15 | public RenderingMode renderingPath;
16 | private ScreenSpaceReflectionPass m_Pass;
17 |
18 | ///
19 | public override void Create()
20 | {
21 | m_Pass = new ScreenSpaceReflectionPass();
22 | m_Pass.renderPassEvent = RenderPassEvent.AfterRenderingSkybox;
23 | m_Pass.Setup(settings, renderingPath);
24 | }
25 |
26 | public override void SetupRenderPasses(ScriptableRenderer renderer, in RenderingData renderingData)
27 | {
28 | m_Pass.SetCameraColorTargetHandle(renderer.cameraColorTargetHandle);
29 | }
30 |
31 | // This method is called when setting up the renderer once per-camera.
32 | public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
33 | {
34 | // Skip if preview or reflection camera
35 | if (renderingData.cameraData.cameraType == CameraType.Preview || renderingData.cameraData.cameraType == CameraType.Reflection)
36 | return;
37 |
38 | renderer.EnqueuePass(m_Pass);
39 | }
40 |
41 | protected override void Dispose(bool disposing)
42 | {
43 | m_Pass.Dispose();
44 | }
45 |
46 |
47 | private class ScreenSpaceReflectionPass : ScriptableRenderPass
48 | {
49 | private RenderingMode m_RenderingMode;
50 | private RTHandle m_CameraColorTargetHandle;
51 | private RTHandle m_DepthPyramidHandle;
52 | private RTHandle m_ColorPyramidHandle;
53 | private RTHandle m_HitPointsHandle;
54 | private RTHandle m_LightingHandle;
55 | private MipGenerator m_MipGenerator;
56 | private PassData m_PassData = new PassData();
57 | private SSRUtils.PackedMipChainInfo m_DepthBufferMipChainInfo = new SSRUtils.PackedMipChainInfo();
58 | private GraphicsBuffer m_DepthPyramidMipLevelOffsetsBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, 15, sizeof(int) * 2);
59 | private Material m_ResolveMat;
60 |
61 | private int m_TracingKernel;
62 | private int m_ReprojectionKernel;
63 | private int m_CopyColorKernel;
64 |
65 | private ProfilingSampler m_ProfilingSampler = new ProfilingSampler("ScreenSpaceReflection");
66 |
67 | private bool ValidatePass(PassData data, bool useRenderGraph = false)
68 | {
69 | if (data.settings == null || !data.settings.enabled)
70 | return false;
71 |
72 | if (data.renderingMode == RenderingMode.Deferred)
73 | {
74 | if (!useRenderGraph && Shader.GetGlobalTexture("_GBuffer2") == null)
75 | return false;
76 | }
77 | else
78 | {
79 | if (Shader.GetGlobalTexture("_CameraDepthTexture") == null)
80 | Shader.SetGlobalTexture("_CameraDepthTexture", Texture2D.blackTexture);
81 |
82 | if (Shader.GetGlobalTexture("_CameraNormalsTexture") == null)
83 | Shader.SetGlobalTexture("_CameraNormalsTexture", Texture2D.blackTexture);
84 | }
85 |
86 | return true;
87 | }
88 |
89 | public void Setup(ScreenSpaceReflectionSettings settings, RenderingMode renderingMode)
90 | {
91 | if (settings == null || settings.depthPyramidCS == null || settings.screenSpaceReflectionsCS == null)
92 | return;
93 |
94 | m_ResolveMat = CoreUtils.CreateEngineMaterial(Shader.Find("Hidden/SSR_Resolver"));
95 | if (m_ResolveMat == null)
96 | return;
97 |
98 | m_PassData.settings = settings;
99 | m_PassData.renderingMode = m_RenderingMode = renderingMode;
100 | m_DepthBufferMipChainInfo.Allocate();
101 | m_MipGenerator = new MipGenerator(settings.depthPyramidCS);
102 | }
103 |
104 | public void SetCameraColorTargetHandle(RTHandle colorTargetHandle)
105 | {
106 | m_CameraColorTargetHandle = colorTargetHandle;
107 | }
108 |
109 | public void Dispose()
110 | {
111 | CoreUtils.SafeRelease(m_DepthPyramidMipLevelOffsetsBuffer);
112 | CoreUtils.Destroy(m_ResolveMat);
113 | m_DepthPyramidHandle?.Release();
114 | m_ColorPyramidHandle?.Release();
115 | m_HitPointsHandle?.Release();
116 | m_LightingHandle?.Release();
117 | }
118 |
119 | #if UNITY_6000_0_OR_NEWER
120 | [Obsolete]
121 | #endif
122 | public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
123 | {
124 | // Enable normal texture if forward(+).
125 | if (m_RenderingMode == RenderingMode.Forward || m_RenderingMode == RenderingMode.ForwardPlus)
126 | {
127 | ConfigureInput(ScriptableRenderPassInput.Normal);
128 | }
129 |
130 | if (!ValidatePass(m_PassData))
131 | return;
132 |
133 | var desc = m_CameraColorTargetHandle.rt.descriptor;
134 | var nonScaledViewport = new Vector2Int(desc.width, desc.height);
135 | m_DepthBufferMipChainInfo.ComputePackedMipChainInfo(nonScaledViewport);
136 |
137 | var depthMipchainSize = m_DepthBufferMipChainInfo.textureSize;
138 | var depthPyramidDesc = new RenderTextureDescriptor(depthMipchainSize.x, depthMipchainSize.y, RenderTextureFormat.RFloat);
139 | depthPyramidDesc.enableRandomWrite = true;
140 | depthPyramidDesc.sRGB = false;
141 | RenderingUtils.ReAllocateIfNeeded(ref m_DepthPyramidHandle, depthPyramidDesc, name:"CameraDepthBufferMipChain");
142 |
143 | var colorPyramidDesc = new RenderTextureDescriptor(desc.width, desc.height, desc.colorFormat, 0, 11);
144 | colorPyramidDesc.enableRandomWrite = true;
145 | colorPyramidDesc.useMipMap = true;
146 | colorPyramidDesc.autoGenerateMips = false;
147 | RenderingUtils.ReAllocateIfNeeded(ref m_ColorPyramidHandle, colorPyramidDesc, name:"CameraColorBufferMipChain");
148 |
149 | var hitPointsDesc = new RenderTextureDescriptor(desc.width, desc.height, colorFormat:UnityEngine.Experimental.Rendering.GraphicsFormat.R16G16_UNorm, 0);
150 | hitPointsDesc.enableRandomWrite = true;
151 | hitPointsDesc.sRGB = false;
152 | RenderingUtils.ReAllocateIfNeeded(ref m_HitPointsHandle, hitPointsDesc, name:"SSR_Hit_Point_Texture");
153 |
154 | var lightingDesc = new RenderTextureDescriptor(desc.width, desc.height, colorFormat:UnityEngine.Experimental.Rendering.GraphicsFormat.R16G16B16A16_SFloat, 0);
155 | lightingDesc.enableRandomWrite = true;
156 | lightingDesc.sRGB = false;
157 | RenderingUtils.ReAllocateIfNeeded(ref m_LightingHandle, lightingDesc, name:"SSR_Lighting_Texture");
158 |
159 | m_TracingKernel = m_PassData.settings.screenSpaceReflectionsCS.FindKernel("ScreenSpaceReflectionsTracing");
160 | m_ReprojectionKernel = m_PassData.settings.screenSpaceReflectionsCS.FindKernel("ScreenSpaceReflectionsReprojection");
161 | m_CopyColorKernel = m_PassData.settings.screenSpaceReflectionsCS.FindKernel("CopyColorTarget");
162 | }
163 |
164 | #if UNITY_6000_0_OR_NEWER
165 | [Obsolete]
166 | #endif
167 | public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
168 | {
169 | if (!ValidatePass(m_PassData))
170 | return;
171 |
172 | var cameraData = renderingData.cameraData;
173 | m_PassData.cb = new ShaderVariablesScreenSpaceReflection();
174 | m_PassData.mipInfo = m_DepthBufferMipChainInfo;
175 | UpdateSSRConstantBuffer(renderingData.cameraData.camera, m_PassData.settings, ref m_PassData.cb, m_ColorPyramidHandle.rt.mipmapCount, m_PassData.mipInfo, cameraData.GetViewMatrix(), cameraData.GetProjectionMatrix());
176 | m_PassData.renderingMode = m_RenderingMode;
177 | m_PassData.cameraColorTargetHandle = m_CameraColorTargetHandle;
178 | m_PassData.depthTexture = m_DepthPyramidHandle;
179 | m_PassData.colorTexture = m_ColorPyramidHandle;
180 | m_PassData.hitPointsTexture = m_HitPointsHandle;
181 | m_PassData.lightingTexture = m_LightingHandle;
182 | m_PassData.mipGenerator = m_MipGenerator;
183 | m_PassData.offsetBufferData = m_DepthBufferMipChainInfo.GetOffsetBufferData(m_DepthPyramidMipLevelOffsetsBuffer);
184 | m_PassData.tracingKernel = m_TracingKernel;
185 | m_PassData.reprojectionKernel = m_ReprojectionKernel;
186 | m_PassData.copyColorKernel = m_CopyColorKernel;
187 | var cameraTargetDescriptor = m_PassData.cameraColorTargetHandle.rt.descriptor;
188 | m_PassData.viewportSize = new Vector2Int(cameraTargetDescriptor.width, cameraTargetDescriptor.height);
189 | m_PassData.resolveMat = m_ResolveMat;
190 |
191 | CommandBuffer cmd = CommandBufferPool.Get();
192 | using (new ProfilingScope(cmd, m_ProfilingSampler))
193 | {
194 | context.ExecuteCommandBuffer(cmd);
195 | cmd.Clear();
196 | ExecutePass(cmd, m_PassData);
197 | }
198 |
199 | context.ExecuteCommandBuffer(cmd);
200 | CommandBufferPool.Release(cmd);
201 | }
202 |
203 | public override void OnCameraCleanup(CommandBuffer cmd)
204 | {
205 | }
206 |
207 |
208 | private static void ExecutePass(CommandBuffer cmd, PassData data)
209 | {
210 | var cs = data.settings.screenSpaceReflectionsCS;
211 | if (cs == null)
212 | return;
213 |
214 | using (new ProfilingScope(cmd, new ProfilingSampler("Depth Pyramid")))
215 | {
216 | data.mipGenerator.RenderMinDepthPyramid(cmd, data.depthTexture, data.mipInfo, false);
217 | }
218 |
219 | var deferredKeyword = new LocalKeyword(cs, "SSR_DEFERRED");
220 |
221 | using (new ProfilingScope(cmd, new ProfilingSampler("SSR Tracing")))
222 | {
223 | // Set keyword to use different normal texture based on rendering mode.
224 | cmd.SetKeyword(cs, deferredKeyword, data.renderingMode == RenderingMode.Deferred);
225 |
226 | cmd.SetComputeTextureParam(cs, data.tracingKernel, ShaderIDs._DepthPyramidTexture, data.depthTexture);
227 | cmd.SetComputeTextureParam(cs, data.tracingKernel, ShaderIDs._SsrHitPointTexture, data.hitPointsTexture);
228 |
229 | cmd.SetComputeBufferParam(cs, data.tracingKernel, ShaderIDs._DepthPyramidMipLevelOffsets, data.offsetBufferData);
230 |
231 | ConstantBuffer.Push(cmd, data.cb, cs, ShaderIDs._ShaderVariablesScreenSpaceReflection);
232 |
233 | cmd.DispatchCompute(cs, data.tracingKernel, SSRUtils.DivRoundUp(data.viewportSize.x, 8), SSRUtils.DivRoundUp(data.viewportSize.y, 8), 1);
234 | }
235 |
236 | using (new ProfilingScope(cmd, new ProfilingSampler("SSR Reprojection")))
237 | {
238 | // Set keyword to use different normal texture based on rendering mode.
239 | cmd.SetKeyword(cs, deferredKeyword, data.renderingMode == RenderingMode.Deferred);
240 |
241 | // Create color mip chain
242 | cmd.SetComputeTextureParam(cs, data.copyColorKernel, ShaderIDs._CameraColorTexture, data.cameraColorTargetHandle);
243 | cmd.SetComputeTextureParam(cs, data.copyColorKernel, ShaderIDs._CopiedColorPyramidTexture, data.colorTexture);
244 | cmd.DispatchCompute(cs, data.copyColorKernel, SSRUtils.DivRoundUp(data.viewportSize.x, 8), SSRUtils.DivRoundUp(data.viewportSize.y, 8), 1);
245 | cmd.GenerateMips(data.colorTexture);
246 |
247 | // Bind resources
248 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, ShaderIDs._DepthPyramidTexture, data.depthTexture);
249 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, ShaderIDs._ColorPyramidTexture, data.colorTexture);
250 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, ShaderIDs._SsrHitPointTexture, data.hitPointsTexture);
251 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, ShaderIDs._SSRAccumTexture, data.lightingTexture);
252 |
253 | cmd.SetComputeBufferParam(cs, data.reprojectionKernel, ShaderIDs._DepthPyramidMipLevelOffsets, data.offsetBufferData);
254 |
255 | ConstantBuffer.Push(cmd, data.cb, cs, ShaderIDs._ShaderVariablesScreenSpaceReflection);
256 |
257 | cmd.DispatchCompute(cs, data.reprojectionKernel, SSRUtils.DivRoundUp(data.viewportSize.x, 8), SSRUtils.DivRoundUp(data.viewportSize.y, 8), 1);
258 | }
259 |
260 | // Resolve
261 | if (data.resolveMat != null)
262 | {
263 | Blitter.BlitCameraTexture(cmd, data.lightingTexture, data.cameraColorTargetHandle, data.resolveMat, 0);
264 | }
265 | }
266 |
267 | private void UpdateSSRConstantBuffer(Camera camera, ScreenSpaceReflectionSettings settings, ref ShaderVariablesScreenSpaceReflection cb, int mipmapCount, SSRUtils.PackedMipChainInfo mipChainInfo, in Matrix4x4 viewMatrix, in Matrix4x4 projMatrix)
268 | {
269 | float n = camera.nearClipPlane;
270 | float f = camera.farClipPlane;
271 | float thickness = settings.objectThickness;
272 |
273 | cb._SsrThicknessScale = 1.0f / (1.0f + thickness);
274 | cb._SsrThicknessBias = -n / (f - n) * (thickness * cb._SsrThicknessScale);
275 | cb._SsrIterLimit = settings.rayMaxIterations;
276 | // Note that the sky is still visible, it just takes its value from reflection probe/skybox rather than on screen.
277 | cb._SsrReflectsSky = settings.reflectSky ? 1 : 0;
278 | float roughnessFadeStart = 1 - settings.smoothnessFadeStart;
279 | cb._SsrRoughnessFadeEnd = 1 - settings.minSmoothness;
280 | float roughnessFadeLength = cb._SsrRoughnessFadeEnd - roughnessFadeStart;
281 | cb._SsrRoughnessFadeEndTimesRcpLength = (roughnessFadeLength != 0) ? (cb._SsrRoughnessFadeEnd * (1.0f / roughnessFadeLength)) : 1;
282 | cb._SsrRoughnessFadeRcpLength = (roughnessFadeLength != 0) ? (1.0f / roughnessFadeLength) : 0;
283 | cb._SsrEdgeFadeRcpLength = Mathf.Min(1.0f / settings.screenFadeDistance, float.MaxValue);
284 | // cb._ColorPyramidUvScaleAndLimitPrevFrame = SSRUtils.ComputeViewportScaleAndLimit(camera.historyRTHandleProperties.previousViewportSize, camera.historyRTHandleProperties.previousRenderTargetSize);
285 | cb._SsrColorPyramidMaxMip = mipmapCount - 1;
286 | cb._SsrDepthPyramidMaxMip = mipChainInfo.mipLevelCount - 1;
287 |
288 | var jitterMatrix = projMatrix * camera.nonJitteredProjectionMatrix.inverse;
289 | cb._CameraViewProjMatrix = jitterMatrix * GL.GetGPUProjectionMatrix(projMatrix, true) * viewMatrix;
290 | cb._InvCameraViewProjMatrix = cb._CameraViewProjMatrix.inverse;
291 | }
292 |
293 |
294 | private class PassData
295 | {
296 | public ScreenSpaceReflectionSettings settings;
297 | public ShaderVariablesScreenSpaceReflection cb;
298 | public RenderingMode renderingMode;
299 | public RTHandle cameraColorTargetHandle;
300 | public RTHandle depthTexture;
301 | public RTHandle colorTexture;
302 | public RTHandle hitPointsTexture;
303 | public RTHandle lightingTexture;
304 | public SSRUtils.PackedMipChainInfo mipInfo;
305 | public MipGenerator mipGenerator;
306 | public GraphicsBuffer offsetBufferData;
307 | public int tracingKernel;
308 | public int reprojectionKernel;
309 | public int copyColorKernel;
310 | public Vector2Int viewportSize;
311 | public Material resolveMat;
312 | }
313 |
314 | #if UNITY_6000_0_OR_NEWER
315 | #region RenderGraph
316 | // This method adds and configures one or more render passes in the render graph.
317 | // This process includes declaring their inputs and outputs,
318 | // but does not include adding commands to command buffers.
319 | public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameContext)
320 | {
321 | // Enable normal texture if forward(+).
322 | if (m_RenderingMode == RenderingMode.Forward || m_RenderingMode == RenderingMode.ForwardPlus)
323 | {
324 | ConfigureInput(ScriptableRenderPassInput.Normal);
325 | }
326 |
327 | if (!ValidatePass(m_PassData, true))
328 | return;
329 |
330 | var blitParameters = new RenderGraphUtils.BlitMaterialParameters();
331 |
332 | using (var builder = renderGraph.AddComputePass("ScreenSpace Reflection", out var passData))
333 | {
334 | passData.settings = m_PassData.settings;
335 |
336 | // Get the data needed to create the list of objects to draw
337 | UniversalRenderingData renderingData = frameContext.Get();
338 | UniversalCameraData cameraData = frameContext.Get();
339 | UniversalLightData lightData = frameContext.Get();
340 | UniversalResourceData resourceData = frameContext.Get();
341 |
342 | builder.AllowGlobalStateModification(true);
343 | builder.UseTexture(resourceData.cameraDepthTexture, AccessFlags.Read);
344 | builder.UseTexture(resourceData.cameraNormalsTexture, AccessFlags.Read);
345 | builder.UseTexture(resourceData.cameraColor, AccessFlags.Read);
346 | if (resourceData.gBuffer != null && resourceData.gBuffer[2].IsValid())
347 | {
348 | builder.UseTexture(resourceData.gBuffer[2], AccessFlags.Read);
349 | passData.gBuffer2 = resourceData.gBuffer[2];
350 | }
351 |
352 | var desc = resourceData.cameraColor.GetDescriptor(renderGraph);
353 | var nonScaledViewport = new Vector2Int(desc.width, desc.height);
354 | m_DepthBufferMipChainInfo.ComputePackedMipChainInfo(nonScaledViewport);
355 |
356 | var depthMipchainSize = m_DepthBufferMipChainInfo.textureSize;
357 | var depthPyramidDesc = new RenderTextureDescriptor(depthMipchainSize.x, depthMipchainSize.y, RenderTextureFormat.RFloat);
358 | depthPyramidDesc.enableRandomWrite = true;
359 | depthPyramidDesc.sRGB = false;
360 | var depthPyramidHandle = UniversalRenderer.CreateRenderGraphTexture(renderGraph, depthPyramidDesc, "CameraDepthBufferMipChain", false);
361 | builder.UseTexture(depthPyramidHandle, AccessFlags.ReadWrite);
362 |
363 | var colorPyramidDesc = new RenderTextureDescriptor(desc.width, desc.height, desc.colorFormat, 0, 11);
364 | var colorPyramidTextureDesc = new TextureDesc(colorPyramidDesc);
365 | colorPyramidTextureDesc.enableRandomWrite = true;
366 | colorPyramidTextureDesc.useMipMap = true;
367 | colorPyramidTextureDesc.autoGenerateMips = false;
368 | colorPyramidTextureDesc.name = "CameraColorBufferMipChain";
369 | var colorPyramidHandle = renderGraph.CreateTexture(colorPyramidTextureDesc);
370 | builder.UseTexture(colorPyramidHandle, AccessFlags.ReadWrite);
371 |
372 | var hitPointsDesc = new RenderTextureDescriptor(desc.width, desc.height, colorFormat:UnityEngine.Experimental.Rendering.GraphicsFormat.R16G16_UNorm, 0);
373 | hitPointsDesc.enableRandomWrite = true;
374 | hitPointsDesc.sRGB = false;
375 | var hitPointsHandle = UniversalRenderer.CreateRenderGraphTexture(renderGraph, hitPointsDesc, "SSR_Hit_Point_Texture", false);
376 | builder.UseTexture(hitPointsHandle, AccessFlags.ReadWrite);
377 |
378 | var lightingDesc = new RenderTextureDescriptor(desc.width, desc.height, colorFormat:UnityEngine.Experimental.Rendering.GraphicsFormat.R16G16B16A16_SFloat, 0);
379 | lightingDesc.enableRandomWrite = true;
380 | lightingDesc.sRGB = false;
381 | var lightingHandle = UniversalRenderer.CreateRenderGraphTexture(renderGraph, lightingDesc, "SSR_Lighting_Texture", false);
382 | builder.UseTexture(lightingHandle, AccessFlags.ReadWrite);
383 |
384 | m_TracingKernel = passData.settings.screenSpaceReflectionsCS.FindKernel("ScreenSpaceReflectionsTracing");
385 | m_ReprojectionKernel = passData.settings.screenSpaceReflectionsCS.FindKernel("ScreenSpaceReflectionsReprojection");
386 | m_CopyColorKernel = passData.settings.screenSpaceReflectionsCS.FindKernel("CopyColorTarget");
387 |
388 | passData.cb = new ShaderVariablesScreenSpaceReflection();
389 | passData.mipInfo = m_DepthBufferMipChainInfo;
390 | UpdateSSRConstantBuffer(cameraData.camera, passData.settings, ref passData.cb, colorPyramidDesc.mipCount, passData.mipInfo, cameraData.GetViewMatrix(), cameraData.GetProjectionMatrix());
391 | passData.renderingMode = m_RenderingMode;
392 | passData.cameraColorTargetHandle = resourceData.cameraColor;
393 | passData.depthTexture = depthPyramidHandle;
394 | passData.colorTexture = colorPyramidHandle;
395 | passData.hitPointsTexture = hitPointsHandle;
396 | passData.lightingTexture = lightingHandle;
397 | passData.mipGenerator = m_MipGenerator;
398 | passData.offsetBufferData = m_DepthBufferMipChainInfo.GetOffsetBufferData(m_DepthPyramidMipLevelOffsetsBuffer);
399 | passData.tracingKernel = m_TracingKernel;
400 | passData.reprojectionKernel = m_ReprojectionKernel;
401 | passData.copyColorKernel = m_CopyColorKernel;
402 | passData.depthVolumeDepth = depthPyramidDesc.volumeDepth;
403 | var cameraTargetDescriptor = passData.cameraColorTargetHandle.GetDescriptor(renderGraph);
404 | passData.viewportSize = new Vector2Int(cameraTargetDescriptor.width, cameraTargetDescriptor.height);
405 | passData.resolveMat = m_ResolveMat;
406 |
407 | var offsetBufferHandle = renderGraph.ImportBuffer(passData.offsetBufferData);
408 | builder.UseBuffer(offsetBufferHandle, AccessFlags.Read);
409 | builder.SetRenderFunc((RenderGraphPassData data, ComputeGraphContext context) => ExecutePass(context.cmd, data));
410 |
411 | // Use member pass data to transfer blit parameters.
412 | blitParameters.source = passData.lightingTexture;
413 | blitParameters.destination = passData.cameraColorTargetHandle;
414 | blitParameters.material = passData.resolveMat;
415 | }
416 |
417 | using (var builder = renderGraph.AddRasterRenderPass("ScreenSpace Reflection", out var passData))
418 | {
419 | // Resolve
420 | builder.UseTexture(blitParameters.source, AccessFlags.Read);
421 | builder.SetRenderAttachment(blitParameters.destination, 0);
422 | builder.SetRenderFunc((RenderGraphPassData data, RasterGraphContext context) =>
423 | {
424 | if (blitParameters.material != null)
425 | {
426 | Blitter.BlitTexture(context.cmd, blitParameters.source, Vector2.one, blitParameters.material, 0);
427 | }
428 | });
429 | }
430 | }
431 |
432 | private static void ExecutePass(ComputeCommandBuffer cmd, RenderGraphPassData data)
433 | {
434 | var cs = data.settings.screenSpaceReflectionsCS;
435 | if (cs == null)
436 | return;
437 |
438 | using (new ProfilingScope(cmd, new ProfilingSampler("Depth Pyramid")))
439 | {
440 | data.mipGenerator.RenderMinDepthPyramid(cmd, data.depthTexture, data.mipInfo, data.depthVolumeDepth, false);
441 | }
442 |
443 | var deferredKeyword = new LocalKeyword(cs, "SSR_DEFERRED");
444 |
445 | using (new ProfilingScope(cmd, new ProfilingSampler("SSR Tracing")))
446 | {
447 | // Set keyword to use different normal texture based on rendering mode.
448 | cmd.SetKeyword(cs, deferredKeyword, data.renderingMode == RenderingMode.Deferred);
449 |
450 | if (data.renderingMode == RenderingMode.Deferred)
451 | {
452 | cmd.SetComputeTextureParam(cs, data.tracingKernel, "_GBuffer2", data.gBuffer2);
453 | }
454 |
455 | cmd.SetComputeTextureParam(cs, data.tracingKernel, "_DepthPyramidTexture", data.depthTexture);
456 | cmd.SetComputeTextureParam(cs, data.tracingKernel, "_SsrHitPointTexture", data.hitPointsTexture);
457 |
458 | cmd.SetComputeBufferParam(cs, data.tracingKernel, ShaderIDs._DepthPyramidMipLevelOffsets, data.offsetBufferData);
459 |
460 | ConstantBuffer.Push(data.cb, cs, ShaderIDs._ShaderVariablesScreenSpaceReflection);
461 |
462 | cmd.DispatchCompute(cs, data.tracingKernel, SSRUtils.DivRoundUp(data.viewportSize.x, 8), SSRUtils.DivRoundUp(data.viewportSize.y, 8), 1);
463 | }
464 |
465 | using (new ProfilingScope(cmd, new ProfilingSampler("SSR Reprojection")))
466 | {
467 | // Set keyword to use different normal texture based on rendering mode.
468 | cmd.SetKeyword(cs, deferredKeyword, data.renderingMode == RenderingMode.Deferred);
469 |
470 | if (data.renderingMode == RenderingMode.Deferred)
471 | {
472 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, "_GBuffer2", data.gBuffer2);
473 | }
474 |
475 | // Create color mip chain
476 | cmd.SetComputeTextureParam(cs, data.copyColorKernel, ShaderIDs._CameraColorTexture, data.cameraColorTargetHandle);
477 | cmd.SetComputeTextureParam(cs, data.copyColorKernel, ShaderIDs._CopiedColorPyramidTexture, data.colorTexture);
478 | cmd.DispatchCompute(cs, data.copyColorKernel, SSRUtils.DivRoundUp(data.viewportSize.x, 8), SSRUtils.DivRoundUp(data.viewportSize.y, 8), 1);
479 |
480 | RenderTexture rt = data.colorTexture;
481 | rt.GenerateMips();
482 |
483 | // Bind resources
484 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, ShaderIDs._DepthPyramidTexture, data.depthTexture);
485 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, ShaderIDs._ColorPyramidTexture, data.colorTexture);
486 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, ShaderIDs._SsrHitPointTexture, data.hitPointsTexture);
487 | cmd.SetComputeTextureParam(cs, data.reprojectionKernel, ShaderIDs._SSRAccumTexture, data.lightingTexture);
488 |
489 | cmd.SetComputeBufferParam(cs, data.reprojectionKernel, ShaderIDs._DepthPyramidMipLevelOffsets, data.offsetBufferData);
490 |
491 | ConstantBuffer.Push(data.cb, cs, ShaderIDs._ShaderVariablesScreenSpaceReflection);
492 |
493 | cmd.DispatchCompute(cs, data.reprojectionKernel, SSRUtils.DivRoundUp(data.viewportSize.x, 8), SSRUtils.DivRoundUp(data.viewportSize.y, 8), 1);
494 | }
495 | }
496 |
497 | private class RenderGraphPassData
498 | {
499 | public ScreenSpaceReflectionSettings settings;
500 | public ShaderVariablesScreenSpaceReflection cb;
501 | public RenderingMode renderingMode;
502 | public TextureHandle cameraColorTargetHandle;
503 | public TextureHandle depthTexture;
504 | public TextureHandle colorTexture;
505 | public TextureHandle hitPointsTexture;
506 | public TextureHandle lightingTexture;
507 | public TextureHandle gBuffer2;
508 | public SSRUtils.PackedMipChainInfo mipInfo;
509 | public MipGenerator mipGenerator;
510 | public GraphicsBuffer offsetBufferData;
511 | public int tracingKernel;
512 | public int reprojectionKernel;
513 | public int copyColorKernel;
514 | public int depthVolumeDepth;
515 | public Vector2Int viewportSize;
516 | public Material resolveMat;
517 | }
518 | #endregion
519 | #endif
520 | }
521 | }
522 | }
523 |
--------------------------------------------------------------------------------
/Runtime/ScreenSpaceReflection.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 31ec43bb34e3ff542892e0b797881487
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences:
7 | - settings: {fileID: 11400000, guid: 46315cf78a9f9024fbf58a12c57c16be, type: 2}
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Runtime/ScreenSpaceReflectionSettings.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.Rendering;
3 |
4 | namespace UniversalScreenSpaceReflection
5 | {
6 | [CreateAssetMenu(menuName = "UniversalSSR/Settings")]
7 | public class ScreenSpaceReflectionSettings : ScriptableObject
8 | {
9 | [Header("Shaders")]
10 | public ComputeShader depthPyramidCS;
11 | public ComputeShader screenSpaceReflectionsCS;
12 |
13 | [Header("General")]
14 | [Tooltip("Enable Screen Space Reflections.")]
15 | public bool enabled = true;
16 |
17 | [Range(0.0f, 1.0f)] public float minSmoothness = 0.5f;
18 | [Range(0.0f, 1.0f)] public float smoothnessFadeStart = 0.9f;
19 |
20 | [Header("Ray Marching")]
21 | ///
22 | /// When enabled, SSR handles sky reflection for opaque objects (not supported for SSR on transparent).
23 | ///
24 | public bool reflectSky = true;
25 |
26 | // SSR Data
27 | ///
28 | /// Controls the distance at which URP fades out SSR near the edge of the screen.
29 | ///
30 | [Range(0.0f, 1.0f)] public float objectThickness = 0.01f;
31 |
32 | ///
33 | /// Controls the typical thickness of objects the reflection rays may pass behind.
34 | ///
35 | [Range(0.0f, 1.0f)] public float screenFadeDistance = 0.1f;
36 |
37 | [Range(0, 512)] public int rayMaxIterations = 256;
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Runtime/ScreenSpaceReflectionSettings.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 30369b8245cc3f840832c23fcf73be90
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences:
7 | - depthPyramidCS: {fileID: 7200000, guid: f16d03b7874a24f418713cda8a6ca007, type: 3}
8 | - screenSpaceReflectionsCS: {fileID: 7200000, guid: f0f28b04d94cb664398e3e0cac4dc8a6, type: 3}
9 | executionOrder: 0
10 | icon: {instanceID: 0}
11 | userData:
12 | assetBundleName:
13 | assetBundleVariant:
14 |
--------------------------------------------------------------------------------
/Runtime/ShaderIDs.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace UniversalScreenSpaceReflection
4 | {
5 | internal static class ShaderIDs
6 | {
7 | public static readonly int _DepthPyramidMipLevelOffsets = Shader.PropertyToID("_DepthPyramidMipLevelOffsets");
8 | public static readonly int _SrcOffsetAndLimit = Shader.PropertyToID("_SrcOffsetAndLimit");
9 | public static readonly int _DstOffset = Shader.PropertyToID("_DstOffset");
10 | public static readonly int _DepthMipChain = Shader.PropertyToID("_DepthMipChain");
11 |
12 | public static readonly int _ShaderVariablesScreenSpaceReflection = Shader.PropertyToID("_ShaderVariablesScreenSpaceReflection");
13 | public static readonly int _DepthPyramidTexture = Shader.PropertyToID("_DepthPyramidTexture");
14 | public static readonly int _ColorPyramidTexture = Shader.PropertyToID("_ColorPyramidTexture");
15 | public static readonly int _SsrHitPointTexture = Shader.PropertyToID("_SsrHitPointTexture");
16 | public static readonly int _SSRAccumTexture = Shader.PropertyToID("_SSRAccumTexture");
17 |
18 | public static readonly int _CameraColorTexture = Shader.PropertyToID("_CameraColorTexture");
19 | public static readonly int _CopiedColorPyramidTexture = Shader.PropertyToID("_CopiedColorPyramidTexture");
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Runtime/ShaderIDs.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 935430c0b444e1f4d8669c3309df2f60
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/ShaderVariablesScreenSpaceReflection.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace UniversalScreenSpaceReflection
4 | {
5 | internal struct ShaderVariablesScreenSpaceReflection
6 | {
7 | public float _SsrThicknessScale;
8 | public float _SsrThicknessBias;
9 | public int _SsrIterLimit;
10 | public int _SsrPad0_;
11 |
12 | public float _SsrRoughnessFadeEnd;
13 | public float _SsrRoughnessFadeRcpLength;
14 | public float _SsrRoughnessFadeEndTimesRcpLength;
15 | public float _SsrEdgeFadeRcpLength;
16 |
17 | public int _SsrDepthPyramidMaxMip;
18 | public int _SsrColorPyramidMaxMip;
19 | public int _SsrReflectsSky;
20 | public int _SsrPad1_;
21 |
22 | public Matrix4x4 _CameraViewProjMatrix;
23 | public Matrix4x4 _InvCameraViewProjMatrix;
24 | // public Vector4 _ColorPyramidUvScaleAndLimitPrevFrame;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Runtime/ShaderVariablesScreenSpaceReflection.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2a17ddc1192988a4fab3a2f9f6caaa50
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/Shaders.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9a05b7e63df29b54abb8c431140e310c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/Shaders/Common.hlsl:
--------------------------------------------------------------------------------
1 | #ifndef SSR_TEXTURECOMMON_INCLUDED
2 | #define SSR_TEXTURECOMMON_INCLUDED
3 |
4 | #if defined(UNITY_TEXTURE2D_X_ARRAY_SUPPORTED)
5 | #define COORD_TEXTURE2D_X(pixelCoord) uint3(pixelCoord, SLICE_ARRAY_INDEX)
6 | #define RW_TEXTURE2D_X(type, textureName) RW_TEXTURE2D_ARRAY(type, textureName)
7 | #else
8 | #define COORD_TEXTURE2D_X(pixelCoord) pixelCoord
9 | #define RW_TEXTURE2D_X RW_TEXTURE2D
10 | #endif
11 |
12 | #endif
--------------------------------------------------------------------------------
/Runtime/Shaders/Common.hlsl.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 07211ecb6d136f541a6ba99e313f0826
3 | ShaderIncludeImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/Shaders/DepthPyramid.compute:
--------------------------------------------------------------------------------
1 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
2 | #include "./Common.hlsl"
3 |
4 | #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
5 |
6 | #pragma kernel KCopyDepthTextureToMipChain KERNEL_SIZE=8
7 | #pragma kernel KDepthDownsample8DualUav KERNEL_SIZE=8 KERNEL_NAME=KDepthDownsample8DualUav
8 |
9 | TEXTURE2D_X(_CameraDepthTexture);
10 | RW_TEXTURE2D_X(float, _DepthMipChain);
11 |
12 | CBUFFER_START(DepthPyramid)
13 | uint4 _SrcOffsetAndLimit; // {x, y, w - 1, h - 1}
14 | uint4 _DstOffset; // {x, y, 0, 0}
15 | CBUFFER_END
16 |
17 | #if UNITY_REVERSED_Z
18 | # define MIN_DEPTH(l, r) max(l, r)
19 | #else
20 | # define MIN_DEPTH(l, r) min(l, r)
21 | #endif
22 |
23 | [numthreads(KERNEL_SIZE, KERNEL_SIZE, 1)]
24 | void KCopyDepthTextureToMipChain(uint3 dispatchThreadId : SV_DispatchThreadID)
25 | {
26 | _DepthMipChain[dispatchThreadId.xy].r = _CameraDepthTexture[dispatchThreadId.xy].r;
27 | }
28 |
29 | // Downsample a depth texture by taking the min value of sampled pixels
30 | // The size of the dispatch is (DstMipSize / KernelSize).
31 | [numthreads(KERNEL_SIZE, KERNEL_SIZE, 1)]
32 | void KERNEL_NAME(uint3 dispatchThreadId : SV_DispatchThreadID)
33 | {
34 | // UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
35 |
36 | uint2 srcOffset = _SrcOffsetAndLimit.xy;
37 | uint2 srcLimit = _SrcOffsetAndLimit.zw;
38 | uint2 dstOffset = _DstOffset.xy;
39 |
40 | // Upper-left pixel coordinate of quad that this thread will read
41 | uint2 srcPixelUL = srcOffset + (dispatchThreadId.xy << 1);
42 |
43 | float p00 = _DepthMipChain[COORD_TEXTURE2D_X(min(srcPixelUL + uint2(0u, 0u), srcLimit))];
44 | float p10 = _DepthMipChain[COORD_TEXTURE2D_X(min(srcPixelUL + uint2(1u, 0u), srcLimit))];
45 | float p01 = _DepthMipChain[COORD_TEXTURE2D_X(min(srcPixelUL + uint2(0u, 1u), srcLimit))];
46 | float p11 = _DepthMipChain[COORD_TEXTURE2D_X(min(srcPixelUL + uint2(1u, 1u), srcLimit))];
47 | float4 depths = float4(p00, p10, p01, p11);
48 |
49 | // Select the closest sample
50 | float minDepth = MIN_DEPTH(MIN_DEPTH(depths.x, depths.y), MIN_DEPTH(depths.z, depths.w));
51 |
52 | _DepthMipChain[COORD_TEXTURE2D_X(dstOffset + dispatchThreadId.xy)] = minDepth;
53 | }
54 |
55 | #undef MIN_DEPTH
56 |
--------------------------------------------------------------------------------
/Runtime/Shaders/DepthPyramid.compute.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f16d03b7874a24f418713cda8a6ca007
3 | ComputeShaderImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/Shaders/NormalBuffer.hlsl:
--------------------------------------------------------------------------------
1 | #ifndef SSR_NORMAL_BUFFER_INCLUDED
2 | #define SSR_NORMAL_BUFFER_INCLUDED
3 |
4 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Packing.hlsl"
5 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
6 |
7 | // ----------------------------------------------------------------------------
8 | // Encoding/decoding normal buffer functions
9 | // ----------------------------------------------------------------------------
10 |
11 | struct NormalData
12 | {
13 | float3 normalWS;
14 | float perceptualRoughness;
15 | };
16 |
17 | // NormalBuffer texture declaration
18 | #ifdef SSR_DEFERRED
19 | TEXTURE2D_X_HALF(_GBuffer2);
20 | #define LOAD_NORMAL_TEXTURE2D(positionSS) LOAD_TEXTURE2D_X(_GBuffer2, positionSS)
21 | #else
22 | TEXTURE2D_X_FLOAT(_CameraNormalsTexture);
23 | #define LOAD_NORMAL_TEXTURE2D(positionSS) LOAD_TEXTURE2D_X(_CameraNormalsTexture, positionSS)
24 | #endif
25 |
26 | void EncodeIntoNormalBuffer(NormalData normalData, out float4 outNormalBuffer0)
27 | {
28 | #if defined(_GBUFFER_NORMALS_OCT)
29 | // The sign of the Z component of the normal MUST round-trip through the G-Buffer, otherwise
30 | // the reconstruction of the tangent frame for anisotropic GGX creates a seam along the Z axis.
31 | // The constant was eye-balled to not cause artifacts.
32 | // TODO: find a proper solution. E.g. we could re-shuffle the faces of the octahedron
33 | // s.t. the sign of the Z component round-trips.
34 | const float seamThreshold = 1.0 / 1024.0;
35 | normalData.normalWS.z = CopySign(max(seamThreshold, abs(normalData.normalWS.z)), normalData.normalWS.z);
36 |
37 | // RT1 - 8:8:8:8
38 | // Our tangent encoding is based on our normal.
39 | float2 octNormalWS = PackNormalOctQuadEncode(normalData.normalWS);
40 | float3 packNormalWS = PackFloat2To888(saturate(octNormalWS * 0.5 + 0.5));
41 | // We store perceptualRoughness instead of roughness because it is perceptually linear.
42 | outNormalBuffer0 = float4(packNormalWS, normalData.perceptualRoughness);
43 | #else
44 | outNormalBuffer0 = float4(normalData.normalWS, normalData.perceptualRoughness);
45 | #endif
46 | }
47 |
48 | void DecodeFromNormalBuffer(float4 normalBuffer, out NormalData normalData)
49 | {
50 | #if defined(_GBUFFER_NORMALS_OCT)
51 | float3 packNormalWS = normalBuffer.rgb;
52 | float2 octNormalWS = Unpack888ToFloat2(packNormalWS);
53 | normalData.normalWS = UnpackNormalOctQuadEncode(octNormalWS * 2.0 - 1.0);
54 | #else
55 | normalData.normalWS = normalBuffer.rgb;
56 | #endif
57 | normalData.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(normalBuffer.a); // Since GBuffer2 or _CameraNormalsTexture.a = smoothness, convert to roughness.
58 | }
59 |
60 | void DecodeFromNormalBuffer(uint2 positionSS, out NormalData normalData)
61 | {
62 | float4 normalBuffer = LOAD_NORMAL_TEXTURE2D(positionSS);
63 | DecodeFromNormalBuffer(normalBuffer, normalData);
64 | }
65 |
66 | #endif // SSR_NORMAL_BUFFER_INCLUDED
67 |
--------------------------------------------------------------------------------
/Runtime/Shaders/NormalBuffer.hlsl.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: da664fa890d036a45b2723bed560b0e5
3 | ShaderIncludeImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/Shaders/ScreenSpaceReflectionResolver.shader:
--------------------------------------------------------------------------------
1 | Shader "Hidden/SSR_Resolver"
2 | {
3 | SubShader
4 | {
5 | // No culling or depth
6 | Cull Off ZWrite Off ZTest Never
7 |
8 | Pass
9 | {
10 | Name "SSR Resolve"
11 |
12 | Blend One One
13 | BlendOp Add
14 |
15 | HLSLPROGRAM
16 | #pragma vertex Vert
17 | #pragma fragment frag
18 |
19 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
20 | #include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
21 |
22 | half4 frag(Varyings input) : SV_Target
23 | {
24 | float2 uv = input.texcoord;
25 | half3 color = SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_LinearClamp, uv).xyz;
26 |
27 | return half4(color, 0);
28 | }
29 | ENDHLSL
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Runtime/Shaders/ScreenSpaceReflectionResolver.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a4489dfb62c35df4a92c3cff7cd5eca6
3 | ShaderImporter:
4 | externalObjects: {}
5 | defaultTextures: []
6 | nonModifiableTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Runtime/Shaders/ScreenSpaceReflections.compute:
--------------------------------------------------------------------------------
1 |
2 | // Definitions
3 | //--------------------------------------------------------------------------------------------------
4 |
5 | // #pragma enable_d3d11_debug_symbols
6 | #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
7 |
8 | #pragma kernel ScreenSpaceReflectionsTracing SSR_TRACE
9 | #pragma kernel ScreenSpaceReflectionsReprojection SSR_REPROJECT
10 | #pragma kernel CopyColorTarget SSR_COPYCOLOR
11 |
12 | #pragma multi_compile_local _ USE_MOTION_VECTOR // TODO: enabled this if URP > 16.0 or exclude for performance.
13 | #pragma multi_compile_local _ SSR_DEFERRED
14 |
15 | // Tweak parameters.
16 | // #define DEBUG
17 | #define SSR_TRACE_BEHIND_OBJECTS
18 | #define SSR_TRACE_TOWARDS_EYE
19 |
20 | #define SSR_TRACE_EPS 0.000488281f // 2^-11, should be good up to 4K
21 | #define MIN_GGX_ROUGHNESS 0.00001f
22 | #define MAX_GGX_ROUGHNESS 0.99999f
23 |
24 | //--------------------------------------------------------------------------------------------------
25 | // Included headers
26 | //--------------------------------------------------------------------------------------------------
27 |
28 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
29 | #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
30 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderVariablesFunctions.hlsl"
31 | #include "./ShaderVariablesScreenSpaceReflection.hlsl"
32 | #include "./Common.hlsl"
33 | #include "./NormalBuffer.hlsl"
34 |
35 | //--------------------------------------------------------------------------------------------------
36 | // Inputs & outputs
37 | //--------------------------------------------------------------------------------------------------
38 |
39 | // For opaque we do the following operation:
40 | // - Render opaque object in depth buffer
41 | // - Generate depth pyramid from opaque depth buffer
42 | // - Trigger ray from position recover from depth pyramid and raymarch with depth pyramid
43 | // For transparent reflection we chose to not regenerate a depth pyramid to save performance. So we have
44 | // - Generate depth pyramid from opaque depth buffer
45 | // - Trigger ray from position recover from depth buffer (use depth pyramid) and raymarch with depth pyramid
46 | // - Render transparent object with reflection in depth buffer in transparent prepass
47 | // - Trigger ray from position recover from new depth buffer and raymarch with opaque depth pyramid
48 | // So we need a seperate texture for the mip chain and for the depth source when doing the transprent reflection
49 | TEXTURE2D_X(_DepthPyramidTexture);
50 | TEXTURE2D_X(_ColorPyramidTexture);
51 | SAMPLER(s_trilinear_clamp_sampler);
52 |
53 | #ifdef SSR_TRACE
54 | RW_TEXTURE2D_X(float2, _SsrHitPointTexture);
55 | #elif defined(SSR_REPROJECT)
56 | TEXTURE2D_X( _SsrHitPointTexture);
57 | RW_TEXTURE2D_X(float4, _SSRAccumTexture);
58 | #elif defined(SSR_COPYCOLOR)
59 | TEXTURE2D_X( _CameraColorTexture);
60 | RW_TEXTURE2D_X(float4, _CopiedColorPyramidTexture);
61 | #endif
62 |
63 | StructuredBuffer _DepthPyramidMipLevelOffsets;
64 |
65 | //--------------------------------------------------------------------------------------------------
66 | // Helpers
67 | //--------------------------------------------------------------------------------------------------
68 |
69 | float PerceptualRoughnessFade(float perceptualRoughness, float fadeRcpLength, float fadeEndTimesRcpLength)
70 | {
71 | float t = Remap10(perceptualRoughness, fadeRcpLength, fadeEndTimesRcpLength);
72 | return Smoothstep01(t);
73 | }
74 |
75 | void GetNormalAndPerceptualRoughness(uint2 positionSS, out float3 normalWS, out float perceptualRoughness)
76 | {
77 | // Load normal and perceptualRoughness.
78 | NormalData normalData;
79 | DecodeFromNormalBuffer(positionSS, normalData);
80 | normalWS = normalData.normalWS;
81 | perceptualRoughness = normalData.perceptualRoughness;
82 | }
83 |
84 | // Performs fading at the edge of the screen.
85 | float EdgeOfScreenFade(float2 coordNDC, float fadeRcpLength)
86 | {
87 | float2 coordCS = coordNDC * 2 - 1;
88 | float2 t = Remap10(abs(coordCS), fadeRcpLength, fadeRcpLength);
89 | return Smoothstep01(t.x) * Smoothstep01(t.y);
90 | }
91 |
92 | void WriteDebugInfo(uint2 positionSS, float4 value)
93 | {
94 | // #ifdef DEBUG
95 | // _SsrDebugTexture[positionSS] = value;
96 | // #endif
97 | }
98 |
99 | //--------------------------------------------------------------------------------------------------
100 | // Implementation
101 | //--------------------------------------------------------------------------------------------------
102 |
103 | #ifdef SSR_TRACE
104 |
105 | [numthreads(8, 8, 1)]
106 | void ScreenSpaceReflectionsTracing(uint3 groupId : SV_GroupID,
107 | uint3 dispatchThreadId : SV_DispatchThreadID)
108 | {
109 | // UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
110 | uint2 positionSS = dispatchThreadId.xy;
111 | _SsrHitPointTexture[COORD_TEXTURE2D_X(positionSS)] = 0; // clear
112 |
113 | NormalData normalData;
114 | DecodeFromNormalBuffer(positionSS, normalData);
115 |
116 | float deviceDepth = LOAD_TEXTURE2D_X(_DepthPyramidTexture, positionSS).r;
117 |
118 | float2 positionNDC = positionSS * _ScreenSize.zw + (0.5 * _ScreenSize.zw); // Should we precompute the half-texel bias? We seem to use it a lot.
119 | float3 positionWS = ComputeWorldSpacePosition(positionNDC, deviceDepth, _InvCameraViewProjMatrix); // Jittered
120 | float3 V = GetWorldSpaceNormalizeViewDir(positionWS);
121 |
122 | float3 N;
123 | float perceptualRoughness;
124 | GetNormalAndPerceptualRoughness(positionSS, N, perceptualRoughness);
125 |
126 | float3 R = reflect(-V, N);
127 |
128 | float3 camPosWS = GetCurrentViewPosition();
129 |
130 | // Apply normal bias with the magnitude dependent on the distance from the camera.
131 | // Unfortunately, we only have access to the shading normal, which is less than ideal...
132 | positionWS = camPosWS + (positionWS - camPosWS) * (1 - 0.001 * rcp(max(dot(N, V), FLT_EPS)));
133 | deviceDepth = ComputeNormalizedDeviceCoordinatesWithZ(positionWS, _CameraViewProjMatrix).z;
134 | bool killRay = deviceDepth == UNITY_RAW_FAR_CLIP_VALUE;
135 |
136 | // Ref. #1: Michal Drobot - Quadtree Displacement Mapping with Height Blending.
137 | // Ref. #2: Yasin Uludag - Hi-Z Screen-Space Cone-Traced Reflections.
138 | // Ref. #3: Jean-Philippe Grenier - Notes On Screen Space HIZ Tracing.
139 | // Warning: virtually all of the code below assumes reverse Z.
140 |
141 | // We start tracing from the center of the current pixel, and do so up to the far plane.
142 | float3 rayOrigin = float3(positionSS + 0.5, deviceDepth);
143 |
144 | float3 reflPosWS = positionWS + R;
145 | float3 reflPosNDC = ComputeNormalizedDeviceCoordinatesWithZ(reflPosWS, _CameraViewProjMatrix); // Jittered
146 | float3 reflPosSS = float3(reflPosNDC.xy * _ScreenSize.xy, reflPosNDC.z);
147 | float3 rayDir = reflPosSS - rayOrigin;
148 | float3 rcpRayDir = rcp(rayDir);
149 | int2 rayStep = int2(rcpRayDir.x >= 0 ? 1 : 0,
150 | rcpRayDir.y >= 0 ? 1 : 0);
151 | float3 raySign = float3(rcpRayDir.x >= 0 ? 1 : -1,
152 | rcpRayDir.y >= 0 ? 1 : -1,
153 | rcpRayDir.z >= 0 ? 1 : -1);
154 | bool rayTowardsEye = rcpRayDir.z >= 0;
155 |
156 | // Note that we don't need to store or read the perceptualRoughness value
157 | // if we mark stencil during the G-Buffer pass with pixels which should receive SSR,
158 | // and sample the color pyramid during the lighting pass.
159 | killRay = killRay || (reflPosSS.z <= 0);
160 | killRay = killRay || (dot(N, V) <= 0);
161 | killRay = killRay || (perceptualRoughness > _SsrRoughnessFadeEnd);
162 | #ifndef SSR_TRACE_TOWARDS_EYE
163 | killRay = killRay || rayTowardsEye;
164 | #endif
165 |
166 | if (killRay)
167 | {
168 | WriteDebugInfo(positionSS, -1);
169 | return;
170 | }
171 |
172 | // Extend and clip the end point to the frustum.
173 | float tMax;
174 | {
175 | // Shrink the frustum by half a texel for efficiency reasons.
176 | const float halfTexel = 0.5;
177 |
178 | float3 bounds;
179 | bounds.x = (rcpRayDir.x >= 0) ? _ScreenSize.x - halfTexel : halfTexel;
180 | bounds.y = (rcpRayDir.y >= 0) ? _ScreenSize.y - halfTexel : halfTexel;
181 | // If we do not want to intersect the skybox, it is more efficient to not trace too far.
182 | float maxDepth = (_SsrReflectsSky != 0) ? -0.00000024 : 0.00000024; // 2^-22
183 | bounds.z = (rcpRayDir.z >= 0) ? 1 : maxDepth;
184 |
185 | float3 dist = bounds * rcpRayDir - (rayOrigin * rcpRayDir);
186 | tMax = Min3(dist.x, dist.y, dist.z);
187 | }
188 |
189 | // Clamp the MIP level to give the compiler more information to optimize.
190 | const int maxMipLevel = min(_SsrDepthPyramidMaxMip, 14);
191 |
192 | // Start ray marching from the next texel to avoid self-intersections.
193 | float t;
194 | {
195 | // 'rayOrigin' is the exact texel center.
196 | float2 dist = abs(0.5 * rcpRayDir.xy);
197 | t = min(dist.x, dist.y);
198 | }
199 |
200 | float3 rayPos;
201 |
202 | int mipLevel = 0;
203 | int iterCount = 0;
204 | bool hit = false;
205 | bool miss = false;
206 | bool belowMip0 = false; // This value is set prior to entering the cell
207 |
208 | while (!(hit || miss) && (t <= tMax) && (iterCount < _SsrIterLimit))
209 | {
210 | rayPos = rayOrigin + t * rayDir;
211 |
212 | // Ray position often ends up on the edge. To determine (and look up) the right cell,
213 | // we need to bias the position by a small epsilon in the direction of the ray.
214 | float2 sgnEdgeDist = round(rayPos.xy) - rayPos.xy;
215 | float2 satEdgeDist = clamp(raySign.xy * sgnEdgeDist + SSR_TRACE_EPS, 0, SSR_TRACE_EPS);
216 | rayPos.xy += raySign.xy * satEdgeDist;
217 |
218 | int2 mipCoord = (int2)rayPos.xy >> mipLevel;
219 | int2 mipOffset = _DepthPyramidMipLevelOffsets[mipLevel];
220 | // Bounds define 4 faces of a cube:
221 | // 2 walls in front of the ray, and a floor and a base below it.
222 | float4 bounds;
223 |
224 | bounds.xy = (mipCoord + rayStep) << mipLevel;
225 | bounds.z = LOAD_TEXTURE2D_X(_DepthPyramidTexture, mipOffset + mipCoord).r;
226 |
227 | // We define the depth of the base as the depth value as:
228 | // b = DeviceDepth((1 + thickness) * LinearDepth(d))
229 | // b = ((f - n) * d + n * (1 - (1 + thickness))) / ((f - n) * (1 + thickness))
230 | // b = ((f - n) * d - n * thickness) / ((f - n) * (1 + thickness))
231 | // b = d / (1 + thickness) - n / (f - n) * (thickness / (1 + thickness))
232 | // b = d * k_s + k_b
233 | bounds.w = bounds.z * _SsrThicknessScale + _SsrThicknessBias;
234 |
235 | float4 dist = bounds * rcpRayDir.xyzz - (rayOrigin.xyzz * rcpRayDir.xyzz);
236 | float distWall = min(dist.x, dist.y);
237 | float distFloor = dist.z;
238 | float distBase = dist.w;
239 |
240 | // Note: 'rayPos' given by 't' can correspond to one of several depth values:
241 | // - above or exactly on the floor
242 | // - inside the floor (between the floor and the base)
243 | // - below the base
244 | #if 0
245 | bool belowFloor = (raySign.z * (t - distFloor)) < 0;
246 | bool aboveBase = (raySign.z * (t - distBase )) >= 0;
247 | #else
248 | bool belowFloor = rayPos.z < bounds.z;
249 | bool aboveBase = rayPos.z >= bounds.w;
250 | #endif
251 | bool insideFloor = belowFloor && aboveBase;
252 | bool hitFloor = (t <= distFloor) && (distFloor <= distWall);
253 |
254 | // Game rules:
255 | // * if the closest intersection is with the wall of the cell, switch to the coarser MIP, and advance the ray.
256 | // * if the closest intersection is with the heightmap below, switch to the finer MIP, and advance the ray.
257 | // * if the closest intersection is with the heightmap above, switch to the finer MIP, and do NOT advance the ray.
258 | // Victory conditions:
259 | // * See below. Do NOT reorder the statements!
260 |
261 | #ifdef SSR_TRACE_BEHIND_OBJECTS
262 | miss = belowMip0 && insideFloor;
263 | #else
264 | miss = belowMip0;
265 | #endif
266 | hit = (mipLevel == 0) && (hitFloor || insideFloor);
267 | belowMip0 = (mipLevel == 0) && belowFloor;
268 |
269 | // 'distFloor' can be smaller than the current distance 't'.
270 | // We can also safely ignore 'distBase'.
271 | // If we hit the floor, it's always safe to jump there.
272 | // If we are at (mipLevel != 0) and we are below the floor, we should not move.
273 | t = hitFloor ? distFloor : (((mipLevel != 0) && belowFloor) ? t : distWall);
274 | rayPos.z = bounds.z; // Retain the depth of the potential intersection
275 |
276 | // Warning: both rays towards the eye, and tracing behind objects has linear
277 | // rather than logarithmic complexity! This is due to the fact that we only store
278 | // the maximum value of depth, and not the min-max.
279 | mipLevel += (hitFloor || belowFloor || rayTowardsEye) ? -1 : 1;
280 | mipLevel = clamp(mipLevel, 0, maxMipLevel);
281 |
282 | // mipLevel = 0;
283 |
284 | iterCount++;
285 | }
286 |
287 | // Treat intersections with the sky as misses.
288 | miss = miss || ((_SsrReflectsSky == 0) && (rayPos.z == 0));
289 | hit = hit && !miss;
290 |
291 | if (hit)
292 | {
293 | // Note that we are using 'rayPos' from the penultimate iteration, rather than
294 | // recompute it using the last value of 't', which would result in an overshoot.
295 | // It also needs to be precisely at the center of the pixel to avoid artifacts.
296 | float2 hitPositionNDC = floor(rayPos.xy) * _ScreenSize.zw + (0.5 * _ScreenSize.zw); // Should we precompute the half-texel bias? We seem to use it a lot.
297 | _SsrHitPointTexture[COORD_TEXTURE2D_X(positionSS)] = hitPositionNDC.xy;
298 | }
299 |
300 | // If we do not hit anything, 'rayPos.xy' provides an indication where we stopped the search.
301 | WriteDebugInfo(positionSS, float4(rayPos.xy, iterCount, hit ? 1 : 0));
302 | }
303 |
304 | #elif defined(SSR_REPROJECT)
305 |
306 | // NOTE) Technically, unlike HDRP, it does not use reprojection technique.
307 | [numthreads(8, 8, 1)]
308 | void ScreenSpaceReflectionsReprojection(uint3 dispatchThreadId : SV_DispatchThreadID)
309 | {
310 | // UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z);
311 |
312 | const uint2 positionSS0 = dispatchThreadId.xy;
313 | _SSRAccumTexture[COORD_TEXTURE2D_X(positionSS0)] = 0; // clear
314 |
315 | float3 N;
316 | float perceptualRoughness;
317 | GetNormalAndPerceptualRoughness(positionSS0, N, perceptualRoughness);
318 |
319 | // Compute the actual roughness
320 | float roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
321 | roughness = clamp(roughness, MIN_GGX_ROUGHNESS, MAX_GGX_ROUGHNESS);
322 |
323 | float2 hitPositionNDC = LOAD_TEXTURE2D_X(_SsrHitPointTexture, positionSS0).xy;
324 |
325 | if (max(hitPositionNDC.x, hitPositionNDC.y) == 0)
326 | {
327 | // Miss.
328 | return;
329 | }
330 |
331 | // float depthOrigin = LOAD_TEXTURE2D_X(_DepthPyramidTexture, positionSS0.xy).r;
332 |
333 | // PositionInputs posInputOrigin = GetPositionInput(positionSS0.xy, _ScreenSize.zw, depthOrigin, _InvCameraViewProjMatrix, UNITY_MATRIX_V, uint2(8, 8));
334 | // float3 originWS = posInputOrigin.positionWS + _WorldSpaceCameraPos;
335 |
336 | #ifdef USE_MOTION_VECTOR // TODO
337 | #define _RTHandleScale float2(1, 1)
338 |
339 | // TODO: this texture is sparse (mostly black). Can we avoid reading every texel? How about using Hi-S?
340 | float2 motionVectorNDC;
341 | DecodeMotionVector(SAMPLE_TEXTURE2D_X_LOD(_CameraMotionVectorsTexture, s_linear_clamp_sampler, min(hitPositionNDC, 1.0f - 0.5f * _ScreenSize.zw) * _RTHandleScale.xy, 0), motionVectorNDC);
342 | float2 prevFrameNDC = hitPositionNDC - motionVectorNDC;
343 | #undef _RTHandleScale
344 | #else
345 | float2 prevFrameNDC = hitPositionNDC;
346 | #endif
347 |
348 | // float2 prevFrameUV = prevFrameNDC * _ColorPyramidUvScaleAndLimitPrevFrame.xy;
349 | float2 prevFrameUV = prevFrameNDC;
350 |
351 | // TODO: filtering is quite awful. Needs to be non-Gaussian, bilateral and anisotropic.
352 | float mipLevel = lerp(0, _SsrColorPyramidMaxMip, perceptualRoughness);
353 |
354 | // float2 diffLimit = _ColorPyramidUvScaleAndLimitPrevFrame.xy - _ColorPyramidUvScaleAndLimitPrevFrame.zw;
355 | // float2 diffLimitMipAdjusted = diffLimit * pow(2.0,1.5 + ceil(abs(mipLevel)));
356 | // float2 limit = _ColorPyramidUvScaleAndLimitPrevFrame.xy - diffLimitMipAdjusted;
357 | // if (any(prevFrameUV < float2(0.0,0.0)) || any(prevFrameUV > limit))
358 | // {
359 | // // Off-Screen.
360 | // return;
361 | // }
362 | float opacity = EdgeOfScreenFade(prevFrameNDC, _SsrEdgeFadeRcpLength)
363 | * PerceptualRoughnessFade(perceptualRoughness, _SsrRoughnessFadeRcpLength, _SsrRoughnessFadeEndTimesRcpLength);
364 |
365 |
366 | // Note that the color pyramid uses it's own viewport scale, since it lives on the camera.
367 | float3 color = SAMPLE_TEXTURE2D_X_LOD(_ColorPyramidTexture, s_trilinear_clamp_sampler, prevFrameUV, mipLevel).rgb;
368 |
369 | // Disable SSR for negative, infinite and NaN history values.
370 | uint3 intCol = asuint(color);
371 | bool isPosFin = Max3(intCol.r, intCol.g, intCol.b) < 0x7F800000;
372 |
373 | color = isPosFin ? color : 0;
374 | opacity = isPosFin ? opacity : 0;
375 |
376 | _SSRAccumTexture[COORD_TEXTURE2D_X(positionSS0)] = float4(color, 1.0f) * opacity;
377 |
378 | }
379 |
380 | #elif defined(SSR_COPYCOLOR)
381 |
382 | [numthreads(8, 8, 1)]
383 | void CopyColorTarget(uint3 dispatchThreadId : SV_DispatchThreadID)
384 | {
385 | uint2 positionSS = dispatchThreadId.xy;
386 | _CopiedColorPyramidTexture[COORD_TEXTURE2D_X(positionSS)] = LOAD_TEXTURE2D_X(_CameraColorTexture, positionSS);
387 | }
388 |
389 | #endif
390 |
391 | #undef MIN_GGX_ROUGHNESS
392 | #undef MAX_GGX_ROUGHNESS
393 |
--------------------------------------------------------------------------------
/Runtime/Shaders/ScreenSpaceReflections.compute.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f0f28b04d94cb664398e3e0cac4dc8a6
3 | ComputeShaderImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/Shaders/ShaderVariablesScreenSpaceReflection.hlsl:
--------------------------------------------------------------------------------
1 | #ifndef SHADERVARIABLESSCREENSPACEREFLECTION_HLSL
2 | #define SHADERVARIABLESSCREENSPACEREFLECTION_HLSL
3 |
4 | CBUFFER_START(_ShaderVariablesScreenSpaceReflection)
5 | float _SsrThicknessScale;
6 | float _SsrThicknessBias;
7 | int _SsrIterLimit;
8 | int _SsrPad0_;
9 | float _SsrRoughnessFadeEnd;
10 | float _SsrRoughnessFadeRcpLength;
11 | float _SsrRoughnessFadeEndTimesRcpLength;
12 | float _SsrEdgeFadeRcpLength;
13 | int _SsrDepthPyramidMaxMip;
14 | int _SsrColorPyramidMaxMip;
15 | int _SsrReflectsSky;
16 | int _SsrPad1_;
17 | float4x4 _CameraViewProjMatrix;
18 | float4x4 _InvCameraViewProjMatrix;
19 | // float4 _ColorPyramidUvScaleAndLimitPrevFrame;
20 | CBUFFER_END
21 |
22 |
23 | #endif
24 |
--------------------------------------------------------------------------------
/Runtime/Shaders/ShaderVariablesScreenSpaceReflection.hlsl.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 09b93238ce3a2e84baf743e66089ec7e
3 | ShaderIncludeImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Sample.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b6120e7dfde5d6444b4c858461211c7b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Deferred.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a6026a711f00a9a4f8f8bec77681d5a4
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Deferred/Deferred Rendering Sample.unity:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!29 &1
4 | OcclusionCullingSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_OcclusionBakeSettings:
8 | smallestOccluder: 5
9 | smallestHole: 0.25
10 | backfaceThreshold: 100
11 | m_SceneGUID: 00000000000000000000000000000000
12 | m_OcclusionCullingData: {fileID: 0}
13 | --- !u!104 &2
14 | RenderSettings:
15 | m_ObjectHideFlags: 0
16 | serializedVersion: 9
17 | m_Fog: 0
18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19 | m_FogMode: 3
20 | m_FogDensity: 0.01
21 | m_LinearFogStart: 0
22 | m_LinearFogEnd: 300
23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26 | m_AmbientIntensity: 1
27 | m_AmbientMode: 0
28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
30 | m_HaloStrength: 0.5
31 | m_FlareStrength: 1
32 | m_FlareFadeSpeed: 3
33 | m_HaloTexture: {fileID: 0}
34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
35 | m_DefaultReflectionMode: 0
36 | m_DefaultReflectionResolution: 128
37 | m_ReflectionBounces: 1
38 | m_ReflectionIntensity: 1
39 | m_CustomReflection: {fileID: 0}
40 | m_Sun: {fileID: 0}
41 | m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
42 | m_UseRadianceAmbientProbe: 0
43 | --- !u!157 &3
44 | LightmapSettings:
45 | m_ObjectHideFlags: 0
46 | serializedVersion: 12
47 | m_GIWorkflowMode: 1
48 | m_GISettings:
49 | serializedVersion: 2
50 | m_BounceScale: 1
51 | m_IndirectOutputScale: 1
52 | m_AlbedoBoost: 1
53 | m_EnvironmentLightingMode: 0
54 | m_EnableBakedLightmaps: 1
55 | m_EnableRealtimeLightmaps: 0
56 | m_LightmapEditorSettings:
57 | serializedVersion: 12
58 | m_Resolution: 2
59 | m_BakeResolution: 40
60 | m_AtlasSize: 1024
61 | m_AO: 0
62 | m_AOMaxDistance: 1
63 | m_CompAOExponent: 1
64 | m_CompAOExponentDirect: 0
65 | m_ExtractAmbientOcclusion: 0
66 | m_Padding: 2
67 | m_LightmapParameters: {fileID: 0}
68 | m_LightmapsBakeMode: 1
69 | m_TextureCompression: 1
70 | m_FinalGather: 0
71 | m_FinalGatherFiltering: 1
72 | m_FinalGatherRayCount: 256
73 | m_ReflectionCompression: 2
74 | m_MixedBakeMode: 2
75 | m_BakeBackend: 1
76 | m_PVRSampling: 1
77 | m_PVRDirectSampleCount: 32
78 | m_PVRSampleCount: 512
79 | m_PVRBounces: 2
80 | m_PVREnvironmentSampleCount: 256
81 | m_PVREnvironmentReferencePointCount: 2048
82 | m_PVRFilteringMode: 1
83 | m_PVRDenoiserTypeDirect: 1
84 | m_PVRDenoiserTypeIndirect: 1
85 | m_PVRDenoiserTypeAO: 1
86 | m_PVRFilterTypeDirect: 0
87 | m_PVRFilterTypeIndirect: 0
88 | m_PVRFilterTypeAO: 0
89 | m_PVREnvironmentMIS: 1
90 | m_PVRCulling: 1
91 | m_PVRFilteringGaussRadiusDirect: 1
92 | m_PVRFilteringGaussRadiusIndirect: 5
93 | m_PVRFilteringGaussRadiusAO: 2
94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
96 | m_PVRFilteringAtrousPositionSigmaAO: 1
97 | m_ExportTrainingData: 0
98 | m_TrainingDataDestination: TrainingData
99 | m_LightProbeSampleCountMultiplier: 4
100 | m_LightingDataAsset: {fileID: 0}
101 | m_LightingSettings: {fileID: 0}
102 | --- !u!196 &4
103 | NavMeshSettings:
104 | serializedVersion: 2
105 | m_ObjectHideFlags: 0
106 | m_BuildSettings:
107 | serializedVersion: 3
108 | agentTypeID: 0
109 | agentRadius: 0.5
110 | agentHeight: 2
111 | agentSlope: 45
112 | agentClimb: 0.4
113 | ledgeDropHeight: 0
114 | maxJumpAcrossDistance: 0
115 | minRegionArea: 2
116 | manualCellSize: 0
117 | cellSize: 0.16666667
118 | manualTileSize: 0
119 | tileSize: 256
120 | buildHeightMesh: 0
121 | maxJobWorkers: 0
122 | preserveTilesOutsideBounds: 0
123 | debug:
124 | m_Flags: 0
125 | m_NavMeshData: {fileID: 0}
126 | --- !u!1 &795407714
127 | GameObject:
128 | m_ObjectHideFlags: 0
129 | m_CorrespondingSourceObject: {fileID: 0}
130 | m_PrefabInstance: {fileID: 0}
131 | m_PrefabAsset: {fileID: 0}
132 | serializedVersion: 6
133 | m_Component:
134 | - component: {fileID: 795407718}
135 | - component: {fileID: 795407717}
136 | - component: {fileID: 795407716}
137 | - component: {fileID: 795407715}
138 | m_Layer: 0
139 | m_Name: Cube
140 | m_TagString: Untagged
141 | m_Icon: {fileID: 0}
142 | m_NavMeshLayer: 0
143 | m_StaticEditorFlags: 0
144 | m_IsActive: 1
145 | --- !u!65 &795407715
146 | BoxCollider:
147 | m_ObjectHideFlags: 0
148 | m_CorrespondingSourceObject: {fileID: 0}
149 | m_PrefabInstance: {fileID: 0}
150 | m_PrefabAsset: {fileID: 0}
151 | m_GameObject: {fileID: 795407714}
152 | m_Material: {fileID: 0}
153 | m_IncludeLayers:
154 | serializedVersion: 2
155 | m_Bits: 0
156 | m_ExcludeLayers:
157 | serializedVersion: 2
158 | m_Bits: 0
159 | m_LayerOverridePriority: 0
160 | m_IsTrigger: 0
161 | m_ProvidesContacts: 0
162 | m_Enabled: 1
163 | serializedVersion: 3
164 | m_Size: {x: 1, y: 1, z: 1}
165 | m_Center: {x: 0, y: 0, z: 0}
166 | --- !u!23 &795407716
167 | MeshRenderer:
168 | m_ObjectHideFlags: 0
169 | m_CorrespondingSourceObject: {fileID: 0}
170 | m_PrefabInstance: {fileID: 0}
171 | m_PrefabAsset: {fileID: 0}
172 | m_GameObject: {fileID: 795407714}
173 | m_Enabled: 1
174 | m_CastShadows: 1
175 | m_ReceiveShadows: 1
176 | m_DynamicOccludee: 1
177 | m_StaticShadowCaster: 0
178 | m_MotionVectors: 1
179 | m_LightProbeUsage: 1
180 | m_ReflectionProbeUsage: 1
181 | m_RayTracingMode: 2
182 | m_RayTraceProcedural: 0
183 | m_RenderingLayerMask: 1
184 | m_RendererPriority: 0
185 | m_Materials:
186 | - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
187 | m_StaticBatchInfo:
188 | firstSubMesh: 0
189 | subMeshCount: 0
190 | m_StaticBatchRoot: {fileID: 0}
191 | m_ProbeAnchor: {fileID: 0}
192 | m_LightProbeVolumeOverride: {fileID: 0}
193 | m_ScaleInLightmap: 1
194 | m_ReceiveGI: 1
195 | m_PreserveUVs: 0
196 | m_IgnoreNormalsForChartDetection: 0
197 | m_ImportantGI: 0
198 | m_StitchLightmapSeams: 1
199 | m_SelectedEditorRenderState: 3
200 | m_MinimumChartSize: 4
201 | m_AutoUVMaxDistance: 0.5
202 | m_AutoUVMaxAngle: 89
203 | m_LightmapParameters: {fileID: 0}
204 | m_SortingLayerID: 0
205 | m_SortingLayer: 0
206 | m_SortingOrder: 0
207 | m_AdditionalVertexStreams: {fileID: 0}
208 | --- !u!33 &795407717
209 | MeshFilter:
210 | m_ObjectHideFlags: 0
211 | m_CorrespondingSourceObject: {fileID: 0}
212 | m_PrefabInstance: {fileID: 0}
213 | m_PrefabAsset: {fileID: 0}
214 | m_GameObject: {fileID: 795407714}
215 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
216 | --- !u!4 &795407718
217 | Transform:
218 | m_ObjectHideFlags: 0
219 | m_CorrespondingSourceObject: {fileID: 0}
220 | m_PrefabInstance: {fileID: 0}
221 | m_PrefabAsset: {fileID: 0}
222 | m_GameObject: {fileID: 795407714}
223 | serializedVersion: 2
224 | m_LocalRotation: {x: 0.46193978, y: 0.19134173, z: 0.19134173, w: 0.84462327}
225 | m_LocalPosition: {x: 0, y: 3, z: 0}
226 | m_LocalScale: {x: 1, y: 1, z: 1}
227 | m_ConstrainProportionsScale: 0
228 | m_Children: []
229 | m_Father: {fileID: 0}
230 | m_LocalEulerAnglesHint: {x: 45, y: 45, z: 45}
231 | --- !u!1 &1085325871
232 | GameObject:
233 | m_ObjectHideFlags: 0
234 | m_CorrespondingSourceObject: {fileID: 0}
235 | m_PrefabInstance: {fileID: 0}
236 | m_PrefabAsset: {fileID: 0}
237 | serializedVersion: 6
238 | m_Component:
239 | - component: {fileID: 1085325873}
240 | - component: {fileID: 1085325872}
241 | - component: {fileID: 1085325874}
242 | m_Layer: 0
243 | m_Name: Directional Light
244 | m_TagString: Untagged
245 | m_Icon: {fileID: 0}
246 | m_NavMeshLayer: 0
247 | m_StaticEditorFlags: 0
248 | m_IsActive: 1
249 | --- !u!108 &1085325872
250 | Light:
251 | m_ObjectHideFlags: 0
252 | m_CorrespondingSourceObject: {fileID: 0}
253 | m_PrefabInstance: {fileID: 0}
254 | m_PrefabAsset: {fileID: 0}
255 | m_GameObject: {fileID: 1085325871}
256 | m_Enabled: 1
257 | serializedVersion: 10
258 | m_Type: 1
259 | m_Shape: 0
260 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
261 | m_Intensity: 1
262 | m_Range: 10
263 | m_SpotAngle: 30
264 | m_InnerSpotAngle: 21.80208
265 | m_CookieSize: 10
266 | m_Shadows:
267 | m_Type: 2
268 | m_Resolution: -1
269 | m_CustomResolution: -1
270 | m_Strength: 1
271 | m_Bias: 0.05
272 | m_NormalBias: 0.4
273 | m_NearPlane: 0.2
274 | m_CullingMatrixOverride:
275 | e00: 1
276 | e01: 0
277 | e02: 0
278 | e03: 0
279 | e10: 0
280 | e11: 1
281 | e12: 0
282 | e13: 0
283 | e20: 0
284 | e21: 0
285 | e22: 1
286 | e23: 0
287 | e30: 0
288 | e31: 0
289 | e32: 0
290 | e33: 1
291 | m_UseCullingMatrixOverride: 0
292 | m_Cookie: {fileID: 0}
293 | m_DrawHalo: 0
294 | m_Flare: {fileID: 0}
295 | m_RenderMode: 0
296 | m_CullingMask:
297 | serializedVersion: 2
298 | m_Bits: 4294967295
299 | m_RenderingLayerMask: 1
300 | m_Lightmapping: 4
301 | m_LightShadowCasterMode: 0
302 | m_AreaSize: {x: 1, y: 1}
303 | m_BounceIntensity: 1
304 | m_ColorTemperature: 6570
305 | m_UseColorTemperature: 0
306 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
307 | m_UseBoundingSphereOverride: 0
308 | m_UseViewFrustumForShadowCasterCull: 1
309 | m_ShadowRadius: 0
310 | m_ShadowAngle: 0
311 | --- !u!4 &1085325873
312 | Transform:
313 | m_ObjectHideFlags: 0
314 | m_CorrespondingSourceObject: {fileID: 0}
315 | m_PrefabInstance: {fileID: 0}
316 | m_PrefabAsset: {fileID: 0}
317 | m_GameObject: {fileID: 1085325871}
318 | serializedVersion: 2
319 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
320 | m_LocalPosition: {x: 0, y: 3, z: 0}
321 | m_LocalScale: {x: 1, y: 1, z: 1}
322 | m_ConstrainProportionsScale: 0
323 | m_Children: []
324 | m_Father: {fileID: 0}
325 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
326 | --- !u!114 &1085325874
327 | MonoBehaviour:
328 | m_ObjectHideFlags: 0
329 | m_CorrespondingSourceObject: {fileID: 0}
330 | m_PrefabInstance: {fileID: 0}
331 | m_PrefabAsset: {fileID: 0}
332 | m_GameObject: {fileID: 1085325871}
333 | m_Enabled: 1
334 | m_EditorHideFlags: 0
335 | m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
336 | m_Name:
337 | m_EditorClassIdentifier:
338 | m_Version: 3
339 | m_UsePipelineSettings: 1
340 | m_AdditionalLightsShadowResolutionTier: 2
341 | m_LightLayerMask: 1
342 | m_RenderingLayers: 1
343 | m_CustomShadowLayers: 0
344 | m_ShadowLayerMask: 1
345 | m_ShadowRenderingLayers: 1
346 | m_LightCookieSize: {x: 1, y: 1}
347 | m_LightCookieOffset: {x: 0, y: 0}
348 | m_SoftShadowQuality: 0
349 | --- !u!1 &1384457165
350 | GameObject:
351 | m_ObjectHideFlags: 0
352 | m_CorrespondingSourceObject: {fileID: 0}
353 | m_PrefabInstance: {fileID: 0}
354 | m_PrefabAsset: {fileID: 0}
355 | serializedVersion: 6
356 | m_Component:
357 | - component: {fileID: 1384457168}
358 | - component: {fileID: 1384457167}
359 | - component: {fileID: 1384457166}
360 | m_Layer: 0
361 | m_Name: Main Camera
362 | m_TagString: MainCamera
363 | m_Icon: {fileID: 0}
364 | m_NavMeshLayer: 0
365 | m_StaticEditorFlags: 0
366 | m_IsActive: 1
367 | --- !u!81 &1384457166
368 | AudioListener:
369 | m_ObjectHideFlags: 0
370 | m_CorrespondingSourceObject: {fileID: 0}
371 | m_PrefabInstance: {fileID: 0}
372 | m_PrefabAsset: {fileID: 0}
373 | m_GameObject: {fileID: 1384457165}
374 | m_Enabled: 1
375 | --- !u!20 &1384457167
376 | Camera:
377 | m_ObjectHideFlags: 0
378 | m_CorrespondingSourceObject: {fileID: 0}
379 | m_PrefabInstance: {fileID: 0}
380 | m_PrefabAsset: {fileID: 0}
381 | m_GameObject: {fileID: 1384457165}
382 | m_Enabled: 1
383 | serializedVersion: 2
384 | m_ClearFlags: 1
385 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
386 | m_projectionMatrixMode: 1
387 | m_GateFitMode: 2
388 | m_FOVAxisMode: 0
389 | m_Iso: 200
390 | m_ShutterSpeed: 0.005
391 | m_Aperture: 16
392 | m_FocusDistance: 10
393 | m_FocalLength: 50
394 | m_BladeCount: 5
395 | m_Curvature: {x: 2, y: 11}
396 | m_BarrelClipping: 0.25
397 | m_Anamorphism: 0
398 | m_SensorSize: {x: 36, y: 24}
399 | m_LensShift: {x: 0, y: 0}
400 | m_NormalizedViewPortRect:
401 | serializedVersion: 2
402 | x: 0
403 | y: 0
404 | width: 1
405 | height: 1
406 | near clip plane: 0.3
407 | far clip plane: 1000
408 | field of view: 60
409 | orthographic: 0
410 | orthographic size: 5
411 | m_Depth: -1
412 | m_CullingMask:
413 | serializedVersion: 2
414 | m_Bits: 4294967295
415 | m_RenderingPath: -1
416 | m_TargetTexture: {fileID: 0}
417 | m_TargetDisplay: 0
418 | m_TargetEye: 3
419 | m_HDR: 1
420 | m_AllowMSAA: 1
421 | m_AllowDynamicResolution: 0
422 | m_ForceIntoRT: 0
423 | m_OcclusionCulling: 1
424 | m_StereoConvergence: 10
425 | m_StereoSeparation: 0.022
426 | --- !u!4 &1384457168
427 | Transform:
428 | m_ObjectHideFlags: 0
429 | m_CorrespondingSourceObject: {fileID: 0}
430 | m_PrefabInstance: {fileID: 0}
431 | m_PrefabAsset: {fileID: 0}
432 | m_GameObject: {fileID: 1384457165}
433 | serializedVersion: 2
434 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
435 | m_LocalPosition: {x: 0, y: 1, z: -10}
436 | m_LocalScale: {x: 1, y: 1, z: 1}
437 | m_ConstrainProportionsScale: 0
438 | m_Children: []
439 | m_Father: {fileID: 0}
440 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
441 | --- !u!1 &1530449766
442 | GameObject:
443 | m_ObjectHideFlags: 0
444 | m_CorrespondingSourceObject: {fileID: 0}
445 | m_PrefabInstance: {fileID: 0}
446 | m_PrefabAsset: {fileID: 0}
447 | serializedVersion: 6
448 | m_Component:
449 | - component: {fileID: 1530449770}
450 | - component: {fileID: 1530449769}
451 | - component: {fileID: 1530449768}
452 | - component: {fileID: 1530449767}
453 | m_Layer: 0
454 | m_Name: Plane
455 | m_TagString: Untagged
456 | m_Icon: {fileID: 0}
457 | m_NavMeshLayer: 0
458 | m_StaticEditorFlags: 0
459 | m_IsActive: 1
460 | --- !u!64 &1530449767
461 | MeshCollider:
462 | m_ObjectHideFlags: 0
463 | m_CorrespondingSourceObject: {fileID: 0}
464 | m_PrefabInstance: {fileID: 0}
465 | m_PrefabAsset: {fileID: 0}
466 | m_GameObject: {fileID: 1530449766}
467 | m_Material: {fileID: 0}
468 | m_IncludeLayers:
469 | serializedVersion: 2
470 | m_Bits: 0
471 | m_ExcludeLayers:
472 | serializedVersion: 2
473 | m_Bits: 0
474 | m_LayerOverridePriority: 0
475 | m_IsTrigger: 0
476 | m_ProvidesContacts: 0
477 | m_Enabled: 1
478 | serializedVersion: 5
479 | m_Convex: 0
480 | m_CookingOptions: 30
481 | m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
482 | --- !u!23 &1530449768
483 | MeshRenderer:
484 | m_ObjectHideFlags: 0
485 | m_CorrespondingSourceObject: {fileID: 0}
486 | m_PrefabInstance: {fileID: 0}
487 | m_PrefabAsset: {fileID: 0}
488 | m_GameObject: {fileID: 1530449766}
489 | m_Enabled: 1
490 | m_CastShadows: 1
491 | m_ReceiveShadows: 1
492 | m_DynamicOccludee: 1
493 | m_StaticShadowCaster: 0
494 | m_MotionVectors: 1
495 | m_LightProbeUsage: 1
496 | m_ReflectionProbeUsage: 1
497 | m_RayTracingMode: 2
498 | m_RayTraceProcedural: 0
499 | m_RenderingLayerMask: 1
500 | m_RendererPriority: 0
501 | m_Materials:
502 | - {fileID: 2100000, guid: 9daa85b5c6431554697d9d3c4a767421, type: 2}
503 | m_StaticBatchInfo:
504 | firstSubMesh: 0
505 | subMeshCount: 0
506 | m_StaticBatchRoot: {fileID: 0}
507 | m_ProbeAnchor: {fileID: 0}
508 | m_LightProbeVolumeOverride: {fileID: 0}
509 | m_ScaleInLightmap: 1
510 | m_ReceiveGI: 1
511 | m_PreserveUVs: 0
512 | m_IgnoreNormalsForChartDetection: 0
513 | m_ImportantGI: 0
514 | m_StitchLightmapSeams: 1
515 | m_SelectedEditorRenderState: 3
516 | m_MinimumChartSize: 4
517 | m_AutoUVMaxDistance: 0.5
518 | m_AutoUVMaxAngle: 89
519 | m_LightmapParameters: {fileID: 0}
520 | m_SortingLayerID: 0
521 | m_SortingLayer: 0
522 | m_SortingOrder: 0
523 | m_AdditionalVertexStreams: {fileID: 0}
524 | --- !u!33 &1530449769
525 | MeshFilter:
526 | m_ObjectHideFlags: 0
527 | m_CorrespondingSourceObject: {fileID: 0}
528 | m_PrefabInstance: {fileID: 0}
529 | m_PrefabAsset: {fileID: 0}
530 | m_GameObject: {fileID: 1530449766}
531 | m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
532 | --- !u!4 &1530449770
533 | Transform:
534 | m_ObjectHideFlags: 0
535 | m_CorrespondingSourceObject: {fileID: 0}
536 | m_PrefabInstance: {fileID: 0}
537 | m_PrefabAsset: {fileID: 0}
538 | m_GameObject: {fileID: 1530449766}
539 | serializedVersion: 2
540 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
541 | m_LocalPosition: {x: -0.3817138, y: 0.08, z: 3.4094157}
542 | m_LocalScale: {x: 5, y: 1, z: 5}
543 | m_ConstrainProportionsScale: 0
544 | m_Children: []
545 | m_Father: {fileID: 0}
546 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
547 | --- !u!1660057539 &9223372036854775807
548 | SceneRoots:
549 | m_ObjectHideFlags: 0
550 | m_Roots:
551 | - {fileID: 1384457168}
552 | - {fileID: 1085325873}
553 | - {fileID: 795407718}
554 | - {fileID: 1530449770}
555 |
--------------------------------------------------------------------------------
/Sample/Deferred/Deferred Rendering Sample.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3247bd58077fd5247851724636315e1c
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Sample/Deferred/M_Plane_SSRDeferred.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &-2368579414784287288
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 11
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
13 | m_Name:
14 | m_EditorClassIdentifier:
15 | version: 7
16 | --- !u!21 &2100000
17 | Material:
18 | serializedVersion: 8
19 | m_ObjectHideFlags: 0
20 | m_CorrespondingSourceObject: {fileID: 0}
21 | m_PrefabInstance: {fileID: 0}
22 | m_PrefabAsset: {fileID: 0}
23 | m_Name: M_Plane_SSRDeferred
24 | m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
25 | m_Parent: {fileID: 0}
26 | m_ModifiedSerializedProperties: 0
27 | m_ValidKeywords: []
28 | m_InvalidKeywords: []
29 | m_LightmapFlags: 4
30 | m_EnableInstancingVariants: 0
31 | m_DoubleSidedGI: 0
32 | m_CustomRenderQueue: -1
33 | stringTagMap:
34 | RenderType: Opaque
35 | disabledShaderPasses: []
36 | m_LockedProperties:
37 | m_SavedProperties:
38 | serializedVersion: 3
39 | m_TexEnvs:
40 | - _BaseMap:
41 | m_Texture: {fileID: 0}
42 | m_Scale: {x: 1, y: 1}
43 | m_Offset: {x: 0, y: 0}
44 | - _BumpMap:
45 | m_Texture: {fileID: 0}
46 | m_Scale: {x: 1, y: 1}
47 | m_Offset: {x: 0, y: 0}
48 | - _DetailAlbedoMap:
49 | m_Texture: {fileID: 0}
50 | m_Scale: {x: 1, y: 1}
51 | m_Offset: {x: 0, y: 0}
52 | - _DetailMask:
53 | m_Texture: {fileID: 0}
54 | m_Scale: {x: 1, y: 1}
55 | m_Offset: {x: 0, y: 0}
56 | - _DetailNormalMap:
57 | m_Texture: {fileID: 0}
58 | m_Scale: {x: 1, y: 1}
59 | m_Offset: {x: 0, y: 0}
60 | - _EmissionMap:
61 | m_Texture: {fileID: 0}
62 | m_Scale: {x: 1, y: 1}
63 | m_Offset: {x: 0, y: 0}
64 | - _MainTex:
65 | m_Texture: {fileID: 0}
66 | m_Scale: {x: 1, y: 1}
67 | m_Offset: {x: 0, y: 0}
68 | - _MetallicGlossMap:
69 | m_Texture: {fileID: 0}
70 | m_Scale: {x: 1, y: 1}
71 | m_Offset: {x: 0, y: 0}
72 | - _OcclusionMap:
73 | m_Texture: {fileID: 0}
74 | m_Scale: {x: 1, y: 1}
75 | m_Offset: {x: 0, y: 0}
76 | - _ParallaxMap:
77 | m_Texture: {fileID: 0}
78 | m_Scale: {x: 1, y: 1}
79 | m_Offset: {x: 0, y: 0}
80 | - _SpecGlossMap:
81 | m_Texture: {fileID: 0}
82 | m_Scale: {x: 1, y: 1}
83 | m_Offset: {x: 0, y: 0}
84 | - unity_Lightmaps:
85 | m_Texture: {fileID: 0}
86 | m_Scale: {x: 1, y: 1}
87 | m_Offset: {x: 0, y: 0}
88 | - unity_LightmapsInd:
89 | m_Texture: {fileID: 0}
90 | m_Scale: {x: 1, y: 1}
91 | m_Offset: {x: 0, y: 0}
92 | - unity_ShadowMasks:
93 | m_Texture: {fileID: 0}
94 | m_Scale: {x: 1, y: 1}
95 | m_Offset: {x: 0, y: 0}
96 | m_Ints: []
97 | m_Floats:
98 | - _AlphaClip: 0
99 | - _AlphaToMask: 0
100 | - _Blend: 0
101 | - _BlendModePreserveSpecular: 1
102 | - _BumpScale: 1
103 | - _ClearCoatMask: 0
104 | - _ClearCoatSmoothness: 0
105 | - _Cull: 2
106 | - _Cutoff: 0.5
107 | - _DetailAlbedoMapScale: 1
108 | - _DetailNormalMapScale: 1
109 | - _DstBlend: 0
110 | - _DstBlendAlpha: 0
111 | - _EnvironmentReflections: 1
112 | - _GlossMapScale: 0
113 | - _Glossiness: 0
114 | - _GlossyReflections: 0
115 | - _Metallic: 1
116 | - _OcclusionStrength: 1
117 | - _Parallax: 0.005
118 | - _QueueOffset: 0
119 | - _ReceiveShadows: 1
120 | - _Smoothness: 0.715
121 | - _SmoothnessTextureChannel: 0
122 | - _SpecularHighlights: 1
123 | - _SrcBlend: 1
124 | - _SrcBlendAlpha: 1
125 | - _Surface: 0
126 | - _WorkflowMode: 1
127 | - _ZWrite: 1
128 | m_Colors:
129 | - _BaseColor: {r: 0, g: 0, b: 0, a: 1}
130 | - _Color: {r: 0, g: 0, b: 0, a: 1}
131 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
132 | - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
133 | m_BuildTextureStacks: []
134 |
--------------------------------------------------------------------------------
/Sample/Deferred/M_Plane_SSRDeferred.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9daa85b5c6431554697d9d3c4a767421
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 2100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Deferred/SSR Deferred Sample Asset.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
13 | m_Name: SSR Deferred Sample Asset
14 | m_EditorClassIdentifier:
15 | k_AssetVersion: 11
16 | k_AssetPreviousVersion: 11
17 | m_RendererType: 1
18 | m_RendererData: {fileID: 0}
19 | m_RendererDataList:
20 | - {fileID: 11400000, guid: 8002ac05f6e489e468602ecc6d775c14, type: 2}
21 | m_DefaultRendererIndex: 0
22 | m_RequireDepthTexture: 0
23 | m_RequireOpaqueTexture: 0
24 | m_OpaqueDownsampling: 1
25 | m_SupportsTerrainHoles: 1
26 | m_SupportsHDR: 1
27 | m_HDRColorBufferPrecision: 0
28 | m_MSAA: 1
29 | m_RenderScale: 1
30 | m_UpscalingFilter: 0
31 | m_FsrOverrideSharpness: 0
32 | m_FsrSharpness: 0.92
33 | m_EnableLODCrossFade: 1
34 | m_LODCrossFadeDitheringType: 1
35 | m_ShEvalMode: 0
36 | m_MainLightRenderingMode: 1
37 | m_MainLightShadowsSupported: 1
38 | m_MainLightShadowmapResolution: 2048
39 | m_AdditionalLightsRenderingMode: 1
40 | m_AdditionalLightsPerObjectLimit: 4
41 | m_AdditionalLightShadowsSupported: 0
42 | m_AdditionalLightsShadowmapResolution: 2048
43 | m_AdditionalLightsShadowResolutionTierLow: 256
44 | m_AdditionalLightsShadowResolutionTierMedium: 512
45 | m_AdditionalLightsShadowResolutionTierHigh: 1024
46 | m_ReflectionProbeBlending: 0
47 | m_ReflectionProbeBoxProjection: 0
48 | m_ShadowDistance: 50
49 | m_ShadowCascadeCount: 1
50 | m_Cascade2Split: 0.25
51 | m_Cascade3Split: {x: 0.1, y: 0.3}
52 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
53 | m_CascadeBorder: 0.2
54 | m_ShadowDepthBias: 1
55 | m_ShadowNormalBias: 1
56 | m_AnyShadowsSupported: 1
57 | m_SoftShadowsSupported: 0
58 | m_ConservativeEnclosingSphere: 1
59 | m_NumIterationsEnclosingSphere: 64
60 | m_SoftShadowQuality: 2
61 | m_AdditionalLightsCookieResolution: 2048
62 | m_AdditionalLightsCookieFormat: 3
63 | m_UseSRPBatcher: 1
64 | m_SupportsDynamicBatching: 0
65 | m_MixedLightingSupported: 1
66 | m_SupportsLightCookies: 1
67 | m_SupportsLightLayers: 0
68 | m_DebugLevel: 0
69 | m_StoreActionsOptimization: 0
70 | m_EnableRenderGraph: 0
71 | m_UseAdaptivePerformance: 1
72 | m_ColorGradingMode: 0
73 | m_ColorGradingLutSize: 32
74 | m_UseFastSRGBLinearConversion: 0
75 | m_SupportDataDrivenLensFlare: 1
76 | m_ShadowType: 1
77 | m_LocalShadowsSupported: 0
78 | m_LocalShadowsAtlasResolution: 256
79 | m_MaxPixelLights: 0
80 | m_ShadowAtlasResolution: 256
81 | m_VolumeFrameworkUpdateMode: 0
82 | m_Textures:
83 | blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
84 | bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
85 | m_PrefilteringModeMainLightShadows: 1
86 | m_PrefilteringModeAdditionalLight: 4
87 | m_PrefilteringModeAdditionalLightShadows: 1
88 | m_PrefilterXRKeywords: 0
89 | m_PrefilteringModeForwardPlus: 1
90 | m_PrefilteringModeDeferredRendering: 1
91 | m_PrefilteringModeScreenSpaceOcclusion: 1
92 | m_PrefilterDebugKeywords: 0
93 | m_PrefilterWriteRenderingLayers: 0
94 | m_PrefilterHDROutput: 0
95 | m_PrefilterSSAODepthNormals: 0
96 | m_PrefilterSSAOSourceDepthLow: 0
97 | m_PrefilterSSAOSourceDepthMedium: 0
98 | m_PrefilterSSAOSourceDepthHigh: 0
99 | m_PrefilterSSAOInterleaved: 0
100 | m_PrefilterSSAOBlueNoise: 0
101 | m_PrefilterSSAOSampleCountLow: 0
102 | m_PrefilterSSAOSampleCountMedium: 0
103 | m_PrefilterSSAOSampleCountHigh: 0
104 | m_PrefilterDBufferMRT1: 0
105 | m_PrefilterDBufferMRT2: 0
106 | m_PrefilterDBufferMRT3: 0
107 | m_PrefilterSoftShadowsQualityLow: 0
108 | m_PrefilterSoftShadowsQualityMedium: 0
109 | m_PrefilterSoftShadowsQualityHigh: 0
110 | m_PrefilterSoftShadows: 0
111 | m_PrefilterScreenCoord: 0
112 | m_PrefilterNativeRenderPass: 0
113 | m_ShaderVariantLogLevel: 0
114 | m_ShadowCascades: 0
115 |
--------------------------------------------------------------------------------
/Sample/Deferred/SSR Deferred Sample Asset.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 02e03d619013f7448b8759282b04f079
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Deferred/SSR Deferred Sample Renderer.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
13 | m_Name: SSR Deferred Sample Renderer
14 | m_EditorClassIdentifier:
15 | debugShaders:
16 | debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
17 | type: 3}
18 | hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
19 | m_RendererFeatures:
20 | - {fileID: 5241591385608628538}
21 | m_RendererFeatureMap: 3a29f31498dfbd48
22 | m_UseNativeRenderPass: 0
23 | postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
24 | xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
25 | shaders:
26 | blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
27 | copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
28 | screenSpaceShadowPS: {fileID: 0}
29 | samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
30 | stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
31 | fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
32 | fallbackLoadingPS: {fileID: 4800000, guid: 7f888aff2ac86494babad1c2c5daeee2, type: 3}
33 | materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
34 | coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
35 | coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b,
36 | type: 3}
37 | blitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
38 | cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf,
39 | type: 3}
40 | objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
41 | type: 3}
42 | dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
43 | type: 3}
44 | m_AssetVersion: 2
45 | m_OpaqueLayerMask:
46 | serializedVersion: 2
47 | m_Bits: 4294967295
48 | m_TransparentLayerMask:
49 | serializedVersion: 2
50 | m_Bits: 4294967295
51 | m_DefaultStencilState:
52 | overrideStencilState: 0
53 | stencilReference: 0
54 | stencilCompareFunction: 8
55 | passOperation: 2
56 | failOperation: 0
57 | zFailOperation: 0
58 | m_ShadowTransparentReceive: 1
59 | m_RenderingMode: 1
60 | m_DepthPrimingMode: 0
61 | m_CopyDepthMode: 1
62 | m_AccurateGbufferNormals: 0
63 | m_IntermediateTextureMode: 1
64 | --- !u!114 &5241591385608628538
65 | MonoBehaviour:
66 | m_ObjectHideFlags: 0
67 | m_CorrespondingSourceObject: {fileID: 0}
68 | m_PrefabInstance: {fileID: 0}
69 | m_PrefabAsset: {fileID: 0}
70 | m_GameObject: {fileID: 0}
71 | m_Enabled: 1
72 | m_EditorHideFlags: 0
73 | m_Script: {fileID: 11500000, guid: 31ec43bb34e3ff542892e0b797881487, type: 3}
74 | m_Name: ScreenSpaceReflection
75 | m_EditorClassIdentifier:
76 | m_Active: 1
77 | settings: {fileID: 11400000, guid: 46315cf78a9f9024fbf58a12c57c16be, type: 2}
78 | renderingPath: 1
79 |
--------------------------------------------------------------------------------
/Sample/Deferred/SSR Deferred Sample Renderer.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8002ac05f6e489e468602ecc6d775c14
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Forward.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7a53a7fabf98d8643bc42193f24177b4
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Forward/Forward Rendering Sample.unity:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!29 &1
4 | OcclusionCullingSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_OcclusionBakeSettings:
8 | smallestOccluder: 5
9 | smallestHole: 0.25
10 | backfaceThreshold: 100
11 | m_SceneGUID: 00000000000000000000000000000000
12 | m_OcclusionCullingData: {fileID: 0}
13 | --- !u!104 &2
14 | RenderSettings:
15 | m_ObjectHideFlags: 0
16 | serializedVersion: 9
17 | m_Fog: 0
18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19 | m_FogMode: 3
20 | m_FogDensity: 0.01
21 | m_LinearFogStart: 0
22 | m_LinearFogEnd: 300
23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26 | m_AmbientIntensity: 1
27 | m_AmbientMode: 0
28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
30 | m_HaloStrength: 0.5
31 | m_FlareStrength: 1
32 | m_FlareFadeSpeed: 3
33 | m_HaloTexture: {fileID: 0}
34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
35 | m_DefaultReflectionMode: 0
36 | m_DefaultReflectionResolution: 128
37 | m_ReflectionBounces: 1
38 | m_ReflectionIntensity: 1
39 | m_CustomReflection: {fileID: 0}
40 | m_Sun: {fileID: 0}
41 | m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
42 | m_UseRadianceAmbientProbe: 0
43 | --- !u!157 &3
44 | LightmapSettings:
45 | m_ObjectHideFlags: 0
46 | serializedVersion: 12
47 | m_GIWorkflowMode: 1
48 | m_GISettings:
49 | serializedVersion: 2
50 | m_BounceScale: 1
51 | m_IndirectOutputScale: 1
52 | m_AlbedoBoost: 1
53 | m_EnvironmentLightingMode: 0
54 | m_EnableBakedLightmaps: 1
55 | m_EnableRealtimeLightmaps: 0
56 | m_LightmapEditorSettings:
57 | serializedVersion: 12
58 | m_Resolution: 2
59 | m_BakeResolution: 40
60 | m_AtlasSize: 1024
61 | m_AO: 0
62 | m_AOMaxDistance: 1
63 | m_CompAOExponent: 1
64 | m_CompAOExponentDirect: 0
65 | m_ExtractAmbientOcclusion: 0
66 | m_Padding: 2
67 | m_LightmapParameters: {fileID: 0}
68 | m_LightmapsBakeMode: 1
69 | m_TextureCompression: 1
70 | m_FinalGather: 0
71 | m_FinalGatherFiltering: 1
72 | m_FinalGatherRayCount: 256
73 | m_ReflectionCompression: 2
74 | m_MixedBakeMode: 2
75 | m_BakeBackend: 1
76 | m_PVRSampling: 1
77 | m_PVRDirectSampleCount: 32
78 | m_PVRSampleCount: 512
79 | m_PVRBounces: 2
80 | m_PVREnvironmentSampleCount: 256
81 | m_PVREnvironmentReferencePointCount: 2048
82 | m_PVRFilteringMode: 1
83 | m_PVRDenoiserTypeDirect: 1
84 | m_PVRDenoiserTypeIndirect: 1
85 | m_PVRDenoiserTypeAO: 1
86 | m_PVRFilterTypeDirect: 0
87 | m_PVRFilterTypeIndirect: 0
88 | m_PVRFilterTypeAO: 0
89 | m_PVREnvironmentMIS: 1
90 | m_PVRCulling: 1
91 | m_PVRFilteringGaussRadiusDirect: 1
92 | m_PVRFilteringGaussRadiusIndirect: 5
93 | m_PVRFilteringGaussRadiusAO: 2
94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
96 | m_PVRFilteringAtrousPositionSigmaAO: 1
97 | m_ExportTrainingData: 0
98 | m_TrainingDataDestination: TrainingData
99 | m_LightProbeSampleCountMultiplier: 4
100 | m_LightingDataAsset: {fileID: 0}
101 | m_LightingSettings: {fileID: 0}
102 | --- !u!196 &4
103 | NavMeshSettings:
104 | serializedVersion: 2
105 | m_ObjectHideFlags: 0
106 | m_BuildSettings:
107 | serializedVersion: 3
108 | agentTypeID: 0
109 | agentRadius: 0.5
110 | agentHeight: 2
111 | agentSlope: 45
112 | agentClimb: 0.4
113 | ledgeDropHeight: 0
114 | maxJumpAcrossDistance: 0
115 | minRegionArea: 2
116 | manualCellSize: 0
117 | cellSize: 0.16666667
118 | manualTileSize: 0
119 | tileSize: 256
120 | buildHeightMesh: 0
121 | maxJobWorkers: 0
122 | preserveTilesOutsideBounds: 0
123 | debug:
124 | m_Flags: 0
125 | m_NavMeshData: {fileID: 0}
126 | --- !u!1 &795407714
127 | GameObject:
128 | m_ObjectHideFlags: 0
129 | m_CorrespondingSourceObject: {fileID: 0}
130 | m_PrefabInstance: {fileID: 0}
131 | m_PrefabAsset: {fileID: 0}
132 | serializedVersion: 6
133 | m_Component:
134 | - component: {fileID: 795407718}
135 | - component: {fileID: 795407717}
136 | - component: {fileID: 795407716}
137 | - component: {fileID: 795407715}
138 | m_Layer: 0
139 | m_Name: Cube
140 | m_TagString: Untagged
141 | m_Icon: {fileID: 0}
142 | m_NavMeshLayer: 0
143 | m_StaticEditorFlags: 0
144 | m_IsActive: 1
145 | --- !u!65 &795407715
146 | BoxCollider:
147 | m_ObjectHideFlags: 0
148 | m_CorrespondingSourceObject: {fileID: 0}
149 | m_PrefabInstance: {fileID: 0}
150 | m_PrefabAsset: {fileID: 0}
151 | m_GameObject: {fileID: 795407714}
152 | m_Material: {fileID: 0}
153 | m_IncludeLayers:
154 | serializedVersion: 2
155 | m_Bits: 0
156 | m_ExcludeLayers:
157 | serializedVersion: 2
158 | m_Bits: 0
159 | m_LayerOverridePriority: 0
160 | m_IsTrigger: 0
161 | m_ProvidesContacts: 0
162 | m_Enabled: 1
163 | serializedVersion: 3
164 | m_Size: {x: 1, y: 1, z: 1}
165 | m_Center: {x: 0, y: 0, z: 0}
166 | --- !u!23 &795407716
167 | MeshRenderer:
168 | m_ObjectHideFlags: 0
169 | m_CorrespondingSourceObject: {fileID: 0}
170 | m_PrefabInstance: {fileID: 0}
171 | m_PrefabAsset: {fileID: 0}
172 | m_GameObject: {fileID: 795407714}
173 | m_Enabled: 1
174 | m_CastShadows: 1
175 | m_ReceiveShadows: 1
176 | m_DynamicOccludee: 1
177 | m_StaticShadowCaster: 0
178 | m_MotionVectors: 1
179 | m_LightProbeUsage: 1
180 | m_ReflectionProbeUsage: 1
181 | m_RayTracingMode: 2
182 | m_RayTraceProcedural: 0
183 | m_RenderingLayerMask: 1
184 | m_RendererPriority: 0
185 | m_Materials:
186 | - {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
187 | m_StaticBatchInfo:
188 | firstSubMesh: 0
189 | subMeshCount: 0
190 | m_StaticBatchRoot: {fileID: 0}
191 | m_ProbeAnchor: {fileID: 0}
192 | m_LightProbeVolumeOverride: {fileID: 0}
193 | m_ScaleInLightmap: 1
194 | m_ReceiveGI: 1
195 | m_PreserveUVs: 0
196 | m_IgnoreNormalsForChartDetection: 0
197 | m_ImportantGI: 0
198 | m_StitchLightmapSeams: 1
199 | m_SelectedEditorRenderState: 3
200 | m_MinimumChartSize: 4
201 | m_AutoUVMaxDistance: 0.5
202 | m_AutoUVMaxAngle: 89
203 | m_LightmapParameters: {fileID: 0}
204 | m_SortingLayerID: 0
205 | m_SortingLayer: 0
206 | m_SortingOrder: 0
207 | m_AdditionalVertexStreams: {fileID: 0}
208 | --- !u!33 &795407717
209 | MeshFilter:
210 | m_ObjectHideFlags: 0
211 | m_CorrespondingSourceObject: {fileID: 0}
212 | m_PrefabInstance: {fileID: 0}
213 | m_PrefabAsset: {fileID: 0}
214 | m_GameObject: {fileID: 795407714}
215 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
216 | --- !u!4 &795407718
217 | Transform:
218 | m_ObjectHideFlags: 0
219 | m_CorrespondingSourceObject: {fileID: 0}
220 | m_PrefabInstance: {fileID: 0}
221 | m_PrefabAsset: {fileID: 0}
222 | m_GameObject: {fileID: 795407714}
223 | serializedVersion: 2
224 | m_LocalRotation: {x: 0.46193978, y: 0.19134173, z: 0.19134173, w: 0.84462327}
225 | m_LocalPosition: {x: 0, y: 3, z: 0}
226 | m_LocalScale: {x: 1, y: 1, z: 1}
227 | m_ConstrainProportionsScale: 0
228 | m_Children: []
229 | m_Father: {fileID: 0}
230 | m_LocalEulerAnglesHint: {x: 45, y: 45, z: 45}
231 | --- !u!1 &1085325871
232 | GameObject:
233 | m_ObjectHideFlags: 0
234 | m_CorrespondingSourceObject: {fileID: 0}
235 | m_PrefabInstance: {fileID: 0}
236 | m_PrefabAsset: {fileID: 0}
237 | serializedVersion: 6
238 | m_Component:
239 | - component: {fileID: 1085325873}
240 | - component: {fileID: 1085325872}
241 | - component: {fileID: 1085325874}
242 | m_Layer: 0
243 | m_Name: Directional Light
244 | m_TagString: Untagged
245 | m_Icon: {fileID: 0}
246 | m_NavMeshLayer: 0
247 | m_StaticEditorFlags: 0
248 | m_IsActive: 1
249 | --- !u!108 &1085325872
250 | Light:
251 | m_ObjectHideFlags: 0
252 | m_CorrespondingSourceObject: {fileID: 0}
253 | m_PrefabInstance: {fileID: 0}
254 | m_PrefabAsset: {fileID: 0}
255 | m_GameObject: {fileID: 1085325871}
256 | m_Enabled: 1
257 | serializedVersion: 10
258 | m_Type: 1
259 | m_Shape: 0
260 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
261 | m_Intensity: 1
262 | m_Range: 10
263 | m_SpotAngle: 30
264 | m_InnerSpotAngle: 21.80208
265 | m_CookieSize: 10
266 | m_Shadows:
267 | m_Type: 2
268 | m_Resolution: -1
269 | m_CustomResolution: -1
270 | m_Strength: 1
271 | m_Bias: 0.05
272 | m_NormalBias: 0.4
273 | m_NearPlane: 0.2
274 | m_CullingMatrixOverride:
275 | e00: 1
276 | e01: 0
277 | e02: 0
278 | e03: 0
279 | e10: 0
280 | e11: 1
281 | e12: 0
282 | e13: 0
283 | e20: 0
284 | e21: 0
285 | e22: 1
286 | e23: 0
287 | e30: 0
288 | e31: 0
289 | e32: 0
290 | e33: 1
291 | m_UseCullingMatrixOverride: 0
292 | m_Cookie: {fileID: 0}
293 | m_DrawHalo: 0
294 | m_Flare: {fileID: 0}
295 | m_RenderMode: 0
296 | m_CullingMask:
297 | serializedVersion: 2
298 | m_Bits: 4294967295
299 | m_RenderingLayerMask: 1
300 | m_Lightmapping: 4
301 | m_LightShadowCasterMode: 0
302 | m_AreaSize: {x: 1, y: 1}
303 | m_BounceIntensity: 1
304 | m_ColorTemperature: 6570
305 | m_UseColorTemperature: 0
306 | m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
307 | m_UseBoundingSphereOverride: 0
308 | m_UseViewFrustumForShadowCasterCull: 1
309 | m_ShadowRadius: 0
310 | m_ShadowAngle: 0
311 | --- !u!4 &1085325873
312 | Transform:
313 | m_ObjectHideFlags: 0
314 | m_CorrespondingSourceObject: {fileID: 0}
315 | m_PrefabInstance: {fileID: 0}
316 | m_PrefabAsset: {fileID: 0}
317 | m_GameObject: {fileID: 1085325871}
318 | serializedVersion: 2
319 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
320 | m_LocalPosition: {x: 0, y: 3, z: 0}
321 | m_LocalScale: {x: 1, y: 1, z: 1}
322 | m_ConstrainProportionsScale: 0
323 | m_Children: []
324 | m_Father: {fileID: 0}
325 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
326 | --- !u!114 &1085325874
327 | MonoBehaviour:
328 | m_ObjectHideFlags: 0
329 | m_CorrespondingSourceObject: {fileID: 0}
330 | m_PrefabInstance: {fileID: 0}
331 | m_PrefabAsset: {fileID: 0}
332 | m_GameObject: {fileID: 1085325871}
333 | m_Enabled: 1
334 | m_EditorHideFlags: 0
335 | m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
336 | m_Name:
337 | m_EditorClassIdentifier:
338 | m_Version: 3
339 | m_UsePipelineSettings: 1
340 | m_AdditionalLightsShadowResolutionTier: 2
341 | m_LightLayerMask: 1
342 | m_RenderingLayers: 1
343 | m_CustomShadowLayers: 0
344 | m_ShadowLayerMask: 1
345 | m_ShadowRenderingLayers: 1
346 | m_LightCookieSize: {x: 1, y: 1}
347 | m_LightCookieOffset: {x: 0, y: 0}
348 | m_SoftShadowQuality: 0
349 | --- !u!1 &1384457165
350 | GameObject:
351 | m_ObjectHideFlags: 0
352 | m_CorrespondingSourceObject: {fileID: 0}
353 | m_PrefabInstance: {fileID: 0}
354 | m_PrefabAsset: {fileID: 0}
355 | serializedVersion: 6
356 | m_Component:
357 | - component: {fileID: 1384457168}
358 | - component: {fileID: 1384457167}
359 | - component: {fileID: 1384457166}
360 | m_Layer: 0
361 | m_Name: Main Camera
362 | m_TagString: MainCamera
363 | m_Icon: {fileID: 0}
364 | m_NavMeshLayer: 0
365 | m_StaticEditorFlags: 0
366 | m_IsActive: 1
367 | --- !u!81 &1384457166
368 | AudioListener:
369 | m_ObjectHideFlags: 0
370 | m_CorrespondingSourceObject: {fileID: 0}
371 | m_PrefabInstance: {fileID: 0}
372 | m_PrefabAsset: {fileID: 0}
373 | m_GameObject: {fileID: 1384457165}
374 | m_Enabled: 1
375 | --- !u!20 &1384457167
376 | Camera:
377 | m_ObjectHideFlags: 0
378 | m_CorrespondingSourceObject: {fileID: 0}
379 | m_PrefabInstance: {fileID: 0}
380 | m_PrefabAsset: {fileID: 0}
381 | m_GameObject: {fileID: 1384457165}
382 | m_Enabled: 1
383 | serializedVersion: 2
384 | m_ClearFlags: 1
385 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
386 | m_projectionMatrixMode: 1
387 | m_GateFitMode: 2
388 | m_FOVAxisMode: 0
389 | m_Iso: 200
390 | m_ShutterSpeed: 0.005
391 | m_Aperture: 16
392 | m_FocusDistance: 10
393 | m_FocalLength: 50
394 | m_BladeCount: 5
395 | m_Curvature: {x: 2, y: 11}
396 | m_BarrelClipping: 0.25
397 | m_Anamorphism: 0
398 | m_SensorSize: {x: 36, y: 24}
399 | m_LensShift: {x: 0, y: 0}
400 | m_NormalizedViewPortRect:
401 | serializedVersion: 2
402 | x: 0
403 | y: 0
404 | width: 1
405 | height: 1
406 | near clip plane: 0.3
407 | far clip plane: 1000
408 | field of view: 60
409 | orthographic: 0
410 | orthographic size: 5
411 | m_Depth: -1
412 | m_CullingMask:
413 | serializedVersion: 2
414 | m_Bits: 4294967295
415 | m_RenderingPath: -1
416 | m_TargetTexture: {fileID: 0}
417 | m_TargetDisplay: 0
418 | m_TargetEye: 3
419 | m_HDR: 1
420 | m_AllowMSAA: 1
421 | m_AllowDynamicResolution: 0
422 | m_ForceIntoRT: 0
423 | m_OcclusionCulling: 1
424 | m_StereoConvergence: 10
425 | m_StereoSeparation: 0.022
426 | --- !u!4 &1384457168
427 | Transform:
428 | m_ObjectHideFlags: 0
429 | m_CorrespondingSourceObject: {fileID: 0}
430 | m_PrefabInstance: {fileID: 0}
431 | m_PrefabAsset: {fileID: 0}
432 | m_GameObject: {fileID: 1384457165}
433 | serializedVersion: 2
434 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
435 | m_LocalPosition: {x: 0, y: 1, z: -10}
436 | m_LocalScale: {x: 1, y: 1, z: 1}
437 | m_ConstrainProportionsScale: 0
438 | m_Children: []
439 | m_Father: {fileID: 0}
440 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
441 | --- !u!1 &1530449766
442 | GameObject:
443 | m_ObjectHideFlags: 0
444 | m_CorrespondingSourceObject: {fileID: 0}
445 | m_PrefabInstance: {fileID: 0}
446 | m_PrefabAsset: {fileID: 0}
447 | serializedVersion: 6
448 | m_Component:
449 | - component: {fileID: 1530449770}
450 | - component: {fileID: 1530449769}
451 | - component: {fileID: 1530449768}
452 | - component: {fileID: 1530449767}
453 | m_Layer: 0
454 | m_Name: Plane
455 | m_TagString: Untagged
456 | m_Icon: {fileID: 0}
457 | m_NavMeshLayer: 0
458 | m_StaticEditorFlags: 0
459 | m_IsActive: 1
460 | --- !u!64 &1530449767
461 | MeshCollider:
462 | m_ObjectHideFlags: 0
463 | m_CorrespondingSourceObject: {fileID: 0}
464 | m_PrefabInstance: {fileID: 0}
465 | m_PrefabAsset: {fileID: 0}
466 | m_GameObject: {fileID: 1530449766}
467 | m_Material: {fileID: 0}
468 | m_IncludeLayers:
469 | serializedVersion: 2
470 | m_Bits: 0
471 | m_ExcludeLayers:
472 | serializedVersion: 2
473 | m_Bits: 0
474 | m_LayerOverridePriority: 0
475 | m_IsTrigger: 0
476 | m_ProvidesContacts: 0
477 | m_Enabled: 1
478 | serializedVersion: 5
479 | m_Convex: 0
480 | m_CookingOptions: 30
481 | m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
482 | --- !u!23 &1530449768
483 | MeshRenderer:
484 | m_ObjectHideFlags: 0
485 | m_CorrespondingSourceObject: {fileID: 0}
486 | m_PrefabInstance: {fileID: 0}
487 | m_PrefabAsset: {fileID: 0}
488 | m_GameObject: {fileID: 1530449766}
489 | m_Enabled: 1
490 | m_CastShadows: 1
491 | m_ReceiveShadows: 1
492 | m_DynamicOccludee: 1
493 | m_StaticShadowCaster: 0
494 | m_MotionVectors: 1
495 | m_LightProbeUsage: 1
496 | m_ReflectionProbeUsage: 1
497 | m_RayTracingMode: 2
498 | m_RayTraceProcedural: 0
499 | m_RenderingLayerMask: 1
500 | m_RendererPriority: 0
501 | m_Materials:
502 | - {fileID: 2100000, guid: ad15b2c9b81f2194cb272ee74f7cdfd7, type: 2}
503 | m_StaticBatchInfo:
504 | firstSubMesh: 0
505 | subMeshCount: 0
506 | m_StaticBatchRoot: {fileID: 0}
507 | m_ProbeAnchor: {fileID: 0}
508 | m_LightProbeVolumeOverride: {fileID: 0}
509 | m_ScaleInLightmap: 1
510 | m_ReceiveGI: 1
511 | m_PreserveUVs: 0
512 | m_IgnoreNormalsForChartDetection: 0
513 | m_ImportantGI: 0
514 | m_StitchLightmapSeams: 1
515 | m_SelectedEditorRenderState: 3
516 | m_MinimumChartSize: 4
517 | m_AutoUVMaxDistance: 0.5
518 | m_AutoUVMaxAngle: 89
519 | m_LightmapParameters: {fileID: 0}
520 | m_SortingLayerID: 0
521 | m_SortingLayer: 0
522 | m_SortingOrder: 0
523 | m_AdditionalVertexStreams: {fileID: 0}
524 | --- !u!33 &1530449769
525 | MeshFilter:
526 | m_ObjectHideFlags: 0
527 | m_CorrespondingSourceObject: {fileID: 0}
528 | m_PrefabInstance: {fileID: 0}
529 | m_PrefabAsset: {fileID: 0}
530 | m_GameObject: {fileID: 1530449766}
531 | m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
532 | --- !u!4 &1530449770
533 | Transform:
534 | m_ObjectHideFlags: 0
535 | m_CorrespondingSourceObject: {fileID: 0}
536 | m_PrefabInstance: {fileID: 0}
537 | m_PrefabAsset: {fileID: 0}
538 | m_GameObject: {fileID: 1530449766}
539 | serializedVersion: 2
540 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
541 | m_LocalPosition: {x: -0.3817138, y: 0.08, z: 3.4094157}
542 | m_LocalScale: {x: 5, y: 1, z: 5}
543 | m_ConstrainProportionsScale: 0
544 | m_Children: []
545 | m_Father: {fileID: 0}
546 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
547 | --- !u!1660057539 &9223372036854775807
548 | SceneRoots:
549 | m_ObjectHideFlags: 0
550 | m_Roots:
551 | - {fileID: 1384457168}
552 | - {fileID: 1085325873}
553 | - {fileID: 795407718}
554 | - {fileID: 1530449770}
555 |
--------------------------------------------------------------------------------
/Sample/Forward/Forward Rendering Sample.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d8c848bc1e3566544a244d005ee7b428
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Sample/Forward/M_Plane_SSRForwardLit.mat:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &-2368579414784287288
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 11
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
13 | m_Name:
14 | m_EditorClassIdentifier:
15 | version: 7
16 | --- !u!21 &2100000
17 | Material:
18 | serializedVersion: 8
19 | m_ObjectHideFlags: 0
20 | m_CorrespondingSourceObject: {fileID: 0}
21 | m_PrefabInstance: {fileID: 0}
22 | m_PrefabAsset: {fileID: 0}
23 | m_Name: M_Plane_SSRForwardLit
24 | m_Shader: {fileID: 4800000, guid: 59ac94800b863454d89fe5ea963f5596, type: 3}
25 | m_Parent: {fileID: 0}
26 | m_ModifiedSerializedProperties: 0
27 | m_ValidKeywords: []
28 | m_InvalidKeywords: []
29 | m_LightmapFlags: 4
30 | m_EnableInstancingVariants: 0
31 | m_DoubleSidedGI: 0
32 | m_CustomRenderQueue: -1
33 | stringTagMap:
34 | RenderType: Opaque
35 | disabledShaderPasses: []
36 | m_LockedProperties:
37 | m_SavedProperties:
38 | serializedVersion: 3
39 | m_TexEnvs:
40 | - _BaseMap:
41 | m_Texture: {fileID: 0}
42 | m_Scale: {x: 1, y: 1}
43 | m_Offset: {x: 0, y: 0}
44 | - _BumpMap:
45 | m_Texture: {fileID: 0}
46 | m_Scale: {x: 1, y: 1}
47 | m_Offset: {x: 0, y: 0}
48 | - _DetailAlbedoMap:
49 | m_Texture: {fileID: 0}
50 | m_Scale: {x: 1, y: 1}
51 | m_Offset: {x: 0, y: 0}
52 | - _DetailMask:
53 | m_Texture: {fileID: 0}
54 | m_Scale: {x: 1, y: 1}
55 | m_Offset: {x: 0, y: 0}
56 | - _DetailNormalMap:
57 | m_Texture: {fileID: 0}
58 | m_Scale: {x: 1, y: 1}
59 | m_Offset: {x: 0, y: 0}
60 | - _EmissionMap:
61 | m_Texture: {fileID: 0}
62 | m_Scale: {x: 1, y: 1}
63 | m_Offset: {x: 0, y: 0}
64 | - _MainTex:
65 | m_Texture: {fileID: 0}
66 | m_Scale: {x: 1, y: 1}
67 | m_Offset: {x: 0, y: 0}
68 | - _MetallicGlossMap:
69 | m_Texture: {fileID: 0}
70 | m_Scale: {x: 1, y: 1}
71 | m_Offset: {x: 0, y: 0}
72 | - _OcclusionMap:
73 | m_Texture: {fileID: 0}
74 | m_Scale: {x: 1, y: 1}
75 | m_Offset: {x: 0, y: 0}
76 | - _ParallaxMap:
77 | m_Texture: {fileID: 0}
78 | m_Scale: {x: 1, y: 1}
79 | m_Offset: {x: 0, y: 0}
80 | - _SpecGlossMap:
81 | m_Texture: {fileID: 0}
82 | m_Scale: {x: 1, y: 1}
83 | m_Offset: {x: 0, y: 0}
84 | - unity_Lightmaps:
85 | m_Texture: {fileID: 0}
86 | m_Scale: {x: 1, y: 1}
87 | m_Offset: {x: 0, y: 0}
88 | - unity_LightmapsInd:
89 | m_Texture: {fileID: 0}
90 | m_Scale: {x: 1, y: 1}
91 | m_Offset: {x: 0, y: 0}
92 | - unity_ShadowMasks:
93 | m_Texture: {fileID: 0}
94 | m_Scale: {x: 1, y: 1}
95 | m_Offset: {x: 0, y: 0}
96 | m_Ints: []
97 | m_Floats:
98 | - _AlphaClip: 0
99 | - _AlphaToMask: 0
100 | - _Blend: 0
101 | - _BlendModePreserveSpecular: 1
102 | - _BumpScale: 1
103 | - _ClearCoatMask: 0
104 | - _ClearCoatSmoothness: 0
105 | - _Cull: 2
106 | - _Cutoff: 0.5
107 | - _DetailAlbedoMapScale: 1
108 | - _DetailNormalMapScale: 1
109 | - _DstBlend: 0
110 | - _DstBlendAlpha: 0
111 | - _EnvironmentReflections: 1
112 | - _GlossMapScale: 0
113 | - _Glossiness: 0
114 | - _GlossyReflections: 0
115 | - _Metallic: 1
116 | - _OcclusionStrength: 1
117 | - _Parallax: 0.005
118 | - _QueueOffset: 0
119 | - _ReceiveShadows: 1
120 | - _Smoothness: 0.715
121 | - _SmoothnessTextureChannel: 0
122 | - _SpecularHighlights: 1
123 | - _SrcBlend: 1
124 | - _SrcBlendAlpha: 1
125 | - _Surface: 0
126 | - _WorkflowMode: 1
127 | - _ZWrite: 1
128 | m_Colors:
129 | - _BaseColor: {r: 0, g: 0, b: 0, a: 1}
130 | - _Color: {r: 0, g: 0, b: 0, a: 1}
131 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
132 | - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
133 | m_BuildTextureStacks: []
134 |
--------------------------------------------------------------------------------
/Sample/Forward/M_Plane_SSRForwardLit.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ad15b2c9b81f2194cb272ee74f7cdfd7
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 2100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Forward/SSRForwardSample Asset.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
13 | m_Name: SSRForwardSample Asset
14 | m_EditorClassIdentifier:
15 | k_AssetVersion: 11
16 | k_AssetPreviousVersion: 11
17 | m_RendererType: 1
18 | m_RendererData: {fileID: 0}
19 | m_RendererDataList:
20 | - {fileID: 11400000, guid: 941bedae0eb3c784298514ff7b0fe24e, type: 2}
21 | m_DefaultRendererIndex: 0
22 | m_RequireDepthTexture: 0
23 | m_RequireOpaqueTexture: 0
24 | m_OpaqueDownsampling: 1
25 | m_SupportsTerrainHoles: 1
26 | m_SupportsHDR: 1
27 | m_HDRColorBufferPrecision: 0
28 | m_MSAA: 1
29 | m_RenderScale: 1
30 | m_UpscalingFilter: 0
31 | m_FsrOverrideSharpness: 0
32 | m_FsrSharpness: 0.92
33 | m_EnableLODCrossFade: 1
34 | m_LODCrossFadeDitheringType: 1
35 | m_ShEvalMode: 0
36 | m_MainLightRenderingMode: 1
37 | m_MainLightShadowsSupported: 1
38 | m_MainLightShadowmapResolution: 2048
39 | m_AdditionalLightsRenderingMode: 1
40 | m_AdditionalLightsPerObjectLimit: 4
41 | m_AdditionalLightShadowsSupported: 0
42 | m_AdditionalLightsShadowmapResolution: 2048
43 | m_AdditionalLightsShadowResolutionTierLow: 256
44 | m_AdditionalLightsShadowResolutionTierMedium: 512
45 | m_AdditionalLightsShadowResolutionTierHigh: 1024
46 | m_ReflectionProbeBlending: 0
47 | m_ReflectionProbeBoxProjection: 0
48 | m_ShadowDistance: 50
49 | m_ShadowCascadeCount: 1
50 | m_Cascade2Split: 0.25
51 | m_Cascade3Split: {x: 0.1, y: 0.3}
52 | m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
53 | m_CascadeBorder: 0.2
54 | m_ShadowDepthBias: 1
55 | m_ShadowNormalBias: 1
56 | m_AnyShadowsSupported: 1
57 | m_SoftShadowsSupported: 0
58 | m_ConservativeEnclosingSphere: 1
59 | m_NumIterationsEnclosingSphere: 64
60 | m_SoftShadowQuality: 2
61 | m_AdditionalLightsCookieResolution: 2048
62 | m_AdditionalLightsCookieFormat: 3
63 | m_UseSRPBatcher: 1
64 | m_SupportsDynamicBatching: 0
65 | m_MixedLightingSupported: 1
66 | m_SupportsLightCookies: 1
67 | m_SupportsLightLayers: 0
68 | m_DebugLevel: 0
69 | m_StoreActionsOptimization: 0
70 | m_EnableRenderGraph: 0
71 | m_UseAdaptivePerformance: 1
72 | m_ColorGradingMode: 0
73 | m_ColorGradingLutSize: 32
74 | m_UseFastSRGBLinearConversion: 0
75 | m_SupportDataDrivenLensFlare: 1
76 | m_ShadowType: 1
77 | m_LocalShadowsSupported: 0
78 | m_LocalShadowsAtlasResolution: 256
79 | m_MaxPixelLights: 0
80 | m_ShadowAtlasResolution: 256
81 | m_VolumeFrameworkUpdateMode: 0
82 | m_Textures:
83 | blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
84 | bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
85 | m_PrefilteringModeMainLightShadows: 1
86 | m_PrefilteringModeAdditionalLight: 4
87 | m_PrefilteringModeAdditionalLightShadows: 1
88 | m_PrefilterXRKeywords: 0
89 | m_PrefilteringModeForwardPlus: 1
90 | m_PrefilteringModeDeferredRendering: 1
91 | m_PrefilteringModeScreenSpaceOcclusion: 1
92 | m_PrefilterDebugKeywords: 0
93 | m_PrefilterWriteRenderingLayers: 0
94 | m_PrefilterHDROutput: 0
95 | m_PrefilterSSAODepthNormals: 0
96 | m_PrefilterSSAOSourceDepthLow: 0
97 | m_PrefilterSSAOSourceDepthMedium: 0
98 | m_PrefilterSSAOSourceDepthHigh: 0
99 | m_PrefilterSSAOInterleaved: 0
100 | m_PrefilterSSAOBlueNoise: 0
101 | m_PrefilterSSAOSampleCountLow: 0
102 | m_PrefilterSSAOSampleCountMedium: 0
103 | m_PrefilterSSAOSampleCountHigh: 0
104 | m_PrefilterDBufferMRT1: 0
105 | m_PrefilterDBufferMRT2: 0
106 | m_PrefilterDBufferMRT3: 0
107 | m_PrefilterSoftShadowsQualityLow: 0
108 | m_PrefilterSoftShadowsQualityMedium: 0
109 | m_PrefilterSoftShadowsQualityHigh: 0
110 | m_PrefilterSoftShadows: 0
111 | m_PrefilterScreenCoord: 0
112 | m_PrefilterNativeRenderPass: 0
113 | m_ShaderVariantLogLevel: 0
114 | m_ShadowCascades: 0
115 |
--------------------------------------------------------------------------------
/Sample/Forward/SSRForwardSample Asset.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 55656894993f6934086ca26070d4e731
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Forward/SSRForwardSample Renderer.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &-613335217044710296
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: 31ec43bb34e3ff542892e0b797881487, type: 3}
13 | m_Name: ScreenSpaceReflection
14 | m_EditorClassIdentifier:
15 | m_Active: 1
16 | settings: {fileID: 11400000, guid: 46315cf78a9f9024fbf58a12c57c16be, type: 2}
17 | renderingPath: 0
18 | --- !u!114 &11400000
19 | MonoBehaviour:
20 | m_ObjectHideFlags: 0
21 | m_CorrespondingSourceObject: {fileID: 0}
22 | m_PrefabInstance: {fileID: 0}
23 | m_PrefabAsset: {fileID: 0}
24 | m_GameObject: {fileID: 0}
25 | m_Enabled: 1
26 | m_EditorHideFlags: 0
27 | m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
28 | m_Name: SSRForwardSample Renderer
29 | m_EditorClassIdentifier:
30 | debugShaders:
31 | debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
32 | type: 3}
33 | hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
34 | m_RendererFeatures:
35 | - {fileID: -613335217044710296}
36 | m_RendererFeatureMap: 681cd0a3defe7cf7
37 | m_UseNativeRenderPass: 0
38 | postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
39 | xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
40 | shaders:
41 | blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
42 | copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
43 | screenSpaceShadowPS: {fileID: 0}
44 | samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
45 | stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
46 | fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
47 | fallbackLoadingPS: {fileID: 4800000, guid: 7f888aff2ac86494babad1c2c5daeee2, type: 3}
48 | materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
49 | coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
50 | coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b,
51 | type: 3}
52 | blitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
53 | cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf,
54 | type: 3}
55 | objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
56 | type: 3}
57 | dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
58 | type: 3}
59 | m_AssetVersion: 2
60 | m_OpaqueLayerMask:
61 | serializedVersion: 2
62 | m_Bits: 4294967295
63 | m_TransparentLayerMask:
64 | serializedVersion: 2
65 | m_Bits: 4294967295
66 | m_DefaultStencilState:
67 | overrideStencilState: 0
68 | stencilReference: 0
69 | stencilCompareFunction: 8
70 | passOperation: 2
71 | failOperation: 0
72 | zFailOperation: 0
73 | m_ShadowTransparentReceive: 1
74 | m_RenderingMode: 0
75 | m_DepthPrimingMode: 0
76 | m_CopyDepthMode: 1
77 | m_AccurateGbufferNormals: 0
78 | m_IntermediateTextureMode: 1
79 |
--------------------------------------------------------------------------------
/Sample/Forward/SSRForwardSample Renderer.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 941bedae0eb3c784298514ff7b0fe24e
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Forward/Shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b94fd7702529a314c8217befe5163b09
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Sample/Forward/Shader/SSRForwardLit.shader:
--------------------------------------------------------------------------------
1 | Shader "SSR Sample/SSR Forward Lit"
2 | {
3 | Properties
4 | {
5 | // Specular vs Metallic workflow
6 | _WorkflowMode("WorkflowMode", Float) = 1.0
7 |
8 | [MainTexture] _BaseMap("Albedo", 2D) = "white" {}
9 | [MainColor] _BaseColor("Color", Color) = (1,1,1,1)
10 |
11 | _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
12 |
13 | _Smoothness("Smoothness", Range(0.0, 1.0)) = 0.5
14 | _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
15 |
16 | _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
17 | _MetallicGlossMap("Metallic", 2D) = "white" {}
18 |
19 | _SpecColor("Specular", Color) = (0.2, 0.2, 0.2)
20 | _SpecGlossMap("Specular", 2D) = "white" {}
21 |
22 | [ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
23 | [ToggleOff] _EnvironmentReflections("Environment Reflections", Float) = 1.0
24 |
25 | _BumpScale("Scale", Float) = 1.0
26 | _BumpMap("Normal Map", 2D) = "bump" {}
27 |
28 | _Parallax("Scale", Range(0.005, 0.08)) = 0.005
29 | _ParallaxMap("Height Map", 2D) = "black" {}
30 |
31 | _OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
32 | _OcclusionMap("Occlusion", 2D) = "white" {}
33 |
34 | [HDR] _EmissionColor("Color", Color) = (0,0,0)
35 | _EmissionMap("Emission", 2D) = "white" {}
36 |
37 | _DetailMask("Detail Mask", 2D) = "white" {}
38 | _DetailAlbedoMapScale("Scale", Range(0.0, 2.0)) = 1.0
39 | _DetailAlbedoMap("Detail Albedo x2", 2D) = "linearGrey" {}
40 | _DetailNormalMapScale("Scale", Range(0.0, 2.0)) = 1.0
41 | [Normal] _DetailNormalMap("Normal Map", 2D) = "bump" {}
42 |
43 | // SRP batching compatibility for Clear Coat (Not used in Lit)
44 | [HideInInspector] _ClearCoatMask("_ClearCoatMask", Float) = 0.0
45 | [HideInInspector] _ClearCoatSmoothness("_ClearCoatSmoothness", Float) = 0.0
46 |
47 | // Blending state
48 | _Surface("__surface", Float) = 0.0
49 | _Blend("__blend", Float) = 0.0
50 | _Cull("__cull", Float) = 2.0
51 | [ToggleUI] _AlphaClip("__clip", Float) = 0.0
52 | [HideInInspector] _SrcBlend("__src", Float) = 1.0
53 | [HideInInspector] _DstBlend("__dst", Float) = 0.0
54 | [HideInInspector] _SrcBlendAlpha("__srcA", Float) = 1.0
55 | [HideInInspector] _DstBlendAlpha("__dstA", Float) = 0.0
56 | [HideInInspector] _ZWrite("__zw", Float) = 1.0
57 | [HideInInspector] _BlendModePreserveSpecular("_BlendModePreserveSpecular", Float) = 1.0
58 | [HideInInspector] _AlphaToMask("__alphaToMask", Float) = 0.0
59 |
60 | [ToggleUI] _ReceiveShadows("Receive Shadows", Float) = 1.0
61 | // Editmode props
62 | _QueueOffset("Queue offset", Float) = 0.0
63 |
64 | // ObsoleteProperties
65 | [HideInInspector] _MainTex("BaseMap", 2D) = "white" {}
66 | [HideInInspector] _Color("Base Color", Color) = (1, 1, 1, 1)
67 | [HideInInspector] _GlossMapScale("Smoothness", Float) = 0.0
68 | [HideInInspector] _Glossiness("Smoothness", Float) = 0.0
69 | [HideInInspector] _GlossyReflections("EnvironmentReflections", Float) = 0.0
70 |
71 | [HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
72 | [HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
73 | [HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
74 | }
75 |
76 | SubShader
77 | {
78 | // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
79 | // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
80 | // material work with both Universal Render Pipeline and Builtin Unity Pipeline
81 | Tags
82 | {
83 | "RenderType" = "Opaque"
84 | "RenderPipeline" = "UniversalPipeline"
85 | "UniversalMaterialType" = "Lit"
86 | "IgnoreProjector" = "True"
87 | }
88 | LOD 300
89 |
90 | // ------------------------------------------------------------------
91 | // Forward pass. Shades all light in a single pass. GI + emission + Fog
92 | Pass
93 | {
94 | // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
95 | // no LightMode tag are also rendered by Universal Render Pipeline
96 | Name "ForwardLit"
97 | Tags
98 | {
99 | "LightMode" = "UniversalForward"
100 | }
101 |
102 | // -------------------------------------
103 | // Render State Commands
104 | Blend[_SrcBlend][_DstBlend], [_SrcBlendAlpha][_DstBlendAlpha]
105 | ZWrite[_ZWrite]
106 | Cull[_Cull]
107 | AlphaToMask[_AlphaToMask]
108 |
109 | HLSLPROGRAM
110 | #pragma target 2.0
111 |
112 | // -------------------------------------
113 | // Shader Stages
114 | #pragma vertex LitPassVertex
115 | #pragma fragment LitPassFragment
116 |
117 | // -------------------------------------
118 | // Material Keywords
119 | #pragma shader_feature_local _NORMALMAP
120 | #pragma shader_feature_local _PARALLAXMAP
121 | #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
122 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
123 | #pragma shader_feature_local_fragment _SURFACE_TYPE_TRANSPARENT
124 | #pragma shader_feature_local_fragment _ALPHATEST_ON
125 | #pragma shader_feature_local_fragment _ _ALPHAPREMULTIPLY_ON _ALPHAMODULATE_ON
126 | #pragma shader_feature_local_fragment _EMISSION
127 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
128 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
129 | #pragma shader_feature_local_fragment _OCCLUSIONMAP
130 | #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
131 | #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
132 | #pragma shader_feature_local_fragment _SPECULAR_SETUP
133 |
134 | // -------------------------------------
135 | // Universal Pipeline keywords
136 | #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
137 | #pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
138 | #pragma multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
139 | #pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
140 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
141 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
142 | #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
143 | #pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
144 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
145 | #pragma multi_compile_fragment _ _LIGHT_COOKIES
146 | #pragma multi_compile _ _LIGHT_LAYERS
147 | #pragma multi_compile _ _FORWARD_PLUS
148 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
149 |
150 |
151 | // -------------------------------------
152 | // Unity defined keywords
153 | #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
154 | #pragma multi_compile _ SHADOWS_SHADOWMASK
155 | #pragma multi_compile _ DIRLIGHTMAP_COMBINED
156 | #pragma multi_compile _ LIGHTMAP_ON
157 | #pragma multi_compile _ DYNAMICLIGHTMAP_ON
158 | #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
159 | #pragma multi_compile_fog
160 | #pragma multi_compile_fragment _ DEBUG_DISPLAY
161 |
162 | //--------------------------------------
163 | // GPU Instancing
164 | #pragma multi_compile_instancing
165 | #pragma instancing_options renderinglayer
166 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
167 |
168 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
169 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
170 | ENDHLSL
171 | }
172 |
173 | Pass
174 | {
175 | Name "ShadowCaster"
176 | Tags
177 | {
178 | "LightMode" = "ShadowCaster"
179 | }
180 |
181 | // -------------------------------------
182 | // Render State Commands
183 | ZWrite On
184 | ZTest LEqual
185 | ColorMask 0
186 | Cull[_Cull]
187 |
188 | HLSLPROGRAM
189 | #pragma target 2.0
190 |
191 | // -------------------------------------
192 | // Shader Stages
193 | #pragma vertex ShadowPassVertex
194 | #pragma fragment ShadowPassFragment
195 |
196 | // -------------------------------------
197 | // Material Keywords
198 | #pragma shader_feature_local_fragment _ALPHATEST_ON
199 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
200 |
201 | //--------------------------------------
202 | // GPU Instancing
203 | #pragma multi_compile_instancing
204 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
205 |
206 | // -------------------------------------
207 | // Universal Pipeline keywords
208 |
209 | // -------------------------------------
210 | // Unity defined keywords
211 | #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
212 |
213 | // This is used during shadow map generation to differentiate between directional and punctual light shadows, as they use different formulas to apply Normal Bias
214 | #pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
215 |
216 | // -------------------------------------
217 | // Includes
218 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
219 | #include "Packages/com.unity.render-pipelines.universal/Shaders/ShadowCasterPass.hlsl"
220 | ENDHLSL
221 | }
222 |
223 | Pass
224 | {
225 | // Lightmode matches the ShaderPassName set in UniversalRenderPipeline.cs. SRPDefaultUnlit and passes with
226 | // no LightMode tag are also rendered by Universal Render Pipeline
227 | Name "GBuffer"
228 | Tags
229 | {
230 | "LightMode" = "UniversalGBuffer"
231 | }
232 |
233 | // -------------------------------------
234 | // Render State Commands
235 | ZWrite[_ZWrite]
236 | ZTest LEqual
237 | Cull[_Cull]
238 |
239 | HLSLPROGRAM
240 | #pragma target 4.5
241 |
242 | // Deferred Rendering Path does not support the OpenGL-based graphics API:
243 | // Desktop OpenGL, OpenGL ES 3.0, WebGL 2.0.
244 | #pragma exclude_renderers gles3 glcore
245 |
246 | // -------------------------------------
247 | // Shader Stages
248 | #pragma vertex LitGBufferPassVertex
249 | #pragma fragment LitGBufferPassFragment
250 |
251 | // -------------------------------------
252 | // Material Keywords
253 | #pragma shader_feature_local _NORMALMAP
254 | #pragma shader_feature_local_fragment _ALPHATEST_ON
255 | //#pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
256 | #pragma shader_feature_local_fragment _EMISSION
257 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
258 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
259 | #pragma shader_feature_local_fragment _OCCLUSIONMAP
260 | #pragma shader_feature_local _PARALLAXMAP
261 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
262 |
263 | #pragma shader_feature_local_fragment _SPECULARHIGHLIGHTS_OFF
264 | #pragma shader_feature_local_fragment _ENVIRONMENTREFLECTIONS_OFF
265 | #pragma shader_feature_local_fragment _SPECULAR_SETUP
266 | #pragma shader_feature_local _RECEIVE_SHADOWS_OFF
267 |
268 | // -------------------------------------
269 | // Universal Pipeline keywords
270 | #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
271 | //#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
272 | //#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
273 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
274 | #pragma multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
275 | #pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
276 | #pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
277 | #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED
278 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
279 |
280 | // -------------------------------------
281 | // Unity defined keywords
282 | #pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
283 | #pragma multi_compile _ SHADOWS_SHADOWMASK
284 | #pragma multi_compile _ DIRLIGHTMAP_COMBINED
285 | #pragma multi_compile _ LIGHTMAP_ON
286 | #pragma multi_compile _ DYNAMICLIGHTMAP_ON
287 | #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
288 | #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
289 |
290 | //--------------------------------------
291 | // GPU Instancing
292 | #pragma multi_compile_instancing
293 | #pragma instancing_options renderinglayer
294 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
295 |
296 | // -------------------------------------
297 | // Includes
298 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
299 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl"
300 | ENDHLSL
301 | }
302 |
303 | Pass
304 | {
305 | Name "DepthOnly"
306 | Tags
307 | {
308 | "LightMode" = "DepthOnly"
309 | }
310 |
311 | // -------------------------------------
312 | // Render State Commands
313 | ZWrite On
314 | ColorMask R
315 | Cull[_Cull]
316 |
317 | HLSLPROGRAM
318 | #pragma target 2.0
319 |
320 | // -------------------------------------
321 | // Shader Stages
322 | #pragma vertex DepthOnlyVertex
323 | #pragma fragment DepthOnlyFragment
324 |
325 | // -------------------------------------
326 | // Material Keywords
327 | #pragma shader_feature_local_fragment _ALPHATEST_ON
328 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
329 |
330 | // -------------------------------------
331 | // Unity defined keywords
332 | #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
333 |
334 | //--------------------------------------
335 | // GPU Instancing
336 | #pragma multi_compile_instancing
337 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
338 |
339 | // -------------------------------------
340 | // Includes
341 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
342 | #include "Packages/com.unity.render-pipelines.universal/Shaders/DepthOnlyPass.hlsl"
343 | ENDHLSL
344 | }
345 |
346 | // This pass is used when drawing to a _CameraNormalsTexture texture
347 | Pass
348 | {
349 | Name "DepthNormals"
350 | Tags
351 | {
352 | "LightMode" = "DepthNormals"
353 | }
354 |
355 | // -------------------------------------
356 | // Render State Commands
357 | ZWrite On
358 | Cull[_Cull]
359 |
360 | HLSLPROGRAM
361 | #pragma target 2.0
362 |
363 | // -------------------------------------
364 | // Shader Stages
365 | #pragma vertex DepthNormalsVertex
366 | #pragma fragment DepthNormalsFragment
367 |
368 | // -------------------------------------
369 | // Material Keywords
370 | #pragma shader_feature_local _NORMALMAP
371 | #pragma shader_feature_local _PARALLAXMAP
372 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
373 | #pragma shader_feature_local_fragment _ALPHATEST_ON
374 | #pragma shader_feature_local_fragment _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
375 |
376 | // -------------------------------------
377 | // Unity defined keywords
378 | #pragma multi_compile_fragment _ LOD_FADE_CROSSFADE
379 |
380 | // -------------------------------------
381 | // Universal Pipeline keywords
382 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"
383 |
384 | //--------------------------------------
385 | // GPU Instancing
386 | #pragma multi_compile_instancing
387 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
388 |
389 | // -------------------------------------
390 | // Includes
391 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
392 | #include "./SSRForwardLitDepthNormalsPass.hlsl"
393 | ENDHLSL
394 | }
395 |
396 | // This pass it not used during regular rendering, only for lightmap baking.
397 | Pass
398 | {
399 | Name "Meta"
400 | Tags
401 | {
402 | "LightMode" = "Meta"
403 | }
404 |
405 | // -------------------------------------
406 | // Render State Commands
407 | Cull Off
408 |
409 | HLSLPROGRAM
410 | #pragma target 2.0
411 |
412 | // -------------------------------------
413 | // Shader Stages
414 | #pragma vertex UniversalVertexMeta
415 | #pragma fragment UniversalFragmentMetaLit
416 |
417 | // -------------------------------------
418 | // Material Keywords
419 | #pragma shader_feature_local_fragment _SPECULAR_SETUP
420 | #pragma shader_feature_local_fragment _EMISSION
421 | #pragma shader_feature_local_fragment _METALLICSPECGLOSSMAP
422 | #pragma shader_feature_local_fragment _ALPHATEST_ON
423 | #pragma shader_feature_local_fragment _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
424 | #pragma shader_feature_local _ _DETAIL_MULX2 _DETAIL_SCALED
425 | #pragma shader_feature_local_fragment _SPECGLOSSMAP
426 | #pragma shader_feature EDITOR_VISUALIZATION
427 |
428 | // -------------------------------------
429 | // Includes
430 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
431 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitMetaPass.hlsl"
432 |
433 | ENDHLSL
434 | }
435 |
436 | Pass
437 | {
438 | Name "Universal2D"
439 | Tags
440 | {
441 | "LightMode" = "Universal2D"
442 | }
443 |
444 | // -------------------------------------
445 | // Render State Commands
446 | Blend[_SrcBlend][_DstBlend]
447 | ZWrite[_ZWrite]
448 | Cull[_Cull]
449 |
450 | HLSLPROGRAM
451 | #pragma target 2.0
452 |
453 | // -------------------------------------
454 | // Shader Stages
455 | #pragma vertex vert
456 | #pragma fragment frag
457 |
458 | // -------------------------------------
459 | // Material Keywords
460 | #pragma shader_feature_local_fragment _ALPHATEST_ON
461 | #pragma shader_feature_local_fragment _ALPHAPREMULTIPLY_ON
462 |
463 | #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
464 |
465 | // -------------------------------------
466 | // Includes
467 | #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
468 | #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/Universal2D.hlsl"
469 | ENDHLSL
470 | }
471 | }
472 |
473 | FallBack "Hidden/Universal Render Pipeline/FallbackError"
474 | CustomEditor "UnityEditor.Rendering.Universal.ShaderGUI.LitShader"
475 | }
476 |
--------------------------------------------------------------------------------
/Sample/Forward/Shader/SSRForwardLit.shader.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 59ac94800b863454d89fe5ea963f5596
3 | ShaderImporter:
4 | externalObjects: {}
5 | defaultTextures: []
6 | nonModifiableTextures: []
7 | userData:
8 | assetBundleName:
9 | assetBundleVariant:
10 |
--------------------------------------------------------------------------------
/Sample/Forward/Shader/SSRForwardLitDepthNormalsPass.hlsl:
--------------------------------------------------------------------------------
1 | #ifndef UNIVERSAL_SSR_FORWARD_LIT_DEPTH_NORMALS_PASS_INCLUDED
2 | #define UNIVERSAL_SSR_FORWARD_LIT_DEPTH_NORMALS_PASS_INCLUDED
3 |
4 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
5 | #if defined(LOD_FADE_CROSSFADE)
6 | #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/LODCrossFade.hlsl"
7 | #endif
8 |
9 | #if defined(_DETAIL_MULX2) || defined(_DETAIL_SCALED)
10 | #define _DETAIL
11 | #endif
12 |
13 | // GLES2 has limited amount of interpolators
14 | #if defined(_PARALLAXMAP) && !defined(SHADER_API_GLES)
15 | #define REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR
16 | #endif
17 |
18 | #if (defined(_NORMALMAP) || (defined(_PARALLAXMAP) && !defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR))) || defined(_DETAIL)
19 | #define REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR
20 | #endif
21 |
22 | struct Attributes
23 | {
24 | float4 positionOS : POSITION;
25 | float4 tangentOS : TANGENT;
26 | float2 texcoord : TEXCOORD0;
27 | float3 normal : NORMAL;
28 | UNITY_VERTEX_INPUT_INSTANCE_ID
29 | };
30 |
31 | struct Varyings
32 | {
33 | float4 positionCS : SV_POSITION;
34 | float2 uv : TEXCOORD1;
35 | half3 normalWS : TEXCOORD2;
36 |
37 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
38 | half4 tangentWS : TEXCOORD4; // xyz: tangent, w: sign
39 | #endif
40 |
41 | half3 viewDirWS : TEXCOORD5;
42 |
43 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
44 | half3 viewDirTS : TEXCOORD8;
45 | #endif
46 |
47 | UNITY_VERTEX_INPUT_INSTANCE_ID
48 | UNITY_VERTEX_OUTPUT_STEREO
49 | };
50 |
51 |
52 | Varyings DepthNormalsVertex(Attributes input)
53 | {
54 | Varyings output = (Varyings)0;
55 | UNITY_SETUP_INSTANCE_ID(input);
56 | UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
57 |
58 | output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
59 | output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
60 |
61 | VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
62 | VertexNormalInputs normalInput = GetVertexNormalInputs(input.normal, input.tangentOS);
63 |
64 | half3 viewDirWS = GetWorldSpaceNormalizeViewDir(vertexInput.positionWS);
65 | output.normalWS = half3(normalInput.normalWS);
66 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR) || defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
67 | float sign = input.tangentOS.w * float(GetOddNegativeScale());
68 | half4 tangentWS = half4(normalInput.tangentWS.xyz, sign);
69 | #endif
70 |
71 | #if defined(REQUIRES_WORLD_SPACE_TANGENT_INTERPOLATOR)
72 | output.tangentWS = tangentWS;
73 | #endif
74 |
75 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
76 | half3 viewDirTS = GetViewDirectionTangentSpace(tangentWS, output.normalWS, viewDirWS);
77 | output.viewDirTS = viewDirTS;
78 | #endif
79 |
80 | return output;
81 | }
82 |
83 | void DepthNormalsFragment(
84 | Varyings input
85 | , out half4 outNormalWS : SV_Target0
86 | #ifdef _WRITE_RENDERING_LAYERS
87 | , out float4 outRenderingLayers : SV_Target1
88 | #endif
89 | )
90 | {
91 | UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
92 |
93 | half4 sampleVar = SampleAlbedoAlpha(input.uv, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
94 | half smoothness = SampleMetallicSpecGloss(input.uv, sampleVar.a).a;
95 | Alpha(sampleVar.a, _BaseColor, _Cutoff);
96 |
97 | #ifdef LOD_FADE_CROSSFADE
98 | LODFadeCrossFade(input.positionCS);
99 | #endif
100 |
101 | #if defined(_GBUFFER_NORMALS_OCT)
102 | float3 normalWS = normalize(input.normalWS);
103 | float2 octNormalWS = PackNormalOctQuadEncode(normalWS); // values between [-1, +1], must use fp32 on some platforms
104 | float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); // values between [ 0, 1]
105 | half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); // values between [ 0, 1]
106 | outNormalWS = half4(packedNormalWS, smoothness); // Store smoothness for Forward
107 | #else
108 | float2 uv = input.uv;
109 | #if defined(_PARALLAXMAP)
110 | #if defined(REQUIRES_TANGENT_SPACE_VIEW_DIR_INTERPOLATOR)
111 | half3 viewDirTS = input.viewDirTS;
112 | #else
113 | half3 viewDirTS = GetViewDirectionTangentSpace(input.tangentWS, input.normalWS, input.viewDirWS);
114 | #endif
115 | ApplyPerPixelDisplacement(viewDirTS, uv);
116 | #endif
117 |
118 | #if defined(_NORMALMAP) || defined(_DETAIL)
119 | float sgn = input.tangentWS.w; // should be either +1 or -1
120 | float3 bitangent = sgn * cross(input.normalWS.xyz, input.tangentWS.xyz);
121 | float3 normalTS = SampleNormal(uv, TEXTURE2D_ARGS(_BumpMap, sampler_BumpMap), _BumpScale);
122 |
123 | #if defined(_DETAIL)
124 | half detailMask = SAMPLE_TEXTURE2D(_DetailMask, sampler_DetailMask, uv).a;
125 | float2 detailUv = uv * _DetailAlbedoMap_ST.xy + _DetailAlbedoMap_ST.zw;
126 | normalTS = ApplyDetailNormal(detailUv, normalTS, detailMask);
127 | #endif
128 |
129 | float3 normalWS = TransformTangentToWorld(normalTS, half3x3(input.tangentWS.xyz, bitangent.xyz, input.normalWS.xyz));
130 | #else
131 | float3 normalWS = input.normalWS;
132 | #endif
133 |
134 | outNormalWS = half4(NormalizeNormalPerPixel(normalWS), smoothness); // Store smoothness for Forward
135 | #endif
136 |
137 | #ifdef _WRITE_RENDERING_LAYERS
138 | uint renderingLayers = GetMeshRenderingLayer();
139 | outRenderingLayers = float4(EncodeMeshRenderingLayer(renderingLayers), 0, 0, 0);
140 | #endif
141 | }
142 |
143 | #endif
144 |
--------------------------------------------------------------------------------
/Sample/Forward/Shader/SSRForwardLitDepthNormalsPass.hlsl.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 887530ab0860bc64a885ca07815c52de
3 | ShaderIncludeImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Setting.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3248973e8c116ba4eaf2aec673c85358
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Setting/Screen Space Reflection Settings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: 30369b8245cc3f840832c23fcf73be90, type: 3}
13 | m_Name: Screen Space Reflection Settings
14 | m_EditorClassIdentifier:
15 | depthPyramidCS: {fileID: 7200000, guid: f16d03b7874a24f418713cda8a6ca007, type: 3}
16 | screenSpaceReflectionsCS: {fileID: 7200000, guid: f0f28b04d94cb664398e3e0cac4dc8a6,
17 | type: 3}
18 | enabled: 1
19 | minSmoothness: 0.5
20 | smoothnessFadeStart: 0.9
21 | reflectSky: 1
22 | objectThickness: 0.01
23 | screenFadeDistance: 0.1
24 | rayMaxIterations: 256
25 |
--------------------------------------------------------------------------------
/Setting/Screen Space Reflection Settings.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 46315cf78a9f9024fbf58a12c57c16be
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/UniversalScreenSpaceReflection.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "UniversalScreenSpaceReflection",
3 | "rootNamespace": "",
4 | "references": [
5 | "GUID:c579267770062bf448e75eb160330b7f",
6 | "GUID:15fc0a57446b3144c949da3e2b9737a9",
7 | "GUID:b4517ec124862cb4bb3b8b27d72843a6",
8 | "GUID:ab67fb10353d84448ac887a7367cbda8",
9 | "GUID:3eae0364be2026648bf74846acb8a731",
10 | "GUID:df380645f10b7bc4b97d4f5eb6303d95",
11 | "GUID:46a67ded66a63de48b9329c593fc08de"
12 | ],
13 | "includePlatforms": [],
14 | "excludePlatforms": [],
15 | "allowUnsafeCode": false,
16 | "overrideReferences": false,
17 | "precompiledReferences": [],
18 | "autoReferenced": true,
19 | "defineConstraints": [],
20 | "versionDefines": [],
21 | "noEngineReferences": false
22 | }
--------------------------------------------------------------------------------
/UniversalScreenSpaceReflection.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9f4bfc553c1578d41af9c5c675178b99
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "com.unity.universal-screenspacereflection",
3 | "displayName":"Universal Screen Space Reflection",
4 | "version": "1.0.1",
5 | "unity": "2022.3",
6 | "description": "The ScreenSpaceRelfection package for URP",
7 | "dependencies":
8 | {
9 | "com.unity.render-pipelines.core": "14.0.0"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/package.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bd1222e690c64db4a869cc8a0cca23a0
3 | PackageManifestImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------