2.1 Add maps for our shader
Step 1: In our empty effect:
float4x4 worldviewproj:worldviewprojection;
Right-click the following line and select Insert Snippets
Select "Texture and Sampler" in the box to the right
Double-click on the name of a box and modify it to diffuse so that all "Name" becomes "diffuse" automatically.
Step 2: Add the program segment so that the code becomes
float4x4 worldviewproj:worldviewprojection;
Texture Diffuse <
String resourcename = "";//optional default file name
String uiname = "diffuse texture";
String resourcetype = "2D";
>;
Sampler2d Diffusesampler = sampler_state {
Texture = <diffuse>;
Minfilter = Linear;
Magfilter = Linear;
Mipfilter = Linear;
Addressu = Wrap;
ADDRESSV = Wrap;
};
struct Vs_output
{
FLOAT4 pos:position;
FLOAT2 tex:texcoord0;
};
Vs_output Mainvs (float4 pos:position,float2 tex:texcoord0) {
Vs_output vsout;
Vsout.pos = Mul (pos,worldviewproj);
Vsout.tex = Tex;
return vsout;
}
Float4 Mainps (float2 tex:texcoord0): COLOR {
Return tex2d (Diffusesampler, Tex);
}
Technique TECHNIQUE0 {
Pass P0 {
VertexShader = Compile vs_3_0 Mainvs ();
PixelShader = Compile ps_3_0 Mainps ();
}
}