SurfaceData.bslinc 885 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Technique : base("SurfaceData") =
  2. {
  3. Pass =
  4. {
  5. Common =
  6. {
  7. struct SurfaceData
  8. {
  9. float4 albedo;
  10. float4 worldNormal;
  11. float depth;
  12. float roughness;
  13. float metalness;
  14. };
  15. #if MSAA_COUNT > 1
  16. bool needsPerSampleShading(SurfaceData samples[MSAA_COUNT])
  17. {
  18. float3 albedo = samples[0].albedo.xyz;
  19. float3 normal = samples[0].worldNormal.xyz;
  20. float depth = samples[0].depth;
  21. [unroll]
  22. for(int i = 1; i < MSAA_COUNT; i++)
  23. {
  24. float3 otherAlbedo = samples[i].albedo.xyz;
  25. float3 otherNormal = samples[i].worldNormal.xyz;
  26. float otherDepth = samples[i].depth;
  27. [branch]
  28. 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)
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. #endif
  36. };
  37. };
  38. };