DeferredLightCommon.bslinc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "$ENGINE$\GBufferInput.bslinc"
  2. #include "$ENGINE$\PerCameraData.bslinc"
  3. #include "$ENGINE$\LightingCommon.bslinc"
  4. mixin DeferredLightCommon
  5. {
  6. mixin GBufferInput;
  7. mixin PerCameraData;
  8. mixin LightingCommon;
  9. depth
  10. {
  11. write = false;
  12. #ifdef INSIDE_GEOMETRY
  13. read = false;
  14. #else
  15. read = true;
  16. #endif
  17. };
  18. raster
  19. {
  20. #ifdef INSIDE_GEOMETRY
  21. cull = cw;
  22. #else
  23. cull = ccw;
  24. #endif
  25. };
  26. code
  27. {
  28. cbuffer PerLight
  29. {
  30. // x, y, z - World position of the light
  31. // w - Radius of the area light source, zero if not an area light
  32. float4 gLightPositionAndSrcRadius;
  33. float4 gLightColorAndLuminance;
  34. // x - outerAngle in radians, y - cos(outerAngle), z - 1.0f/(cos(innerAngle) - cos(outerAngle)), w - inverse light attenuation radius
  35. float4 gLightSpotAnglesAndSqrdInvAttRadius;
  36. float4 gLightDirectionAndAttRadius;
  37. // xyz - light position shifted in order to adjust for area spot lights
  38. // w - light type -> Directional = 0, Radial = >0, Spot = >0.5
  39. float4 gShiftedLightPositionAndType;
  40. // x - Num sides (zero for radial lights)
  41. // y - Num slices (zero for radial lights)
  42. // z - Sphere radius for radial lights
  43. // w - Cone radius for spot lights
  44. float4 gLightGeometry;
  45. float4x4 gMatConeTransform;
  46. }
  47. LightData getLightData()
  48. {
  49. LightData output;
  50. output.position = gLightPositionAndSrcRadius.xyz;
  51. output.attRadius = gLightDirectionAndAttRadius.w;
  52. output.direction = gLightDirectionAndAttRadius.xyz;
  53. output.luminance = gLightColorAndLuminance.w;
  54. output.spotAngles = gLightSpotAnglesAndSqrdInvAttRadius.xyz;
  55. output.attRadiusSqrdInv = gLightSpotAnglesAndSqrdInvAttRadius.w;
  56. output.color = gLightColorAndLuminance.rgb;
  57. output.srcRadius = gLightPositionAndSrcRadius.w;
  58. output.shiftedLightPosition = gShiftedLightPositionAndType.rgb;
  59. return output;
  60. }
  61. };
  62. };