Created
August 1, 2011 16:34
-
-
Save qpfiffer/1118464 to your computer and use it in GitHub Desktop.
Notes on BasicEffect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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