StitchUp is an XNA 4.0 Content Pipeline extension which implements most of the ideas in Shawn Hargreaves' article Generating Shaders From HLSL Fragments.
- Download the latest release from the downloads page. The zip file contains StitchUp.Content.Pipeline.dll, which is the only one you need.
- Read the wiki for information on writing shader fragments and how to use the various importers and processors that are included in StitchUp.
- You want to create your effect files from re-usable shader fragments.
- You want to vary the number of lights or textures you use, but without needing to rewrite the shader.
- Because it's new and shiny?
Fragment file:
fragment base_texture;
[textures]
texture2D color_map;
[vertexattributes]
float2 uv;
[interpolators]
float2 uv;
[ps 2_0]
__hlsl__
void main(INPUT input, inout OUTPUT output)
{
output.color = tex2D(color_map, input.uv);
}
__hlsl__
Stitched effect file:
Shaders\Fragments\VertexTransform.fragment
Shaders\Fragments\BaseTexture.fragment
Shaders\Fragments\DetailTexture.fragment
- Add
StitchUp.Content.Pipeline.dllas a reference to your content project. - Create fragments and stitched effect files as needed. If you use
.fragmentand.stitchedeffectas the file extensions, the files should automatically be linked to the correct StitchUp importers and processors. You don't need a processor for.fragmentfiles. - You can either load the stitched effect at runtime (in the same way as you would load a normal effect),
or you can use the StitchUp model processor to associate the effect with a model at compile-time.
To do this:
- Select the model in your content project.
- Change the Content Processor to "Model - StitchUp".
- Set the "Stitched Effect" processor property to the path (relative to the root of your content
project) of your
.stitchedeffectfile.