You can place whatever you want inside a billboard. It can be a part of the texture on a quad (thus you can place there a sprite, you can even generate it with our tool sprite-sheet-to-x3d ).
Everything is some geometry, in any case:)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2018-08-16
Thanks. So I will try, I hope that geom bills will be fast enough...If not... There are shader billboards also, can I use them?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
. So I will try, I hope that geom bills will be fast enough...If not... There are shader billboards also, can I use them?
Hm, I'm afraid I don't understand your terminilogy here. Everything that you render is a geometry (this is true for both Castle Game Engine and all other engines). And everything is rendered using shaders (on modern GPU).
If by "shader billboards" you mean a billboard that is rotated (to be oriented toward camera) on shaders: you can use custom shaders in CGE, so it is possible. The default "Billboard" node is rotated on CPU, because it is fast in all my tests :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2018-08-16
Ok, ok ... Just usualy some of engines have slowly default billboards... I need 1k-10k bills without fps falling...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In particular, note that If you will create a huge number of very small shapes, then the application will be slow indeed. Billboards or not billboards. The solution is to create larger shapes, composed from many quads.
It may be problematic if you want all of the shapes to be billboards. Various optimizations are possible. One could indeed rotate the quads in shaders, but it would require passing additional information to each vertex (such that vertex knows about the quad it is part of).
In general, if you want to have a huge number of small billboards in 3D, then you're probably looking for a particle engine in 3D. We don't have a ready particle engine for 3D yet, we have a 2D particle engine ( https://github.com/Kagamma/cge-2d-particle-emitter ).
If you will get to the point where you have something slow, it is best to submit a complete (compileable) example here (or to https://github.com/castle-engine/castle-engine/issues ). I can always suggest ways to make it faster, or I can add some necessary feature to CGE.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2018-08-16
Ok, I will try. (P.S. i just need to draw sprite squares, without rotation and perspective e.t.c, just scaled, positioned, and zbuffered). Anyway shader variant always works fine...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I do not know your exact use-case, but note that if you don't use perspective, and you simply want a 2D game, then you don't need to use Billboard node at all :)
Just use TCastle2DSceneManager that creates an orthogonal projection (typically best for 2D). Inside it, add TCastle2DScene instances (with anything, like quads) that are flat (each quad has the Z coordinate equal).
The Z-buffer works as usual in 2D games. Things further away (with larger Z) are behind things that are near.
Yes, there must be perspective and size. I just want to make big forest. Tree will be rendertotexture every frame with camera rotation, that repeat scene camera. Trees must be transparent when they far from camera, and may be they will be replacced by real trees at near distance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Gabriel, hi! Seems like we're solving the same issue :D I've been trying to do the same forest generation some time ago (thanks to Michalis Kamburelis it really works!), but I didn't finish it yet. I'll search for the latest version of my project and will try to post it today evening - it's not as optimized as it should, but working quiet nice.
I'm going to rewrite it soon, but I'm not sure if I'll manage to get to overworld generation (including forest) this year - I already can do that much "cleaner" and "efficient", just need to put some time in that :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
P.S. Pay attention, that in the example I'll post here, there is a memory issue. So in order to maintain a stable operation of billboards for trees or similar world objects, you'd be much faster with pre-rendered sprites. E.g. maintaining 400 trees in my example required ~6Gb of RAM. So, this mehtod may be used only for "close forest" FPS optimization. For distant trees you'll need to use identical sprites (to save up memory).
As far as I've researched the issue, people say that it's more otpimal to have 8 pre-rendered sprites per object (as viewed from 8 different sides) and "switched" simultaneously without fades or whatever. Thou I didn't implement this part yet.
P.S.2. You don't actually need a billboard in case you're going to generate images. You can generate both texture image and correctly oriented quad without using a billboard node at all. That's what you'll find in the example.
P.S.3. I also have very remote plans (and in my case it might actually never even "start to happen") to make some sort of CastleTrees that can be made to generate random trees optimized for Castle Game Engine use with all LODs included (including billboard sprites). But yeah, while I have most of the algorithm ready on paper, that's certainly not gonna happen in real code this year :) I'm still knee deep in interface development, and I see no finish line :)
Last edit: EugeneLoza 2018-08-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just want rendertotexture one tree (maybe more) for one frame, there will be incorrect perspective, but I think it will be nice. I want to make ultralight and lightpoly, but very good looking and sharp flightsim.
What you think about https://www.youtube.com/watch?v=oNAAb-_r_oU
I'm not expert in shaders writing (don't ever try to make one), but as I can understand It's universal solution for any kind of language and engine, that supports shaders...
P.S. I try some engines before, but as I can see from comments in the net castle engine is people liked one... And also pascal is pretty nice, warm and soft small thing for me... (++ to much paradoxal, python maybe good, but slowly transfom me into monkey by "tab to space" option)
Last edit: Gabriel 2018-08-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ugh... I've tried to recover the project (it's about 1.5 years old, so I've completely forgotten what did I do there :)) and it appears to be extremely buggy. Now I recall it was something like that before, as I've never finished it. I've uploaded it to GitLab, but it doesn't seem that there is anything useful there, it should be completely rewritten from a scratch.
How can I make much number of flat billboards?
To create flat geometry, use various nodes from https://castle-engine.io/x3d_implementation_geometry3d.php or https://castle-engine.io/x3d_implementation_geometry2d.php . There are examples as X3D nodes, and examples as Pascal code. Use IndexedFaceSet, or QuadSet, or Rectangle2D... many choices, they all can be flat.
To make them billboards (automatically oriented toward the viewer), place them as children of TBillboardNode. See e.g. how https://github.com/castle-engine/wyrd-forest/blob/master/code/gametext3d.pas places the Text inside a Billboard.
Great thanks. I will try... P.S. Can I use billboad sprites, I just afraid, that geometry bills will be slow...
You can place whatever you want inside a billboard. It can be a part of the texture on a quad (thus you can place there a sprite, you can even generate it with our tool sprite-sheet-to-x3d ).
Everything is some geometry, in any case:)
Thanks. So I will try, I hope that geom bills will be fast enough...If not... There are shader billboards also, can I use them?
Hm, I'm afraid I don't understand your terminilogy here. Everything that you render is a geometry (this is true for both Castle Game Engine and all other engines). And everything is rendered using shaders (on modern GPU).
If by "shader billboards" you mean a billboard that is rotated (to be oriented toward camera) on shaders: you can use custom shaders in CGE, so it is possible. The default "Billboard" node is rotated on CPU, because it is fast in all my tests :)
Ok, ok ... Just usualy some of engines have slowly default billboards... I need 1k-10k bills without fps falling...
We have a lot of optimization hints on https://castle-engine.io/manual_optimization.php :)
In particular, note that If you will create a huge number of very small shapes, then the application will be slow indeed. Billboards or not billboards. The solution is to create larger shapes, composed from many quads.
It may be problematic if you want all of the shapes to be billboards. Various optimizations are possible. One could indeed rotate the quads in shaders, but it would require passing additional information to each vertex (such that vertex knows about the quad it is part of).
In general, if you want to have a huge number of small billboards in 3D, then you're probably looking for a particle engine in 3D. We don't have a ready particle engine for 3D yet, we have a 2D particle engine ( https://github.com/Kagamma/cge-2d-particle-emitter ).
If you will get to the point where you have something slow, it is best to submit a complete (compileable) example here (or to https://github.com/castle-engine/castle-engine/issues ). I can always suggest ways to make it faster, or I can add some necessary feature to CGE.
Ok, I will try. (P.S. i just need to draw sprite squares, without rotation and perspective e.t.c, just scaled, positioned, and zbuffered). Anyway shader variant always works fine...
I do not know your exact use-case, but note that if you don't use perspective, and you simply want a 2D game, then you don't need to use
Billboard
node at all :)Just use
TCastle2DSceneManager
that creates an orthogonal projection (typically best for 2D). Inside it, addTCastle2DScene
instances (with anything, like quads) that are flat (each quad has the Z coordinate equal).The Z-buffer works as usual in 2D games. Things further away (with larger Z) are behind things that are near.
See https://github.com/castle-engine/castle-engine/wiki/2D-Games for many pointers (including links to docs and examples) about 2D games. Note that you can actually mix the 2D and 3D content.
Oh, sorry for "perspective", O`korz particles must have distance dependent size...
Yes, there must be perspective and size. I just want to make big forest. Tree will be rendertotexture every frame with camera rotation, that repeat scene camera. Trees must be transparent when they far from camera, and may be they will be replacced by real trees at near distance.
@Gabriel, hi! Seems like we're solving the same issue :D I've been trying to do the same forest generation some time ago (thanks to Michalis Kamburelis it really works!), but I didn't finish it yet. I'll search for the latest version of my project and will try to post it today evening - it's not as optimized as it should, but working quiet nice.
I'm going to rewrite it soon, but I'm not sure if I'll manage to get to overworld generation (including forest) this year - I already can do that much "cleaner" and "efficient", just need to put some time in that :)
Great thanks, glad to hear, will be waiting...
P.S. Pay attention, that in the example I'll post here, there is a memory issue. So in order to maintain a stable operation of billboards for trees or similar world objects, you'd be much faster with pre-rendered sprites. E.g. maintaining 400 trees in my example required ~6Gb of RAM. So, this mehtod may be used only for "close forest" FPS optimization. For distant trees you'll need to use identical sprites (to save up memory).
As far as I've researched the issue, people say that it's more otpimal to have 8 pre-rendered sprites per object (as viewed from 8 different sides) and "switched" simultaneously without fades or whatever. Thou I didn't implement this part yet.
P.S.2. You don't actually need a billboard in case you're going to generate images. You can generate both texture image and correctly oriented
quad
without using a billboard node at all. That's what you'll find in the example.P.S.3. I also have very remote plans (and in my case it might actually never even "start to happen") to make some sort of
CastleTrees
that can be made to generate random trees optimized for Castle Game Engine use with all LODs included (including billboard sprites). But yeah, while I have most of the algorithm ready on paper, that's certainly not gonna happen in real code this year :) I'm still knee deep in interface development, and I see no finish line :)Last edit: EugeneLoza 2018-08-17
I just want rendertotexture one tree (maybe more) for one frame, there will be incorrect perspective, but I think it will be nice. I want to make ultralight and lightpoly, but very good looking and sharp flightsim.
What you think about https://www.youtube.com/watch?v=oNAAb-_r_oU
I'm not expert in shaders writing (don't ever try to make one), but as I can understand It's universal solution for any kind of language and engine, that supports shaders...
P.S. I try some engines before, but as I can see from comments in the net castle engine is people liked one... And also pascal is pretty nice, warm and soft small thing for me... (++ to much paradoxal, python maybe good, but slowly transfom me into monkey by "tab to space" option)
Last edit: Gabriel 2018-08-17
Ugh... I've tried to recover the project (it's about 1.5 years old, so I've completely forgotten what did I do there :)) and it appears to be extremely buggy. Now I recall it was something like that before, as I've never finished it. I've uploaded it to GitLab, but it doesn't seem that there is anything useful there, it should be completely rewritten from a scratch.
It'd be much more useful just to follow Michalis' example: https://github.com/castle-engine/castle-engine/blob/master/examples/3d_rendering_processing/render_3d_to_texture_and_use_as_quad.lpr
Thank you. I'll try to launch it today's evening...
Last edit: Gabriel 2018-08-18