|
17 | 17 | #define SSR_FINAL_BLEND_STATIC_FACTOR 0.95 |
18 | 18 | #define SSR_FINAL_BLEND_DYNAMIC_FACTOR 0.7 |
19 | 19 |
|
| 20 | +#define SSR_ENABLE_CONTACTS 0 |
| 21 | + |
20 | 22 | // |
21 | 23 | // Helper structs |
22 | 24 | // |
@@ -72,10 +74,13 @@ float4x4 _InverseProjectionMatrix; |
72 | 74 | float4x4 _ScreenSpaceProjectionMatrix; |
73 | 75 |
|
74 | 76 | float4 _Params; // x: attenuation, y: distance fade, z: maximum march distance, w: blur pyramid lod count |
| 77 | +float2 _Params2; // x: aspect ratio, y: noise tiling |
75 | 78 | #define _Attenuation _Params.x |
76 | 79 | #define _DistanceFade _Params.y |
77 | 80 | #define _MaximumMarchDistance _Params.z |
78 | 81 | #define _BlurPyramidLODCount _Params.w |
| 82 | +#define _AspectRatio _Params2.x |
| 83 | +#define _NoiseTiling _Params2.y |
79 | 84 |
|
80 | 85 | // TODO: hardcode these |
81 | 86 | int _MaximumIterationCount; |
@@ -179,8 +184,8 @@ Result march(Ray ray, VaryingsDefault input) |
179 | 184 |
|
180 | 185 | float stride = 1.0 - min(1.0, -ray.origin.z * 0.01); |
181 | 186 |
|
182 | | - float2 uv = input.texcoord * 10.0; |
183 | | - uv.y *= 0.5625; |
| 187 | + float2 uv = input.texcoord * _NoiseTiling; |
| 188 | + uv.y *= _AspectRatio; |
184 | 189 |
|
185 | 190 | float jitter = _Noise.SampleLevel(sampler_Noise, uv + _WorldSpaceCameraPos.xz, 0).a; |
186 | 191 | stride *= _Bandwidth; |
@@ -351,9 +356,13 @@ float4 FragComposite(VaryingsDefault i) : SV_Target |
351 | 356 | float3 eye = mul((float3x3)_InverseViewMatrix, normalize(position)); |
352 | 357 | position = mul(_InverseViewMatrix, float4(position, 1.0)).xyz; |
353 | 358 |
|
354 | | - //float4 test = _Test.SampleLevel(sampler_Test, i.texcoord, 0); |
| 359 | +#if SSR_ENABLE_CONTACTS |
| 360 | + float4 test = _Test.SampleLevel(sampler_Test, i.texcoord, 0); |
| 361 | + float4 resolve = _Resolve.SampleLevel(sampler_Resolve, i.texcoord, SmoothnessToRoughness(gbuffer1.a) * (_BlurPyramidLODCount - 1.0) * test.z + 1.0); |
| 362 | +#else |
| 363 | + float4 resolve = _Resolve.SampleLevel(sampler_Resolve, i.texcoord, SmoothnessToRoughness(gbuffer1.a) * (_BlurPyramidLODCount - 1.0) + 1.0); |
| 364 | +#endif |
355 | 365 |
|
356 | | - float4 resolve = _Resolve.SampleLevel(sampler_Resolve, i.texcoord, SmoothnessToRoughness(gbuffer1.a) * (_BlurPyramidLODCount - 1.0) /* * test.z */ + 1.0); |
357 | 366 | float confidence = saturate(2.0 * dot(-eye, normalize(reflect(-eye, normal)))); |
358 | 367 |
|
359 | 368 | UnityLight light; |
|
0 commit comments