MSAACoverage.bsl 994 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. code
  10. {
  11. float fsmain(VStoFS input) : SV_Target0
  12. {
  13. SurfaceData surfaceData[MSAA_COUNT];
  14. [unroll]
  15. for(uint i = 0; i < MSAA_COUNT; ++i)
  16. surfaceData[i] = getGBufferData((int2)input.uv0, i);
  17. float3 albedo = surfaceData[0].albedo.xyz;
  18. float3 normal = surfaceData[0].worldNormal.xyz;
  19. float depth = surfaceData[0].depth;
  20. [unroll]
  21. for(int i = 1; i < MSAA_COUNT; i++)
  22. {
  23. float3 otherAlbedo = surfaceData[i].albedo.xyz;
  24. float3 otherNormal = surfaceData[i].worldNormal.xyz;
  25. float otherDepth = surfaceData[i].depth;
  26. [branch]
  27. if((abs(depth - otherDepth) > 0.01f) ||
  28. (dot(normal, otherNormal) < 0.99f) ||
  29. (abs(dot(albedo - otherAlbedo, float3(1, 1, 1))) > 0.01f))
  30. {
  31. return 1.0f;
  32. }
  33. }
  34. return 0.0f;
  35. }
  36. };
  37. };