Jump to content

  • Log In with Google      Sign In   
  • Create Account


Can not set texture coordinate


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 14 January 2013 - 06:06 AM

Hi,

Sorry for so silly question,

I can't set texture coordinates in my shader. They are always equal 0.

 

So, here is declarations in shader:

Texture ColorTexture;

sampler ColorTextureSampler = 
sampler_state 
{ 
texture = <ColorTexture> ; 
magfilter = NONE; 
minfilter = NONE; 
mipfilter = NONE; 
AddressU = wrap; 
AddressV = wrap; 
};

struct VertexShaderInput
{
    float4 Position : POSITION;
    float2 texCoord : TEXCOORD0;
};

struct VertexShaderOutput 
{
    float4 Position : POSITION;
    float2 texCoord : TEXCOORD0;

};

 

 

and program code:

 

List<Vertex> points = new List<Vertex>();
for (int j = 0; j < list.Count; j++)
{
points.Add(new Vertex()
{
Coord = new Vector2(SomeTextureCoordinate, 0),
Position = new Vector3(list[j].X, list[j].Y, list[j].Z)
});
}

VertexFormat myVertexFormat = VertexFormat.Position | VertexFormat.Texture0;

vertices = new VertexBuffer(d3dDevice, sizeOfVertex * totalPointsCount, Usage.WriteOnly,
myVertexFormat, Pool.Managed);

var vertexElems = new[] {
                new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
                new VertexElement(0, 12, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0),
                VertexElement.VertexDeclarationEnd
            };
            vertexDecl = new VertexDeclaration(d3dDevice, vertexElems);

            d3dDevice.VertexFormat = myVertexFormat;
            d3dDevice.VertexDeclaration = vertexDecl;

 

 

Position set well, but texCoord in shader is always 0. 

I did all declarations in VertexBuffer, device and shader, so, where is the problem?



Sponsor:

#2 Yura   Members   -  Reputation: 263

Like
0Likes
Like

Posted 14 January 2013 - 09:16 AM

I found mistake, now it works

VertexFormat myVertexFormat = VertexFormat.Position | VertexFormat.Texture0;

need to be

VertexFormat myVertexFormat = VertexFormat.Position | VertexFormat.Texture1;






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS