Merge changes I776588c1,I7292a2fb into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / controls / scene-view / scene-view-impl.h
index 3aa93b4..647df5e 100644 (file)
@@ -33,8 +33,9 @@
 
 // INTERNAL INCLUDES
 #include <dali-scene3d/internal/common/environment-map-load-task.h>
-#include <dali-scene3d/internal/common/image-based-light-observer.h>
+#include <dali-scene3d/internal/common/light-observer.h>
 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
+#include <dali-scene3d/public-api/loader/shader-manager.h>
 
 namespace Dali
 {
@@ -105,14 +106,14 @@ public:
    *
    * @param[in] item scene observer to be registered.
    */
-  void RegisterSceneItem(Scene3D::Internal::ImageBasedLightObserver* item);
+  void RegisterSceneItem(Scene3D::Internal::LightObserver* item);
 
   /**
    * @brief Unregister an item
    *
    * @param[in] item scene observer to be unregistered.
    */
-  void UnregisterSceneItem(Scene3D::Internal::ImageBasedLightObserver* item);
+  void UnregisterSceneItem(Scene3D::Internal::LightObserver* item);
 
   /**
    * @copydoc SceneView::SetImageBasedLightSource()
@@ -130,6 +131,46 @@ public:
   float GetImageBasedLightScaleFactor() const;
 
   /**
+   * @brief Adds a Light object to this SceneView.
+   * Multiple light object can be added on this SceneView
+   * But the number of lights those actually turned on has limitation.
+   * Scene3D::Light::GetMaximumEnabledLightCount() method can be used to know the maximum namber.
+   *
+   * @param[in] light Light object to be added.
+   */
+  void AddLight(Scene3D::Light light);
+
+  /**
+   * @brief Removes a Light object to this SceneView.
+   * If the light is currently turned on, and SceneView has lights more than maximum number of enabled light.
+   * One of light in queue is turned on after this light is removed.
+   *
+   * @param[in] light Light object to be removed.
+   */
+  void RemoveLight(Scene3D::Light light);
+
+  /**
+   * @brief Set a shadow to this scene by input light.
+   * Currently, SceneView supports only one shadow.
+   *
+   * @param[in] light Light object to make shadow.
+   * @note The shadow will be drawn if the input light is turn on in current scene.
+   */
+  void SetShadow(Scene3D::Light light);
+
+  /**
+   * @brief Removes Shadow from this SceneView.
+   *
+   * @param[in] light Light object to be removed.
+   */
+  void RemoveShadow(Scene3D::Light light);
+
+  /**
+   * @copydoc SceneView::GetActivatedLightCount()
+   */
+  uint32_t GetActivatedLightCount() const;
+
+  /**
    * @copydoc SceneView::UseFramebuffer()
    */
   void UseFramebuffer(bool useFramebuffer);
@@ -179,6 +220,18 @@ public:
    */
   Quaternion GetSkyboxOrientation() const;
 
+  /**
+   * @brief Retrieves ShaderManager of this SceneView.
+   * @return ShaderManager of this SceneView.
+   */
+  Dali::Scene3D::Loader::ShaderManagerPtr GetShaderManager() const;
+
+  /**
+   * @brief Update shader uniforms about shadow.
+   * @param[in] light Light that makes shadow.
+   */
+  void UpdateShadowUniform(Scene3D::Light light);
+
 protected:
   /**
    * @brief Constructs a new SceneView.
@@ -291,26 +344,41 @@ private:
    */
   void NotifyImageBasedLightTextureChange();
 
+  /**
+   * @brief Update shadowMap framebuffer when the size should be changed.
+   * @param[in] shadowMapSize The size of shadowMap texture. The texture's width and hight is equal.
+   */
+  void UpdateShadowMapBuffer(uint32_t shadowMapSize);
+
 private:
   Toolkit::Visual::Base mVisual;
 
   /////////////////////////////////////////////////////////////
   // FrameBuffer and Rendertask to render child objects as a 3D Scene
-  Dali::WeakHandle<Dali::Window>                           mWindow;
-  Integration::SceneHolder                                 mSceneHolder;
-  CameraActor                                              mDefaultCamera;
-  CameraActor                                              mSelectedCamera;
-  std::vector<CameraActor>                                 mCameras;
-  std::vector<Scene3D::Internal::ImageBasedLightObserver*> mItems;
-  Dali::FrameBuffer                                        mFrameBuffer;
-  Dali::Texture                                            mTexture;
-  Dali::RenderTask                                         mRenderTask;
-  Layer                                                    mRootLayer;
-  int32_t                                                  mWindowOrientation;
-  Dali::Actor                                              mSkybox;
-  Quaternion                                               mSkyboxOrientation;
-  float                                                    mSkyboxIntensity{1.0f};
-  uint8_t                                                  mFrameBufferMultiSamplingLevel{0u};
+  Dali::WeakHandle<Dali::Window>                 mWindow;
+  Integration::SceneHolder                       mSceneHolder;
+  CameraActor                                    mDefaultCamera;
+  CameraActor                                    mSelectedCamera;
+  std::vector<CameraActor>                       mCameras;
+  std::vector<Scene3D::Internal::LightObserver*> mItems;
+  Dali::FrameBuffer                              mFrameBuffer;
+  Dali::Texture                                  mTexture;
+  Dali::RenderTask                               mRenderTask;
+  Layer                                          mRootLayer;
+  int32_t                                        mWindowOrientation;
+  Dali::Actor                                    mSkybox;
+  Quaternion                                     mSkyboxOrientation;
+  float                                          mSkyboxIntensity{1.0f};
+  uint8_t                                        mFrameBufferMultiSamplingLevel{0u};
+
+  // Shader Factory
+  Dali::Scene3D::Loader::ShaderManagerPtr mShaderManager;
+
+  // Light
+  std::vector<std::pair<Scene3D::Light, bool>> mLights; // Pair of Light object and flag that denotes the light is currently activated or not.
+  Dali::FrameBuffer                            mShadowFrameBuffer;
+  Dali::RenderTask                             mShadowMapRenderTask;
+  Scene3D::Light                               mShadowLight;
 
   // Asynchronous Loading.
   EnvironmentMapLoadTaskPtr mSkyboxLoadTask;
@@ -333,8 +401,6 @@ private:
   bool                        mSkyboxDirty{false};
   bool                        mIblDiffuseDirty{false};
   bool                        mIblSpecularDirty{false};
-
-  // TODO : Light Source
 };
 
 } // namespace Internal