SurfaceData.bslinc 948 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. mixin SurfaceData
  2. {
  3. code
  4. {
  5. struct SurfaceData
  6. {
  7. float4 albedo;
  8. float4 worldNormal;
  9. float depth;
  10. float roughness;
  11. float metalness;
  12. };
  13. #ifdef MSAA_COUNT
  14. #if MSAA_COUNT > 1
  15. bool needsPerSampleShading(SurfaceData samples[MSAA_COUNT])
  16. {
  17. // Always shade all samples, otherwise there is visible aliasing. It could be enabled if HDR is not used.
  18. return true;
  19. float3 albedo = samples[0].albedo.xyz;
  20. float3 normal = samples[0].worldNormal.xyz;
  21. float depth = samples[0].depth;
  22. [unroll]
  23. for(int i = 1; i < MSAA_COUNT; i++)
  24. {
  25. float3 otherAlbedo = samples[i].albedo.xyz;
  26. float3 otherNormal = samples[i].worldNormal.xyz;
  27. float otherDepth = samples[i].depth;
  28. [branch]
  29. if((abs(depth - otherDepth) > 0.01f) || (dot(normal, otherNormal) < 0.99f) || (abs(dot(albedo - otherAlbedo, float3(1, 1, 1))) > 0.01f))
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. #endif
  37. #endif
  38. };
  39. };