Static sprites
Moderator: Moderators
Static sprites
Is there some simple possibility how to render sprites (or maybe also other components) that are static on the screen and do not react to 3D rotations of camera? Currently, I either use transformation of all these "static" bitmaps to fonts or create models having the same position as camera but opposite rotation and rendering all the "static" stuff (indicators, controllers, ...). Both techniques work, but require some overhead, especially if there are many such objects of different sizes on screen. Cannot ZGE provide some simpler mechanism?
My idea is to have, e.g., a variant (or a "2D" flag of) of the RenderTransformGroup/RenderTransform which would work in "camera's space", similarly to RenderText.
My idea is to have, e.g., a variant (or a "2D" flag of) of the RenderTransformGroup/RenderTransform which would work in "camera's space", similarly to RenderText.
Hi Rado1,
Anyway, countering Camera transformations and the 2D mode of RenderText aren't the same thing. One will give you a orthographic projection, the other won't alter the projection of the active camera.
Rendering a GUI on top of a 3D game is usually done by overwriting the Projection and ModelView matrices. The only way to do this without extensions is by using two RenderPasses .. which is a bit inconvenient*, but you can always simply call glLoadMatrixf. Attached is a simple example.
*A ApplyCamera component that can be used in OnRender would be the best / easiest solution in my opinion.
K
You probably mean 3D transformations, only countering the 3D rotations ( but not translation and scale ) will give you billboard sprites. Like the trees in Mario 64.Rado1 wrote:Is there some simple possibility how to render sprites that are static on the screen and do not react to 3D rotations of camera?
Anyway, countering Camera transformations and the 2D mode of RenderText aren't the same thing. One will give you a orthographic projection, the other won't alter the projection of the active camera.
Rendering a GUI on top of a 3D game is usually done by overwriting the Projection and ModelView matrices. The only way to do this without extensions is by using two RenderPasses .. which is a bit inconvenient*, but you can always simply call glLoadMatrixf. Attached is a simple example.
*A ApplyCamera component that can be used in OnRender would be the best / easiest solution in my opinion.
K
- Attachments
-
- Layer2D.zgeproj
- (24.55 KiB) Downloaded 701 times
My explanation was not probably clear, I meant rendering of GUI components like gun sights, various controls (e.g., buttons), radarmaps, etc. for games, not "classical" billboard sprites put in scenes. See the attached screenshot.Kjell wrote:You probably mean 3D transformations, only countering the 3D rotations ( but not translation and scale ) will give you billboard sprites. Like the trees in Mario 64.
I would like to avoid multiple render passes. Could you please give me an example of usage glLoadMatrixf for rendering "static sprites"? (I do not understand all this OpenGL transformations, yet.)Kjell wrote:Rendering a GUI on top of a 3D game is usually done by overwriting the Projection and ModelView matrices. The only way to do this without extensions is by using two RenderPasses .. which is a bit inconvenient*, but you can always simply call glLoadMatrixf.
Sounds interesting. Can you please describe how to use such a component?Kjell wrote:*A ApplyCamera component that can be used in OnRender would be the best / easiest solution in my opinion.
- Attachments
-
- Example of static GUI components
- scr.png (66.69 KiB) Viewed 16522 times
Hi, thanks for your example Kjell, very usefull for UI. Then I tried to play with it to obtain a billboard sprite.
I followed some tutorials here http://www.lighthouse3d.com/opengl/bill ... p?billSphe , without success...
I'm discovering 3D transformations and matrix so can you give me a hint ?
Thanks !
I followed some tutorials here http://www.lighthouse3d.com/opengl/bill ... p?billSphe , without success...
I'm discovering 3D transformations and matrix so can you give me a hint ?
Thanks !
Hi Ats,
What ( and how many ) will you be using it for? The easiest way is to use the negative rotation of the camera .. but this will kill performance in large quantities. Attached is a example regardless.
K
What ( and how many ) will you be using it for? The easiest way is to use the negative rotation of the camera .. but this will kill performance in large quantities. Attached is a example regardless.
K
- Attachments
-
- Billboards.zgeproj
- (2.21 KiB) Downloaded 712 times
Last edited by Kjell on Wed Oct 31, 2012 5:56 pm, edited 1 time in total.
Thanks !!! I was so far away from what you did in your example...
I'm trying to create a planet hologram like that one:
(Screenshot taken from Anastasyia)
I already managed to create a good one using a simple texture and a transparent grid, but I was testing to create one using fake voxels: a lot of little billboards. In fact, 128x64 = 8192 billboards... That's a lot, so maybe I'll stick to my simple texture...
Anyway, I'll surely use billboards for the next part of my tests so once again, thanks for your good snippets
I'm trying to create a planet hologram like that one:
(Screenshot taken from Anastasyia)
I already managed to create a good one using a simple texture and a transparent grid, but I was testing to create one using fake voxels: a lot of little billboards. In fact, 128x64 = 8192 billboards... That's a lot, so maybe I'll stick to my simple texture...
Anyway, I'll surely use billboards for the next part of my tests so once again, thanks for your good snippets
Hi Ats,
The easiest approach would be to render points instead of sprites, but points have a constant size ( they don't get bigger closer to the camera ) which is probably not what you want. The best technique would be to use geometry shaders, but you can get away with regular shaders if you pull some tricks ..
http://www.youtube.com/watch?v=Keu-p9-Wnsc
Not sure what hardware you're targeting though
K
You really don't want to use the method I posted for something like that.Ats wrote:I'm trying to create a planet hologram
The easiest approach would be to render points instead of sprites, but points have a constant size ( they don't get bigger closer to the camera ) which is probably not what you want. The best technique would be to use geometry shaders, but you can get away with regular shaders if you pull some tricks ..
http://www.youtube.com/watch?v=Keu-p9-Wnsc
Not sure what hardware you're targeting though
K
Hi Kjell, I'm still trying to do the planet hologram from time to time...
Are you rendering the sphere using some efficient shader code, or do you place the points by hand on the sphere surface coordinates, and then making them facing the camera and scaling them with the distance ?
One more question, is your exemple working on a high-end GSM / android ?
Thanks!
Are you rendering the sphere using some efficient shader code, or do you place the points by hand on the sphere surface coordinates, and then making them facing the camera and scaling them with the distance ?
One more question, is your exemple working on a high-end GSM / android ?
Thanks!
Hi Ats,
K
The method shown in the video uses a static mesh ( so it only has to be uploaded to the GPU once ) containing the vertices for all sprites, but their coordinates are calculated by a vertex shader.Ats wrote:Are you rendering the sphere using some efficient shader code?
Yes, although not using ZGameEditor at the moment .. since ES 2.0 isn't supported yet. But even for ES 1.1 there are better techniques than using a model for each individual sprite.Ats wrote:Is your exemple working on a high-end GSM / android?
K