MSAACoverage.bsl 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "$ENGINE$\PPBase.bslinc"
  2. #include "$ENGINE$\GBufferInput.bslinc"
  3. #include "$ENGINE$\PerCameraData.bslinc"
  4. technique MSAACoverage
  5. {
  6. mixin PPBase;
  7. mixin GBufferInput;
  8. mixin PerCameraData;
  9. variations
  10. {
  11. MSAA_COUNT = { 2, 4, 8 };
  12. };
  13. code
  14. {
  15. float fsmain(VStoFS input) : SV_Target0
  16. {
  17. SurfaceData surfaceData[MSAA_COUNT];
  18. [unroll]
  19. for(uint i = 0; i < MSAA_COUNT; ++i)
  20. surfaceData[i] = getGBufferData((int2)input.uv0, i);
  21. float3 albedo = surfaceData[0].albedo.xyz;
  22. float3 normal = surfaceData[0].worldNormal.xyz;
  23. float depth = surfaceData[0].depth;
  24. [unroll]
  25. for(int i = 1; i < MSAA_COUNT; i++)
  26. {
  27. float3 otherAlbedo = surfaceData[i].albedo.xyz;
  28. float3 otherNormal = surfaceData[i].worldNormal.xyz;
  29. float otherDepth = surfaceData[i].depth;
  30. [branch]
  31. if((abs(depth - otherDepth) > 0.01f) ||
  32. (dot(normal, otherNormal) < 0.99f) ||
  33. (abs(dot(albedo - otherAlbedo, float3(1, 1, 1))) > 0.01f))
  34. {
  35. return 1.0f;
  36. }
  37. }
  38. return 0.0f;
  39. }
  40. };
  41. };