diff --git a/Effects/PointLightCollection.cs b/Effects/PointLightCollection.cs index 53c459b..3a53f1c 100644 --- a/Effects/PointLightCollection.cs +++ b/Effects/PointLightCollection.cs @@ -40,8 +40,7 @@ namespace Kav set { positions[i] = value.Position; - colors[i] = value.Color.ToVector3() * value.Intensity; - intensities[i] = value.Intensity; + colors[i] = value.Color.ToVector3() * value.Radius; lightPositionsParam.SetValue(positions); lightColorsParam.SetValue(colors); } diff --git a/Lights/PointLight.cs b/Lights/PointLight.cs index 50f32ca..eefe100 100644 --- a/Lights/PointLight.cs +++ b/Lights/PointLight.cs @@ -8,19 +8,17 @@ namespace Kav public Vector3 Position { get; } public Color Color { get; } - public float Intensity { get; } + public float Radius { get; } - public float EffectiveRadius { get; } public BoundingSphere BoundingSphere { get; } - public PointLight(Vector3 position, Color color, float intensity = 1f) + public PointLight(Vector3 position, Color color, float radius) { Position = position; Color = color; - Intensity = intensity; + Radius = radius; - EffectiveRadius = (float) System.Math.Sqrt(Intensity); - BoundingSphere = new BoundingSphere(position, EffectiveRadius); + BoundingSphere = new BoundingSphere(position, Radius); } } } diff --git a/Models/UnitSphere.glb b/Models/UnitSphere.glb index b495e77..21c6bbc 100644 Binary files a/Models/UnitSphere.glb and b/Models/UnitSphere.glb differ diff --git a/Renderer.cs b/Renderer.cs index 594f0fb..ce82881 100644 --- a/Renderer.cs +++ b/Renderer.cs @@ -467,15 +467,7 @@ namespace Kav PointLight pointLight ) { GraphicsDevice.SetRenderTarget(renderTarget); - if (Vector3.Distance(camera.Position, pointLight.Position) < pointLight.EffectiveRadius) - { - GraphicsDevice.RasterizerState = RasterizerState.CullClockwise; - } - else - { - GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; - } - + GraphicsDevice.RasterizerState = RasterizerState.CullClockwise; GraphicsDevice.DepthStencilState = DepthStencilState.None; GraphicsDevice.BlendState = BlendState.Additive; @@ -489,12 +481,12 @@ namespace Kav DeferredPointLightEffect.PointLightPosition = pointLight.Position; DeferredPointLightEffect.PointLightColor = - pointLight.Color.ToVector3() * pointLight.Intensity; + pointLight.Color.ToVector3() * pointLight.Radius; DeferredPointLightEffect.FarPlane = 25f; // FIXME: magic value DeferredPointLightEffect.World = - Matrix.CreateScale(pointLight.EffectiveRadius) * + Matrix.CreateScale(pointLight.Radius) * Matrix.CreateTranslation(pointLight.Position); DeferredPointLightEffect.View = camera.View; DeferredPointLightEffect.Projection = camera.Projection;