XNA Deferred Shading, Replace BasicEffect
- by Alex
I have implemented deferred shading in my XNA 4.0 project, meaning that I need all objects to start out with the same shader "RenderGBuffer.fx". How can I use a custom Content Processor to:
Not load any textures by default (I want to manually do this)
Use "RenderGBuffer.fx" as the default shader instead of BasicEffect
Below is the progress so far
public class DeferredModelProcessor : ModelProcessor
{
EffectMaterialContent deferredShader;
public DeferredModelProcessor()
{
}
protected override MaterialContent ConvertMaterial(MaterialContent material, ContentProcessorContext context)
{
deferredShader = new EffectMaterialContent();
deferredShader.Effect = new ExternalReference<EffectContent>("DeferredShading/RenderGBuffer.fx");
return context.Convert<MaterialContent, MaterialContent>(deferredShader, typeof(MaterialProcessor).Name);
}
}