BallZ

Post screenshots, binaries and projectfiles of the projects you have made with ZGE that you want to share!

Moderator: Moderators

User avatar
y offs et
Posts: 418
Joined: Wed Apr 22, 2009 4:26 pm
Location: BC, Canada

Post by y offs et »

That's a cool idea of slanting the letters of the clock - although I feel you've gone too far.

Makes me feel the screen is going to wrap around my face like headphones, rather than the illusion of up close in a theatre.
"great expectations"
senji
Posts: 1
Joined: Sat Mar 26, 2011 11:33 pm

value editing in Ballz

Post by senji »

I'm a complete newbie to ZGE, I just discovered it via FL Studio 9.9 beta. I quickly realized that Ballz would be a great program to study. However, as I try to edit the parameters, such as rotating the mesh, or making the ballz larger or smaller, nothing changes. I was able to change the OnUpdate->Timer to 60 seconds. What am I doing wrong? Is something locked that needs to be unlocked or what? Fascinating program!

Thank you
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Hi senji and welcome to the ZGE-forums.

BallZ is quite an advanced script and maybe not the best to start with :)

ZGE is also a bit different from other tools and has a learning curve but once you get over that you can do pretty powerful things like all the ZgeViz scripts demonstrates.

Try Kjells Video Tutorials. Check out the simple sample projects such as ZPong (included in the download). Also the ZgeViz development documentation.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

@Rado1

Your BallZ visualizer made it in the official FL Studio 10 trailer ( check the 5 minute mark ) :wink:

http://www.youtube.com/watch?v=OfMJkVd6Ffg

Good job!
K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Thank you Kjell for good news. I am pleased to see it. Also Crystal Cube has been selected to be shown...interesting...

Rado1
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

After quite a long time I returned to BallZ screen saver because I wanted to make some more experiments with OpenGL. Attached you will find BallZ 2 with:

- better looking balls rendered by GLSL point sprites
- usage of "scalable" font with alpha test for rendering time
- some more shapes; see screenshots
- more effective computing of positions, colors and sizes

My main motivation was to improve performance; it has changed from original average ca. 120 FPS to new average ca. 220 FPS. Not too much because the most of the time still taken by computations, but there's some improvement. Another motivation was learning point sprites which I want to use for 3d particles in future.

I attached also ZGE project file for your inspiration and also ...

... I'm not fully satisfied with usage of OpenGL vertex arrays. For instance, calling glVertexPointer() and glColorPointer() on each rendering does not seem to be optimal. For Kjell (and similar people knowing OpenGL much better than me): could you please have a look at the current implementation and try to help me to optimize it? Thank you in advance.

Any comments are welcome!
Attachments
BallZ2.zip
ZGE project, (optional) config file and screensaver
(133.67 KiB) Downloaded 533 times
screenshots
screenshots
scr.png (313.68 KiB) Viewed 20518 times
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,
Rado1 wrote:I'm not fully satisfied with usage of OpenGL vertex arrays. For instance, calling glVertexPointer() and glColorPointer() on each rendering does not seem to be optimal.
Those calls cannot be avoided ( since you're also using RenderText ) .. but it's probably ( depends on the driver implementation ) faster to allocate a VBO and update it each frame using glBufferSubData. Also, you could try to interleave the position & color attributes to get the required data per vertex closer to each other .. in which case you'd want to pad / include the w-coordinate for your position attribute to make sure the data is aliased nicely.

Concerning speeding up your CPU computations .. you might want to inline your functions, use 1D arrays ( instead of 2D ) and go with plain floats instead of vectors. Or if you want to go all out, you could do the computations on the GPU by rendering them to a frame ( floating-point ) or feedback buffer.

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Thanks Kjell for your valuable ideas. See my comments below.
Kjell wrote:.. but it's probably ( depends on the driver implementation ) faster to allocate a VBO and update it each frame using glBufferSubData.
I tried this already but observed no performance improvement. That's probably because I need to update client-side memory each render pass and pass it to server side. I finally decide to remove VBOs to simplify the code. What would help is glMapBuffer, but this is not available in ZGE since it's not possible to treat pointers as arrays.
Kjell wrote:Also, you could try to interleave the position & color attributes to get the required data per vertex closer to each other .. in which case you'd want to pad / include the w-coordinate for your position attribute to make sure the data is aliased nicely.
I tried glInterleavedArrays() with GL_C3F_V3F format, but there was no space for ball size. I could not find a better format. Is there some way I could use interleaved arrays?
Kjell wrote:Concerning speeding up your CPU computations .. you might want to inline your functions,
Do you mean, for instance, interpolate() function which is used quite often? That's pity that ZGE does not provide inline functions.
Kjell wrote:use 1D arrays ( instead of 2D ) and go with plain floats instead of vectors
Does it really help? I'm not creating vectors on the fly. Is not a vector just a sequence of floats?
Kjell wrote:Or if you want to go all out, you could do the computations on the GPU by rendering them to a frame ( floating-point ) or feedback buffer.
That's really interesting idea! Do you have some hint how to do it in my case?
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I haven't tried the new version yet but it looks really nice judging by the images you posted.

How do you come up with ideas for all these cool formations? :)

Computing it all on the GPU could be very fast of course but based on my experience that is pretty difficult to make compatible between GPU drivers. Btw, ZGE should support ComputeShader as a component at some point.

Inline functions is something I hope to add to ZGE.

For expressions that is performance critical you could try avoiding functions that allocate memory, i.e. "vector2/3/4" will allocate memory that needs to be garbage collected. Using string-type also allocates memory.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,
Rado1 wrote:I tried this already but observed no performance improvement.
In that case your driver probably keeps the memory allocated for the vertex arrays on the GPU intact across frames :wink:
Rado1 wrote:Is there some way I could use interleaved arrays?
If for instance you have a float array that contains interleaved 2D positions + 2D texCoords, you can simply use for example ..

Code: Select all

glVertexPointer(2, GL_FLOAT, 16, myArray[0]);
glTexCoordPointer(2, GL_FLOAT, 16, myArray[2]);
Kjell wrote:Do you mean, for instance, interpolate() function which is used quite often?
Any function call adds a couple of additional cycles. It's a matter of size VS speed ( and ZGE usually leans towards small size ).
Rado1 wrote:Does it really help? I'm not creating vectors on the fly. Is not a vector just a sequence of floats?
Actually, i just double-checked by benchmarking floats VS vectors and there's not much difference. My bad :oops:
Rado1 wrote:That's really interesting idea! Do you have some hint how to do it in my case?
I posted a lame / simple example of this principle here.

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Kjell wrote:If for instance you have a float array that contains interleaved 2D positions + 2D texCoords, you can simply use for example ..

Code: Select all

glVertexPointer(2, GL_FLOAT, 16, myArray[0]);
glTexCoordPointer(2, GL_FLOAT, 16, myArray[2]);
I thought myArray[2] returns 3-rd element of array by value, not a pointer to the 3rd element. I would be happy if it worked as in C, but...
Kjell wrote:I posted a lame / simple example of this principle here
I'm going to have a look at it. Thanks!
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Kjell wrote:
Rado1 wrote:I tried this already but observed no performance improvement.
In that case your driver probably keeps the memory allocated for the vertex arrays on the GPU intact across frames :wink:
That's my experience too. Drivers have become very clever and many techniques that was previously faster now make almost no difference in practice.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hmm,
VilleK wrote:Drivers have become very clever and many techniques that was previously faster now make almost no difference in practice.
Depends on the GPU / manufacturer .. if you're using a Intel GPU for example, not so much :roll:
Rado1 wrote:I would be happy if it worked as in C
It's the same as in C .. but without the address-of ( & ) operator in front.

K
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post by Rado1 »

Kjell,

I tried interleaved arrays again and performance was slightly improved by ca. 10-20 FPS; nothing special, but it works. I have a problem now when trying to use interleaved vertex array with VBO. My data structure is, symbolically speaking, <vec4 position, vec4 color>. How to specify offsets relative to the start of the buffer object for the pointer (last) parameter of glColorPointer() function? In C I would write "(GLubyte*) NULL + 16". I can use "null" for the glColorPointer() because it is the first value in interleaved array. Any idea? Of course, the simplest solution is to use two VBOs, one for position and another one for color and size. Is is the only solution in ZGE?

FYI I re-tested BallZ with two non-interleaved VBOs and its performance is really identical to original version without VBOs and two non-interleaved VAs on AMD FirePro M2000. So VA interleaving helps better than VBOs on my GPU.
Last edited by Rado1 on Tue Jul 14, 2015 9:51 pm, edited 1 time in total.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi Rado1,
Rado1 wrote:How to specify offsets relative to the start of the buffer object for the pointer (last) parameter of glColorPointer() function?
Either change the "xptr pointer" argument in the various pointer-related functions ( glVertexPointer / glTexCoordPointer etc. ) to "int pointer" and pass the offset as a plain literal .. or ( when you want to keep the argument as xptr ) use the following syntax:

Code: Select all

// For example a vec2 texture coordinate at byte 8 of a 32-byte vertex

glTexCoordPointer(2, GL_FLOAT, 32, reinterpret_cast<xptr>(8));
K
Post Reply