shared float4x4 view;
shared float4x4 proj;
shared texture tex;
sampler smp = sampler_state
{
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
struct AppIn
{
float4 position : POSITION;
float2 texcoord : TEXCOORD;
float3 normal : NORMAL;
};
struct VertexOut
{
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
float3 normal : TEXCOORD1;
};
struct PixelOut
{
float4 color : COLOR;
};
VertexOut shadeVertex (AppIn input, uniform float4x4 view, uniform float4x4 proj)
{
VertexOut output;
output.position = mul (mul (input.position, view), proj);
output.normal = mul (input.normal, (float3x3) view);
output.texcoord = input.texcoord;
return output;
}
PixelOut shadePixel (VertexOut input,uniform sampler smp)
{
PixelOut output;
float3 lightDir = float3 (0, 0, -1);
float diffuse = dot (normalize (input.normal), lightDir);
float specular = pow (diffuse, 16.0f);
output.color = diffuse * tex2D (smp, input.texcoord) + specular;
return output;
}
technique t0
{
pass p0
{
Texture[0] = tex;
VertexShader = compile vs_2_0 shadeVertex (view, proj);
PixelShader = compile ps_2_0 shadePixel (smp);
}
}
Effect file trouble
I'm new to effect file and I do not understand why my texture (tex) is not displayed...
You're supposed to "include" the texture within the sampler definition :
You also don't need to include
under the technique.
[SOURCE]sampler smp = sampler_state{ Texture = (tex); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear;};[/SOURCE]
You also don't need to include
[SOURCE]Texture[0] = (tex);[/SOURCE]
under the technique.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement