View Full Version : Getting XZ Coords in VS for Textur
10-31-2010, 08:10 AM
i got an hopefully simple question.
ok, how to describe the problem:
i render an object and need inside the
vertexshader the X and Z Position
including transformation and rotation.
For example an chessboard.. if you move an box
over the board ,the top of the box got the same texture(coords)
like the chessboard direct under the box (the sides dosn't matter)
gl_Vertex.xz ... perfect..but only tranformation and Rotation is missing
gl_Position = gl_ModelViewProjectionMatrix * gl_Pos;
gl_Position.xz = ->brings me strange results
what can i do?
10-31-2010, 12:43 PM
You didn't describe what you mean by "strange results," so you make anyone trying to answer your question have to guess what your problem is.
You used the phrase "including transformation and rotation" in your fourth paragraph (and essentially again in the sixth paragraph). What do you mean by transformation? Do you really mean translation? Rotation is a transformation. So is perspective projection.
I'm guessing what you don't like is the projection transform which you have applied to your computation of gl_Position. If you want a version of your X and Z coordinates but without the perspective transformation applied to them, then separate your modelview and projection transforms, and save the X and Z coordinates between your application of them.
11-01-2010, 09:40 AM
at moment i do this:
// submit the 2d rotation matrix of the object
gl.glUniform1fARB(rx1 , (float) (1*Math.sin((tree_r1[i]+90+(itest1*90))*3.141593/180)) );
gl.glUniform1fARB(rz1 , (float) (1*Math.cos((tree_r1[i]+90+(itest1*90))*3.141593/180)) );
gl.glUniform1fARB(rx2 , (float) (1*Math.sin((tree_r1[i]+0+(itest1*90))*3.141593/180)) );
gl.glUniform1fARB(rz2 , (float) (1*Math.cos((tree_r1[i]+0+(itest1*90))*3.141593/180)) );
//submit the transform position in space
gl.glUniform1fARB(po_x , tree_x[i]-view_map_x);
gl.glUniform1fARB(po_z , tree_z[i]-view_map_z);
"gl_TexCoord.xy= vec2(po.xy-posi_start)*posi_vv;\n" +
its a bit dirty and i think not
the best for a good performance, but its working
(the problem could be when i want to rotate the
object at X/Z Axis)
could be cool if i could get the object data
including rotation and tranform inside
the vs direct
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.