Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture Point Sprite Example #17

Open
kybr opened this issue Nov 22, 2018 · 7 comments
Open

Texture Point Sprite Example #17

kybr opened this issue Nov 22, 2018 · 7 comments

Comments

@kybr
Copy link
Member

kybr commented Nov 22, 2018

I want to know how to do a cloud of points that obey perspective where each point is rendered as a texture. I've written this many times is the old system. It is a very common request from students.

However, I'm struggling to do this given the new system. In particular...

  1. I don't know whether the default shader system supports this use case. If it does, I don't know how to use it. I would assume, a) create a simple 16x16 pixel texture, b) create a point mesh, c) bind the texture, d) call g.texture() to use the default shader for textures, and e) win. But, this does not work for me.
  2. When I write my own shader, I have to use version 330 GLSL, so I adapted my shader which uses the old GLSL and fixed-pipeline "magic" variables. Again, I cannot get it to work for me, even though I think it should. I have something that compiles, but i don't see anything. Does one still need to call glEnable(GL_POINT_SPRITE) and glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE)??
  3. There is no example to follow that shows how to do this very, very common case.
  4. The "way" of doing graphics (i.e., default shaders concatenated as strings to cover common use cases) is still totally undocumented, so I (and others) are left to read the source and infer and deduce what might be the "right way" to use the default shader system.

Perhaps the "right way" to do a point sprite cloud is totally different than it used to be; Perhaps the "right way" is so radically different that I'm going about it all wrong. Perhaps I should be using instancing?

In any case, I need an example. Here's a non-texture-sprite cloud I wrote:

https://github.com/kybr/mat201b/blob/master/example/shader_point_cloud.cpp

Here's the current shader sprite example in AlloSystem

https://github.com/AlloSphere-Research-Group/AlloSystem/blob/devel/allocore/examples/graphics/shaderSprites.cpp

(Does it really have to use a geometry shader?)

@kybr
Copy link
Member Author

kybr commented Nov 23, 2018

Done. I added an example. I didn't end up adapting the AlloSystem example.

Please review examples/graphics/point-cloud-geometry-shader-texture-sprite.cpp for coding style, readability, efficacy, grammar, etc. Anything you see that might make this not a good example, please call it out.

I'm interested if there's a better way to do this, generally. Also, I'm not sure that depth and blending are configured correctly or in the best way.

@LancePutnam
Copy link
Member

LancePutnam commented Nov 23, 2018 via email

@kybr
Copy link
Member Author

kybr commented Nov 23, 2018

they prevent certain optimizations.

what optimizations? link?


so, the scheme for a point cloud might be to duplicate each point 3 times so there are 4 total per logical point, the use gl_VertexID % 4 to decide offsets?

thanks, Lance.

@kybr
Copy link
Member Author

kybr commented Nov 23, 2018

after a few minutes of trying... it seems like using gl_VertexID with a scheme to avoid a geometry shader (in this case) is a bit of work. i think i have to change the draw primitive to triangles or triangle strip and use an element/index array. and i notice that your example uses a geometry shader.

unless it truly ruins performance, i think that it's better to have a clear example that does use a GS rather than a more performant example that is considerably more complicated. still, it's even better to have both :)

@grrrwaaa
Copy link
Member

grrrwaaa commented Nov 24, 2018 via email

@LancePutnam
Copy link
Member

LancePutnam commented Nov 24, 2018 via email

@grrrwaaa
Copy link
Member

grrrwaaa commented Nov 24, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants