Schnigges
Schnigges

Reputation: 1326

Render a vectorfield with Point Sprites in OpenGL

I'd like to render a vectorfield visualization with OpenGL. Right now, I have a 3D cube filled with points which I need to replace with arrows. I've read a lot about Point Sprites in OpenGL and they seem to fit my needs pretty good.

I haven't really worked with textures yet, so there are some questions regarding the use of them together with Point Sprites:

First of all, is it possible to easily replace my points with arrows by just using a texture? If so, is it possible to rotate or scale those point sprites by an arbitrary degree using shaders?

If there are other possibilites than point sprites for achieving this, it would also be great to hear about them. I'm using OpenGL 4.2.

Upvotes: 0

Views: 740

Answers (2)

Nicol Bolas
Nicol Bolas

Reputation: 473537

Point sprites are always screen-aligned squares. And they have an implementation-dependent maximum size.

If you need to do something like this, you should use a Geometry Shader that takes points as inputs, and outputs a quad (as 4 vertices of a triangle strip). Then you can do whatever you want.

Note that you should try to pass as little information as you can get away with out of the GS. Ideally, for maximum performance, you should only output to gl_Position and to a vec2 indicating where in the quad a particular location is.

Upvotes: 2

genpfault
genpfault

Reputation: 52083

is it possible to ... scale those point sprites by an arbitrary degree using shaders?

No, point sprites have an implementation-defined upper limit on size.

Upvotes: 1

Related Questions