Skip to content

Instantly share code, notes, and snippets.

@qpfiffer
Created August 1, 2011 16:34
Show Gist options
  • Select an option

  • Save qpfiffer/1118464 to your computer and use it in GitHub Desktop.

Select an option

Save qpfiffer/1118464 to your computer and use it in GitHub Desktop.
Notes on BasicEffect
// This is how the WorlViewProj matrix is computed:
Matrix worldViewProj;
Matrix.Multiply(ref world, ref view, out worldView);
Matrix.Multiply(ref worldView, ref projection, out worldViewProj);
// This is how it is used in the HLSL file:
struct CommonVSOutput
{
float4 Pos_ps;
float4 Diffuse;
float3 Specular;
float FogFactor;
};
CommonVSOutput ComputeCommonVSOutput(float4 position)
{
CommonVSOutput vout;
vout.Pos_ps = mul(position, WorldViewProj);
vout.Diffuse = DiffuseColor;
vout.Specular = 0;
vout.FogFactor = ComputeFogFactor(position);
return vout;
}
// This is how I was drawing models before I ripped out BasicEffect:
effect.World = transforms[mesh.ParentBone.Index];
effect.World *= Matrix.CreateRotationY(Model.Rotation);
effect.World *= Matrix.CreateTranslation(Model.Position);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment