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


C# Graphics.Effect类代码示例

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


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


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