ppedof.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //---------------------------------------------------------
  2. //Native exceptions - legacy methods for direct access to specific postprocesses. Each one is evaluated and handled separately, this just connects them to the system.
  3. //!DOF postprocess, does not directly use materials
  4. class PPEDOF: PPEClassBase
  5. {
  6. //g_Game.OverrideDOF(bool enable, float focusDistance, float focusLength, float focusLengthNear, float blur, float focusDepthOffset);
  7. static const int PARAM_ENABLE = 0;
  8. static const int PARAM_FOCUS_DIST = 1;
  9. static const int PARAM_FOCUS_LEN = 2;
  10. static const int PARAM_FOCUS_LEN_NEAR = 3;
  11. static const int PARAM_BLUR = 4;
  12. static const int PARAM_FOCUS_DEPTH_OFFSET = 5;
  13. static const int L_0_ADS = 100;
  14. static const int L_1_ADS = 100;
  15. static const int L_2_ADS = 100;
  16. static const int L_3_ADS = 100;
  17. static const int L_4_ADS = 100;
  18. static const int L_5_ADS = 100;
  19. override int GetPostProcessEffectID()
  20. {
  21. return PPEExceptions.DOF;
  22. }
  23. override void RegisterMaterialParameters()
  24. {
  25. //no known max. 1000 used as max
  26. RegisterParameterScalarBool(PARAM_ENABLE,"Enable",false);
  27. RegisterParameterScalarFloat(PARAM_FOCUS_DIST,"FocusDistance",2.0,0.0,1000.0); //2.0f used in code with null camera interpolation
  28. RegisterParameterScalarFloat(PARAM_FOCUS_LEN,"FocusLength",-1.0,-1.0,1000.0); //-1.0f used as code default
  29. RegisterParameterScalarFloat(PARAM_FOCUS_LEN_NEAR,"FocusLengthNear",-1.0,-1.0,1000.0); //-1.0f used as code default
  30. RegisterParameterScalarFloat(PARAM_BLUR,"Blur",1.0,0.0,1000.0); //1.0f used in code with null camera interpolation
  31. RegisterParameterScalarFloat(PARAM_FOCUS_DEPTH_OFFSET,"FocusDepthOffset",0.0,0.0,1000.0); //0.0f used as code default
  32. }
  33. override void ApplyValueChanges()
  34. {
  35. if (m_UpdatedParameters.Count() > 0)
  36. {
  37. SetFinalParameterValue(-1); //unique handling
  38. }
  39. m_UpdatedParameters.Clear();
  40. }
  41. //! Overriden to handle the specific exception
  42. override void SetFinalParameterValue(int parameter_idx)
  43. {
  44. Param enabled_par = GetParameterCommandData(PARAM_ENABLE).GetCurrentValues();
  45. bool is_enabled = Param1<bool>.Cast(enabled_par).param1;
  46. if (is_enabled)
  47. {
  48. array<float> array_values = {-1.0};
  49. for (int i = 1; i < PARAM_FOCUS_DEPTH_OFFSET + 1; i++)
  50. {
  51. Param values = GetParameterCommandData(i).GetCurrentValues();
  52. float value_var_float = Param1<float>.Cast(values).param1;
  53. array_values.Insert(value_var_float);
  54. }
  55. g_Game.OverrideDOF(true, array_values.Get(PARAM_FOCUS_DIST), array_values.Get(PARAM_FOCUS_LEN), array_values.Get(PARAM_FOCUS_LEN_NEAR), array_values.Get(PARAM_BLUR), array_values.Get(PARAM_FOCUS_DEPTH_OFFSET));
  56. }
  57. else
  58. {
  59. g_Game.OverrideDOF(false,0.0,0.0,0.0,0.0,1.0);
  60. }
  61. }
  62. }