   Vertex creation in the vertex shader??
  Hello,I'm a newbie on GPU programming.I'm trying to make grids from a single quad using the vertex shader(VS).Although I read an article about that, I cannot understand it.It says that it is possible to make grids by translating and scaling a quad using a simple VS code.But, how is it possible?As far as I know, the VS cannot create a new vertex.Even if I translate the quad stored in vertex buffer in my VS,the output of VS is the moved quad, right?For example, let me put 4 vertices in my vertex buffer and 6 indices in the index buffer like this.vertex[0] = (0, 0, 0); vertex[1] = (1, 0, 0);vertex[2] = (0, 1, 0); vertex[3] = (1, 1, 0);index[0] = 0; index[1] = 1; index[2] = 2;index[3] = 2; index[4] = 1; index[5] = 3;Then, if I move these vertices by 1 to the right (X-axis) in my VS,can I get two quads (original + moved) sharing two vertices (v1, v3)? In my short knowledge, I can get only the moved one since a new vertex cannot be created. One vertex comes in to the VS, then one goes out, am I wrong?If so, it is not possible to make grids from a quad in VS. :-(I think I'm missing something here. Please help me to figure this out.Thanks in advance for your help.   
  The vertex shader only works on one vertex at a time, and can't create or destroy vertices.You can effectively "destroy" a vertex by moving it somewhere out of the viewport, however.If you want to create vertices, you'll need to use a geometry shader, and that's only available in Direct3D10, which is only available if you have Vista and a DX10 card.What article are you talking about?   ;  The vertex shader cannot create new vertices, correct. What you're thinking of probably involves sending the same vertex four times, and using information encoded with the vertex (often texture coordinates) to bias the vertex away from its original value in one of four directions. This can be used to make screen-aligned quads.   ;  Thank you for replies.Actually, I'm reading the GPU gems 2, chapter 2.The title is terrain rendering using GPU-based geometry clipmaps.In order to render a large terrain, they use several types of small blocks.In my understanding, they move and scale those blocks repeatedly.That's the reason why I asked the question.Well, is this possible because they do not make new vertices but render the same quad by moving it?   ;Quote:Original post by backleeWell, is this possible because they do not make new vertices but render the same quad moving it?Nope. As you said, once it's moved, the original quad doesn't exist (Unless you render over 2 frames, and keep the backbuffer).They must be passing in multiple quads, and discarding ones they don't use (I've not read any of the GPU Gems series, so I can't comment for sure).   ;  As far as I can see, "2.3.2 Vertex and Index Buffers" details the data structure for that article. In fact, there's code on the CD (and available here), so there's absolutely no need to speculate on what they're doing.   ;  Thanks for the link.I should have write down the code in my post.But the problem is that I cannot understand the code exactly. :-(I can see a block (for example, 2x2) is moved and scaled in the HLSL code.However, I'm still confused on that this means a new block is createdor just it is moved in the vertex shader.How can a block be processed repeatedly in VS?;Quote:Original post by backleeHowever, I'm still confused on that this means a new block is createdor just it is moved in the vertex shader.How can a block be processed repeatedly in VS?It's just moved. You CANNOT create vertices in a vertex shader. Ever. It's not possible.From reading the readme.txt in the downloaded source code, it says that it renders a normal map, surely that just gives the impression of there being more vertices?Do you have full source code? Have you tried turning on wireframe mode?   ;  Um... If I have the application code, it might help my understanding.But all I have is the render.fx (02.zip) from the above link.Then, I wonder how many times the VS is called.If I store 4 vertices in my vertex buffer,then is the VS called 4 times?Could I call the VS in the loop of the application code?[Edited by - backlee on September 12, 2007 2:14:31 AM];Quote:If I store 4 vertices in my vertex buffer,then is the VS called 4 times?Yes, one time per vertex.The VS is called when you draw geometry. You can't call it "manually".   