engineGL3DSupport.cpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #include "engineGL3DSupport.h"
  2. void errorCallbackCustom(std::string err, void *userData)
  3. {
  4. RequestedContainerInfo *data = (RequestedContainerInfo *)userData;
  5. data->consoleWrite((err + "\n").c_str());
  6. }
  7. std::string readEntireFileCustom(const char *fileName, bool &couldNotOpen, void *userData)
  8. {
  9. RequestedContainerInfo *data = (RequestedContainerInfo *)userData;
  10. couldNotOpen = false;
  11. size_t size = 0;
  12. if (!data->getFileSize(fileName, size))
  13. {
  14. couldNotOpen = true;
  15. return "";
  16. }
  17. std::string buffer;
  18. buffer.resize(size + 1);
  19. if (!data->readEntireFile(fileName, &buffer.at(0), size))
  20. {
  21. couldNotOpen = true;
  22. return "";
  23. }
  24. return buffer;
  25. }
  26. std::vector<char> readEntireFileBinaryCustom(const char *fileName, bool &couldNotOpen, void *userData)
  27. {
  28. RequestedContainerInfo *data = (RequestedContainerInfo *)userData;
  29. couldNotOpen = false;
  30. size_t size = 0;
  31. if (!data->getFileSizeBinary(fileName, size))
  32. {
  33. couldNotOpen = true;
  34. return {};
  35. }
  36. std::vector<char> buffer;
  37. buffer.resize(size + 1, 0);
  38. if (!data->readEntireFileBinary(fileName, &buffer.at(0), size))
  39. {
  40. couldNotOpen = true;
  41. return {};
  42. }
  43. return buffer;
  44. }
  45. bool defaultFileExistsCustom(const char *fileName, void *userData)
  46. {
  47. RequestedContainerInfo *data = (RequestedContainerInfo *)userData;
  48. size_t s = 0;
  49. return data->getFileSizeBinary(fileName, s);
  50. }
  51. void pika::gl3d::generalSettingsWindow(int imguiId, ::gl3d::Renderer3D &renderer)
  52. {
  53. ImGui::PushID(imguiId);
  54. //ImGui::SliderFloat("Gama Corections", &gamaCorection, 1, 3);
  55. ImGui::SliderFloat("Exposure", &renderer.internal.lightShader.lightPassUniformBlockCpuData.exposure, 0.1, 10);
  56. auto normalMap = renderer.isNormalMappingEnabeled();
  57. ImGui::Checkbox("Normal map", &normalMap);
  58. renderer.enableNormalMapping(normalMap);
  59. static bool lightSubScater = renderer.isLightSubScatteringEnabeled();
  60. ImGui::Checkbox("Light sub scater", &lightSubScater);
  61. renderer.enableLightSubScattering(lightSubScater);
  62. ImGui::Checkbox("Adaptive resolution", &renderer.adaptiveResolution.useAdaptiveResolution);
  63. ImGui::Text("Adaptive rez ratio: %.1f", renderer.adaptiveResolution.rezRatio);
  64. //ImGui::Checkbox("Z pre pass", &renderer.zPrePass);
  65. ImGui::Checkbox("Frustum culling", &renderer.frustumCulling);
  66. ImGui::PopID();
  67. }
  68. void pika::gl3d::fxaaSettingsWindow(int imguiId, ::gl3d::Renderer3D &renderer)
  69. {
  70. ImGui::PushID(imguiId);
  71. ImGui::Checkbox("FXAA", &renderer.antiAlias.usingFXAA);
  72. auto &fxaaData = renderer.getFxaaSettings();
  73. ImGui::DragFloat("edgeDarkTreshold", &fxaaData.edgeDarkTreshold, 0.001, 0, 1);
  74. ImGui::DragFloat("edgeMinTreshold", &fxaaData.edgeMinTreshold, 0.001, 0, 1);
  75. ImGui::DragFloat("quaityMultiplier", &fxaaData.quaityMultiplier, 0.001, 0, 1);
  76. ImGui::DragInt("ITERATIONS", &fxaaData.ITERATIONS, 1, 1, 32);
  77. ImGui::DragFloat("SUBPIXEL_QUALITY", &fxaaData.SUBPIXEL_QUALITY, 0.001, 0, 1);
  78. ImGui::PopID();
  79. }
  80. void pika::gl3d::ssaoSettingsWindow(int imguiId, ::gl3d::Renderer3D &renderer)
  81. {
  82. ImGui::PushID(imguiId);
  83. ImGui::Checkbox("SSAO", &renderer.internal.lightShader.useSSAO);
  84. ImGui::SliderFloat("SSAO bias", &renderer.internal.ssao.ssaoShaderUniformBlockData.bias, 0, 0.5);
  85. ImGui::SliderFloat("SSAO radius", &renderer.internal.ssao.ssaoShaderUniformBlockData.radius, 0, 2);
  86. ImGui::SliderInt("SSAO sample count", &renderer.internal.ssao.ssaoShaderUniformBlockData.samplesTestSize, 0, 64);
  87. ImGui::SliderFloat("SSAO exponent", &renderer.internal.ssao.ssao_finalColor_exponent, 0, 16);
  88. ImGui::PopID();
  89. }
  90. void pika::gl3d::ssrSettingsWindow(int imguiId, ::gl3d::Renderer3D &renderer)
  91. {
  92. ImGui::PushID(imguiId);
  93. ImGui::Checkbox("SSR", &renderer.internal.hasLastFrameTexture);
  94. auto d = renderer.getSSRdata();
  95. ImGui::SliderFloat("max ray delta", &d.maxRayDelta, 0.0001f, 2.f); //for clamping infinity
  96. ImGui::SliderFloat("max ray step", &d.maxRayStep, 0.01f, 5.f);
  97. ImGui::SliderInt("max steps", &d.maxSteps, 5, 150);
  98. ImGui::SliderFloat("min ray step", &d.minRayStep, 0.001f, 1.f);
  99. ImGui::SliderInt("binary search steps", &d.numBinarySearchSteps, 2, 20);
  100. renderer.setSSRdata(d);
  101. ImGui::PopID();
  102. }
  103. void pika::gl3d::bloomSettingsWindow(int imguiId, ::gl3d::Renderer3D &renderer)
  104. {
  105. ImGui::PushID(imguiId);
  106. ImGui::Checkbox("Bloom", &renderer.bloom());
  107. ImGui::DragFloat("Bloom tresshold", &renderer.internal.lightShader.lightPassUniformBlockCpuData.bloomTresshold,
  108. 0.01, 0, 1);
  109. ImGui::DragFloat("Bloom intensity", &renderer.postProcess.bloomIntensty, 0.01, 0, 10);
  110. ImGui::Checkbox("High quality down sample", &renderer.bloomHighQualityDownSample());
  111. ImGui::Checkbox("High quality up sample", &renderer.bloomHighQualityUpSample());
  112. ImGui::PopID();
  113. }
  114. void pika::gl3d::chromaticAberationSettingsWindow(int imguiId, ::gl3d::Renderer3D &renderer)
  115. {
  116. ImGui::PushID(imguiId);
  117. ImGui::Checkbox("Chromatic aberation", &renderer.chromaticAberationEnabeled());
  118. ImGui::DragFloat("Chromatic aberation strength", &renderer.postProcess.chromaticAberationStrength,
  119. 1, 0, 200);
  120. ImGui::DragFloat("Chromatic aberation defocus", &renderer.postProcess.unfocusDistance,
  121. 0.01, 0, 100);
  122. ImGui::PopID();
  123. }