I have an idea and I want to know if this would be possible in any way. I want to render a scene and use the resulting image to find out which triangles were or are visible from my current point of view.
Let me give you an example: I would render the scene into a custom framebuffer and store a certain ID to every pixel, the ID would be an identifier to the original primitive. Now my problem is that I don't know how to find out which pixel belonged to which triangle. My first idea was to just pass an ID along the shader stages, but I don't know if that would be possible. If I can find out which primitives were drawn, I could cull the others. Is there any way to find out which pixel belonged to which (original) triangle?
There is a similar question here on Stackoverflow, but it does not really answer my question (see question).
Why do I want to do this?
I have a server-client scenario where my server is very powerful whereas my client is not. The server sends the model data to the client and the client renders it locally. To reduce the rendering time and the amount of memory needed, I want to do precalculations on the server and only send certain parts of the model to the client.
Edit: Changed my question because I misunderstood some concepts.