shader.fx
float4x4 World;
float4x4 View;
float4x4 Projection;
texture gTex;
sampler TexS = sampler_state
{
Texture = ;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
struct VertexOut
{
float4 Pos : POSITION;
float2 tex0 : TEXCOORD2;
};
VertexOut VShader(float4 Pos : POSITION,float2 tex0 : TEXCOORD0)
{
VertexOut Vert = (VertexOut)0;
float4x4 Transform;
Transform = mul(World, View);
Transform = mul(Transform, Projection);
Vert.Pos = mul(Pos, Transform);
Vert.tex0 = tex0;
return Vert;
}
float4 PS(float2 tex0 : TEXCOORD2) : COLOR
{
return tex2D(TexS, tex0);
}
technique FirstTechnique
{
pass FirstPass
{
Lighting = TRUE;
ZEnable = TRUE;
//FillMode = WireFrame;
VertexShader = compile vs_2_0 VShader();
PixelShader = compile ps_2_0 TransformPS();
}
}
//loading the texture and setting the effect params
D3DXCreateTextureFromFile(d3ddev,"wings.bmp",&Texture);
effect->FindNextValidTechnique(NULL, &technique); // find the best technique
xWorldHandle = effect->GetParameterByName(NULL,"World");
xViewHandle = effect->GetParameterByName(NULL,"View");
xProjectionHandle = effect->GetParameterByName(NULL,"Projection");
xTextureHandle = effect->GetParameterByName(NULL,"gTex");
//rendering the mesh with effect
effect->SetTexture(xTextureHandle,Texture);
//render with shader
effect->Begin(NULL, NULL); // begin using the effect
effect->BeginPass(0); // begin the pass
//draw here
for(DWORD i = 0; i < numMaterials; i++) // loop through each subset
{
meshSpaceship->DrawSubset(i); // draw the subset
}
effect->EndPass(); // end the pass
effect->End(); // end the effect
can anyone help me with this its driving me crazy