14-shadowvolumes: switched to imgui (#1169)
This commit is contained in:
parent
236ef4b875
commit
b89b1459a2
@ -2001,8 +2001,8 @@ class ExampleShadowVolumes : public entry::AppI
|
|||||||
m_settings_mixedSvImpl = true;
|
m_settings_mixedSvImpl = true;
|
||||||
m_settings_useStencilTexture = false;
|
m_settings_useStencilTexture = false;
|
||||||
m_settings_drawShadowVolumes = false;
|
m_settings_drawShadowVolumes = false;
|
||||||
m_settings_numLights = 1.0f;
|
m_settings_numLights = 1;
|
||||||
m_settings_instanceCount = 9.0f;
|
m_settings_instanceCount = 9;
|
||||||
m_settings_shadowVolumeImpl = ShadowVolumeImpl::DepthFail;
|
m_settings_shadowVolumeImpl = ShadowVolumeImpl::DepthFail;
|
||||||
m_settings_shadowVolumeAlgorithm = ShadowVolumeAlgorithm::EdgeBased;
|
m_settings_shadowVolumeAlgorithm = ShadowVolumeAlgorithm::EdgeBased;
|
||||||
m_scrollAreaRight = 0;
|
m_scrollAreaRight = 0;
|
||||||
@ -2139,69 +2139,75 @@ class ExampleShadowVolumes : public entry::AppI
|
|||||||
, uint16_t(m_viewState.m_height)
|
, uint16_t(m_viewState.m_height)
|
||||||
);
|
);
|
||||||
|
|
||||||
imguiBeginScrollArea("Settings", m_viewState.m_width - 256 - 10, 10, 256, 700, &m_scrollAreaRight);
|
ImGui::SetNextWindowPos(ImVec2(m_viewState.m_width - 256.0f, 10.0f) );
|
||||||
|
ImGui::Begin("Settings"
|
||||||
|
, NULL
|
||||||
|
, ImVec2(256.0f, 700.0f)
|
||||||
|
, ImGuiWindowFlags_AlwaysAutoResize
|
||||||
|
);
|
||||||
|
|
||||||
const char* titles[2] =
|
const char* titles[2] =
|
||||||
{
|
{
|
||||||
"Scene 0",
|
"Scene 0",
|
||||||
"Scene 1",
|
"Scene 1",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (imguiCheck(titles[Scene0], Scene0 == m_currentScene) )
|
if (ImGui::RadioButton(titles[Scene0], Scene0 == m_currentScene) )
|
||||||
{
|
{
|
||||||
m_currentScene = Scene0;
|
m_currentScene = Scene0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imguiCheck(titles[Scene1], Scene1 == m_currentScene) )
|
if (ImGui::RadioButton(titles[Scene1], Scene1 == m_currentScene) )
|
||||||
{
|
{
|
||||||
m_currentScene = Scene1;
|
m_currentScene = Scene1;
|
||||||
}
|
}
|
||||||
|
|
||||||
imguiSlider("Lights", m_settings_numLights, 1.0f, float(MAX_LIGHTS_COUNT), 1.0f);
|
ImGui::SliderInt("Lights", &m_settings_numLights, 1, MAX_LIGHTS_COUNT);
|
||||||
|
|
||||||
if (imguiCheck("Update lights", m_settings_updateLights) )
|
ImGui::Checkbox("Update lights", &m_settings_updateLights);
|
||||||
{
|
|
||||||
m_settings_updateLights = !m_settings_updateLights;
|
|
||||||
}
|
|
||||||
|
|
||||||
imguiIndent();
|
ImGui::Indent();
|
||||||
|
|
||||||
if (imguiCheck("Light pattern 0", LightPattern0 == m_lightPattern, m_settings_updateLights) )
|
if (ImGui::RadioButton("Light pattern 0", LightPattern0 == m_lightPattern) )
|
||||||
{
|
{
|
||||||
m_lightPattern = LightPattern0;
|
m_lightPattern = LightPattern0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imguiCheck("Light pattern 1", LightPattern1 == m_lightPattern, m_settings_updateLights) )
|
if (ImGui::RadioButton("Light pattern 1", LightPattern1 == m_lightPattern) )
|
||||||
{
|
{
|
||||||
m_lightPattern = LightPattern1;
|
m_lightPattern = LightPattern1;
|
||||||
}
|
}
|
||||||
|
|
||||||
imguiUnindent();
|
ImGui::Unindent();
|
||||||
|
|
||||||
if (imguiCheck("Update scene", m_settings_updateScene, Scene0 == m_currentScene) )
|
if ( Scene0 == m_currentScene )
|
||||||
{
|
{
|
||||||
m_settings_updateScene = !m_settings_updateScene;
|
ImGui::Checkbox("Update scene", &m_settings_updateScene);
|
||||||
}
|
}
|
||||||
|
|
||||||
imguiSeparatorLine();
|
ImGui::Separator();
|
||||||
imguiLabel("Stencil buffer implementation:");
|
|
||||||
m_settings_shadowVolumeImpl = (imguiCheck("Depth fail", ShadowVolumeImpl::DepthFail == m_settings_shadowVolumeImpl, !m_settings_mixedSvImpl) ? ShadowVolumeImpl::DepthFail : m_settings_shadowVolumeImpl);
|
ImGui::Text("Stencil buffer implementation:");
|
||||||
m_settings_shadowVolumeImpl = (imguiCheck("Depth pass", ShadowVolumeImpl::DepthPass == m_settings_shadowVolumeImpl, !m_settings_mixedSvImpl) ? ShadowVolumeImpl::DepthPass : m_settings_shadowVolumeImpl);
|
ImGui::Checkbox("Mixed", &m_settings_mixedSvImpl);
|
||||||
m_settings_mixedSvImpl = (imguiCheck("Mixed", m_settings_mixedSvImpl) ? !m_settings_mixedSvImpl : m_settings_mixedSvImpl);
|
if (!m_settings_mixedSvImpl)
|
||||||
|
{
|
||||||
|
m_settings_shadowVolumeImpl = (ImGui::RadioButton("Depth fail", ShadowVolumeImpl::DepthFail == m_settings_shadowVolumeImpl) ? ShadowVolumeImpl::DepthFail : m_settings_shadowVolumeImpl);
|
||||||
|
m_settings_shadowVolumeImpl = (ImGui::RadioButton("Depth pass", ShadowVolumeImpl::DepthPass == m_settings_shadowVolumeImpl) ? ShadowVolumeImpl::DepthPass : m_settings_shadowVolumeImpl);
|
||||||
|
}
|
||||||
|
|
||||||
imguiLabel("Shadow volume implementation:");
|
ImGui::Text("Shadow volume implementation:");
|
||||||
m_settings_shadowVolumeAlgorithm = (imguiCheck("Face based impl.", ShadowVolumeAlgorithm::FaceBased == m_settings_shadowVolumeAlgorithm) ? ShadowVolumeAlgorithm::FaceBased : m_settings_shadowVolumeAlgorithm);
|
m_settings_shadowVolumeAlgorithm = (ImGui::RadioButton("Face based impl.", ShadowVolumeAlgorithm::FaceBased == m_settings_shadowVolumeAlgorithm) ? ShadowVolumeAlgorithm::FaceBased : m_settings_shadowVolumeAlgorithm);
|
||||||
m_settings_shadowVolumeAlgorithm = (imguiCheck("Edge based impl.", ShadowVolumeAlgorithm::EdgeBased == m_settings_shadowVolumeAlgorithm) ? ShadowVolumeAlgorithm::EdgeBased : m_settings_shadowVolumeAlgorithm);
|
m_settings_shadowVolumeAlgorithm = (ImGui::RadioButton("Edge based impl.", ShadowVolumeAlgorithm::EdgeBased == m_settings_shadowVolumeAlgorithm) ? ShadowVolumeAlgorithm::EdgeBased : m_settings_shadowVolumeAlgorithm);
|
||||||
|
|
||||||
imguiLabel("Stencil:");
|
ImGui::Text("Stencil:");
|
||||||
if (imguiCheck("Use stencil buffer", !m_settings_useStencilTexture) )
|
if (ImGui::RadioButton("Use stencil buffer", !m_settings_useStencilTexture) )
|
||||||
{
|
{
|
||||||
if (m_settings_useStencilTexture)
|
if (m_settings_useStencilTexture)
|
||||||
{
|
{
|
||||||
m_settings_useStencilTexture = false;
|
m_settings_useStencilTexture = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (imguiCheck("Use texture as stencil", m_settings_useStencilTexture) )
|
if (ImGui::RadioButton("Use texture as stencil", m_settings_useStencilTexture) )
|
||||||
{
|
{
|
||||||
if (!m_settings_useStencilTexture)
|
if (!m_settings_useStencilTexture)
|
||||||
{
|
{
|
||||||
@ -2209,48 +2215,46 @@ class ExampleShadowVolumes : public entry::AppI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imguiSeparatorLine();
|
ImGui::Separator();
|
||||||
imguiLabel("Mesh:");
|
ImGui::Text("Mesh:");
|
||||||
if (imguiCheck("Bunny - high poly", BunnyHighPoly == m_currentMesh) )
|
if (ImGui::RadioButton("Bunny - high poly", BunnyHighPoly == m_currentMesh) )
|
||||||
{
|
{
|
||||||
m_currentMesh = BunnyHighPoly;
|
m_currentMesh = BunnyHighPoly;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imguiCheck("Bunny - low poly", BunnyLowPoly == m_currentMesh) )
|
if (ImGui::RadioButton("Bunny - low poly", BunnyLowPoly == m_currentMesh) )
|
||||||
{
|
{
|
||||||
m_currentMesh = BunnyLowPoly;
|
m_currentMesh = BunnyLowPoly;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Scene1 == m_currentScene)
|
if (Scene1 == m_currentScene)
|
||||||
{
|
{
|
||||||
imguiSlider("Instance count", m_settings_instanceCount, 1.0f, float(MAX_INSTANCE_COUNT), 1.0f);
|
ImGui::SliderInt("Instance count", &m_settings_instanceCount, 1, MAX_INSTANCE_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
imguiLabel("CPU Time: %7.1f [ms]", double(m_profTime)*toMs);
|
ImGui::Text("CPU Time: %7.1f [ms]", double(m_profTime)*toMs);
|
||||||
imguiLabel("Volume Vertices: %5.uk", m_numShadowVolumeVertices/1000);
|
ImGui::Text("Volume Vertices: %5.uk", m_numShadowVolumeVertices/1000);
|
||||||
imguiLabel("Volume Indices: %6.uk", m_numShadowVolumeIndices/1000);
|
ImGui::Text("Volume Indices: %6.uk", m_numShadowVolumeIndices/1000);
|
||||||
m_numShadowVolumeVertices = 0;
|
m_numShadowVolumeVertices = 0;
|
||||||
m_numShadowVolumeIndices = 0;
|
m_numShadowVolumeIndices = 0;
|
||||||
|
|
||||||
imguiSeparatorLine();
|
ImGui::Separator();
|
||||||
m_settings_drawShadowVolumes = imguiCheck("Draw Shadow Volumes", m_settings_drawShadowVolumes)
|
ImGui::Checkbox("Draw Shadow Volumes", &m_settings_drawShadowVolumes);
|
||||||
? !m_settings_drawShadowVolumes
|
|
||||||
: m_settings_drawShadowVolumes
|
|
||||||
;
|
|
||||||
imguiIndent();
|
|
||||||
imguiUnindent();
|
|
||||||
|
|
||||||
imguiEndScrollArea();
|
ImGui::End();
|
||||||
|
|
||||||
static int32_t scrollAreaLeft = 0;
|
ImGui::SetNextWindowPos(ImVec2(10, m_viewState.m_height - 77 - 10) );
|
||||||
imguiBeginScrollArea("Show help:", 10, m_viewState.m_height - 77 - 10, 120, 77, &scrollAreaLeft);
|
ImGui::Begin("Show help:"
|
||||||
m_settings_showHelp = imguiButton(m_settings_showHelp ? "ON" : "OFF")
|
, NULL
|
||||||
? !m_settings_showHelp
|
, ImVec2(120.0f, 77.0f)
|
||||||
: m_settings_showHelp
|
, ImGuiWindowFlags_AlwaysAutoResize
|
||||||
;
|
);
|
||||||
|
|
||||||
imguiEndScrollArea();
|
if ( ImGui::Button(m_settings_showHelp ? "ON" : "OFF") )
|
||||||
|
m_settings_showHelp = !m_settings_showHelp;
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
imguiEndFrame();
|
imguiEndFrame();
|
||||||
|
|
||||||
//update settings
|
//update settings
|
||||||
@ -2281,9 +2285,9 @@ class ExampleShadowVolumes : public entry::AppI
|
|||||||
{
|
{
|
||||||
for (uint8_t ii = 0; ii < m_settings_numLights; ++ii)
|
for (uint8_t ii = 0; ii < m_settings_numLights; ++ii)
|
||||||
{
|
{
|
||||||
lightPosRadius[ii][0] = bx::fcos(2.0f*bx::kPi/m_settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
|
lightPosRadius[ii][0] = bx::fcos(2.0f*bx::kPi/float(m_settings_numLights) * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
|
||||||
lightPosRadius[ii][1] = 20.0f;
|
lightPosRadius[ii][1] = 20.0f;
|
||||||
lightPosRadius[ii][2] = bx::fsin(2.0f*bx::kPi/m_settings_numLights * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
|
lightPosRadius[ii][2] = bx::fsin(2.0f*bx::kPi/float(m_settings_numLights) * float(ii) + lightTimeAccumulator * 1.1f + 3.0f) * 20.0f;
|
||||||
lightPosRadius[ii][3] = 20.0f;
|
lightPosRadius[ii][3] = 20.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2291,9 +2295,9 @@ class ExampleShadowVolumes : public entry::AppI
|
|||||||
{
|
{
|
||||||
for (uint8_t ii = 0; ii < m_settings_numLights; ++ii)
|
for (uint8_t ii = 0; ii < m_settings_numLights; ++ii)
|
||||||
{
|
{
|
||||||
lightPosRadius[ii][0] = bx::fcos(float(ii) * 2.0f/m_settings_numLights + lightTimeAccumulator * 1.3f + bx::kPi) * 40.0f;
|
lightPosRadius[ii][0] = bx::fcos(float(ii) * 2.0f/float(m_settings_numLights) + lightTimeAccumulator * 1.3f + bx::kPi) * 40.0f;
|
||||||
lightPosRadius[ii][1] = 20.0f;
|
lightPosRadius[ii][1] = 20.0f;
|
||||||
lightPosRadius[ii][2] = bx::fsin(float(ii) * 2.0f/m_settings_numLights + lightTimeAccumulator * 1.3f + bx::kPi) * 40.0f;
|
lightPosRadius[ii][2] = bx::fsin(float(ii) * 2.0f/float(m_settings_numLights) + lightTimeAccumulator * 1.3f + bx::kPi) * 40.0f;
|
||||||
lightPosRadius[ii][3] = 20.0f;
|
lightPosRadius[ii][3] = 20.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2897,8 +2901,8 @@ class ExampleShadowVolumes : public entry::AppI
|
|||||||
bool m_settings_mixedSvImpl;
|
bool m_settings_mixedSvImpl;
|
||||||
bool m_settings_useStencilTexture;
|
bool m_settings_useStencilTexture;
|
||||||
bool m_settings_drawShadowVolumes;
|
bool m_settings_drawShadowVolumes;
|
||||||
float m_settings_numLights;
|
int m_settings_numLights;
|
||||||
float m_settings_instanceCount;
|
int m_settings_instanceCount;
|
||||||
ShadowVolumeImpl::Enum m_settings_shadowVolumeImpl;
|
ShadowVolumeImpl::Enum m_settings_shadowVolumeImpl;
|
||||||
ShadowVolumeAlgorithm::Enum m_settings_shadowVolumeAlgorithm;
|
ShadowVolumeAlgorithm::Enum m_settings_shadowVolumeAlgorithm;
|
||||||
int32_t m_scrollAreaRight;
|
int32_t m_scrollAreaRight;
|
||||||
|
Loading…
Reference in New Issue
Block a user