How to display the texture coordinate of an object?

[QUOTE=GClements;1266764]glRenderMode(GL_FEEDBACK) will do that, sort of. However:

  • It reports “processed” geometry. Culled primitives aren’t reported, if quads or polygons are broken into triangles, it may report the triangles rather than the original primitives.

  • I wouldn’t bet heavily on it actually working on modern hardware.

If you want to do a lot of this sort of thing, you’re probably better off using shaders and transform feedback mode.[/QUOTE]

So it is. shader has such feedback channel which can send the vertex data back to vertex processor,

Getting the texture coordinates used for a particular vertex is not something that fixed-function OpenGL can do.

Now that metioned the fixed-pipe, I want to know when this api delivers the data to the piple or shader to process?
and can this api use in vertex shader?

glGetTexGen() returns one of the parameters (mode or plane) for the equations which map vertex coordinates to texture coordinates (i.e. whatever values you passed to glTexGen() in the first place).

If you want the actual texture coordinates, you need to evaluate those equations yourself, using the generation parameters, the vertex coordinates (either object-space for object-linear mode or eye-space for the other modes), and possibly the vertex normal (for the sphere map, reflection map or normal map modes).

The equations used to generate texture coordinates from vertex coordinates are given in section 12.1.3 of the OpenGL 4.5 compatibility profile specification. Most of them are also given in the glTexGen reference page, although the behaviour of the normal map and reflection map modes isn’t given there (they use the same equations as the sphere map mode, but the generated texture coordinate is the eye-space normal or the reflection vector, respectively).

[QUOTE=GClements;1266768]glGetTexGen() returns one of the parameters (mode or plane) for the equations which map vertex coordinates to texture coordinates (i.e. whatever values you passed to glTexGen() in the first place).

If you want the actual texture coordinates, you need to evaluate those equations yourself, using the generation parameters, the vertex coordinates (either object-space for object-linear mode or eye-space for the other modes), and possibly the vertex normal (for the sphere map, reflection map or normal map modes).

The equations used to generate texture coordinates from vertex coordinates are given in section 12.1.3 of the OpenGL 4.5 compatibility profile specification. Most of them are also given in the glTexGen reference page, although the behaviour of the normal map and reflection map modes isn’t given there (they use the same equations as the sphere map mode, but the generated texture coordinate is the eye-space normal or the reflection vector, respectively).[/QUOTE]

I skimed the function, and I wonder what is the reference plane acting? 9for either the mode of obj-linear or eye space), what role is it?

For object-linear or eye-linear mode, each texture coordinate is the “distance” of the vertex from the plane, i.e. the dot-product of vertex position (in object space or eye space) with the plane coefficients.

From the reference page:

If the texture generation function is GL_OBJECT_LINEAR, the function

g = p[sub]1[/sub] × x[sub]o[/sub] + p[sub]2[/sub] × y[sub]o[/sub] + p[sub]3[/sub] × z[sub]o[/sub] + p[sub]4[/sub] × w[sub]o[/sub]

is used, where g is the value computed for the coordinate named in coord, p[sub]1[/sub], p[sub]2[/sub], p[sub]3[/sub] and p[sub]4[/sub] are the four values supplied in params, and x[sub]o[/sub], y[sub]o[/sub], z[sub]o[/sub] and w[sub]o[/sub] are the object coordinates of the vertex.

Eye-linear is similar except that both the coordinates and the plane are transformed to eye space (the plane is transformed by the model-view matrix in effect at the time of the glTexGen() call, i.e. it’s specified in object space but stored in eye space).

[QUOTE=GClements;1266789]For object-linear or eye-linear mode, each texture coordinate is the “distance” of the vertex from the plane, i.e. the dot-product of vertex position (in object space or eye space) with the plane coefficients.

From the reference page:

Eye-linear is similar except that both the coordinates and the plane are transformed to eye space (the plane is transformed by the model-view matrix in effect at the time of the glTexGen() call, i.e. it’s specified in object space but stored in eye space).[/QUOTE]

That’s what I ask, the plane is what? will it contain texture or equal to screen position? or something?
is it arbitrary or not?

It’s a plane, i.e. a set of points satisfying the equation p1.x+p2.y+p3.z+p4.w=0. Its normal is the vector (p1,p2,p3) and p4 determines its distance from the origin. A vertex which lies on the plane (i.e. which satisfies that equation) will have the corresponding generated texture coordinate equal to zero. More generally, the generated texture coordinate for a vertex is equal to its signed “distance” to the plane (i.e. the value p1.x+p2.y+p3.z+p4.w).

Each of the 4 planes (s,t,r,q) is effectively one row of a matrix which transforms 4D vertex coordinates to 4D texture coordinates (transforming a vector by a matrix is essentially a sequence of dot products; each component of the resulting vector is the dot product between one row of the matrix and the original vector).

I asked “what is the reference plane acting? 9for either the mode of obj-linear or eye space), what role is it?” seem too uncertain to make sense of it.
How to explain correctly in English? in order not to misunderstand.
The plane, it acts as what? How to define the plane? The distance is only a number, (despite it can be served as a vector in physics), but tex coord represents two values, s and t. how will the opgl derive the s,t next?

Each texture coordinate (i.e. each component (s, t, r, or q) of the texture coordinates) is generated separately.

You can enable or disable generation of each component individually, you can (and usually do) specify a different plane for each component, you can even specify a different mode for each component (although I can’t think of a situation where that would make sense).

This is why the first parameter to all forms of glTexGen is the coordinate: either GL_S, GL_T, GL_R, or GL_Q.

If you want to generate both s and t, you need to specify one plane for the s coordinate and one plane for the t coordinate. You also need glEnable(GL_TEXTURE_GEN_S) and glEnable(GL_TEXTURE_GEN_T).

[QUOTE=GClements;1266796]Each texture coordinate (i.e. each component (s, t, r, or q) of the texture coordinates) is generated separately.

You can enable or disable generation of each component individually, you can (and usually do) specify a different plane for each component, you can even specify a different mode for each component (although I can’t think of a situation where that would make sense).

This is why the first parameter to all forms of glTexGen is the coordinate: either GL_S, GL_T, GL_R, or GL_Q.

If you want to generate both s and t, you need to specify one plane for the s coordinate and one plane for the t coordinate. You also need glEnable(GL_TEXTURE_GEN_S) and glEnable(GL_TEXTURE_GEN_T).[/QUOTE]
then, what is critial to specify " the plane" for either s or t?

I also confuse this GL_S,T,…generally we define a coordiante by (s,t…), hardly define only one paramter for point or a vector, if there is only one variable, we can define others as constants.
;ole this, x=3, means either a line which is parallel to y axis by a 3 distance or a plane which is parallel to yoz plane by 3… they are not a point.
howevr, what we deal with is point to point map,

So the plane is a core, What does it do? How to choose it?

It seems it is a problem not to answer easily? or Have I not described the issue clearly or properly? or it is an easy question, needn’t to answer?

I don’t see how I can explain it any more clearly.

Have you tried reading the glTexGen reference page (or the specification)?

[QUOTE=GClements;1266869]I don’t see how I can explain it any more clearly.

Have you tried reading the glTexGen reference page (or the specification)?[/QUOTE]

Thanks, I think I might have not expreseds clearly or positively what I ask or what I want to knpw.
I read that and I know the equation and how to resolve it. but I don’t know the plane’s positoin. If you donlt know the plane, you will not get the equation. How do you make up it’s parameters?(a,b,c), for a fixed vertex, different plane will get differnt distance.
The reference has not illustrated where the plane is. and how to acquire its paramters.
Is the plane the relative projection plane?
What is GL_OBJECT_PLANE? where is it? is it screen coordinate?

In the math reference, there is
Your code would look something like this
for(i=0; i<total; i++)
{
myTexCoord[i].s = dot4D(myVertex[i], myPlane_S);
myTexCoord[i].t = dot4D(myVertex[i], myPlane_T);
}
Where is myPlane_st? IZ It image plane(project plane)? I guess it is. right?
This is calculated on cpu, if we move it to vertex shader, will it calculate on gpu?

[QUOTE=reader1;1266871]I read that and I know the equation and how to resolve it. but I don’t know the plane’s positoin. If you donlt know the plane, you will not get the equation. How do you make up it’s parameters?(a,b,c), for a fixed vertex, different plane will get differnt distance.
The reference has not illustrated where the plane is. and how to acquire its paramters.
[/QUOTE]
The plane’s parameters are specified by calling glTexGen() with [var]pname[/var] equal to GL_OBJECT_PLANE or GL_EYE_PLANE.

In the case of GL_OBJECT_PLANE, the parameters can be retrieved via glGetTexGen() with [var]pname[/var] equal to GL_OBJECT_PLANE.

In the case of GL_EYE_PLANE, the plane is specified in object space but transformed to eye space based upon the model-view matrix at the time of the glTexGen() call. Calling glGetTexGen() with [var]pname[/var] equal to GL_EYE_PLANE.returns the transformed (eye-space) parameters rather than the original values passed to glTexGen().

The plane’s normal is (p1,p2,p3). If you want the plane to pass through a point x,y,z,w then p4 must be set to -(p1x+p2y+p3*z)/w.

If texture coordinate generation is enabled, the calculation will typically be performed on the GPU. glTexGen() and glEnable(GL_TEXTURE_GEN_S) etc are part of the fixed-function pipeline; if a vertex shader is active, they have no effect.

[QUOTE=GClements;1266874]The plane’s parameters are specified by calling glTexGen() with [var]pname[/var] equal to GL_OBJECT_PLANE

In the case of GL_OBJECT_PLANE, the parameters can be retrieved via glGetTexGen() with [var]pname[/var] equal to GL_OBJECT_PLANE.

In the case of GL_EYE_PLANE, the plane is specified n [/QUOTE]
Thanks, That’s what I want to know. The plane, we aim mainly at GL_OBJECT_PLANE. ignore other issues.
I know it locates at object system. but what is its coordinate? where is it in this coord sys?

for example, there is a vertex A(…); How do you define the PLANE? Is it the project screen? or something you point arbitrarily?
plane, plane, just ask the plane, not others thing.

for example, if you point it as (0, 0, 3, 0), how do you define the 3? if it were not 3, the distance would be different, then get different tex coord. this is question. How to assign the plane positoin?

or Overtate speaking, if there is a vertex position is at The Empire Building, and there will be different effect of mapping, if the GL_OBJECT_PLANE is in Washington, or eiher in Moscow, or in Berlin etc. How shall we chooode the plane? if it were project surface, we may choose it in Beijing, or in Paris depend on the effect we wish?