CodeWalrus

Development => PC, Mac & Vintage Computers => Topic started by: Snektron on January 22, 2015, 10:31:58 PM

Title: FBO Particle System
Post by: Snektron on January 22, 2015, 10:31:58 PM
Ever since i started programming, i've been interested in particle systems.
The mouseattractor ones. I've made several of them, the
first one on my laptop could'nt even handle a thousand without killing the
computer (that are the drawbacks of Java i guess :/).

Also, this summer became interested in GLSL (Shading) and started learning that.
Then after a while i read somewhere that GPU's could be used
for more than only drawing images on screen (well, i knew that before, but i never
really knew how such a thing would be accomplished). And yeah, that includes particle systems.
So i started reading up on them, and i actually managed to make one myself :D.

[spoiler]
(http://quantuminfinity.net/files/part1.png)
(http://quantuminfinity.net/files/part2.png)
(http://quantuminfinity.net/files/part3.png)
(http://quantuminfinity.net/files/part4.png)
[/spoiler]

(some screenshots ^)
I can run easily 2 million particles.
It's not quite done yet though, as i've learnt several optimization tricks (yeah, it's was a forgotten project for a few months).
So i'll be working on this project for a few days (i didn't want to attach the project just yet, as
you'd need to recompile it to change the texture size etc). Let me know
what you think and if you have any ideas i should include :)
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 22, 2015, 11:46:25 PM
Oooh those looks nice :D, I wonder how fast it is on, let's say, a 2010 Intel Core i7 computer? Also some of those could be used for wallpapers I think. I can't wait to see it in action :)
Title: Re: FBO Particle Syste
Post by: Snektron on January 23, 2015, 12:09:59 AM
Its not going to matter on what cpu it runs (it could theoretically run on a z80... Youd only need pci on z80)
Because its fully ran on the gpu :). Much more power.
And GPU's are made for handeling the same routine (pos / vel updates) for large amounts of data, making it ideally for
Particle systems :P

What really will be interesting of someone has a monster gpu, because it probably can run a few million particles with ease.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 23, 2015, 01:40:30 AM
Aah ok, but would it require a GPU from this year or would it run fine on a 3-5 years old one?
Title: Re: FBO Particle System
Post by: Snektron on January 23, 2015, 06:36:19 AM
Well it uses like GLSL 150,
Aka OpenGL 1.5 (or 130 i cant remember)
Anyway, most pc's should run it fine :).
You could probably run it on an integrated
GPU, though you'd need to reduce the texture
size :p

EDIT: I just remembered that i might have used some
methods in the Java part from OpenGL 3, but most
GPU's come shipped standard with this. I'll need
to implement some kind of check for this.
Title: Re: FBO Particle System
Post by: novenary on January 23, 2015, 07:22:38 AM
I have an AMD 7970. I should try to run it. Cause it looks pretty epic. :D
Title: Re: FBO Particle System
Post by: unknownloner on January 23, 2015, 12:52:56 PM
Yeah if you're using FBOs it'll require GL 3.0 or GL_EXT_Framebuffer_Object
Title: Re: FBO Particle System
Post by: Snektron on January 23, 2015, 02:19:10 PM
I believe im using a crossover between 3.0 and ext, since
some constants i needed for ext were only in 3.0.
Title: Re: FBO Particle System
Post by: unknownloner on January 23, 2015, 04:40:23 PM
Spoiler, if you're using LWJGL the EXT calls are literally exactly the same as the 3.0 calls (they both call the same C code).
Title: Re: FBO Particle System
Post by: Snektron on January 23, 2015, 04:46:30 PM
That's why it works, but as i said, GL30 doesnt have all EXT constants and
vice versa. (and yeah, i do use LWJGL).
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 24, 2015, 12:26:01 AM
Quote from: Streetwalrus on January 23, 2015, 07:22:38 AM
I should try to run it. Cause it looks pretty epic. :D

Good luck running it, because there is no download available :P. I hope one comes out soon, though. :)
Title: Re: FBO Particle System
Post by: Snektron on January 24, 2015, 11:37:26 AM
Update 1:
I've replaced the position & velocity texture generation,
since Java's BufferedImage could only work with 8 bit color components.
255 different positions is not that much :P. Now it can do 65535 positions (16 bit).
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 24, 2015, 03:11:39 PM
Cool to hear :D
Title: Re: FBO Particle System
Post by: Snektron on January 24, 2015, 11:24:47 PM
So i've started working on the console. At first i was gonna make it within a JFrame
(Java's window class) but with that it has a 50% FPS drop and freezes every once
in a while :(. I've also realized i'll need a seperate thread for the engine, so the console
doesn't get blocked. Also the display is now resizable :).
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 25, 2015, 05:08:22 PM
Could the slowdown be due to java itself? :P

Also good to see new updates. :)
Title: Re: FBO Particle System
Post by: Snektron on January 25, 2015, 05:20:11 PM
Quote from: DJ Omnimaga on January 25, 2015, 05:08:22 PM
Could the slowdown be due to java itself? :P

Could verywell be. I've noticed that AWT (Java's library used for things like windows and general user interfaces, including JFrame)
is one of the worst standard Java libraries. A new object just to change 4 bytes representing a color to an int??
Come on really? just one static method is more than enough, and theres no way to change the color values
of the object.
Title: Re: FBO Particle System
Post by: unknownloner on January 26, 2015, 03:12:29 PM
Creating new objects in Java really isn't a big deal, even for that. Not like it requires a malloc or anything. In practice object allocation & GC is fast enough that I got a software 3d renderer working which allocated a bunch of vectors for each triangle each frame (I was transforming the input triangles and using immutable vectors). Worked fine for rendering a huge minecraft-like world. That's not to say that I like AWT, I don't, but don't judge it harshly for the wrong reasons.

Edit: video of renderer in question, most of cpu is being spent on pixel fill and it's single threaded.
Title: Re: FBO Particle System
Post by: Snektron on January 26, 2015, 04:24:13 PM
Pretty nice vid :P. But i find making an object for every pixel of an image just bad practice, even though
Java can handle it easily. Though on Android it really does make a difference :)
P.S.: You call that big?
(http://quantuminfinity.net/files/ray.png)
Title: Re: FBO Particle System
Post by: unknownloner on January 26, 2015, 04:45:35 PM
Not every pixel, every vertex ;)
And yeah I was creating new objects just because I didn't want to rewrite the vectors
Title: Re: FBO Particle System
Post by: Snektron on January 26, 2015, 04:48:01 PM
No i didn't mean it that way :P. When you create a BufferedImage and you want to set the color
of a pixel, you can either use AWT's Color class or just do it yourself with one line of code.
The problem is withthe Color class you'd need to create a new Color object for every pixel.
Title: Re: FBO Particle System
Post by: unknownloner on January 26, 2015, 04:50:29 PM
Well yeah for setting pixels you use setRGB or you access the DataBuffer directly (which is what my renderer does I think... I don't remember). then use Color for filling large rectangles with G2D
Title: Re: FBO Particle System
Post by: Snektron on January 26, 2015, 04:51:39 PM
Well as i said in my last update, i actually made my own image class for 16 bit/pixel images :P
Title: Re: FBO Particle System
Post by: Snektron on January 27, 2015, 10:18:28 AM
Update:
- Started working on the console:
  - Set pos/vel texture size
  - enable/disable noise
  - enable/disable gravity

Edit: More updateees
- More settings:
- enable/disable particle age
- set gravity strength
- System capabillities check (for to check if the user can run fbo's etc)
- error message boxes
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 27, 2015, 05:35:50 PM
Awesome. I hope you add a GUI for people who want to change parameters, though, since many people are not fond of command prompts. I can't wait to try it out :)
Title: Re: FBO Particle System
Post by: Snektron on January 27, 2015, 05:42:08 PM
spoiler:
(http://quantuminfinity.net/files/spoiler.png)
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 27, 2015, 05:56:38 PM
That's good. :) Can we change colors, by the way?
Title: Re: FBO Particle System
Post by: Snektron on January 27, 2015, 09:50:03 PM
Update & release
Now you can 8)
- Added reset settings button
- Added color picker

Download:
Exe version: quantuminfinity.net/files/particles.exe (http://quantuminfinity.net/files/particles.exe)
Jar version: quantuminfinity.net/files/FBOParticles.jar (http://quantuminfinity.net/files/FBOParticles.jar)

Jar works on every system and can run by double-clicking, but if that doesn't work
you can always start it with
java -jar FBOParticles.jar

If you encounter a crash, please also run it with the above command and send me the error message :)
The default texture size is 512*512 (262144) so please don't run this on your old laptop :P.
The maximum texture size is set to 4096*4096, but you need quite the GPU to run this. It is not
required to make texture size powers of 2. Also, just to be safe, you run this at your own risk
(though i don't think it will fry your GPU :P). If you close the Particle Console you can reopen it
by pressing 'F1'. You can attract the particles with left mouse, and repel them with right.
both mouse buttons at the same times freezes the particles until you release them.

if you have any questions, feedback or suggestions of what settings i should add please leave them
below :)
Title: Re: FBO Particle System
Post by: CKH4 on January 27, 2015, 10:00:43 PM
I'll try it but I only have AMD R5 onboard so it'll probably lag.
Title: Re: FBO Particle System
Post by: Snektron on January 27, 2015, 10:03:57 PM
You'd be surprised :) Also you can just change the texture size to like 256 or even 128 of your system can't handle it.
For reference: My AMD R7 250 (specs (http://www.club-3d.com/index.php/products/reader.en/product/radeon-r7-250.html)) runs at about 60 Fps on 1536.
Title: Re: FBO Particle System
Post by: matrefeytontias on January 27, 2015, 10:18:40 PM
Breaks on me with :
QuoteError creating shader: 0(143) : error C7011: implicit cast from "int" to "bool"
0(170) : error C7011: implicit cast from "int" to "bool"
0(173) : error C7011: implicit cast from "int" to "bool"
0(177) : warning C7533: global variable gl_FragData is deprecated after version 120
Title: Re: FBO Particle System
Post by: Snektron on January 27, 2015, 10:22:55 PM
Quote from: matrefeytontias on January 27, 2015, 10:18:40 PM
Breaks on me with :
QuoteError creating shader: 0(143) : error C7011: implicit cast from "int" to "bool"
0(170) : error C7011: implicit cast from "int" to "bool"
0(173) : error C7011: implicit cast from "int" to "bool"
0(177) : warning C7533: global variable gl_FragData is deprecated after version 120
oops, looks like this is a GPU problem, where my GPU defines a boolean as an int being 0 or 1,
and yours just as an integer (i used supething like if (useGravity) which should be if (useGravity == 1)). I'll update it shortly.

EDIT: Also looks like i forgot to end the process properly. This will also be updated shortly.
EDIT2: Updated. you can download via the normal links :)
Title: Re: FBO Particle System
Post by: CKH4 on January 27, 2015, 11:43:06 PM
Super sexy, I can surprisingly run 512 at 60fps and 1024 at 30fps. Also your download is not commonly downloaded and could be dangerous according to Google. https://support.google.Com/webmasters/answer/168328 (https://support.google.com/webmasters/answer/168328) May interest you if you plan on long term support for this project.
Title: Re: FBO Particle System
Post by: Snektron on January 27, 2015, 11:59:02 PM
Thanks :) and i will defenitely look into un-dangerousing it. Tomorrow.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 28, 2015, 03:53:12 AM
I am not getting any error when running it, but the window remains completely black and nothing else than the Particle System console and the software window shows up.
Title: Re: FBO Particle System
Post by: CKH4 on January 28, 2015, 03:56:53 AM
Mine took a minute and read initializing before finally loading. My processor is pretty decent for a laptop so that may have to do with why mine loaded pretty quick. Maybe cumred snektron will know...
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 28, 2015, 04:10:43 AM
Well I waited about 5 minutes and nothing appeared. Just the FPS and some stuff in the title bar that changed every now and then (40-60)
Title: Re: FBO Particle System
Post by: Snektron on January 28, 2015, 06:48:52 AM
Quote from: DJ Omnimaga on January 28, 2015, 03:53:12 AM
I am not getting any error when running it, but the window remains completely black and nothing else than the Particle System console and the software window shows up.
That's strange... Maybe i forgot some openGL checks your machine doesnt have... Have you ran it via the cmd/terminal? And have you tried more particles? Maybe there were too few to see anything. Or maybe you have a wrong java version. Oh and what OS are you using?

EDIT: I tried it out on my dad's linux machine and turns out there was another shader error. I fixed it but that doesnt mean it was your problem, dj.
Title: Re: FBO Particle System
Post by: Duke "Tape" Eiyeron on January 28, 2015, 02:06:12 PM
Now, you have to improve it, make it modulable, add gradients, pause, other interaction tools, make it open, allow other rendering methods because I LOVE THAT PROTOTYPE!
Title: Re: FBO Particle System
Post by: CKH4 on January 28, 2015, 03:34:46 PM
https://play.google.com/store/apps/details?id=com.softwaresemantics.diyglsllwp&hl=en&referrer=utm_source%3Dgoogle%26utm_medium%3Dorganic%26utm_term%3Dglsl+background+windows&pcampaignid=APPU_ogDJVNGGDcOVNpXSgvgG (https://play.google.com/store/apps/details?id=com.softwaresemantics.diyglsllwp&hl=en&referrer=utm_source%3Dgoogle%26utm_medium%3Dorganic%26utm_term%3Dglsl+background+windows&pcampaignid=APPU_ogDJVNGGDcOVNpXSgvgG), Android port maybe?

Also maybe options for the particles to continue off screen.
Title: Re: FBO Particle System
Post by: Snektron on January 28, 2015, 03:42:15 PM
I tried that app, but it doesn't work (my own version works though... i should probably finish it sometime :))
Also, i use Framebuffers (Render to texture) to update the particle speed since a shader cannot save values
to the next frame or even next pixel, and i don't think the diy glsl lwp supports that. Android does have framebuffers though, but it would probably a tremendous battery drain :(.

As for the particles off screen, the way i save values is every pixel of a texture is one particle, the x, y and age are stored in x, y and z
as a value from 0-1. i could make them continue off screen, but that would mean losing on-screen precision :(. maybe ill add it
as an option later.
Title: Re: FBO Particle System
Post by: CKH4 on January 28, 2015, 03:50:44 PM
That app worked for me but they changed the url where it was hosted (that was recently fixed) so it's possible that you visited then.
Title: Re: FBO Particle System
Post by: Snektron on January 28, 2015, 04:02:23 PM
Oh interesting :o i'll take a look at it later.
Title: Re: FBO Particle System
Post by: CKH4 on January 28, 2015, 04:06:22 PM
Actually it looks like it may have changed again, or maybe my brain just died.

Edit.
Its open source so it can be easily changed.
https://github.com/cyrilmhansen/DIYGlslLwp (https://github.com/cyrilmhansen/DIYGlslLwp)
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 28, 2015, 07:29:12 PM
Quote from: Cumred_Snektron on January 28, 2015, 06:48:52 AM
Quote from: DJ Omnimaga on January 28, 2015, 03:53:12 AM
I am not getting any error when running it, but the window remains completely black and nothing else than the Particle System console and the software window shows up.
That's strange... Maybe i forgot some openGL checks your machine doesnt have... Have you ran it via the cmd/terminal? And have you tried more particles? Maybe there were too few to see anything. Or maybe you have a wrong java version. Oh and what OS are you using?

EDIT: I tried it out on my dad's linux machine and turns out there was another shader error. I fixed it but that doesnt mean it was your problem, dj.
Windows 7 64 bits. I don't know if I have the latest java version, though. I updated a month ago or two but everytime I do I get errors or it fails to install properky. Maybe that's why?
Title: Re: FBO Particle System
Post by: Snektron on January 28, 2015, 07:46:56 PM
hmm maybe. have you ran it with Java -jar FBOParticles.jar ?
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 28, 2015, 11:39:54 PM
Nope, still no luck. It says Fps: 60 Particles: 2350296 (tex size: 1536).


I also tried uninstalling Java then installing it again (both 32 and 64 bits) and still no luck. I am thinking it's just my graphic card that cannot handle it properly. It's from late 2011 or early 2012, after all.
Title: Re: FBO Particle System
Post by: CKH4 on January 29, 2015, 02:11:10 AM
On the subject of errors this happens when I try to run on Android via phoneME.
(http://i.imgur.com/irgzUBr.jpg)
Title: Re: FBO Particle System
Post by: TheMachine02 on January 29, 2015, 08:55:44 AM
There is definitly something wrong with one unsupported extension, since my intel HD3000 (openGL 3.0 I think)  can't run this program, but my nvidia710M (openGL 4.4) can.

16000000 of particles  O.O
(http://i.imgur.com/vHOYrrW.png)
Title: Re: FBO Particle System
Post by: Snektron on January 29, 2015, 09:14:28 AM
Quote from: CKH4 on January 29, 2015, 02:11:10 AM
On the subject of errors this happens when I try to run on Android via phoneME.
(http://i.imgur.com/irgzUBr.jpg)
Well what did you expect? PoneME is java ME and my particle program is java SE.
Also i don't think there are android lwjgl natives so that defenitely won't work.
Nice try though, i shall think about an Android port :P.

Quote from: TheMachine02 on January 29, 2015, 08:55:44 AM
There is definitly something wrong with one unsupported extension, since my intel HD3000 (openGL 3.0 I think)  can't run this program, but my nvidia710M (openGL 4.4) can.

16000000 of particles  O.O
Any error messages? And 16M *.* That's a lot. At what FPS is that? :P
My poor AMD R7 250 can just about hanlde 10M at 15 fps.

Quote from: DJ Omnimaga on January 28, 2015, 11:39:54 PM
Nope, still no luck. It says Fps: 60 Particles: 2350296 (tex size: 1536).


I also tried uninstalling Java then installing it again (both 32 and 64 bits) and still no luck. I am thinking it's just my graphic card that cannot handle it properly. It's from late 2011 or early 2012, after all.
Oops, looks like i accidently released my heavy version. Anyway i shall add some native error checks, to see
if they have some errors. strange you can't run this but can run Minecraft, since minecraft also uses FBO's, Shaders
etc (but not OpenGL 3 so maybe that's the case).
Title: Re: FBO Particle System
Post by: TheMachine02 on January 29, 2015, 10:37:44 AM
16M is like at 4fps :p
Same error as DJ_O, nothing appears, no error is produce, just nothing is displayed. OpengGl 3.3 is available on this card though, and minecrfat run on it (badly, but run).
And minecraft don't use shader as my knowing .... it realllly bad code. It use openGL 2.0 or so.

Title: Re: FBO Particle System
Post by: CKH4 on January 29, 2015, 01:07:29 PM
Ok, that makes sense. I was expecting that it would work because I believe that phoneME has open gl and Java 3d support. So yep, failure to read on my part.

Is the source available? I'd like to try to learn Java (and get better at GLSL because I pretty much suck).
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 29, 2015, 01:27:11 PM
@Cumred I got an AMD Radeon HD 6700 series. I also have OpenGL 6.14.10.12002.
Title: Re: FBO Particle System
Post by: Snektron on January 29, 2015, 02:30:42 PM
Quote from: DJ Omnimaga on January 29, 2015, 01:27:11 PM
@Cumred I got an AMD Radeon HD 6700 series. I also have OpenGL 6.14.10.12002.
Seems legit, the latest openGL version is 4.5
EDIT: looks like windows uses it's own version codes ??? classic Microsoft

Quote from: TheMachine02 on January 29, 2015, 10:37:44 AM
16M is like at 4fps :p
Same error as DJ_O, nothing appears, no error is produce, just nothing is displayed. OpengGl 3.3 is available on this card though, and minecrfat run on it (badly, but run).
And minecraft don't use shader as my knowing .... it realllly bad code. It use openGL 2.0 or so.
Hmm i really need to find out what's causing that... :(
Also minecraft does in fact use shaders and framebuffers (i occasionally make mods, so i can look through the source :P).

Quote from: CKH4 on January 29, 2015, 01:07:29 PM
Is the source available? I'd like to try to learn Java (and get better at GLSL because I pretty much suck).

Not yet, but it will. I was first just gonna finish the project, but i've decided to continue working on it...
As of right now the code is quite messy and the first thing i'm gonna do is rewrite and reorganise a lot of
code. I'm not a great fan of working with Github when i do a solo project, but after the code is cleaned up i'll
upload after every update :). Also if you ever need any help with Java/GLSL i'm glad to help :).
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 29, 2015, 03:15:32 PM
Yeah I checked online and was surprised that my version was this high. This is what AMD Catalyst control center reports, at least.
Title: Re: FBO Particle System
Post by: Snektron on January 29, 2015, 03:42:18 PM
Debug release
to anybody having problems, i've released a debug version, which checks for errors after every
OpenGL call.
Download  (http://quantuminfinity.net/files/Particles-debug.jar)
This does require to be ran via the command line, because i don't have a custom logger.
java -jar Particles-debug.jar
Please post the error message :)

oh, and a small hint for people who don't know:
on most systems you can use ' > file' after a command to print it to a file
java -jar Particles-debug.jar > out.txt
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 29, 2015, 03:53:48 PM
This one freezes... O.O


But here is the debug info:

QuoteException in thread "main" org.lwjgl.opengl.OpenGLException: Out of memory (1285)
        at org.lwjgl.opengl.Util.checkGLError(Util.java:59)
        at org.lwjgl.opengl.GL11.glDrawArrays(GL11.java:1205)
        at net.quantuminfinity.particles.VBOPointCloud.render(VBOPointCloud.java:25)
        at net.quantuminfinity.particles.Renderer.onDraw(Renderer.java:213)
        at net.quantuminfinity.simpleengine.Engine.loop(Engine.java:72)
        at net.quantuminfinity.simpleengine.Engine.start(Engine.java:37)
        at net.quantuminfinity.particles.Particles.<init>(Particles.java:17)
        at net.quantuminfinity.particles.Particles.main(Particles.java:24)
Title: Re: FBO Particle System
Post by: Snektron on January 29, 2015, 04:05:40 PM
Yeah it's supposed to freeze, but it worked :D
now i finally have some error codes to work with.
Title: Re: FBO Particle System
Post by: TheMachine02 on January 29, 2015, 04:06:33 PM
Well, I test it, and for me it does .... nothing. No error - no drawing ><
Title: Re: FBO Particle System
Post by: Snektron on January 29, 2015, 04:07:56 PM
wut. What's the exact command you ran it with?
Also @DJO my first guess is that you do not have enough (v)ram.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 29, 2015, 04:17:27 PM
I have 1 GB vRAM
Title: Re: FBO Particle System
Post by: Snektron on January 29, 2015, 04:19:04 PM
I did some reading up and appearantly the call i use to draw the points
(stored in a point cloud) causes a memory leak on some drivers.
i'll see if there's a way around this.
Title: Re: FBO Particle System
Post by: TheMachine02 on January 29, 2015, 04:19:46 PM
I run it with :
java -jar Particles-debug.jar
pause

actually my G710M have also 1GB GDDR3, so VRAM size is not pb of DJ_O

I test it with GPU-Z, my intelHD3000 does do something, but idk what ><, memory comsuption went okay.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 29, 2015, 04:28:02 PM
OMG I got it!!! *.* :w00t:

When I tried updating my drivers earlier I looked at the wrong location on AMD's website. Their site is confusing and now I found where to check. I finally found a more recent driver update and now the program works. :D

You should maybe look into making it compatible with older drivers and hardware, though, since many people got older machines.
Title: Re: FBO Particle System
Post by: Snektron on January 29, 2015, 04:29:10 PM
Yay! and i don't know if that's possible since the error is in the driver...
i may be able to add a secondary rendering method though...
Title: Re: FBO Particle System
Post by: matrefeytontias on January 29, 2015, 08:08:01 PM
The "latest" version that you put on page 3 crashes a second after showing both windows without me doing anything. That's the exe version by the way.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on January 29, 2015, 08:12:28 PM
Yeah he told me that it's supposed to do that apparently.

Also wow at 2048x2048! O.O
Title: Re: FBO Particle System
Post by: Snektron on January 29, 2015, 08:32:52 PM
That's the debug version DJO :P and there's no debug exe. Strange that it crashes,
Try running it via the command line and post any errors.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 02, 2015, 04:26:58 AM
By the way I think the FPS counter is a little off. Sometimes I notice that the frame rate drops a bit for a while, yet it still displays 60 FPS in the title bar.

Also one setting in particular is interesting. You can draw stuff :D

(https://img.ourl.ca/thegamefbo.png)


Also I think if I ever needed to make video animations this could be useful *.*
Title: Re: FBO Particle System
Post by: Snektron on February 02, 2015, 08:00:28 AM
Wow i didn't even realize you could do that :P
I also thought of makeing an audio visualiser with this kind of particle system,
but ill do that maybe later.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 02, 2015, 12:15:32 PM
Oh that would be cool actually.

What would be cool though is if you allowed people to run scripts so that animations could be programmed. Eg a script where you move the cursor from one point to another in a few seconds, then hold right mouse button for 1s, then left for 1s. In sound case it would be nice as well as people could use this to make music. :P
Title: Re: FBO Particle System
Post by: CKH4 on February 02, 2015, 03:42:57 PM
DJ O: I had noticed it before, you're much more accurate than I am. Also your script suggestion would be cool but  it may already be possible with a current program.

Cumred: Yes that would be great.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 02, 2015, 04:54:31 PM
Quote from: CKH4 on February 02, 2015, 03:42:57 PM
DJ O: I had noticed it before, you're much more accurate than I am. Also your script suggestion would be cool but  it may already be possible with a current program.

Cumred: Yes that would be great.
what is the current program? Is it open-source?
Title: Re: FBO Particle System
Post by: Snektron on February 02, 2015, 07:03:47 PM
That reminds me actually, i wanted to put the source on GitHub. I'll do that now :P
EDIT: Done: https://github.com/RobinDeWalvis/ParticleSystem (https://github.com/RobinDeWalvis/ParticleSystem)
Since i'm not a great of working with GitHub when it's a solo project,
this wil not regularly be updated (i'll upload everytime i update something).
Title: Re: FBO Particle System
Post by: CKH4 on February 03, 2015, 12:47:40 AM
I was thinking something similar to this, http://tuxradar.com/content/xdotool-script-your-mouse (http://tuxradar.com/content/xdotool-script-your-mouse).

Also yay for source.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 03, 2015, 01:04:39 AM
Quote from: Cumred_Snektron on February 02, 2015, 07:03:47 PM
That reminds me actually, i wanted to put the source on GitHub. I'll do that now :P
EDIT: Done: https://github.com/RobinDeWalvis/ParticleSystem (https://github.com/RobinDeWalvis/ParticleSystem)
Since i'm not a great of working with GitHub when it's a solo project,
this wil not regularly be updated (i'll upload everytime i update something).
Cool to hear :D. Just make sure to backup often if you don't update your GitHub repo regularly, though.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 21, 2015, 03:16:41 PM
Do you plan to expand this further or even use the engine in a game, by the way?
Title: Re: FBO Particle System
Post by: Snektron on February 21, 2015, 04:42:12 PM
I was actually thinking of making some things like emitters, attractors, black holes etc. But ill have to see :p
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 21, 2015, 06:48:06 PM
Maybe miotatsu could use it for magic spells in Piworld :P
Title: Re: FBO Particle System
Post by: Snektron on February 22, 2015, 06:03:58 PM
You forget that PiWorld is in C and my particle system in Java :P. Though it shouldnt be too hard to port it :)
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 23, 2015, 02:56:08 AM
Oh right, I forgot about that. How does it run so fast though? O.O (seeing how laggy Minecraft could get back then)
Title: Re: FBO Particle System
Post by: Snektron on February 23, 2015, 07:02:44 AM
That's because it uses the GPU to handle updates :P.
The only thing java does is some shader code and the update loop. Basically the position and velocity are stored in 2 textures. Then i use a technique called render to texture which updates the pos and vel tex. Then the pos yex is rendered to the screen. :P (ill explain a bit more later, dont have time atm)
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 23, 2015, 04:56:31 PM
Oh right, I always forget about the GPU. :P
Title: Re: FBO Particle System
Post by: Duke "Tape" Eiyeron on February 23, 2015, 05:07:29 PM
It's funny how this *simple* program made me rethink about my general knowledge on the computer programing model. USing GPUs as anything other than 1337 games rendering became quite useful and we should now take them in account when developing heavy programs. I'm not saying anything not obvious but heck, tell the guys which made the GeForce 256 that one day we could use their future GPUs for processing medical samples, rendering epic GFX for movies or just process a frigging lot of data not related to polygon sorting!
Title: Re: FBO Particle System
Post by: Snektron on February 23, 2015, 06:00:45 PM
Quote from: Eiyeron on February 23, 2015, 05:07:29 PM
rendering epic GFX for movies

You think they are not used for that? Even blender has a build in mode which renders using the GPU :). Also, the amount of data they can proccess makes them excellent for btc mining. Oh and using the gpu for things like you suggested is called GPGPU, you might want to read up upon that :)
Title: Re: FBO Particle System
Post by: Duke "Tape" Eiyeron on February 23, 2015, 06:04:47 PM
Quote from: Cumred_Snektron on February 23, 2015, 06:00:45 PM
Quote from: Eiyeron on February 23, 2015, 05:07:29 PM
rendering epic GFX for movies

You think they are not used for that? Even blender has a build in mode which renders using the GPU :). Also, the amount of data they can proccess makes them excellent for btc mining. Oh and using the gpu for things like you suggested is called GPGPU, you might want to read up upon that :)

I was specefically talking about such uses of the GPUs. (-_(//));
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 23, 2015, 11:52:49 PM
Then there are also 4K demos. Those look really impressive considering they fit under 4 KB of code. I wonder if they would run on older computers or if they just use slower code shortcuts in order to keep size to a minimum? On calcs, some people will optimize for size and it will slow the game down, but at one point you can't really optimize for size anymore because it will get so slow on such older CPU/lack of GPU that the game will become unplayable. But on higher end computers even the sky isn't the limit. :P
Title: Re: FBO Particle System
Post by: Snektron on February 24, 2015, 07:19:58 AM
With a bit of dirty code i can prop this all in one class file under 4K too. But modern GPU's have enough vram for quite a lot of data (except for the crappy 2mb integrated ones).
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 24, 2015, 07:35:35 AM
But I remember that many games before that required a 32 MB GPU would often not run on my 64 or 96 MB integrated Intel GPU. Sometimes they also require pixel shader support or various other things. Does your particle system require such dependencies or others?
Title: Re: FBO Particle System
Post by: Snektron on February 24, 2015, 08:50:01 AM
Well, yeah, but i've implemented a check in my partile system to see if the GPU has the needed features (Shader support, FBO support, OpenGL >= 3.0). Also it needs at least texsize*texsize*2*4*2*2 + texsize*texsize*4*4 bytes of vram (4 4-component 16-bit textures for pos and vel (2 for reading 2 for writing),  and a 4-component (vec4) 32 bit float point cloud with the same amount of vertices as the number of pixels in the pos texture).











texsizevram needed
51212.6 MB
102450.3 MB
1536113.24 MB
2048201.3 MB
2560314.6 MB
3072453.0 MB
3584616.6 MB
4096805.3 MB
And that doesn't include the Shader's size :P
Title: Re: FBO Particle System
Post by: Duke "Tape" Eiyeron on February 24, 2015, 01:53:48 PM
CPU VRAM or GPU VRAM?
Title: Re: FBO Particle System
Post by: Snektron on February 24, 2015, 02:12:49 PM
Since when does a cpu have vram...
Title: Re: FBO Particle System
Post by: Duke "Tape" Eiyeron on February 24, 2015, 02:48:14 PM
Since they do have integrated GPU? Joke aside, I haven't corretly read your post nor written my reply. I meant that RAM can be used as storage memory for GPUs and thus wnated to know if your system could support integrated GPU memory.
Title: Re: FBO Particle System
Post by: Snektron on February 24, 2015, 03:27:03 PM
I dont know actually ;D
Title: Re: FBO Particle System
Post by: CKH4 on February 24, 2015, 03:35:13 PM
It works on my r5 integrated.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 24, 2015, 05:21:52 PM
What's cool is when a game requires certain video features, but will automatically decrease graphics quality or remove game features if the GPU doesn't support them. The game might look like crap (for example, when I played Halo on my Intel Celeron textures were very poor quality) but at least you'll still be able to play it. Many stores over here do not refund you if you buy a game, install it and find out it doesn't work at all.
Title: Re: FBO Particle System
Post by: Snektron on February 24, 2015, 05:24:21 PM
Isn't that why video settings is a thing :P?
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 24, 2015, 05:27:02 PM
Nah. Some games will not even run at all if your GPU doesn't support them. Windows will throw and error or the game will crash. In such case, the video settings screen won't be of any help. And in the case where you can setup video settings before launching the game, then I saw many instances where even at minimum settings some games would still fail to run.


At least Halo Combat Evolved just warned me that my card was not supported and that features will be greatly reduced. The game ran perfectly, but textures looked much worse (Nintendo 64 quality) than what they would look like at minimum settings.
Title: Re: FBO Particle System
Post by: Snektron on February 24, 2015, 05:31:28 PM
I often find that when i run games in low res textures, i'd rather have nearest neighbor than linear interpollation. But maybe that's just my opinion :P
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on February 24, 2015, 05:42:28 PM
Indeed, but it depends for me. Some textures and 3D really look bad without linear interpolation (eg some Playstation 1 games). I usually prefer nearest neighbor at lower resolution (eg 320x240 and even then sometimes 160x120 might be more ideal if graphics are too blocky). But yeah, if I take the following picture, for example, I prefer the N64 one (except the floor maybe):

(http://www.geeksundergrace.com/wp-content/uploads/2014/11/2.png)
http://www.geeksundergrace.com/wp-content/uploads/2014/11/2.png
Title: Re: FBO Particle System
Post by: Snektron on April 12, 2015, 01:01:13 PM
After doing some other projects for a while, i think i'm going to work on this again. I want to add something to choose from multiple shaders,
for example a vectorfield particle shader and a blur post shader. I've already made the classes for these since i was experimenting:
(http://i.imgur.com/RuJUBx8.jpg)
every update it adds a noise value to x and y, resulting in some kind of patterns.
Title: Re: FBO Particle System
Post by: Duke "Tape" Eiyeron on April 12, 2015, 01:49:03 PM
Quote from: DJ Omnimaga on February 24, 2015, 05:42:28 PM
Indeed, but it depends for me. Some textures and 3D really look bad without linear interpolation (eg some Playstation 1 games). I usually prefer nearest neighbor at lower resolution (eg 320x240 and even then sometimes 160x120 might be more ideal if graphics are too blocky). But yeah, if I take the following picture, for example, I prefer the N64 one (except the floor maybe):

(http://www.geeksundergrace.com/wp-content/uploads/2014/11/2.png)
http://www.geeksundergrace.com/wp-content/uploads/2014/11/2.png

Actually, I prefer PS1's pixellated textures. ^^
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on April 13, 2015, 10:57:56 PM
Nice that you are working on this again Cumred. :D
Title: Re: FBO Particle System
Post by: Duke "Tape" Eiyeron on April 14, 2015, 10:37:17 AM
Yeah, that's a fun project and I'd like to see much more doable effects with my GPU! :D
Title: Re: FBO Particle System
Post by: Snektron on April 14, 2015, 01:23:36 PM
I'm glad you guys like it :) i started to update to lwjgl 3, but it doesn't really seem to work so maybe i'll just keep it lwjgl 2.9.
Title: Re: FBO Particle System
Post by: Snektron on September 28, 2015, 09:55:07 PM
(http://i.imgur.com/18bE2eL.png)

I've been looking into Compute Shaders, which are a seperate type of shader. Instead for drawing, these are more for data processing and computing (hence the name). It also allows users to store data in the VRAM in normal types, so i can use that instead of some weird texture storage. Also it way more precise, so the result should be better looking and faster :) I will be experimenting some more with this. If i release something i should probably make another topic though.
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on September 29, 2015, 05:48:32 AM
Looks interesting. I am curious about what kind of animations and renderings you could do with that technique. Make a topic when ready :)
Title: Re: FBO Particle System
Post by: Snektron on September 29, 2015, 09:24:03 PM
For starters i can now really easily make 3D particle things.
Actually, i was coming up with some ideas to integrate this into a minecraft mod - The player would place a particle controller of some kind.
Then, with blocks like arrows, black holes and white holes it would create a gravity field after right clicking it or something. then it would upload that gravity field to
the gpu where it updates and draws the particles. it would allow for some amazing effects. And since its a clientside thing mainly, every player can set how many particles he/she wants to render, if at all.
Title: Re: FBO Particle System
Post by: semiprocoder on September 29, 2015, 09:28:18 PM
sounds really cool. Hopefully you finish this cause I've been needing some new mods to revitalize my interest in the game.
Title: Re: FBO Particle System
Post by: Snektron on September 29, 2015, 09:29:56 PM
Im actually still thinking about it, but i'll try to start soon :)

On a side note:
(http://i.imgur.com/hUSVJW9.png)
98% GPU Load oops
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on September 30, 2015, 03:00:22 AM
I like the idea Cumred. Also maybe the engine could be used in an actual FPS where textures are basically particles. It would be a bit like that LSD game on the original Playstation console, but still interesting. :P
Title: Re: FBO Particle System
Post by: novenary on October 01, 2015, 12:09:26 PM
Can you add rainbow mode ? :P
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on October 04, 2015, 08:22:44 PM
That would be interesting to see actually, although it depends in which pattern the particles are rendered. The result wouldn't be that great if they are randomly generated, since it would just be like static on a TV. :P
Title: Re: FBO Particle System
Post by: Snektron on October 04, 2015, 10:17:55 PM
I could make the color rely on the position of a particle, that would be cool.
Title: Re: FBO Particle System
Post by: c4ooo on October 04, 2015, 10:23:43 PM
It would be cool if there was an fps like this, with the user being to select beatwean two different color schemes- either by having the particles be colored on basis of distance from user, or by (in-game) "heat" (Like infrared).

Also, you should forget that you still have a cpu :P
Title: Re: FBO Particle System
Post by: Snektron on October 04, 2015, 10:46:55 PM
Welcome to the world of shaders m8. Cpus are only usefull for getting data to shaders :P

In the mod i could have a color block make the color of particles at a position anf interpolate between multiple blocks
Title: Re: FBO Particle System
Post by: Dream of Omnimaga on October 04, 2015, 11:18:01 PM
Quote from: Cumred_Snektron on October 04, 2015, 10:17:55 PM
I could make the color rely on the position of a particle, that would be cool.
That would be indeed. You could maybe do like the Rainbow Road in Mario Kart Wii and Seven?
Title: Re: FBO Particle System
Post by: Snektron on October 04, 2015, 11:19:11 PM
Yeah that would be cool