| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- mixin SurfaceData
- {
- code
- {
- struct SurfaceData
- {
- float4 albedo;
- float4 worldNormal;
- float depth;
- float roughness;
- float metalness;
- };
-
- #ifdef MSAA_COUNT
- #if MSAA_COUNT > 1
- bool needsPerSampleShading(SurfaceData samples[MSAA_COUNT])
- {
- // Always shade all samples, otherwise there is visible aliasing. It could be enabled if HDR is not used.
- return true;
-
- float3 albedo = samples[0].albedo.xyz;
- float3 normal = samples[0].worldNormal.xyz;
- float depth = samples[0].depth;
- [unroll]
- for(int i = 1; i < MSAA_COUNT; i++)
- {
- float3 otherAlbedo = samples[i].albedo.xyz;
- float3 otherNormal = samples[i].worldNormal.xyz;
- float otherDepth = samples[i].depth;
- [branch]
- if((abs(depth - otherDepth) > 0.01f) || (dot(normal, otherNormal) < 0.99f) || (abs(dot(albedo - otherAlbedo, float3(1, 1, 1))) > 0.01f))
- {
- return true;
- }
- }
-
- return false;
- }
- #endif
- #endif
- };
- };
|