Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

EffectParameter Class

Represents an Effect parameter.

Namespace: Microsoft.Xna.Framework.Graphics
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

public sealed class EffectParameter

Creating and assigning a EffectParameter instance for each technique in your Effect is significantly faster than using the Parameters indexed property on Effect.

To use a EffectParameter you must:

  1. Create a EffectParameter for each parameter in your Effect that you will be setting in Draw or Update.

    public EffectParameter mWorld;
    public EffectParameter mCameraView;
    public EffectParameter CameraPos;
    public EffectParameter mCameraProj;
    
  2. Assign an Effect parameter to your EffectParameter.

    mWorld = effect.Parameters["g_mWorld"];
    mCameraView = effect.Parameters["g_mCameraView"];
    CameraPos = effect.Parameters["g_CameraPos"];
    mCameraProj = effect.Parameters["g_mCameraProj"];
    
  3. Call SetValue on your EffectParameter to change the parameter value.

    MyEffect.CameraPos.SetValue(CameraPos);
    MyEffect.mCameraView.SetValue(view);
    MyEffect.mCameraProj.SetValue(projection);
    MyEffect.LightPos.SetValue(LightPos);
    MyEffect.mLightView.SetValue(Matrix.CreateLookAt(LightPos, bounds.Center, Vector3.Up));
    

Xbox 360, Windows XP SP2, Windows Vista

Community Additions

ADD
Show:
© 2015 Microsoft