Exemplo n.º 1
0
 public static void ThrowInvalidOperationIfNull(Texture2D texture, string memberName)
 {
     if (texture == null)
     {
         throw new InvalidOperationException(memberName);
     }
 }
Exemplo n.º 2
0
 public static void ValidateColor(Texture2D colorTexture, byte red, byte green, byte blue)
 {
     using (ReadPixelBuffer readPixelBuffer = colorTexture.CopyToBuffer(ImageFormat.RedGreenBlue, ImageDatatype.UnsignedByte, 1))
     {
         byte[] color = readPixelBuffer.CopyToSystemMemory<byte>();
         Assert.AreEqual(red, color[0], "Red does not match");
         Assert.AreEqual(green, color[1], "Green does not match");
         Assert.AreEqual(blue, color[2], "Blue does not match");
     }
 }
Exemplo n.º 3
0
        ///////////////////////////////////////////////////////////////////////

        private static void ValidateDepth(Texture2D depthTexture, float depth)
        {
            using (ReadPixelBuffer readPixelBuffer = depthTexture.CopyToBuffer(ImageFormat.DepthComponent, ImageDatatype.Float, 1))
            {
                float[] readDepth = readPixelBuffer.CopyToSystemMemory<float>();
                Assert.AreEqual (depth, readDepth[0]);
            }
        }
Exemplo n.º 4
0
 internal static void Attach(FramebufferAttachment attachPoint, Texture2D texture)
 {
     if (texture != null)
     {
         // TODO:  Mipmap level
         Texture2DGL3x textureGL = (Texture2DGL3x)texture;
         GL.FramebufferTexture(FramebufferTarget.Framebuffer, attachPoint, textureGL.Handle.Value, 0);
     }
     else
     {
         GL.FramebufferTexture(FramebufferTarget.Framebuffer, attachPoint, 0, 0);
     }
 }
Exemplo n.º 5
0
        private void RenderTileToLevelTexture(Context context, ClipmapLevel level, RasterDataDetails details, RasterTileRegion region, Texture2D tileTexture)
        {
            Texture2D levelTexture;
            Vector2I originInTextures;
            ClipmapLevel.Extent nextExtent;

            if (details.Type == RasterType.Terrain)
            {
                levelTexture = level.HeightTexture;
                originInTextures = level.OriginInTextures;
                nextExtent = level.NextExtent;
            }
            else
            {
                levelTexture = level.ImageryTexture;
                originInTextures = level.OriginInImagery;
                nextExtent = level.NextImageryExtent;
            }

            context.TextureUnits[0].Texture = tileTexture;
            context.TextureUnits[0].TextureSampler = Device.TextureSamplers.NearestClamp;

            _framebuffer.ColorAttachments[_updateTexelOutput] = levelTexture;

            int clipmapSize = nextExtent.East - nextExtent.West + 1;
            int destWest = (originInTextures.X + (region.Tile.West + region.West - nextExtent.West)) % clipmapSize;
            int destSouth = (originInTextures.Y + (region.Tile.South + region.South - nextExtent.South)) % clipmapSize;

            int width = region.East - region.West + 1;
            int height = region.North - region.South + 1;

            _updateSourceOrigin.Value = new Vector2F(region.West, region.South);
            _updateUpdateSize.Value = new Vector2F(width, height);
            _updateDestinationOffset.Value = new Vector2F(destWest, destSouth);

            // Save the current state of the context
            Rectangle oldViewport = context.Viewport;
            Framebuffer oldFramebuffer = context.Framebuffer;

            // Update the context and draw
            context.Viewport = new Rectangle(0, 0, levelTexture.Description.Width, levelTexture.Description.Height);
            context.Framebuffer = _framebuffer;
            context.Draw(_unitQuadPrimitiveType, _updateDrawState, _sceneState);

            // Restore the context to its original state
            context.Framebuffer = oldFramebuffer;
            context.Viewport = oldViewport;
        }
Exemplo n.º 6
0
        public void Render(Context context, SceneState sceneState, Texture2D silhouetteTexture, Texture2D depthTexture)
        {
            //
            // Render the line on terrain using the wall method
            //
            context.TextureUnits[0].Texture = silhouetteTexture;
            context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp;
            context.TextureUnits[1].Texture = depthTexture;
            context.TextureUnits[1].TextureSampler = Device.TextureSamplers.LinearClamp;
            context.Draw(PrimitiveType.LinesAdjacency, _wallDrawState, sceneState);

            //
            // Render the line on terrain using the depth-fail shadow volume method
            //
            context.TextureUnits[0].Texture = silhouetteTexture;
            context.TextureUnits[0].TextureSampler = Device.TextureSamplers.LinearClamp;
            context.Draw(PrimitiveType.LinesAdjacency, _shadowVolumePassOne, sceneState);
            
            //
            // Render where the stencil is set; note that the stencil is also cleared 
            // where it is set.
            //
            context.Draw(PrimitiveType.LinesAdjacency, _shadowVolumePassTwo, sceneState);
        }
Exemplo n.º 7
0
 private void SetFramebufferAttachments(Texture2D day, Texture2D night, Texture2D blend)
 {
     _framebuffer.ColorAttachments[_globe.FragmentOutputs("dayColor")] = day;
     _framebuffer.ColorAttachments[_globe.FragmentOutputs("nightColor")] = night;
     _framebuffer.ColorAttachments[_globe.FragmentOutputs("blendAlpha")] = blend;
     _framebuffer.DepthAttachment = _depthTexture;
 }