Geometry shader - rotate quads in the direction of their faces?

Hello everyone or should I say glsl pros?,

I write a little glsl-shader that basically use a geometry shader to create 3 vertical quads on the position of a face.
Now I want to rotate the quads in one of the directions (forwards or backward) where their faces show.
So the top vertices should rotate around the bottom axis (the axis between the two bottom vertices) for every individual quad.

I don’t get it maybe someone can help me with this?
I also add a blend with the shader so you can see how I create the quads.
draw quad to face.blend (273 KB)

I don’t understand exactly what you want.

  1. You will generate 5 or basically 8 (if you not limit the vertices to max_vertices=12) vertical quads not 3. Change the angel to 0.5943951, you will see.
  2. I don’t know what you want to rotate around which axis. Du you want to mirror the texture coordinates so “Tex” shows in the direction? Make an image so ever boy can understand what you want to rotate around what.

If you want to get the right amount of planes you need to delete the outer loop. Then set the inner loop is i<4 (i<n+1) or i<=3 to only generate three planes. Then all “Tex” textures should also have the same orientation.

Oh thank you for your Correction.

Below is a picture how I want to rotate the quads. I have tried it with a yRotationmatrix (function is in the code) but than the edge of the top is longer than the bottom edge. I think thats because the quads share the same vertex when they side by side but I’m not sure. Also the size of the quad is squatschted. I don’t know how to make it like on the picture.
stc=1

Below is a picture how I want to rotate the quads.

I think you have forgotten to upload the picture.

Oh sorry, thats crazy I sure that I have uploaded the picture and appended it to the post.
So here again the picture:

Attachments


Okay some time has passed but I haven’t found the solution, so I try to ask again one last time.
Does anyone have an idea, how to fix my the problem above?

Thanks Maujoe :wink:

Actually I don’t have time to play around with such things. But in case that nobody else has answered you I had spent some hours on this.
The first problem is that you call EndPrimitive() only one time so all vertices are connected to one triangle stripe.
You need to call it three times for three times for your three planes.
The second problem is that your script rotates and add two vertices than it rotates and add two vertices again and so on. So the top and bottom length depends on the rotation angle.
Third problem you have drawn your plane along the x axis. and you have rotated along the y axis.

draw quad to face2.blend (279 KB)

Yes, that is exactly what I have tried to do.
A big Thank you, one more time and I’m sorry that you had to spend your time to fix my mistakes. :o