Added runtime fx compilation and lighting

Tuesday, February 17, 2009 by gradbot

I spent some time fighting with matrices to get the lighting correct but I'm happy now that I have a rotating and moving object in XNA that is lit from a single stationary source. I'm using the plastic shader that comes with NVIDIA FX Composer 2.5.




Here's my runtime code that compiles a fx file into an Effect.


let compileEffect(fileName : string)=
let compiledEffect =
Effect.CompileEffectFromFile(
fileName,
null,
null,
CompilerOptions.Debug,
TargetPlatform.Windows)
let effectCode =
compiledEffect.GetEffectCode()
new Effect(
this.graphics.GraphicsDevice,
effectCode,
CompilerOptions.Debug,
null)

source code

Filed under , , having  

0 comments: