当前位置: 首页>>代码示例>>C#>>正文


C# Texture2D.GenerateMipMaps方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Texture2D.GenerateMipMaps方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.GenerateMipMaps方法的具体用法?C# Texture2D.GenerateMipMaps怎么用?C# Texture2D.GenerateMipMaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.Texture2D的用法示例。


在下文中一共展示了Texture2D.GenerateMipMaps方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Generate2DNoise

        public Texture2D Generate2DNoise(NoiseParameters noiseParams, int width, int height, int mipCount)
        {
            Vector2 invRes = Vector2.One / new Vector2(width, height);
            noise2DShader.SetupShader();
            GFX.Device.SetVertexShaderConstant(0, invRes);
            GFX.Device.SetPixelShaderConstant(0, invRes);
            GFX.Device.SetPixelShaderConstant(1, new Vector4(noiseParams.Amplitude, noiseParams.Frequency, noiseParams.Persistance, noiseParams.Octaves));
            GFX.Device.Textures[0] = ComputeRandomTexture(width / 2, height / 2);

            RenderTarget2D rtNoise = new RenderTarget2D(GFX.Device, width, height, 1, SurfaceFormat.Color);
            DepthStencilBuffer dsOld = GFX.Device.DepthStencilBuffer;
            GFX.Device.DepthStencilBuffer = GFX.Inst.dsBufferLarge;
            GFX.Device.SetRenderTarget(0, rtNoise);
            GFXPrimitives.Quad.Render();
            GFX.Device.SetRenderTarget(0, null);
            GFX.Device.DepthStencilBuffer = dsOld;

            Color[] colorData = new Color[width * height];
            rtNoise.GetTexture().GetData<Color>(colorData);
            Texture2D noiseTexture = new Texture2D(GFX.Device, width, height, mipCount, TextureUsage.None, SurfaceFormat.Color);
            noiseTexture.SetData<Color>(colorData);
            noiseTexture.GenerateMipMaps(TextureFilter.GaussianQuad);
            return noiseTexture;
        }
开发者ID:MattVitelli,项目名称:IslandAdventure,代码行数:24,代码来源:PerlinNoiseSimulator.cs

示例2: WaterRenderer

        public WaterRenderer(ContentManager contentManager, Scene scene, Camera camera)
            : base(contentManager)
        {
            effect = Content.Load<Effect>("water");
             bumpTexture = Content.Load<Texture2D>("water_texture");

             bumpTexture.GenerateMipMaps(TextureFilter.Anisotropic);
             this.camera = camera;

             var vertices = new VertexPositionTexture[6 * scene.Water.WaterQuads.Count];
             int idx = 0;
             foreach (var quad in scene.Water.WaterQuads)
             {
            vertices[idx++] = new VertexPositionTexture(new Vector3(quad.Xmin, quad.Level, -quad.Ymin),
               new Vector2(quad.Xmin, -quad.Ymin) / WaterTextureCoordsDivisor);
            vertices[idx++] = new VertexPositionTexture(new Vector3(quad.Xmax, quad.Level, -quad.Ymin),
               new Vector2(quad.Xmax, -quad.Ymin) / WaterTextureCoordsDivisor);
            vertices[idx++] = new VertexPositionTexture(new Vector3(quad.Xmin, quad.Level, -quad.Ymax),
               new Vector2(quad.Xmin, -quad.Ymax) / WaterTextureCoordsDivisor);

            vertices[idx++] = new VertexPositionTexture(new Vector3(quad.Xmax, quad.Level, -quad.Ymin),
               new Vector2(quad.Xmax, -quad.Ymin) / WaterTextureCoordsDivisor);
            vertices[idx++] = new VertexPositionTexture(new Vector3(quad.Xmax, quad.Level, -quad.Ymax),
               new Vector2(quad.Xmax, -quad.Ymax) / WaterTextureCoordsDivisor);
            vertices[idx++] = new VertexPositionTexture(new Vector3(quad.Xmin, quad.Level, -quad.Ymax),
               new Vector2(quad.Xmin, -quad.Ymax) / WaterTextureCoordsDivisor);
             }

             vertexBuffer = new VertexBuffer(Device, vertices.Length * VertexPositionTexture.SizeInBytes, BufferUsage.None);
             vertexBuffer.SetData(vertices);
             vertexDeclaration = new VertexDeclaration(Device, VertexPositionTexture.VertexElements);
             primitivesToDraw = scene.Water.WaterQuads.Count * 2;

             projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Device.Viewport.AspectRatio,
            Config.Instance.Rendering.NearClippingDistance, Config.Instance.Rendering.FarClippingDistance);
        }
开发者ID:dennisyolkin,项目名称:gta_gameworld_renderer,代码行数:36,代码来源:WaterRenderer.cs

示例3: CopyTextureToRenderTarget

 private void CopyTextureToRenderTarget(Texture2D src, RenderTarget2D rt, ref Texture2D dest)
 {
     var dsb = GraphicsDevice.DepthStencilBuffer;
     GraphicsDevice.DepthStencilBuffer = null;
     GraphicsDevice.SetRenderTarget(0, rt);
     spriteBatch.Begin(SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.None);
     spriteBatch.Draw(src, new Rectangle(0, 0, src.Width, src.Height), Color.White);
     spriteBatch.End();
     GraphicsDevice.SetRenderTarget(0, null);
     GraphicsDevice.DepthStencilBuffer = dsb;
     dest = rt.GetTexture();
     dest.GenerateMipMaps(TextureFilter.Linear);
 }
开发者ID:romainpi,项目名称:berkelium-managed,代码行数:13,代码来源:BerkeliumTestGame.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Texture2D.GenerateMipMaps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。