private void DrawTextureCube(Camera camera) { var shader = ShaderContainer.GetShader("RTextureCube"); shader.UseProgram(); if (skyBox == null) { var shape = ShapeGenerator.GetCubePositions(Vector3.Zero, 2.0f); skyBox = new Mesh3D(shape.Item1.Select(v => new Vertex3d(v.X, v.Y, v.Z)).ToArray(), shape.Item2); } // Use nearest neighbor to preserve pixel boundaries. if (sampler == null) { sampler = new SamplerObject { MagFilter = TextureMagFilter.Nearest, MinFilter = TextureMinFilter.Nearest } } ; // Texture unit 0 should be reserved for image preview. sampler.Bind(0); shader.SetTexture("image", Texture, 0); // Use the existing rotation matrix to support changing the view. shader.SetMatrix4x4("mvpMatrix", camera.RotationMatrix * Matrix4.CreatePerspectiveFieldOfView(1.5708f, camera.RenderWidth / (float)camera.RenderHeight, 0.01f, 10.0f)); // The colors need to be converted back to sRGB gamma. shader.SetBoolToInt("isSrgb", IsSrgb); // Disable culling since only the backside will be visible. GL.Disable(EnableCap.CullFace); skyBox.Draw(shader); } }