1

Is there a way to pass an array of vertex data from the cpu straight to a geometry shader?

If i want to build a sphere inside a GS, I'd rather have a pre calculated array of points that I can access from within the shader instead of generating them on the fly every frame

Maybe there's a way to access a veretex buffer from a shader I don't know about?

I'm using Panda3D but pure OpenGL explanations are more than welcome as well!

Thanks in advance

Roman
  • 107
  • 7
  • 2
    "*If i want to build a sphere inside a GS*" You don't want to do that. There's only one kind of sphere mesh, so if you absolutely have to generate one, a vertex shader is just as capable of generating it as a GS. "*I'd rather have a pre calculated array of points*" If you already have a sphere, then you're not "build"ing it in the GS. So what's the point of the GS in this exercise? – Nicol Bolas Jul 07 '20 at 13:23
  • GS has very limited number of vertexes it can emit per primitive so even if you pass just center and radius you can not create triangulation for the sphere... much better is to compute the sphere in fragment shader and use GS only to create BBOX QUAD (2*triangle) – Spektre Jul 07 '20 at 18:03
  • Each shader stage may access arbitrary data via UBO/SSBO/TBO/Texture interfaces, so it can be done, but using the GS stage for this task is not a particular good fit. – derhass Jul 07 '20 at 18:32
  • Are you doing this because you want to draw a lot of spheres? In that case much better solution is to use instancing - store only one unit sphere and, separately, per-sphere center, radius... – Quimby Jul 07 '20 at 18:41
  • Ok I get your point.. makes sense, so what is a geometry shader for if not for stuff like that? – Roman Jul 07 '20 at 21:17
  • 2
    GS is for changing primitives, handle cross sections, emitting simple shapes from GL_POINTS, emitting BBOX for curves, computing face related stuff like normals ,Handle circular coordinates (what goes out from one side comes in from other) etc ... – Spektre Jul 08 '20 at 07:27

0 Answers0