SurfaceData.bslinc 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. Technique : base("SurfaceData") =
  2. {
  3. Language = "HLSL11";
  4. Pass =
  5. {
  6. Common =
  7. {
  8. struct SurfaceData
  9. {
  10. float4 albedo;
  11. float4 worldNormal;
  12. float depth;
  13. float roughness;
  14. float metalness;
  15. };
  16. #if MSAA_COUNT > 1
  17. bool needsPerSampleShading(SurfaceData samples[MSAA_COUNT])
  18. {
  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.1f || abs(dot(abs(normal - otherNormal), float3(1, 1, 1))) > 0.1f || abs(dot(albedo - otherAlbedo, float3(1, 1, 1))) > 0.1f)
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. #endif
  37. };
  38. };
  39. };
  40. Technique : base("SurfaceData") =
  41. {
  42. Language = "GLSL";
  43. Pass =
  44. {
  45. Common =
  46. {
  47. struct SurfaceData
  48. {
  49. vec4 albedo;
  50. vec4 worldNormal;
  51. float depth;
  52. float roughness;
  53. float metalness;
  54. };
  55. };
  56. };
  57. };