Public Group

#### Archived

This topic is now archived and is closed to further replies.

# n00b texture mapping problem

This topic is 5229 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

yeah, its me again having a n00b problem... (using VC++6 and D3D) ok, I have 6 vertices forming 2 triangles to make a square, I am sure my texture coordinates are ok I mean, the 0,0 is on the top left vertex, 1,1 at the botom right and 1,0 and 0,1 at top right and botom left... the problem is there is only 1 of the 2 triangles who shows the texture... the other one is black... got idea on what could cause this ?? Im using screen space vertices also, and I think maybe the texture on the black triangle is shown on the other side which isnt seen but im not sure bout that...

##### Share on other sites
I don´t know does D3D work same way in this subject as OpenGL but are you sure that you have drawn the vertexes in right order?

##### Share on other sites
What do you mean is there an order ? I have my first 3 vertices for the 1st triangle then the next 3 for the other one...

##### Share on other sites
quote:
Original post by k0lpA
What do you mean is there an order ? I have my first 3 vertices for the 1st triangle then the next 3 for the other one...

You have to define your vertices in clockwise order, otherwise the normals point the wrong way. Add some code to rotate your box, and you''ll probably see your texture on the back side of one of the triangles.

##### Share on other sites
Ok, I´m on pretty basic level on these things too and I remembered things little wrong, so my question was pretty irrelevant, sorry.

Anyway here´s what I meant, (I just didn´t remember at the time that texture will be showed on both sides):

By order I meant that (atleast in OpenGL) you have to draw vertices in certain order (clockwise or counter clockwise) to specifie which way the primitive is.

In OpenGL (by default) it is so that counter clockwise order will be the front..

So if D3D works the same way you should draw your vertices (for example) like this to see the fron face (counter clockwise):
  A / \  B---C

By drawing them this way you would see the back face (clockwise):

  A / \  C---B

But because primitive will be textured on both sides (atleast in OpenGL by default), that shouldn´t be a problem.. Sorry.

[edited by - Mkk on March 22, 2004 5:33:50 PM]

##### Share on other sites
the vertices should be placed like this in the order 0,1,2,3,4,5 :

1/5-------3
|**\*****|
|***\****|
|****\***|
|*****\**|
|******\*|
0-------2/4

[edited by - -indirectx- on March 23, 2004 12:54:12 PM]

##### Share on other sites
Still only 1 triangle is textured are u sure the order is the same with pixel coordinates ?

##### Share on other sites
Turn off D3D lighting when the engine starts

someat like

d3ddevice->SetRenderState(D3DRS_LIGHTING, 0);

Then the normals won''t have any effect and you can see if they are the problem or not.

What''s your render loop look like?

Matt

##### Share on other sites
Anyway here´s what I meant, (I just didn´t remember at the time that texture will be showed on both sides):

Yeah but if the normal''s facing the other way then there may not be any light on the triangle - thus rendering it black.

##### Share on other sites
Its not the problem, D3D ligthing is off
heres my render loop :
App.D3D_device->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );App.D3D_device->SetVertexShader(MyVertex);App.D3D_device->SetStreamSource(0,vb,sizeof(TexVertex));App.D3D_device->SetTexture(0,Texture);App.D3D_device->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);App.D3D_device->SetTexture(0,NULL);App.D3D_device->EndScene();App.D3D_device->Present( NULL, NULL, NULL, NULL );

and this is where I set my vertices
//1st triangle	Verts[0].V.x = Location.x + 64;	Verts[0].V.y = Location.y;	Verts[0].V.z = 0;	Verts[0].tu = 1.0f;	Verts[0].tv = 0.0f;	Verts[1].V.x = Location.x + 64;	Verts[1].V.y = Location.y + 64;	Verts[1].V.z = 0;	Verts[1].tu = 1.0f;	Verts[1].tv = 1.0f;	Verts[2].V.x = Location.x;	Verts[2].V.y = Location.y;	Verts[2].V.z = 0;	Verts[2].tu = 0.0f;	Verts[2].tv = 0.0f;//2nd triangle	Verts[3].V.x = Location.x;	Verts[3].V.y = Location.y + 64;	Verts[3].V.z = 0;	Verts[3].tu = 0.0f;	Verts[3].tv = 1.0f;	Verts[4].V.x = Location.x;	Verts[4].V.y = Location.y;	Verts[4].V.z = 0;	Verts[4].tu = 0.0f;	Verts[4].tv = 0.0f;	Verts[5].V.x = Location.x + 64;	Verts[5].V.y = Location.y + 64;	Verts[5].V.z = 0;	Verts[5].tu = 1.0f;	Verts[5].tv = 1.0f;

[edited by - k0lpA on March 25, 2004 5:16:36 PM]

[edited by - k0lpA on March 25, 2004 5:17:18 PM]

[edited by - k0lpA on March 25, 2004 5:17:42 PM]

[edited by - k0lpA on March 25, 2004 5:18:04 PM]

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 10
• 9
• 9
• 46
• 41
• ### Forum Statistics

• Total Topics
631751
• Total Posts
3002076
×