public void Draw(SharpDX.Toolkit.Graphics.GraphicsDevice graphicsDevice, Camera camera, SharpDX.Toolkit.Graphics.Texture skyCubemap) { if (heightmapTexture == null) return; clipmapRenderer.UpdateInstanceData(camera.Position); Matrix viewProjection = camera.ViewMatrix * camera.ProjectionMatrix; Matrix viewProjectionInverse = viewProjection; viewProjectionInverse.Invert(); var cameraConstantBuffer = shader.Effect.ConstantBuffers["Camera"]; cameraConstantBuffer.Parameters["View"].SetValue(camera.ViewMatrix); cameraConstantBuffer.Parameters["ViewProjection"].SetValue(viewProjection); cameraConstantBuffer.Parameters["InverseViewProjection"].SetValue(viewProjectionInverse); cameraConstantBuffer.Parameters["CameraPosition"].SetValue(camera.Position); cameraConstantBuffer.IsDirty = true; cameraConstantBuffer.Update(); shader.Effect.Parameters["Heightmap"].SetResource(heightmapTexture); // shader.Effect.Parameters["SkyCubemap"].SetResource(skyCubemap); // graphicsDevice.SetRasterizerState(graphicsDevice.RasterizerStates.WireFrameCullNone); graphicsDevice.SetDepthStencilState(graphicsDevice.DepthStencilStates.Default); shader.Effect.CurrentTechnique.Passes[0].Apply(); clipmapRenderer.DrawGeometry(graphicsDevice); shader.Effect.CurrentTechnique.Passes[0].UnApply(); }