PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Utilities/Graphics/BlendMode.cs

#
C# | 69 lines | 12 code | 5 blank | 52 comment | 0 complexity | 43884dd020614a974376748411bd24bd MD5 | raw file
Possible License(s): Apache-2.0
  1. namespace Delta.Utilities.Graphics
  2. {
  3. /// <summary>
  4. /// Blending presets are used for setting alpha blending operations of
  5. /// various types for producing different effects. Now set directly
  6. /// in materials because we want to sort them by blend mode too :)
  7. /// Note: Needed in Content modules already because atlas textures
  8. /// need to know about the blend modes!
  9. /// </summary>
  10. public enum BlendMode
  11. {
  12. /// <summary>
  13. /// The default preset is opaque, which is the fastest blending type
  14. /// because it uses no blending obviously. Also works with AlphaTesting,
  15. /// which is decided once a material is created (then an AlphaTest shader
  16. /// will be chosen). This blend state is the default for all materials
  17. /// that have no alpha channel in the diffuseMap!
  18. /// </summary>
  19. Opaque,
  20. /// <summary>
  21. /// Same as opaque, but use AlphaTest to discard any pixel below 0.66f
  22. /// in the alpha channel. Rendering this is faster than Translucency
  23. /// because we need no sorting and we can skip lots of pixels, which
  24. /// makes the pixel shader go faster. This is however not always true for
  25. /// mobile GPUs as discard is sometimes as expensive as actual rendering!
  26. /// Still this is a useful feature to not write to the depth buffer for
  27. /// transparent pixels thus helping with sorting.
  28. /// </summary>
  29. AlphaTest,
  30. /// <summary>
  31. /// Subtractive rendering mode is pretty much the opposite of additive
  32. /// blending. Instead of always adding more brightness to the target
  33. /// screen pixels, this one subtracts brightness. It is usually and
  34. /// mostly only used for fake shadowing effects (blob shadows) and
  35. /// sometimes in clever combinations of particle effects.
  36. /// </summary>
  37. Subtractive,
  38. /// <summary>
  39. /// Additive blending is used to accumulate the color we already got
  40. /// on screen plus the diffuseMap * AmbientColor. This makes the result
  41. /// image brighter and should be used with care. Has the advantage that
  42. /// we do not need to sort, we can just render this out in any order
  43. /// on top of the Opaque materials and it will always look the same.
  44. /// This blend state usually has to be set by hand to a material!
  45. /// </summary>
  46. Additive,
  47. /// <summary>
  48. /// The normal version of alpha blending, which uses ambientColor.A *
  49. /// diffuseMap alpha and blends that with SrcAlpha InvDestColor (default
  50. /// alpha blending technique). This blend mode is the default for
  51. /// all materials that have an alpha channel in diffuseMap!
  52. /// Note: Only translucent images with alpha should use this blend mode.
  53. /// </summary>
  54. Translucency,
  55. /// <summary>
  56. /// LightEffect, which is using a special blend mode of DestColor+One,
  57. /// which will maybe change later a bit. Basically used for light effects
  58. /// (similar to lightmap shader, but just using a lightmap, no diffuse
  59. /// texture). Needs to set by hand for lightmap materials, only a couple
  60. /// of materials even need to use this, e.g. glow, light and flare effects.
  61. /// </summary>
  62. LightEffect,
  63. }
  64. }