Sign in to follow this  

Basic Texture Shader not working

This topic is 4745 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

float4x4 worldViewProj;
texture testTexture;
sampler DiffuseSampler;

struct VS_OUTPUT
{
    float4 Pos : POSITION;
    float2 Tex : TEXCOORD0;
};

VS_OUTPUT vs_main(float4 inPos : POSITION, 
	float2 inTex : TEXCOORD0 )
{
    VS_OUTPUT Out = (VS_OUTPUT)0;
    Out.Pos = mul(inPos, worldViewProj);
    Out.Tex = inTex;
    return Out;
}

float4 ps_main( VS_OUTPUT In ) : COLOR0
{
    return tex2D(DiffuseSampler, In.Tex);
}

//--------------------------------------------------------------------------------------
// Renders scene to render target
//--------------------------------------------------------------------------------------
technique Technique0
{
    pass P0
    {          
        VertexShader = compile vs_1_1 vs_main();
        PixelShader  = compile ps_1_1 ps_main();
    }
}
I make sure I pass in the texture, and update the matrix every frame, but it still doesn't work properly. My object geometrically is correct, but instead of being displayed with a texture, it's just black.

Share this post


Link to post
Share on other sites

This topic is 4745 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