Sign in to follow this  

Effect file trouble

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm new to effect file and I do not understand why my texture (tex) is not displayed...
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);
	}
}



Share this post


Link to post
Share on other sites
You're supposed to "include" the texture within the sampler definition :

[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.

Share this post


Link to post
Share on other sites

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this