Sign in to follow this  
B_old

Strangeness when texturing a billboard in a vertex shader

Recommended Posts

Hello, with the help from another member I offloaded some of my billboard code to the vertex shader. The strange thing happens when I texture the billboard. The billboard gets textured in a way that shouldn't be possible from my texcoords. Here is my vertex shader:
float4x4 g_transform; 

float3 g_offsets[4];
float2 g_texCoords[] =  { (0.0f, 1.0f), (0.0f, 1.0f), (0.0f, 0.0f), (0.0f, 1.0f) };

struct VS_Output
{
    float4 pos     : POSITION;   
    float4 diffuse : COLOR0;    
    float2 tex     : TEXCOORD0; 
};

VS_Output vertexShader(float3 pos : Position, float4 color : Color0, float3 info : TexCoord0, float2 index : TexCoord1)
{
    VS_Output output;

   	output.pos = mul(float4(pos + g_offsets[index.x] * info.x, 1.0f), g_transform);

    output.diffuse = color;  
    output.tex = g_texCoords[index.x];

    return output;    
}

technique Billboard
{
    pass P0
    {          
        VertexShader = compile vs_2_0 vertexShader();
        PixelShader  = 0;
    }
}

And here is a picture of the result. How can the whole texture be mapped with coordinates like this? Thanks for any help.

Share this post


Link to post
Share on other sites
Nobody has somehting to say to this?
I wonder how those texturecoordinates can produce such a result.
{ (0.0f, 1.0f), (0.0f, 1.0f), (0.0f, 0.0f), (0.0f, 1.0f) }
Where might be a good place to ask about this?

Share this post


Link to post
Share on other sites
I do not know the inner workings of your code, but those texcoords makes no sense to me. what are you trying to map?

are you sure you don't need the (0, 0) ( 1, 0 ) ( 1, 1 ) ( 0, 1 ) texcoords?

Share this post


Link to post
Share on other sites
Quote:
Original post by Wixner
I do not know the inner workings of your code, but those texcoords makes no sense to me.

That is the point of this thread. Please take a look at the picture (a link can be found in my first post). I don't understand how the texture can be mapped like that with those strange texcoords.

Share this post


Link to post
Share on other sites

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