• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Graphics.Effect类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Effect类属于Microsoft.Xna.Framework.Graphics命名空间,在下文中一共展示了Effect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Edge

        public Edge(SpriteBatch spriteBatch, Settings settings, Effect normalDepthMapEffect, Effect edgeEffect)
            : base(spriteBatch)
        {
            if (settings == null) throw new ArgumentNullException("settings");
            if (normalDepthMapEffect == null) throw new ArgumentNullException("normalDepthMapEffect");
            if (edgeEffect == null) throw new ArgumentNullException("edgeEffect");

            this.settings = settings;

            var pp = GraphicsDevice.PresentationParameters;
            var width = (int) (pp.BackBufferWidth * settings.MapScale);
            var height = (int) (pp.BackBufferHeight * settings.MapScale);

            //----------------------------------------------------------------
            // エフェクト

            // 法線深度マップ
            this.normalDepthMapEffect = new NormalDepthMapEffect(normalDepthMapEffect);

            // エッジ強調
            this.edgeEffect = new EdgeEffect(edgeEffect);
            this.edgeEffect.MapWidth = width;
            this.edgeEffect.MapHeight = height;

            //----------------------------------------------------------------
            // レンダ ターゲット

            normalDepthMap = new RenderTarget2D(GraphicsDevice, width, height,
                false, SurfaceFormat.Vector4, DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents);
        }
开发者ID:willcraftia,项目名称:TestBlocks,代码行数:30,代码来源:Edge.cs


示例2: Draw

        public void Draw(Effect effect, Space space)
        {
            contactLines.Clear();
            int contactCount = 0;
            foreach (var pair in space.NarrowPhase.Pairs)
            {
                var pairHandler = pair as CollidablePairHandler;
                if (pairHandler != null)
                {
                    foreach (ContactInformation information in pairHandler.Contacts)
                    {
                        contactCount++;
                        contactLines.Add(new VertexPositionColor(information.Contact.Position, Color.White));
                        contactLines.Add(new VertexPositionColor(information.Contact.Position + information.Contact.Normal * information.Contact.PenetrationDepth, Color.Red));
                        contactLines.Add(new VertexPositionColor(information.Contact.Position + information.Contact.Normal * information.Contact.PenetrationDepth, Color.White));
                        contactLines.Add(new VertexPositionColor(information.Contact.Position + information.Contact.Normal * (information.Contact.PenetrationDepth + .3f), Color.White));
                    }
                }
            }

            if (contactCount > 0)
            {
                foreach (var pass in effect.CurrentTechnique.Passes)
                {
                    pass.Apply();

                    game.GraphicsDevice.DrawUserPrimitives(PrimitiveType.LineList, contactLines.Elements, 0, contactLines.Count / 2);
                }
            }

        }
开发者ID:VICOGameStudio-Ujen,项目名称:igf,代码行数:31,代码来源:ContactDrawer.cs


示例3: CubeMapShadowMaskRenderer

        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="CubeMapShadowMaskRenderer"/> class.
        /// </summary>
        /// <param name="graphicsService">The graphics service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicsService"/> is <see langword="null"/>.
        /// </exception>
        public CubeMapShadowMaskRenderer(IGraphicsService graphicsService)
        {
            if (graphicsService == null)
            throw new ArgumentNullException("graphicsService");

              _effect = graphicsService.Content.Load<Effect>("DigitalRune/Deferred/CubeMapShadowMask");
              _parameterViewInverse = _effect.Parameters["ViewInverse"];
              _parameterFrustumCorners = _effect.Parameters["FrustumCorners"];
              _parameterGBuffer0 = _effect.Parameters["GBuffer0"];
              _parameterParameters0 = _effect.Parameters["Parameters0"];
              _parameterParameters1 = _effect.Parameters["Parameters1"];
              _parameterParameters2 = _effect.Parameters["Parameters2"];
              _parameterLightPosition = _effect.Parameters["LightPosition"];
              _parameterShadowView = _effect.Parameters["ShadowView"];
              _parameterJitterMap = _effect.Parameters["JitterMap"];
              _parameterShadowMap = _effect.Parameters["ShadowMap"];
              _parameterSamples = _effect.Parameters["Samples"];

              Debug.Assert(_parameterSamples.Elements.Count == _samples.Length);

              // TODO: Use struct parameter. Not yet supported in MonoGame.
              // Struct effect parameters are not yet supported in the MonoGame effect processor.
              //var parameterShadow = _effect.Parameters["ShadowParam"];
              //_parameterNear = parameterShadow.StructureMembers["Near"];
              //...
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:34,代码来源:CubeMapShadowMaskRenderer.cs


示例4: LoadContent

    public void LoadContent()
    {
#if gradient
      generateTextureEffect = game.Content.Load<Effect>(@"effects\GenerateTerrainTextureGradient");
      gradientTexture = game.Content.Load<Texture2D>(@"textures\gradient_01");

      generateTextureEffect.Parameters["gradient"].SetValue(gradientTexture);

#else
      string[] textureNames = { 
                                "dirt_01", "dirt_03",
                                "sand_02", "sand_03",
                                "grass_01", "grass_02", "grass_03",
                                "water_01", "stone_02", "stone_03",
                                "snow_01", "snow_03"
                              };

      generateTextureEffect = game.Content.Load<Effect>(@"effects\GenerateTerrainTexturePack");
      slopemapTexture = game.Content.Load<Texture2D>(@"textures\slopemap");

      // load diffuse textures
      textures = new Texture2D[textureNames.Length];
      for (int i = 0; i < textures.Length; i++)
        textures[i] = game.Content.Load<Texture2D>(@"textures\" + textureNames[i]);


#endif

      // texture declaration
      vertexPositionTexture = VertexPositionTexture.VertexDeclaration; // new VertexDeclaration(device, VertexPositionTexture.VertexElements);
    }
开发者ID:TrinityGaming,项目名称:Planet_40,代码行数:31,代码来源:TerrainTextureGenerator.cs


示例5: Terrain

 public Terrain(GraphicsDevice gd, GraphicsDeviceManager gdm, Effect e, MazeGame m)
 {
     device = gd;
     graphics = gdm;
     effect = e;
     instance = m;
 }
开发者ID:ChosenOreo,项目名称:OreoEngine.3D.XNA,代码行数:7,代码来源:Terrain.cs


示例6: InitTerrain

 public void InitTerrain(Texture2D terrainHeightMap, Effect terrainEffect)
 {
     TerrainEffect = terrainEffect;
     SetHeightData(terrainHeightMap);
     SetVerts();
     SetIndices();
 }
开发者ID:vishaknag,项目名称:Simulation-rocketLaunch_ParticleSystem,代码行数:7,代码来源:Terrain.cs


示例7: Draw

 public void Draw(Effect effect)
 {
     for (int i = 0; i < this.listEntity.Count; i++)
     {
         this.listEntity[i].Draw(this.graphics, effect);
     }
 }
开发者ID:Jiwan,项目名称:ROSE-Camera-Editor,代码行数:7,代码来源:DecorationBlock.cs


示例8: InstancedModelDrawer

        public InstancedModelDrawer(Game game)
            : base(game)
        {
            var resourceContentManager = new ResourceContentManager(game.Services, DrawerResource.ResourceManager);
#if WINDOWS
            instancingEffect = resourceContentManager.Load<Effect>("InstancedEffect");
#else
            instancingEffect = resourceContentManager.Load<Effect>("InstancedEffectXbox");
#endif
            //instancingEffect = game.Content.Load<Effect>("InstancedEffect");

            worldTransformsParameter = instancingEffect.Parameters["WorldTransforms"];
            textureIndicesParameter = instancingEffect.Parameters["TextureIndices"];
            viewParameter = instancingEffect.Parameters["View"];
            projectionParameter = instancingEffect.Parameters["Projection"];

            instancingEffect.Parameters["LightDirection1"].SetValue(Vector3.Normalize(new Vector3(.8f, -1.5f, -1.2f)));
            instancingEffect.Parameters["DiffuseColor1"].SetValue(new Vector3(.66f, .66f, .66f));
            instancingEffect.Parameters["LightDirection2"].SetValue(Vector3.Normalize(new Vector3(-.8f, 1.5f, 1.2f)));
            instancingEffect.Parameters["DiffuseColor2"].SetValue(new Vector3(.3f, .3f, .5f));
            instancingEffect.Parameters["AmbientAmount"].SetValue(.5f);

            instancingEffect.Parameters["Colors"].SetValue(colors);

        }
开发者ID:Anomalous-Software,项目名称:BEPUPhysics,代码行数:25,代码来源:InstancedModelDrawer.cs


示例9: ModelLoader

        public ModelLoader(ContentManager contentManager, GraphicsDevice graphicsDevice)
        {
            content = contentManager;
            graphics = graphicsDevice;

            modelEffect = contentManager.Load<Effect>("EffectFiles/model");
        }
开发者ID:kiniry-teaching,项目名称:UCD,代码行数:7,代码来源:ModelLoader.cs


示例10: Draw

        public override void Draw(SpriteBatch sb, Effect effect)
        {
            if (myModel != null)//don't do anything if the model is null
            {
                // Copy any parent transforms.
                Matrix worldMatrix = Matrix.CreateScale(scale) * Matrix.CreateTranslation(Position);

                // Draw the model. A model can have multiple meshes, so loop.
                foreach (ModelMesh mesh in myModel.Meshes)
                {
                    // This is where the mesh orientation is set, as well as our camera and projection.
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {

                        foreach (EffectPass pass in effect.CurrentTechnique.Passes)
                        {
                            part.Effect = effect;
                            effect.Parameters["World"].SetValue(mesh.ParentBone.Transform * worldMatrix);
                            effect.Parameters["ModelTexture"].SetValue(myTexture);

                            Matrix worldInverseTransposeMatrix = Matrix.Transpose(Matrix.Invert(mesh.ParentBone.Transform * worldMatrix));
                        }
                    }

                    // Draw the mesh, using the effects set above.
                    mesh.Draw();
                }
            }
        }
开发者ID:CaKlassen,项目名称:Titanium,代码行数:29,代码来源:Potion.cs


示例11: LoadContent

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(device);

            //Load the fx files
            extractEffect = Game.Content.Load<Effect>("BloomExtract");
            combineEffect = Game.Content.Load<Effect>("BloomCombine");
            gaussBlurEffect = Game.Content.Load<Effect>("GaussBlur");


            // Look up the resolution and format of our main backbuffer.
            PresentationParameters pp = device.PresentationParameters;

            int width = pp.BackBufferWidth;
            int height = pp.BackBufferHeight;

            SurfaceFormat format = pp.BackBufferFormat;

            //Set how the bloom will behave
            setBloomSetting(0.25f, 4f, 2f, 1f, 2f, 0f);

            // Create a texture for reading back the backbuffer contents.
            resolveTarget = new ResolveTexture2D(device, width, height, 1, format);

            //Can make the backbuffers smaller to increase efficiency, makes bloom less pronounced
            /**
            width /= 2;
            height /= 2;
            */ //for example 

            renderTarget1 = new RenderTarget2D(device, width, height, 1, format);
            renderTarget2 = new RenderTarget2D(device, width, height, 1, format);
        }
开发者ID:Daniel-Nichol,项目名称:ox-g1-surface,代码行数:33,代码来源:BloomComponent.cs


示例12: StencilSolidEffect

 public StencilSolidEffect(Effect effect)
 {
     _effect = effect;
     _pass = _effect.CurrentTechnique.Passes[0];
     _projection = effect.Parameters["Projection"];
     _transformation = effect.Parameters["Transformation"];
 }
开发者ID:liwq-net,项目名称:XnaVG,代码行数:7,代码来源:StencilSolidEffect.cs


示例13: ParticleEffect

        public ParticleEffect(Effect _fx, ParticleEffectConfig conf)
        {
            fx = _fx;
            fx.CurrentTechnique = fx.Techniques[0];

            fxPassSimple = fx.CurrentTechnique.Passes[conf.PassSimple];
            fxpVP = fx.Parameters[conf.ParamVP];
            fxpTime = fx.Parameters[conf.ParamTime];
            fxpMapSize = fx.Parameters[conf.ParamMapSize];

            fxPassLightning = fx.CurrentTechnique.Passes[conf.PassLightning];
            fxpLSplits = fx.Parameters[conf.ParamSplits];

            fxPassFire = fx.CurrentTechnique.Passes[conf.PassFire];
            fxpFRates = fx.Parameters[conf.ParamRates];
            fxpFScales = fx.Parameters[conf.ParamScales];
            fxpFOff1 = fx.Parameters[conf.ParamOffset1];
            fxpFOff2 = fx.Parameters[conf.ParamOffset2];
            fxpFOff3 = fx.Parameters[conf.ParamOffset3];
            fxpFDistortScale = fx.Parameters[conf.ParamDistortScale];
            fxpFDistortBias = fx.Parameters[conf.ParamDistortBias];

            fxPassAlert = fx.CurrentTechnique.Passes[conf.PassAlert];

            // Set Default Values
            LightningSplits = DEFAULT_SPLITS;
            FireDistortScale = DEFAULT_DISTORT_SCALE;
            FireDistortBias = DEFAULT_DISTORT_BIAS;
            FireOffset1 = DEFAULT_OFFSET;
            FireOffset2 = DEFAULT_OFFSET;
            FireOffset3 = DEFAULT_OFFSET;
            FireRates = DEFAULT_RATES;
            FireScales = DEFAULT_SCALES;
        }
开发者ID:RegrowthStudios,项目名称:VoxelRTS,代码行数:34,代码来源:ParticleEffect.cs


示例14: GameResourceEffect

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="key">key name</param>
        /// <param name="assetName">asset name</param>
        /// <param name="resource">effect resource</param>
        public GameResourceEffect(string key, string assetName, Effect resource)
            : base(key, assetName)
        {
            this.effect = resource;

            this.resource = (object)this.effect;
        }
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:13,代码来源:GameResourceEffect.cs


示例15: Terrain

        public Terrain(float CellSize, float Height, float TextureTiling, int size, Vector3 Position, Vector3 LightDirection,
                        GraphicsDevice GraphicsDevice, Effect effect,
                        Texture2D BaseTexture, Type type = Type.Flat, float terrainOffset = 0,
                        Texture2D RedTexture = null, Texture2D GreenTexture = null, Texture2D WeightTexture = null)
        {
            this.type = type;
            this.size = this.width = this.length = size;
            this.cellSize = CellSize;
            this.height = Height;
            this.Position = Position;
            this.baseTexture = BaseTexture;
            this.redTexture = RedTexture;
            this.greenTexture = GreenTexture;
            this.weightTexture = WeightTexture;
            this.textureTiling = TextureTiling;
            this.lightDirection = LightDirection;
            this.terrainOffset = terrainOffset;
            this.PersistantRot = Matrix.Identity;
            //this.GraphicsDevice = GraphicsDevice;
            this.LightPosition = new Vector3(0, -2500000f, 0);
            this.waterSphere = new BoundingSphere(Vector3.Zero, PlanetRadius + Planet.HeightMag);

            nVertices = width * length;

            //2 tris per cell, 3 indices per tris
            nIndices = (width - 1) * (length - 1) * 6;

            this.effect = effect;
            //vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionNormalTexture), nVertices, BufferUsage.WriteOnly);
            //indexBuffer = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, nIndices, BufferUsage.WriteOnly);
        }
开发者ID:Infinity-Universe-Community,项目名称:infinity-universe,代码行数:31,代码来源:Terrain.cs


示例16: WheelMenu

        public WheelMenu( MenuScreen screen, Camera camera, float wheelScale, 
            float screenScale, float startX, float activeX, float finishX, float y)
            : base(screen, Vector2.Zero)
        {
            this.wheelScale = wheelScale;
              scaleMatrix = Matrix.CreateScale( wheelScale );
              this.camera = camera;
              angle = MathHelper.PiOver4;

              TransitionOnPosition = new Vector2( startX, y );
              Position = new Vector2( activeX, y );
              TransitionOffPosition = new Vector2( finishX, y );

              rotateSpring = new SpringInterpolater( 1, 50, SpringInterpolater.GetCriticalDamping( 50 ) );

              lastX = startX;

              ContentManager content = screen.ScreenManager.Game.Content;

              entryEffect = content.Load<Effect>( "Effects/basic" ).Clone( Screen.ScreenManager.GraphicsDevice );
              entryEffect.CurrentTechnique = entryEffect.Techniques["DiffuseColor"];
              entryEffect.Parameters["LightingEnabled"].SetValue( false );
              entryWorldEffectParameter = entryEffect.Parameters["World"];
              entryViewEffectParameter = entryEffect.Parameters["View"];
              entryProjectionEffectParameter = entryEffect.Parameters["Projection"];
              entryDiffuseEffectParameter = entryEffect.Parameters["DiffuseMap"];

              wheelModel = content.Load<CustomModel>( "Models/hamsterWheel" );
              foreach ( CustomModel.ModelPart part in wheelModel.ModelParts )
              {
            part.Effect.CurrentTechnique = part.Effect.Techniques["Color"];
            part.Effect.Parameters["Color"].SetValue( new Color( Color.LightGray, 0 ).ToVector4() );
              }
        }
开发者ID:yxrkt,项目名称:AvatarHamsterPanic,代码行数:34,代码来源:WheelMenu.cs


示例17: Draw_Box

        public static void Draw_Box(Vector2 position, float width, float height, Color c, SpriteBatch b, float rotation = 0, byte alpha = 255, Effect e = null, bool wrong = false)
        {
            Vector2 topLeft = new Vector2(position.X - (width / 2), position.Y - (height / 2));
            Vector2 bottomRight = new Vector2(position.X + (width / 2), position.Y + (height / 2));

            Draw_Box(topLeft, bottomRight, c, b, rotation, alpha, e, wrong);
        }
开发者ID:YogurtFP,项目名称:YogUI,代码行数:7,代码来源:DrawManager.cs


示例18: Load

        /// <summary>
        /// Load your graphics content.
        /// </summary>
        public void Load(GraphicsDevice device, ContentManager content)
        {
            GraphicsDevice = device;

            spriteBatch = new SpriteBatch(GraphicsDevice);

            bloomExtractEffect = content.Load<Effect>("BloomExtract");
            bloomCombineEffect = content.Load<Effect>("BloomCombine");
            gaussianBlurEffect = content.Load<Effect>("GaussianBlur");


            // Look up the resolution and format of our main backbuffer.
            PresentationParameters pp = GraphicsDevice.PresentationParameters;

            int width = pp.BackBufferWidth;
            int height = pp.BackBufferHeight;

            SurfaceFormat format = pp.BackBufferFormat;

            // Create a texture for reading back the backbuffer contents.
            resolveTarget = new ResolveTexture2D(GraphicsDevice, width, height, 1, format);

            // Create two rendertargets for the bloom processing. These are half the
            // size of the backbuffer, in order to minimize fillrate costs. Reducing
            // the resolution in this way doesn't hurt quality, because we are going
            // to be blurring the bloom images in any case.
            width /= 4;
            height /= 4;

            renderTarget1 = new RenderTarget2D(GraphicsDevice, width, height, 1, format);
            renderTarget2 = new RenderTarget2D(GraphicsDevice, width, height, 1, format);
        }
开发者ID:GlennSandoval,项目名称:Infiniminer,代码行数:35,代码来源:BloomComponent.cs


示例19: DepthMapEffect

 public DepthMapEffect(Effect cloneSource)
     : base(cloneSource)
 {
     world = Parameters["World"];
     view = Parameters["View"];
     projection = Parameters["Projection"];
 }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:7,代码来源:DepthMapEffect.cs


示例20: InstancedModelDrawer

        public InstancedModelDrawer(Game game)
            : base(game)
        {
            instancingEffect = game.Content.Load<Effect>("InstancedEffect");

            worldTransformsParameter = instancingEffect.Parameters["WorldTransforms"];
            textureIndicesParameter = instancingEffect.Parameters["TextureIndices"];
            viewParameter = instancingEffect.Parameters["View"];
            projectionParameter = instancingEffect.Parameters["Projection"];

            instancingEffect.Parameters["LightDirection1"].SetValue(Vector3.Normalize(new Vector3(.8f, -1.5f, -1.2f)));
            instancingEffect.Parameters["DiffuseColor1"].SetValue(new Vector3(.66f, .66f, .66f));
            instancingEffect.Parameters["LightDirection2"].SetValue(Vector3.Normalize(new Vector3(-.8f, 1.5f, 1.2f)));
            instancingEffect.Parameters["DiffuseColor2"].SetValue(new Vector3(.3f, .3f, .5f));
            instancingEffect.Parameters["AmbientAmount"].SetValue(.5f);

            instancingEffect.Parameters["Texture0"].SetValue(textures[0]);
            instancingEffect.Parameters["Texture1"].SetValue(textures[1]);
            instancingEffect.Parameters["Texture2"].SetValue(textures[2]);
            instancingEffect.Parameters["Texture3"].SetValue(textures[3]);
            instancingEffect.Parameters["Texture4"].SetValue(textures[4]);
            instancingEffect.Parameters["Texture5"].SetValue(textures[5]);
            instancingEffect.Parameters["Texture6"].SetValue(textures[6]);
            instancingEffect.Parameters["Texture7"].SetValue(textures[7]);

            //This vertex declaration could be compressed or made more efficient, but such optimizations weren't critical.
            instancingVertexDeclaration = new VertexDeclaration(new[] {new VertexElement(0, VertexElementFormat.Single, VertexElementUsage.TextureCoordinate, 1)});
        }
开发者ID:gpforde,项目名称:GPBrakes,代码行数:28,代码来源:InstancedModelDrawer.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Graphics.EffectParameter类代码示例发布时间:2022-05-26
下一篇:
C# Graphics.ESTexture2D类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap