PDA

View Full Version : Texture problems

Photon
12-01-2012, 10:49 AM
I'm trying to do very simple rendering.
My vertex buffer has 8 floats per vertex (3 for position, 3 for normal, 2 for texture)
I'm drawing two triangles, each having its 3 vertices, but I'm getting one triangle drawing ok, and the other with strange results.

These are the vertices (CCW, as required)
-0.5,0.5,0,0,0,1,0,0
0.5,-0.5,0,0,0,1,1,1
0.5,0.5,0,0,0,1,1,0
-0.5,0.5,0,0,0,1,0,0
-0.5,-0.5,0,0,0,1,0,1
0.5,-0.5,0,0,0,1,1,1

and the indices are simply 0,1,2 and 3,4,5

My texture is the test pattern:
http://mlgsoft.com/tmp/sq.png

and the resulting rendering looks like:
http://mlgsoft.com/tmp/output.png

I would appreciate any idea on why this happens.

newbiecow
12-04-2012, 04:19 AM
I'm trying to do very simple rendering.
My vertex buffer has 8 floats per vertex (3 for position, 3 for normal, 2 for texture)
I'm drawing two triangles, each having its 3 vertices, but I'm getting one triangle drawing ok, and the other with strange results.

These are the vertices (CCW, as required)
-0.5,0.5,0,0,0,1,0,0
0.5,-0.5,0,0,0,1,1,1
0.5,0.5,0,0,0,1,1,0
-0.5,0.5,0,0,0,1,0,0
-0.5,-0.5,0,0,0,1,0,1
0.5,-0.5,0,0,0,1,1,1

and the indices are simply 0,1,2 and 3,4,5

My texture is the test pattern:
http://mlgsoft.com/tmp/sq.png

and the resulting rendering looks like:
http://mlgsoft.com/tmp/output.png

I would appreciate any idea on why this happens.

Can you paste your texture mapping code directly here?

newbiecow
12-04-2012, 04:29 AM
Though you have described your problem abstractly right but paste some significant code is much persuasive and conveneint for test.

Best regards,

newbiecow

Photon
12-04-2012, 05:00 AM
After struggling with this for a long time, I did manage to find the cause, albeit by accident.
I tried to run it on another machine and then got a link error from the shader program. The bug was that I defined an input to the fragment shader with an incorrect type (vec3 instead of vec2).

It seems that my main machine (with nVidia 650m) simply ignored the problem and continued to generate this display. The other machine produced an error and then discovering the bug was trivial.

newbiecow
12-04-2012, 07:51 AM
After struggling with this for a long time, I did manage to find the cause, albeit by accident.
I tried to run it on another machine and then got a link error from the shader program. The bug was that I defined an input to the fragment shader with an incorrect type (vec3 instead of vec2).

It seems that my main machine (with nVidia 650m) simply ignored the problem and continued to generate this display. The other machine produced an error and then discovering the bug was trivial.

Very well! At least you found the cause and solved it!