I have a problem with drawing a texture stretched over a rectangular area in XNA. For some background : it is a 3d project, where at some place I'm putting a big broadcast screen 'filming' some other area. This is done by renderstates and the texture is rendered perfectly well (I checked by rendering into a file). The problem is, when I set this as a texture of my defined area, the mapped texture consists of tiles as you can see on the picture I'm uploading. The area where the texture should be stretched is defined like this:
VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[6];
vertices[0].Position = new Vector3(0.0F, 20.0F, 0.0F);
vertices[0].TextureCoordinate.X = 0;
vertices[0].TextureCoordinate.Y = 0;
vertices[1].Position = new Vector3(50.0F, 0.0F, 0.0F);
vertices[1].TextureCoordinate.X = 1f;
vertices[1].TextureCoordinate.Y = 1f;
vertices[2].Position = new Vector3(0.0F, 0.0F, 0.0F);
vertices[2].TextureCoordinate.X = 0f;
vertices[2].TextureCoordinate.Y = 1f;
vertices[3].Position = new Vector3(50.0F, 0.0F, 0.0F);
vertices[3].TextureCoordinate.X = 1f;
vertices[3].TextureCoordinate.Y = 1f;
vertices[4].Position = new Vector3(0.0F, 20.0F, 0.0F);
vertices[4].TextureCoordinate.X = 0f;
vertices[4].TextureCoordinate.Y = 0f;
vertices[5].Position = new Vector3(50.0F, 20.0F, 0.0F);
vertices[5].TextureCoordinate.X = 1f;
vertices[5].TextureCoordinate.Y = 0f;
telebimBuffer = new VertexBuffer(GraphicsDevice, VertexPositionNormalTexture.VertexDeclaration, vertices.ToList().Count, BufferUsage.WriteOnly);
telebimBuffer.SetData<VertexPositionNormalTexture>(vertices);
What worries me is that I tried playing with there texture coordinates and could not see any difference :/. I'm rendering with my own effect file, this might be a source of problems, you can get this file here: http://gamma.mini.pw.edu.pl/~zabak/random/PhongAlternative.fx
The rendered texture is passed as "xTexture" to the effect file.
Finally the screen showing my problem: http://gamma.mini.pw.edu.pl/~zabak/random/gk3d_2error.jpg As you can see I get a large number of tile in the broadcast screen, the goal is to get the texture stretched over. (For purpose of doing the screenshot I turned off lights by commenting the
color = (color+specular+diffuse*diffuseIntensity+ambientLightColor)+light1+light2+light3;
line in my effect file.)
UPDATE: I changed declaration from the effect file from this one:
struct VertexShaderOutputPerPixelDiffuse
{
float4 Position : POSITION;
float3 WorldNormal : TEXCOORD0;
float3 WorldPosition : TEXCOORD1;
float2 TextureCoords: TEXCOORD2;
};
to this one:
struct VertexShaderOutputPerPixelDiffuse
{
float4 Position : POSITION;
float3 WorldNormal : TEXCOORD0;
float3 WorldPosition : TEXCOORD2;
float2 TextureCoords: TEXCOORD1;
};
And the broadcast screen works but the lights are messed up. Can someone tell me please what I'm doing wrong?