Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2D Instanced GPU Accerelated Object (Extension Idea) #1726

Open
YogaindoCR opened this issue Oct 16, 2024 · 7 comments
Open

2D Instanced GPU Accerelated Object (Extension Idea) #1726

YogaindoCR opened this issue Oct 16, 2024 · 7 comments

Comments

@YogaindoCR
Copy link

YogaindoCR commented Oct 16, 2024

Since 3D GPU Accelerated project is possible, Why don't we make a 2D GPU Accelerated extension?
I know this is possible using Simple 3D, But it takes some work to implement.

Isn't this a good idea? Having a lot of object in scratch without worrying about lags

@YogaindoCR YogaindoCR changed the title 2D Instanced GPU Accerelated Object 2D Instanced GPU Accerelated Object (Extension Idea) Oct 16, 2024
@David-Orangemoon
Copy link
Contributor

Most of the lag that comes from scratch 2d isn't really scratch's doing. It already uses the gpu to draw everything and transform it. Though the big hurdle is stuff that should only happen cpu side.

@YogaindoCR
Copy link
Author

YogaindoCR commented Oct 16, 2024

Most of the lag that comes from scratch 2d isn't really scratch's doing. It already uses the gpu to draw everything and transform it. Though the big hurdle is stuff that should only happen cpu side.

Well, having a single sprite that has a entire 2D RPG map image with thousand object in it. It's way better than having a thousand clones with each has their own "For this sprite only variable", "For this sprite only list", Broadcast listener and so on. Scratch CPU bottlenecking is horrendous.

I used an low end spec, the 100% CPU and 20% GPU Usage on Turbowarp games is very concerning.

This extension might be the solution for a bigger project that used a lot of clones.

@CST1229
Copy link
Collaborator

CST1229 commented Oct 16, 2024

Well, having a single sprite that has a entire 2D RPG map image with thousand object in it. It's way better than having a thousand clones with each has their own "For this sprite only variable", "For this sprite only list", Broadcast listener and so on. Scratch CPU bottlenecking is horrendous.

I think Pen works for this (that also uses the GPU).

@David-Orangemoon
Copy link
Contributor

Most of the lag that comes from scratch 2d isn't really scratch's doing. It already uses the gpu to draw everything and transform it. Though the big hurdle is stuff that should only happen cpu side.

Well, having a single sprite that has a entire 2D RPG map image with thousand object in it. It's way better than having a thousand clones with each has their own "For this sprite only variable", "For this sprite only list", Broadcast listener and so on. Scratch CPU bottlenecking is horrendous.

I used an low end spec, the 100% CPU and 20% GPU Usage on Turbowarp games is very concerning.

This extension might be the solution for a bigger project that used a lot of clones.

It would probably be best to not have objects off screen or after a certain distance ticking, and as CST said Pen Rendering would be your best bet.

@YogaindoCR
Copy link
Author

YogaindoCR commented Oct 17, 2024

I think Pen works for this (that also uses the GPU).

I tried this once before on the older version of turbowarp and lags a lot on my pc, Might gonna gave this another shot.

It would probably be best to not have objects off screen or after a certain distance ticking, and as CST said Pen Rendering would be your best bet.

I already this, I made a system where if the clone was on outside the screen it will automatically deleted and recreated again when inside the screen, It helps but if it had many object to render, the game stutter for a milisecond to check and spawn the clone that inside the screen.
I might consider this extension as a another shot for game optimization.

@YogaindoCR
Copy link
Author

YogaindoCR commented Oct 21, 2024

I just tested out all method to prove that using GPU is a good idea!
Here is what I test with Clones, Stamping, GPU 2D Instancing ( Using Simple3D )

1000 Clones:
Clones
It's already dropping framerate on 1000 clones in 24~ FPS

1000 Stamping:
Stamp
Even worse, on 18~ FPS, Stamping is not a good idea.

10000 GPU Instancing ( Removing the X variable readout adding 10fps )
image
180~ FPS!! it's 100x times faster than stamping! Well it's instanced, so it run way faster.
But we got an Image how efficient this idea is.

image
We can use the CPU for another else, no longer CPU bottlenecking!

@FurryR
Copy link
Contributor

FurryR commented Nov 10, 2024

Uhh so why can't we apply this tech to clones or stamps?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants