public LightBall(PointLight light) : base(Models.Sphere, light.Position) { name = "Light Ball"; info = String.Format("- Color: {0}", light.Color); this.light = light; diffuseColor = light.Color; ambientColor = light.Color; specularColor = light.Color; scale = 0.8f; alpha = 0.5f; randomOffset = new Random().Next(1000); }
public Lighting(World world) { this.world = world; pSunColor = Shaders.Common.Parameters["vSunColor"]; pSunVector = Shaders.Common.Parameters["vSunVector"]; pAmbientColor = Shaders.Common.Parameters["vAmbientColor"]; pAmbientLight = Shaders.Common.Parameters["fAmbient"]; pNumberOfLights = Shaders.Common.Parameters["iNumLights"]; pSunIntensity = Shaders.Common.Parameters["fSunIntensity"]; pFogColor = Shaders.Common.Parameters["vFogColor"]; //Shaders.Common.Parameters["tCloudShadowMap"].SetValue(world.Game.Content.Load<Texture2D>(@"textures\sky\clouds")); Random r = new Random(); if (lights[0] == null) { for (int i = 0; i < lights.Length; i++) { Vector3 color = new Vector3(r.Next(1000) / 1000.0f, r.Next(1000) / 1000.0f, r.Next(1000) / 1000.0f); lights[i] = new PointLight(Vector3.Zero, color, Shaders.Common.Parameters["lights"].Elements[i]); } } // setup the shadowmap render target GraphicsDevice g = world.GraphicsDevice; PresentationParameters pp = world.GraphicsDevice.PresentationParameters; int shadowWidth = pp.BackBufferWidth; int shadowHeight = pp.BackBufferHeight; smapTarget = new RenderTarget2D(g, shadowWidth, shadowHeight, 1, SurfaceFormat.Single); smapStencilBuffer = new DepthStencilBuffer(g, shadowWidth, shadowHeight, g.DepthStencilBuffer.Format); }