• Advertisement
Sign in to follow this  

Textures Only Halfway Appear on Object

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a wierd bug which is causing my textures to only partially apply to the objects they are supposed to attach to. Here are some screenshots of the problem: ex1.jpg (a floor) ex2.jpg (a flag) ex3.jpg (the wall of a building) If anyone knows what might cause that I would greatly appreciate it.

Share this post


Link to post
Share on other sites
Advertisement
Hard to say without source code, but you might check if you are specifying your texture coords correctly.

Share this post


Link to post
Share on other sites
Hmm, from the look of your screenshots all those surfaces seem to consist of two triangles, and only one of them is getting textured. You'd probably want to revise your rendering code. Hard to tell anything else from the given information

Hope this helps

Regards,
/Omid

Share this post


Link to post
Share on other sites
Well, I am importing objects from a Lightwave Object File and mostly I am getting values of zero (which I am pretty sure I shouldn't be) and some where the uv values are out of range. Then, of course, there are the ones that are correct.


Correct Value (uv_x,uv_y vertice_x,vertice_y,vertice_z):

0.499769,0.030978 -0.209296,5.080000,-0.156972
0.964398,0.933453 -4.419600,3.553767,-4.377104
0.035139,0.943386 -4.419600,3.594134,4.063160


Texture Not Appearing Value (uv_x,uv_y vertice_x,vertice_y,vertice_z):

0.000000,0.000000 -0.209296,5.080000,-0.156972
0.000000,0.000000 -4.419600,3.594134,4.063160
0.000000,0.000000 -4.419600,3.553767,-4.377104


Out of Range Value (uv_x,uv_y vertice_x,vertice_y,vertice_z):

0.275434,0.001534 -4.583527,-0.254022,3.810000
0.275434,0.998466 -4.435033,-0.219739,3.962400
-42201683186052844000000000000000000000.000000,1.001327 -4.583527,-0.254022,3.962400


What might I look for which would cause that value to be so far out of range?

Share this post


Link to post
Share on other sites
Did you write the parser yourself? I would guess you are parsing the file incorrectly.

Share this post


Link to post
Share on other sites
i would bet 10$ that you you are doing one of these things wrong:

1. you are specifying texture coordinates AFTER vertex coordinate, in that case the coordinate will apply to NEXT vertex, you need to call gltexcoord BEFORE glvertex.

2. you have array of data, which has a off by 1 error when you reference data inside it.

if none of above applies post us your rendering code - the code between glbegin and glend.

Share this post


Link to post
Share on other sites
I will have to debug my code to see if I have the off by 1 error, but I do have glTexCoord before glVertex. Here is a small snippet of my rendering code. If you need me to post the whole code for the function I can.



if(global->lwo[object].polygon[i].numberOfVertices==3) glBegin(GL_TRIANGLES);
if(global->lwo[object].polygon[i].numberOfVertices==4) glBegin(GL_QUADS);
if(global->lwo[object].polygon[i].numberOfVertices>=5) glBegin(GL_POLYGON);

for(j=0; j<global->lwo[object].polygon[i].numberOfVertices; j++)
{
if(global->lwo[object].polygon[i].vertice[j].drawNormals==1)
{
glNormal3f(global->lwo[object].polygon[i].vertice[j].normal.x * normalScaler,global->lwo[object].polygon[i].vertice[j].normal.y * normalScaler,global->lwo[object].polygon[i].vertice[j].normal.z * normalScaler);
}

if(global->lwo[object].polygon[i].image!=-1) glTexCoord2f(global->lwo[object].polygon[i].vertice[j].uv_x,global->lwo[object].polygon[i].vertice[j].uv_y);

glVertex3f(global->lwo[object].polygon[i].vertice[j].x,global->lwo[object].polygon[i].vertice[j].y,global->lwo[object].polygon[i].vertice[j].z);


glEnd();



Share this post


Link to post
Share on other sites
If, as you say, the data coming from your parser is already incorrect, that must be fixed first. No amount of debugging your rendering code will fix a parse problem.

Share this post


Link to post
Share on other sites
Is it possible, that you render one of the triangles with the front face to the camera and the other with the back face? actually i am not sure if this generally might be a problem, but maybe it's worth a look :-/

Share this post


Link to post
Share on other sites
Quote:
Original post by gold
If, as you say, the data coming from your parser is already incorrect, that must be fixed first. No amount of debugging your rendering code will fix a parse problem.


I will check the parser, but I am using the Lightwave SDK basecode for the lwo file import, so it can't be too far off base.

Share this post


Link to post
Share on other sites
Quote:
Original post by rapunzel
Is it possible, that you render one of the triangles with the front face to the camera and the other with the back face? actually i am not sure if this generally might be a problem, but maybe it's worth a look :-/


Maybe, but I am not sure (if that were the case) how I would know whether something is a backface or a frontface.

Share this post


Link to post
Share on other sites
if you look at the half textured objects from the other side, is the opposite halfof it textured, or still the same? or none?

Share this post


Link to post
Share on other sites
There is no such thing as "two-sided texturing". The triangle face matters only for a) culling, b) polygon mode, c) two-sided lighting, d) two-sided stencil.

Share this post


Link to post
Share on other sites
Quote:
Original post by Braden
Well, I am importing objects from a Lightwave Object File and mostly I am getting values of zero (which I am pretty sure I shouldn't be) and some where the uv values are out of range. Then, of course, there are the ones that are correct.

...

What might I look for which would cause that value to be so far out of range?


This is the post I am responding to; when you say the value is out of range, are these the raw values returned by the parser? Or do you process the data in some manner before attempting to render? If the values are bad coming from the parser, that needs to be understood first. If your parser returns correct values and they are corrupted by the time they reach the rendering code, thats where you need to debug. This doesnt sound like a rendering / OpenGL usage issue but a parser or application problem.

Share this post


Link to post
Share on other sites
Quote:
Texture Not Appearing Value (uv_x,uv_y vertice_x,vertice_y,vertice_z):
0.000000,0.000000 -0.209296,5.080000,-0.156972
0.000000,0.000000 -4.419600,3.594134,4.063160
0.000000,0.000000 -4.419600,3.553767,-4.377104

this triangle will appear as a single solid color (the color at the corner of the texture)

another option with the parser being wrong is perhaps the model has incorrect texturecoordinates in the first place

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement