@@ -208,6 +208,11 @@ void FrameGraph::loadPrograms()
208208}
209209
210210
211+ GLfloat toTanHalf (math::Radian<GLfloat> aAngle)
212+ {
213+     return  math::tan (aAngle / 2 .f );
214+ }
215+ 
211216void  FrameGraph::renderFinalScene (const  scenic::SceneTree & aSceneTree,
212217                                  Voxelizer & aVoxelizer)
213218{
@@ -221,9 +226,11 @@ void FrameGraph::renderFinalScene(const scenic::SceneTree & aSceneTree,
221226    graphics::setUniform (program, " u_VoxelSize" mVoxelSize );
222227    graphics::setUniform (program, " u_AabbMin" mSceneAabb .leftBottomZMin ());
223228
224-     graphics::setUniform (program, " u_TanHalfAperture" mFrameControl .mConeAperture .data ());
229+     graphics::setUniform (program, " u_TanHalfAperture" toTanHalf (mFrameControl .mDiffuseConeAperture ));
230+     graphics::setUniform (program, " u_TanHalfShadow" toTanHalf (mFrameControl .mShadowConeAperture ));
225231
226232    graphics::setUniform (program, " u_ToneMapping" mFrameControl .mToneMapping );
233+     graphics::setUniform (program, " u_ShadowMethod" mFrameControl .mFinalSceneShadow );
227234
228235    glProgramUniform4fv (program,
229236                        glGetUniformLocation (program, " u_LightingFactors" 
@@ -242,7 +249,7 @@ void FrameGraph::renderConeTrace(const scenic::SceneTree & aSceneTree,
242249    graphics::setUniform (program, " u_VoxelSize" mVoxelSize );
243250    graphics::setUniform (program, " u_AabbMin" mSceneAabb .leftBottomZMin ());
244251
245-     graphics::setUniform (program, " u_TanHalfAperture" mFrameControl .mConeAperture . data ( ));
252+     graphics::setUniform (program, " u_TanHalfAperture" toTanHalf ( mFrameControl .mDiffuseConeAperture ));
246253    graphics::setUniform (program, " u_GridAlign" mFrameControl .mGridAlign );
247254
248255    graphics::setUniform (program, " u_ConeTraceMode" 
@@ -296,7 +303,8 @@ void FrameGraph::appendUi()
296303    imguiui::addComboContinuousEnum<FrameControl::ToneMapping::_End>(
297304        " Tone Mapping" mFrameControl .mToneMapping );
298305
299-     ImGui::SliderAngle (" Diffuse Cone Aperture" mFrameControl .mConeAperture .data (), 1 .f , 180 .f );
306+     ImGui::SliderAngle (" Diffuse Cone Aperture" mFrameControl .mDiffuseConeAperture .data (), 1 .f , 180 .f );
307+     ImGui::SliderAngle (" Shadow Cone Aperture" mFrameControl .mShadowConeAperture .data (), 1 .f , 180 .f );
300308
301309    ImGui::Checkbox (" Grid Aligned Trace Origin" mFrameControl .mGridAlign );
302310
@@ -307,6 +315,8 @@ void FrameGraph::appendUi()
307315    ImGui::SliderFloat (" Indirect specular" mFrameControl .mIndirectSpecularFactor , 0 .f , 4 .f );
308316
309317    ImGui::SeparatorText (" Shadow" 
318+     imguiui::addComboContinuousEnum<FrameControl::ShadowMethod::_End>(
319+         " Final Scene Shadow" mFrameControl .mFinalSceneShadow );
310320    ImGui::InputFloat (" Scale" mFrameControl .mShadowScaleBias .x ());
311321    ImGui::InputFloat (" Bias" mFrameControl .mShadowScaleBias .y ());
312322}
@@ -327,4 +337,18 @@ std::string to_string(FrameGraph::FrameControl::ToneMapping aValue)
327337#undef  STR
328338}
329339
340+ 
341+ std::string to_string (FrameGraph::FrameControl::ShadowMethod aValue)
342+ {
343+ #define  STR (enumerator ) case  FrameGraph::FrameControl::ShadowMethod::enumerator: return  #enumerator
344+     switch  (aValue)
345+     {
346+         STR (ShadowMap);
347+         STR (ConeTracing);
348+     default :
349+         throw  std::logic_error{ " Unhandled shadow method." 
350+     }
351+ #undef  STR
352+ }
353+ 
330354} //  namespace ad
0 commit comments