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


C# Graphics.EffectParameter类代码示例

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


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

示例1: SetLightingMatrices

        /// <summary>
        /// Lazily recomputes the world inverse transpose matrix and
        /// eye position based on the current effect parameter settings.
        /// </summary>
        internal static EffectDirtyFlags SetLightingMatrices(EffectDirtyFlags dirtyFlags, ref Matrix world, ref Matrix view,
                                                             EffectParameter worldParam, EffectParameter worldInverseTransposeParam, EffectParameter eyePositionParam)
        {
            // Set the world and world inverse transpose matrices.
            if ((dirtyFlags & EffectDirtyFlags.World) != 0)
            {
                Matrix worldTranspose;
                Matrix worldInverseTranspose;

                Matrix.Invert(ref world, out worldTranspose);
                Matrix.Transpose(ref worldTranspose, out worldInverseTranspose);

                worldParam.SetValue(world);
                worldInverseTransposeParam.SetValue(worldInverseTranspose);

                dirtyFlags &= ~EffectDirtyFlags.World;
            }

            // Set the eye position.
            if ((dirtyFlags & EffectDirtyFlags.EyePosition) != 0)
            {
                Matrix viewInverse;

                Matrix.Invert(ref view, out viewInverse);

                eyePositionParam.SetValue(viewInverse.Translation);

                dirtyFlags &= ~EffectDirtyFlags.EyePosition;
            }

            return dirtyFlags;
        }
开发者ID:jbekkedal,项目名称:MonoGame,代码行数:36,代码来源:EffectHelpers.cs

示例2: 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

示例3: SetParameter

 private int SetParameter(int offset, EffectParameter param)
 {
   if (param.Data == null)
     return 0;
   int num;
   if (param.Elements.Count > 0)
   {
     num = param.RowCount * param.Elements.Count;
     this.SetData(offset, param.RowCount * param.Elements.Count, param.ColumnCount, 0, param.Data);
   }
   else
   {
     switch (param.ParameterType)
     {
       case EffectParameterType.Bool:
       case EffectParameterType.Int32:
       case EffectParameterType.Single:
         if (param.ParameterClass == EffectParameterClass.Matrix)
         {
           num = param.ColumnCount;
           this.SetData(offset, param.ColumnCount, param.RowCount, param.RegisterCount, param.Data);
           break;
         }
         else
         {
           num = param.RowCount;
           this.SetData(offset, param.RowCount, param.ColumnCount, param.RegisterCount, param.Data);
           break;
         }
       default:
         throw new NotImplementedException("Not supported!");
     }
   }
   return num;
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:35,代码来源:ConstantBuffer.cs

示例4: RenderBatch

        public RenderBatch(GraphicsDevice device, int primitivesPerBatch, bool enableAlphaBlend)
        {
            this.device = device;
            if (enableAlphaBlend)
            {
                BasicEffect be = new BasicEffect(device);
                Effect = be;
                fxMatrices = be;
                be.TextureEnabled = true;
                be.VertexColorEnabled = true;
                be.LightingEnabled = false;
                fxParamTexture = Effect.Parameters["Texture"];
            }
            else
            {
                AlphaTestEffect ate = new AlphaTestEffect(device);
                Effect = ate;
                fxMatrices = ate;
                ate.VertexColorEnabled = true;
                ate.ReferenceAlpha = 128;
                fxParamTexture = Effect.Parameters["Texture"];
            }

            this.maxPrimitivesPerBatch = primitivesPerBatch;
        }
开发者ID:gnomicstudios,项目名称:GGJ13,代码行数:25,代码来源:RenderBatch.cs

示例5: DepthMapEffect

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

示例6: 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

示例7: CloudLayerRenderer

        public CloudLayerRenderer(IGraphicsService graphicsService)
        {
            if (graphicsService == null)
            throw new ArgumentNullException("graphicsService");

              if (graphicsService.GraphicsDevice.GraphicsProfile == GraphicsProfile.Reach)
            throw new NotSupportedException("The CloudLayerRenderer does not support the Reach profile.");

              _effect = graphicsService.Content.Load<Effect>("DigitalRune/Sky/CloudLayer");
              _parameterView = _effect.Parameters["View"];
              _parameterProjection = _effect.Parameters["Projection"];
              _parameterSunDirection = _effect.Parameters["SunDirection"];
              _parameterSkyCurvature = _effect.Parameters["SkyCurvature"];
              _parameterTextureMatrix = _effect.Parameters["Matrix0"];
              _parameterNumberOfSamples = _effect.Parameters["NumberOfSamples"];
              _parameterSampleDistance = _effect.Parameters["SampleDistance"];
              _parameterScatterParameters = _effect.Parameters["ScatterParameters"];
              _parameterHorizonFade = _effect.Parameters["HorizonFade"];
              _parameterSunLight = _effect.Parameters["SunLight"];
              _parameterAmbientLight = _effect.Parameters["AmbientLight"];
              _parameterTexture = _effect.Parameters["NoiseTexture0"];
              _passCloudRgbLinear = _effect.Techniques[0].Passes["CloudRgbLinear"];
              _passCloudAlphaLinear = _effect.Techniques[0].Passes["CloudAlphaLinear"];
              _passCloudRgbGamma = _effect.Techniques[0].Passes["CloudRgbGamma"];
              _passCloudAlphaGamma = _effect.Techniques[0].Passes["CloudAlphaGamma"];
              _passOcclusionRgb = _effect.Techniques[0].Passes["OcclusionRgb"];
              _passOcclusionAlpha = _effect.Techniques[0].Passes["OcclusionAlpha"];

              // We render a spherical patch into the sky. But any mesh which covers the top
              // hemisphere works too.
              //_submesh = MeshHelper.CreateSpherePatch(graphicsService.GraphicsDevice, 1, 1.1f, 10);
              _submesh = MeshHelper.CreateBox(graphicsService.GraphicsDevice);

              _queryGeometry = new Vector3F[4];
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:35,代码来源:CloudLayerRenderer.cs

示例8: 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

示例9: GdxSpriteBatch

        public GdxSpriteBatch(GraphicsDevice graphicsDevice)
        {
            if (graphicsDevice == null)
                throw new ArgumentNullException("graphicsDevice");

            _device = graphicsDevice;

            _spriteEffect = new LocalSpriteEffect(graphicsDevice);
            _matrixTransform = _spriteEffect.Parameters["MatrixTransform"];
            _spritePass = _spriteEffect.CurrentTechnique.Passes[0];

            _transformMatrix = Matrix.Identity;
            //_projectionMatrix = Matrix.CreateOrthographicOffCenter(0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, 0, 0, 1);
            _projectionMatrix = XnaExt.Matrix.CreateOrthographic2D(0, 0, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height, -1, 0);

            Color = Color.White;

            CalculateIndexBuffer();

            _rasterizerScissorState = new RasterizerState() {
                CullMode = CullMode.None,
                ScissorTestEnable = true,
            };

            // projection uses CreateOrthographicOffCenter to create 2d projection
            // matrix with 0,0 in the upper left.
            /*_basicEffect.Projection = Matrix.CreateOrthographicOffCenter
                (0, graphicsDevice.Viewport.Width,
                graphicsDevice.Viewport.Height, 0,
                0, 1);
            this._basicEffect.World = Matrix.Identity;
            this._basicEffect.View = Matrix.CreateLookAt(Vector3.Zero, Vector3.Forward,
                Vector3.Up);*/
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:34,代码来源:GdxSpriteBatch.cs

示例10: DepthOfFieldFilter

        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="DepthOfFieldFilter"/> class.
        /// </summary>
        /// <param name="graphicsService">The graphics service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicsService"/> is <see langword="null"/>.
        /// </exception>
        public DepthOfFieldFilter(IGraphicsService graphicsService)
            : base(graphicsService)
        {
            _effect = GraphicsService.Content.Load<Effect>("DigitalRune/PostProcessing/DepthOfFieldFilter");
              _screenSizeParameter = _effect.Parameters["ScreenSize"];
              _depthTextureParameter = _effect.Parameters["DepthTexture"];
              _nearBlurDistanceParameter = _effect.Parameters["NearBlurDistance"];
              _nearFocusDistanceParameter = _effect.Parameters["NearFocusDistance"];
              _farFocusDistanceParameter = _effect.Parameters["FarFocusDistance"];
              _farBlurDistanceParameter = _effect.Parameters["FarBlurDistance"];
              _farParameter = _effect.Parameters["Far"];
              _blurTextureParameter = _effect.Parameters["BlurTexture"];
              _downsampledDepthTextureParameter = _effect.Parameters["DownsampledDepthTexture"];
              _downsampledCocTextureParameter = _effect.Parameters["DownsampledCocTexture"];
              _offsetsParameter = _effect.Parameters["Offsets"];
              _weightsParameter = _effect.Parameters["Weights"];
              _sceneTextureParameter = _effect.Parameters["SceneTexture"];
              _circleOfConfusionPass = _effect.CurrentTechnique.Passes["CircleOfConfusion"];
              _blurPass = _effect.CurrentTechnique.Passes["Blur"];
              _depthOfFieldPass = _effect.CurrentTechnique.Passes["DepthOfField"];

              _downsampleFilter = PostProcessHelper.GetDownsampleFilter(graphicsService);

              _cocBlur = new Blur(graphicsService);
              _cocBlur.InitializeBoxBlur(5, false);

              NearBlurDistance = 2;
              NearFocusDistance = 5;
              FarFocusDistance = 6;
              FarBlurDistance = 10;
              _downsampleFactor = 2;
              BlurStrength = 1;
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:41,代码来源:DepthOfFieldFilter.cs

示例11: InstancedModelDrawer

        public InstancedModelDrawer(Game game)
            : base(game)
        {
#if WINDOWS
            var resourceContentManager = new ResourceContentManager(game.Services, Indiefreaks.Xna.BEPU.Resources.WindowsPhysicsResources.ResourceManager);
#elif XBOX360
            var resourceContentManager = new ResourceContentManager(game.Services, Indiefreaks.Xna.BEPU.Resources.Xbox360PhysicsResources.ResourceManager);
#else
            ResourceContentManager resourceContentManager = null;
#endif
            instancingEffect = resourceContentManager.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:VICOGameStudio-Ujen,项目名称:igf,代码行数:35,代码来源:InstancedModelDrawer.cs

示例12: Create

        public override void Create()
        {
            buffer = Plane(xCount, yCount);

            //Load the correct shader and set up the parameters
            IGraphicsDeviceService graphicsService = (IGraphicsDeviceService)GameInstance.Services.GetService(typeof(IGraphicsDeviceService));

            effect = SpacewarGame.ContentManager.Load<Effect>(SpacewarGame.Settings.MediaPath + @"shaders\sun");

            worldParam = effect.Parameters["world"];
            worldViewProjectionParam = effect.Parameters["worldViewProjection"];
            sun0TextureParam = effect.Parameters["Sun_Tex0"];
            sun1TextureParam = effect.Parameters["Sun_Tex1"];
            blendFactor = effect.Parameters["blendFactor"];

            //Preload the textures into the cache
            int numFrames = 5;
            sun = new Texture2D[numFrames];

            sun[0] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest1");
            sun[1] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest2");
            sun[2] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest3");
            sun[3] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest4");
            sun[4] = SpacewarGame.ContentManager.Load<Texture2D>(SpacewarGame.Settings.MediaPath + @"textures\suntest5");
        }
开发者ID:RaulPB,项目名称:videogames,代码行数:25,代码来源:EvolvedSun.cs

示例13: EdgeFilter

        //--------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="EdgeFilter"/> class.
        /// </summary>
        /// <param name="graphicsService">The graphics service.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="graphicsService"/> is <see langword="null"/>.
        /// </exception>
        public EdgeFilter(IGraphicsService graphicsService)
            : base(graphicsService)
        {
            _effect = GraphicsService.Content.Load<Effect>("DigitalRune/PostProcessing/EdgeFilter");
              _parameterViewportSize = _effect.Parameters["ViewportSize"];
              _parameterHalfEdgeWidth = _effect.Parameters["HalfEdgeWidth"];
              _parameterDepthThreshold = _effect.Parameters["DepthThreshold"];
              _parameterDepthSensitivity = _effect.Parameters["DepthSensitivity"];
              _parameterNormalThreshold = _effect.Parameters["NormalThreshold"];
              _parameterNormalSensitivity = _effect.Parameters["NormalSensitivity"];
              _parameterCameraBackward = _effect.Parameters["CameraBackward"];
              _parameterSourceTexture = _effect.Parameters["SourceTexture"];
              _parameterSilhouetteColor = _effect.Parameters["SilhouetteColor"];
              _parameterCreaseColor = _effect.Parameters["CreaseColor"];
              _parameterGBuffer0 = _effect.Parameters["GBuffer0"];
              _parameterGBuffer1 = _effect.Parameters["GBuffer1"];
              _passEdge = _effect.Techniques[0].Passes["Edge"];
              _passOnePixelEdge = _effect.Techniques[0].Passes["OnePixelEdge"];

              EdgeWidth = 2.0f;
              DepthThreshold = 0.001f;  // = minDistance / farPlaneDistance
              DepthSensitivity = 1000;  // = farPlaneDistance / (maxDistance - minDistance)
              NormalThreshold = 0.1f;
              NormalSensitivity = 2f;
              SilhouetteColor = new Vector4F(0, 0, 0, 1);
              CreaseColor = new Vector4F(0, 0, 0, 1);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:35,代码来源:EdgeFilter.cs

示例14: OnInit

        protected override void OnInit()
        {
            base.OnInit();

            depthParam = effect.Parameters["Depth"];
            centerParam = effect.Parameters["Center"];
        }
开发者ID:IndiegameGarden,项目名称:TTR,代码行数:7,代码来源:BoomDepthEffect.cs

示例15: _LoadParameters

        protected override void _LoadParameters()
        {
            base._LoadParameters();

            _baseTextureParameter = EffectManager.GetParameter(Effect, "baseTexture");
            Assert.Fatal(_baseTextureParameter != null, "PostProcessMaterial._LoadParameters - Unable to load parameter 'baseTexture'!");
        }
开发者ID:andrewstrauch,项目名称:The-Scarab-Gauntlet,代码行数:7,代码来源:PostProcessMaterial.cs


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