Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>A simple cube will generate 8 vertices, 36 normal's, and 12 texture coordinates,</p> </blockquote> <p>No, a simple cube has 8 <strong>positions</strong>, but a vertex is not just a position, but contains also all the other attributes. So there is in fact no vertex duplication happening, but you're right, that you'll have some redundancy in the attributes.</p> <h3>Update to explain, why this is so</h3> <p>A vertex is the whole vector of its attributes. Change one, and you have a completely different vertex.</p> <p>Suppose you have a vertex shader taking some set of purely abstract attributes and a texture coordinate</p> <pre><code>#version 150 attribute vec2 foobar; attribute vec4 fnord; attribute vec2 texcoord; </code></pre> <p>and this vertex shader computes some position from those attributes, like say</p> <pre><code>void main() { gl_Position = vec3(fnord.xw, dot(foobar,texcoord)); } </code></pre> <p>As you can see, the vertex position now directly depends on all the attributes. But of course other <em>varyings</em> may as well.</p> <p>To save redundant calculations, the GPU maintains a cache mapping from <em>vertex attribute input</em> to <em>transformation stage/vertex shader output</em>. If vertices are accessed by index indirection, then the cache actually uses the index as key.</p> <p>So keep in mind: If anything associated with a vertex changes, you change the whole vertex. And in modern OpenGL the attributes of the vertices, even the position, may end up doing very different things.</p> <blockquote> <p>These functions do not seem to be built into my versions of openGL</p> </blockquote> <p>Oh, they probably are part of your drivers, alright. You probably just didn't <em>load</em> them into your program. The OpenGL DLL covers only the very basic things. For everything else you must load the function pointers dynamically. Just use a nice wrapper like GLEW for this (to be obtained at <a href="http://glew.sourceforge.net" rel="nofollow">http://glew.sourceforge.net</a>).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COso you would suggest simply duplicating the positions and texture coordinates so that I have enough to match the normal count? I must admit I hate this solution but the only way around it is to use the depreciated glBegin and glEnd stuff (basically just draw a list of triangles.)
      singulars
    2. CO@BenjaminDangerJohnson: Yes, this is exactly what you *must* do. I do understand your disliking of it, but this is not only how OpenGL works, but how GPUs are wired internally. To save *redundant* calculations GPUs maintain a cache of tuples of the last dozen or so unique vertex attribute combinations and if that combination appears again, then the result of the computation (of the vertex shader) are fetched from the cache instead of recomputed. Similar for just indices if using glDrawElements. So while it might look like redundancy on first look, it actually saves huge amounts of redundancy.
      singulars
    3. COokay first, thanks for clarify the vertex stuff (although I already knew what one was, I just prefer to use the term vertex instead of point although it is wrong.) and second, if I use shaders, is it possible for me to have multiple shaders for the same model? For example, what if I wanted to have a textured model (I guess this uses the vertex shader) along with bumpmaps and reflectivity (I know it's silly to do all three but this is an example.) I just hope by doing this I avoid having to check if the properties are present on every call and only use them on specific models.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload