How Do I Hack Mass Particle Simulation

Get help using Construct 2

Post » Tue Jul 05, 2016 2:38 am

Hello Everyone. I Have A Rather Weird Question/How Do I.

I Am Trying To Make A Falling Sands Type Game I Can Get Everything Working But The Problem I Get Really Poor Performance With A Decent PC.

And The Reason I Put The Title To That Is Because I Saw This Post: scirra.com/forum/falling-sand-on-gpu-through-pixel-shader_t78983
And I'm Trying To Figure Out How To Do Something Similar To This And Expand On It. And I'm Willing To Learn A lot if Needed To Put This to Use.

Any Help Would Be Great.
B
21
S
9
G
1
Posts: 15
Reputation: 2,055

Post » Tue Jul 05, 2016 4:49 am

To use a shader to do it you'll need two things:
1. A effect to do it
2. To store the result of the effect into a texture so it can be used for the next frame.

I'll start with 2 since that's somewhat simpler. You'll need the paster object to do this. Ideally you could have the effect on the paster object and paste it to itself every frame, but you can't paste an object onto itself. So instead you'll need two pasters with the effect and you'll need to alternate the object you're pasting from and pasting to.
So basically the first time do this:

Paster1: disable effect
Paster2: enable effect
Paster1: paste paster2

Second time do this:

Paster1: enable effect
Paster2: disable effect
Paster2: paste paster1

And repeat from the start.

As far as the effect there isn't really a good reference. My thought is you could do it with two effects.
One to move the sand down. It's logic would look like this:

If pixel=white and pixel below is black
Then set result to black
If pixel=black and pixel below is white
Then set result to white

Then the second would shift even or odd scanlines left or right.

So the effects run for one frame could be:
Down
Odd left
Down
Odd right

This really cries for a test, but webgl doesn't work on my computer.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Tue Jul 05, 2016 5:04 am

I'm Sorry But I'm Completely Lost. How Would I Execute Any Of This? I Know You Said Webgl Does not Work On Your computer But is there anyway you could give me an example? And For The Effect Is This Canvas Plugin Or? Sorry Inadvance I'm A Noob.

Edit: I Have Done Some More Digging And I Have Found This Made By You A While Back:


Quazi's method would work just as fast in C2 except there is no way in C2 to save the result of an effect to use on the next frame.

Other than that the logic to move the pixels is simple.
* if the area is free below a pixel is free move it down.
* if the area is not free try to move down left or down right if those areas are free.

Here is a demonstration using my canvas plugin. As you can see it is very slow. For this sort of thing you'll want a method a lot faster, but for that you'll have to delve into some javascript.
dl.dropboxusercontent.com/u/5426011/examples17/sand.capx


But I Still Don't Quite Understand.
B
21
S
9
G
1
Posts: 15
Reputation: 2,055

Post » Tue Jul 05, 2016 5:57 am

I can't attempt to make an example for a day or so.
You won't need the canvas plugin, you'll need the "paster" plugin. It's much like the canvas plugin but it can utilize webgl. Notice web browsers used to let my machine use webgl.

Other than that the rest is just a rough outline.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Tue Jul 05, 2016 6:25 am

Thank You Ill Look That Up Thanks For The Help.
B
21
S
9
G
1
Posts: 15
Reputation: 2,055

Post » Tue Jul 05, 2016 7:57 pm

Here's the example with two required shaders. It also requires the paster plugin.
https://dl.dropboxusercontent.com/u/542 ... shader.zip

black is empty
white is wall
everything else is a particle.

There are probably other ways to improve it, but since it's using webgl I get very low fps.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Tue Jul 05, 2016 8:13 pm

@Thelegendvinny If you ever get an optimization working, let me know please.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Tue Jul 05, 2016 8:37 pm

@R0J0hound The Example Works Great But The Only Problem Is The Physics, How Could I Get The Physics Working?
B
21
S
9
G
1
Posts: 15
Reputation: 2,055

Post » Tue Jul 05, 2016 9:04 pm

The example is the physics. The particles move down and shift left and right to settle in heaps instead of tall pixel piles. That is roughly what the particles example you referenced does, except it has more spread.

Did you have a different kind of physics in mind?
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Tue Jul 05, 2016 9:55 pm

@R0J0hound For Some Reason It Does Not Do That In Mine. I Have The Paster Plugin And I Put The 2 Effects In The Construct 2 Effects Folder. Is there anything else I had to do? All Mine Does Is Just Float No Physics What So ever. I Don't Know Why I Did Not Edit Anything.
Last edited by Thelegendvinny on Tue Jul 05, 2016 10:04 pm, edited 1 time in total.
B
21
S
9
G
1
Posts: 15
Reputation: 2,055

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests