Panagiotis Christopoulos Charitos пре 9 година
родитељ
комит
aa94692f1e
3 измењених фајлова са 9 додато и 7 уклоњено
  1. 0 4
      include/anki/scene/Light.h
  2. 4 0
      include/anki/scene/LightComponent.h
  3. 5 3
      src/scene/Light.cpp

+ 0 - 4
include/anki/scene/Light.h

@@ -51,10 +51,6 @@ protected:
 class PointLight : public Light
 {
 public:
-	/// The near plane on the shadow map frustums.
-	/// WARNING: If you change here update the shaders.
-	static constexpr F32 FRUSTUM_NEAR_PLANE = 0.1 / 4.0;
-
 	PointLight(SceneGraph* scene);
 	~PointLight();
 

+ 4 - 0
include/anki/scene/LightComponent.h

@@ -20,6 +20,10 @@ class LightComponent : public SceneComponent
 public:
 	static const SceneComponentType CLASS_TYPE = SceneComponentType::LIGHT;
 
+	/// The near plane on the shadow map frustums.
+	/// WARNING: If you change here update the shaders.
+	static constexpr F32 FRUSTUM_NEAR_PLANE = 0.1 / 4.0;
+
 	enum class LightType : U8
 	{
 		POINT,

+ 5 - 3
src/scene/Light.cpp

@@ -237,7 +237,7 @@ Error PointLight::frameUpdate(F32 prevUpdateTime, F32 crntTime)
 
 		const F32 ang = toRad(90.0);
 		const F32 dist = m_sphereW.getRadius();
-		const F32 zNear = FRUSTUM_NEAR_PLANE;
+		const F32 zNear = LightComponent::FRUSTUM_NEAR_PLANE;
 
 		Mat3 rot;
 		const F32 PI = getPi<F32>();
@@ -323,8 +323,10 @@ void SpotLight::onMoveUpdate(MoveComponent& move)
 void SpotLight::onShapeUpdate(LightComponent& light)
 {
 	onShapeUpdateCommon(light);
-	m_frustum.setAll(
-		light.getOuterAngle(), light.getOuterAngle(), 0.5, light.getDistance());
+	m_frustum.setAll(light.getOuterAngle(),
+		light.getOuterAngle(),
+		LightComponent::FRUSTUM_NEAR_PLANE,
+		light.getDistance());
 }
 
 //==============================================================================