How to manipulate polygons and vertices realtime
#1
Posted 14 January 2012 - 05:27 PM
I'm new at all this, and while I understand everything quite well in theory, I'm not too good with verbiage yet. I.e., conceptually, I really understand all the bits and pieces. However, if I use such labels as "pipeline" a bit out of place, forgive. Also, I don't know if the following Q will sound odd, but I really do know what I'm doing with it, and I'd like to be able to pull it off. So...
I'm tinkering around with polygons and such on the rendering pipeline, and I wanted to know how you could go about manipulating the individual vectors from coordinate to coordinate that form the polygon faces. What I'd like to do is have the polygon matrices all lined up (i.e., the world all the way to the projection, the final "2D" image if you will) and then mess around with the polygons vectors in between the vertices. Actually, I would like to mess around with the vector lines before that stage in the pipeline if that's possible.
Basically, I would like to find out how to interface with the lines drawn between vertices on any stage of the pipeline, do my own math on them real-time, and also manipulate the art styles of the vertex-to-vertex vectors as well.
Thanks for any help out there!
#2
Posted 14 January 2012 - 06:30 PM
#3
Posted 14 January 2012 - 06:50 PM
Say you take the vertices 4,3 and, say, 2,1 of a square and the vector line drawn between them. Is there a way to say to the engine, "take these vertices, place one more in between them that I will give to you by this mathematical function, and draw two vectors in lieu of one"? And, is there a way to add artistic "adjustments" to vectors drawn between coordinates, not just using the polygon edges as placeholders, if you will, for the spaces they describe?
#4
Posted 14 January 2012 - 11:52 PM
I still don't know what you mean by "artistic adjustments to vectors" (I think by vectors you really mean line segments) or "placeholders for the spaces they describe".
#5
Posted 15 January 2012 - 04:44 AM
I'm looking to do quite a lot with what must be called "displaced vertices" and such; basically a lot of math somewhere directly prior to the actual frame display. The thing is, I want as few polygons as possible, but I'd like to do adjustments to the polygons somewhere along the render pipeline (and where is something I'm trying to figure out). One of the things I'm struggling with is dealing with what are inherently "structural" things and not actual display things. I.e., usually, the line segments (sorry! That's what I meant by "vectors", learning the correct lingo here) of meshes exist in the undisplayed mesh matrix world of the engine, but not in the actual frame on the screen, where they're "colored over" and not necessarily used as lines themselves.
Firstly, I'd like to use certain line segments ("outline" ones, basically") to draw comic-book style "ink" lines. This would obviously vary frame to frame and require (I'm assuming) algorithms to determine which polygon vertices and line segments are actually the current outline ones. It would also mean, of course, that I'm seeking to directly use the usually non-displayed polygon vertices as art tools themselves (black lines), and that I'm seeking to have artistic control over how they're displayed (what I meant by artistic adjustment to vectors). I'd also have to develop algorithms of some sort to "color in" the spaces made by the outlines (what I meant by placeholders basically), and I'd like to use the polygon points in between the "outline" line segments to determine the shading and such, as those points would obviously contain info about how far various portions of the in-between-the-lines segments protrude inwards or outwards in the mesh in that particular frame. I'm also seeking to figure out how to dynamically create polygon "points" that would generate temporary polygons over a certain area of a mesh. I.e., if for a brief moment a mesh needs to bend or morph in a certain section of its body, I want to be able to create said "points" and have either shading data and/or literal polygons and vertices be created, if only temporarily for the movement.
Hope that all makes sense...? If it doesn't, let me know and I'll go at it again; I know exactly what I'm going at, but I don't know if it's coming across very clearly...
Thanks so much for your help!
I'm really appreciating devmaster.net and the forums; by far the best dev forum I've been on. Thanks again. Great stuff here.
#6
Posted 15 January 2012 - 08:44 AM
One pretty simple way to do outlining is to draw two copies of the mesh; one is drawn normally, with full color, lighting shading, and the second copy is drawn all in black, with backface culling reversed (so that it draws back faces but not front faces) and is slightly expanded by pushing the vertices outward along their normal vectors. This offsetting can be done dynamically in the vertex shader quite easily. The result is that since the front faces of the second draw are missing, it doesn't occlude the surfaces from the first draw, but at the edges you can see a bit of the back side of the expanded mesh.
Doing it this way, the outline would automatically update based on camera position and movement of the object. You could alter the color and thickness of the outline per-vertex as well, if that's what you wanted to do. I think you would need pretty highly tesselated meshes to make this look good from all angles, though.
Another option for outlines is to run an image-space postprocess that detects edges using a Sobel filter and darkens them. That can also be done in a pixel shader using what's called a full-screen pass.
#7
Posted 15 January 2012 - 07:34 PM
#8
Posted 15 January 2012 - 07:36 PM
#9
Posted 15 January 2012 - 08:28 PM
#10
Posted 16 January 2012 - 12:15 AM
Thanks again for all your help. This place is great.
#11
Posted 16 January 2012 - 12:57 AM
Before going too much further with your project, I'd strongly suggest that you roll up your sleeves and dive into the NeHe tutorials and work through those until you have a more concrete idea about how 3D graphics APIs work. There's just so many details and concepts that I won't be able to explain in the space of a forum post, and which you'll learn much faster by trying out and doing yourself than by reading about them in generalities.
#12
Posted 16 January 2012 - 04:00 AM
I think it's possible to do clean looking brush strokes if you can render the edges as lines instead of reverse engineering that from models or images. You can view a couple neat brush algorithms on Mr. Doob's Harmony web app.
#13
Posted 16 January 2012 - 05:23 AM
I see. Yeah, that's basically what I'm trying to do. I simply want to have total access to line segments so I can take the data and write a heck of a lot of my own shaders to do a bunch of things to them. And yes, I'm looking into those NeHe tutorials. They look awesome, planning to rip through most of them shortly.
T.N.:
Wowzers, thanks! That's a lot of great info to take in. Ideally, I'd like to do what you said, take some algorithms a la Mr. Doob's example there and apply them to outline line segments in order to achieve a comic pen/ink/brush look with slight imperfections and variable width.
#14
Posted 16 January 2012 - 05:29 AM
#15
Posted 16 January 2012 - 06:08 AM
#16
Posted 16 January 2012 - 10:54 AM
#17
Posted 16 January 2012 - 11:00 PM


1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












