I have a geometry mesh. At each vertice, I want to write the vertice index on the screen (I use a fontmap for font).
So I need to:
Find the index position in screen space.
Generate square at this position for each number (348 number will need 3 square, 10 will need 2 squares, etcâŚ) and give then good uvs from the font map.
Send this to the GPU.
Draw.
The problem for me seems to be the first stepâŚ
Iâm afraid matrices calculation on the CPU for each vertex to find on screen coordinate could be bigâŚ
Same to generate squares vertices for each number with different uvs. It could be longâŚ
Any of you have a better Idea?
And if anyone have good infos/link to do this kind of stuff efficiently, donât hesitate!
Supposing you have the world coordinates, you need to transform each position for view and projection. You can create a single matrix with the combined Project*View in advance. That means you will need one transformation for one corner of each square, and the other corners can be computed easily (assuming all squares have equal size and orientation on screen).
I would recommend the glm package for easy and quick matrix manipulations, and I donât think a couple of 100 transformations should be a problem. If you are uncertain, make a simple test program just to measure time. Notice also that much of the drawing will be ingoing in parallel with your calculations.
So you will draw ~400 boxes on the screen, with information in each? Sounds quite crowded to me. If you are not showing all boxes at the same time, there there are algorithms that can help you minimize the list of necessary calculations. It also depends on what timing requirements you have on the drawing operation.
Ok, this was how I was thinking to do.
Compute a projection matrix and project every vertex on it. Once I have every vertices projected I can easily compute squares vertex positions.
But this method is still long to compute no? CPU (even multithreaded) have to project (doing matrix computation) each vertices to know the position on the screen and generate squares coordinatesâŚ
Are we talking about the client side (I am)? If not, I really donât know how do this on server side and any help to do this will be really appreciate.
Actually, I was thinking about compute vertex projection (and so, square vertices coordinates) on server side in a map ((four square corner * number of vertices)*pixels in a 1D map).
So stop draw once the vertex shader is compute (because I donât need fragment shader). Then âredrawâ using the real shader the whole and final draw.
I would like to use the ability to video card to quickly compute projection and store them in a map and use this map just after. This will avoid CPU-GPU transferts: Vertex buffer could be generated in a map by the GPU in a non-draw operation and used just after to definitely draw indices on screen.
Maybe Iâm completely wrong but it surprise me if this wasnât possible to doâŚ
Anyone have an idea on this?
Yes, but itâs a CG app and it can potentially display a lot of triangles. Thatâs why I would like a efficient and fast way to do this.
Yes, if I need to use the âCPU wayâ for projection, I could easily remove vertices/square/indices display from computation. But I could like to see if a âGPU only wayâ is possible.
I donât really have formal âtiming requirementsâ (this is not video game).
I did a test, on a fast Intel Core I7, and could execute almost 7 millions âglm::mat4 * glm::vec4â per second, not using constant variables. This was with âgcc -O0â, using one thread.
There is a good chance using CPU computation should suffice for you.