Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6925485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:47:43+00:00 2026-05-27T10:47:43+00:00

I have a problem with drawing a texture stretched over a rectangular area in

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:47:44+00:00Added an answer on May 27, 2026 at 10:47 am

    As pointed by borillis the issue was that my VertexShader output was not matching the PixelShader input. I modified the PixelShader input as follows:

    struct PixelShaderInputPerPixelDiffuse
    {
     float4 Position : POSITION;
     float3 WorldNormal : TEXCOORD0;
     float3 WorldPosition : TEXCOORD2;
     float2 TextureCoords: TEXCOORD1;
    };
    struct VertexShaderOutputPerPixelDiffuse
    {
     float4 Position : POSITION;
     float3 WorldNormal : TEXCOORD0;
     float3 WorldPosition : TEXCOORD2;
     float2 TextureCoords: TEXCOORD1;
    };
    

    And now it works well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have no problem drawing a texture to the screen but I cant get
I have a problem drawing something quickly in .NET. I don't think that any
I am working on kind of drawing program but I have a problem with
I have a complex SQL problem in MS SQL Server, and in drawing on
I have problem in some JavaScript that I am writing where the Switch statement
I have problem when I try insert some data to Informix TEXT column via
I have a problem related to pdf drawing in iPhone. When I draw the
I have problem optimizing drawing Google-like map. It works OK for hundreds of points,
I have a problem with drawing a polygon in Java applet. I don't understand
I've narrowed a problem I have drawing on TImage.Canvas in Delphi 2009 down to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.