SurfaceData.bslinc 839 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. float3 albedo = samples[0].albedo.xyz;
  18. float3 normal = samples[0].worldNormal.xyz;
  19. float depth = samples[0].depth;
  20. [unroll]
  21. for(int i = 1; i < MSAA_COUNT; i++)
  22. {
  23. float3 otherAlbedo = samples[i].albedo.xyz;
  24. float3 otherNormal = samples[i].worldNormal.xyz;
  25. float otherDepth = samples[i].depth;
  26. [branch]
  27. if(abs(depth - otherDepth) > 0.1f || abs(dot(abs(normal - otherNormal), float3(1, 1, 1))) > 0.1f || abs(dot(albedo - otherAlbedo, float3(1, 1, 1))) > 0.1f)
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. #endif
  35. #endif
  36. };
  37. };