Jump to content
  • Advertisement
Sign in to follow this  
Shnoutz

Effect file trouble

This topic is 5230 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!