internal override void OnUpdate() { DayWatch watch = DayWatch.Now; PrevPosition = Position; Position = watch.SunPosition * 180f; float amount = watch.SunHeight; Color4 c; if (watch.IsDay) { if (amount < 0.4) { c = Color4.Lerp(new Color4(1, 1, 1, 0), new Color4(1, 1, 0.2f, 0), 1 - (amount / 0.4f)); } else { c = Color4.Lerp(new Color4(1, 1, 1, 0.8f), new Color4(1, 1, 1, 0), 1 - (amount - 0.4f) / 0.6f); } } else { c = new Color4(1, 1, 0.2f, 0); } Color = c.ToVector4(); Position.X += World.Instance.Player.Position.X; Position.Y += 0; Position.Z += World.Instance.Player.Position.Z; }
internal void ClearTarget() { DayWatch watch = DayWatch.Now; BackgroundColor = Color4.Lerp(new Color4(0.8f, 0.8f, 1f), new Color4(0f, 0f, 0f), 1f - watch.SunHeight); device.ImmediateContext.ClearRenderTargetView(renderView, BackgroundColor); device.ImmediateContext.ClearDepthStencilView(depthView, DepthStencilClearFlags.Depth, 1.0f, 0); }
internal override void OnUpdate() { DayWatch watch = DayWatch.Now; PrevPosition = Position; Position = watch.MoonPosition * 180f; Color4 c = new Color4(1f, 0.8f, 0.8f, 0.8f); Color = c.ToVector4(); Position.X += World.Instance.Player.Position.X; Position.Y += 0; Position.Z += World.Instance.Player.Position.Z; }
internal override void Apply(SlimDX.Direct3D11.Buffer vertices) { Device device = t.Device; device.ImmediateContext.InputAssembler.InputLayout = layout; device.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertices, stride, 0)); effect.GetVariableByName("gWorld").AsMatrix().SetMatrix(Camera.Instance.World); effect.GetVariableByName("gView").AsMatrix().SetMatrix(Camera.Instance.View); effect.GetVariableByName("gProj").AsMatrix().SetMatrix(Camera.Instance.Projection); effect.GetVariableByName("textureArray").AsResource().SetResource(TileTextures.Instance.View); effect.GetVariableByName("time").AsScalar().Set(TheGame.Instance.Time * 50f); float timeOfDay = World.Instance.TimeOfDay; Vector3 lightDirection = new Vector3(0, 0, 0); DayWatch watch = DayWatch.Now; if (watch.IsDay) { lightDirection = -watch.SunPosition; } effect.GetVariableByName("lightDirection").AsVector().Set(lightDirection); effect.GetTechniqueByIndex(TechniqueIndex).GetPassByIndex(0).Apply(device.ImmediateContext); }