當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。