so, i know this isnt exactly python, but im making a game in unity and i have two terrain generating scripts, one generates a bunch on tiles underneath a parent, and the other determines how many parents to place in the world. I want to generate caves, but if i put it in the parent class, the caves might get cut off since those parents are just one chunk of the whole, and if i put it in the parent-placing class, it would be harder to access/destroy the cubes that make up the parent classes in order to generate caves. With you guys having a coder's mindset, i was wondering if i could help get some insight on where to add my terrain generation process.
#game-development
1 messages ยท Page 49 of 1
@fierce wraith Just saying there is a huge difference between feeding the previous buffer back to the compute shader and always feeding it with the original buffer. If you can get away with always feeding the original values, do that.
it may also be that these inaccuracies are not a big problem at all
.. if you are doing "transform feedback" type compute shader
@fierce wraith I see in the code that you are are swapping the buffers. Could you instead calculate the planet position from the original position? That should be a lot more accurate because feeding back the calculated values should definitely keep enhancing inaccuracies per frame.
You would experience the same issue doing these calculations on the CPU
So yes. Like you said.. the value will drift when you calculate them using feedback
Instead pass in a time uniform and move them from the original position every frame.
.. or live with the inaccuracies
i figured it out! @potent ice
woot?
this is me hardcoding a value into the velocity vector by just always setting it to a dvec3(1):
(0.0, 1.0, 1.0)
(1.0, 0.0, 0.0)```
it starts one number to late into the velocity vector
and then writes the last one into the force vector
its messing up by padding the vectors
for some reason it thinks the velocity vector starts 4 numbers in
and then it just sets the next 3 numbers
but the last one is in the force vector
see how the 1 slips into the next line
does this have something to do with the std430 layout?
layout(std430, binding=1) buffer planets_out
{
Planet planets[];
} Out;```
ah. I see. You'll probably still get some inaccuracies, but I guess this just greatly enhanced it
It it even a problem?
well yeah its writing into the wrong vector
pushed your code?
yup just now
Ahh. It's the std430 alignment rules I guess
yeah but how would i fix that?
I think that is the best explanation I have found
yeah but then i should be fine right?
my largest size is 3*8
so why does the padding already mess up on the second dvec3?
That is in the second Planet entry?
yeah its
dvec3
dvec3
dvec3
float
vec4
So your structure is 108 bytes
er yep 92 ๐
Then the structure aligns at 96 bytes. (4 * 24)
So I guess each entry gets offset by 4 bytes?
struct Planet
{
dvec3 pos; // 3*8 bytes
dvec3 vel; // 3*8 bytes
dvec3 frc; // 3*8 bytes
float mass; // 1*4 bytes
vec4 col; // 4*4 bytes
}; // = 92 bytes
hm dont really get all this alignment and offset stuff.
It just means you have to add a 4 byte padding per entry in the array
but how can i add padding?
You have control over the struct.pack
just 4 bytes with anything like a dummy float or something
but writing to the buffer for the first time works fine
just outputting in the compute shader is broken
i think
or is just my reading broken
because it aligns for me
I'm not sure if it applies to both the input and output bufffer, but I would assume so
hmm ok ill have to figure it out tomorrow its way to late here ๐
but thanks for the help!
Your are on the right track at least. Sadly I don't have the hardware to test any of this at the moment
Worst case just make everything a double in your struct so it always aligns perfectly ๐
struct Planet
{
double px, py, pz;
double vx, vy, xy, vz;
double fx, fy, fz;
double mass;
double r, g, b, a;
};
The structure will have an 8 byte alignment this way and all entries fits perfectly
This is actually good for me as well because I have not messed with compute shaders in a long time.
Hm but the fragment shader doesnt like doubles!
For the color atleast
But yeah that seems like the easiest way to do it
Why do you need to pass the color in the compute shader?
I don't, I guess I could have a extra buffer... never thought of that
yup. much better
I always forget you can bind multiple buffers
I guess you can also have multiple in/out ssbos in the compute shader
A good tip I guess is also to greatly scale down what you are doing making a very minimal example just with a position and a velocity
See if you can render that first and expand later
I'm guessing you are using a compute shader here because it would be harder to interact with data for the other planets with transform feedback.
Yeah
Well it all worked fine on a small scale with floats
But I wanted to simulate our solar system and floats just cant keep up with that...
I guess you were just lucky with the alignment initially ๐
What is a good way to pack the data
yup yup nn!
Hi guys, I'm using a demo file messing around with the pygame module but no idea how to implement either a scroll or click and drag to move the camera around ๐
all i have atm but cant navigate around it ๐ is there an easy way to do it?
ps it's isometric not a 2d hill
128px blocks 29x49
map size
Do you know how to read mouse coordinates or mouse position delta?
Break your problem down into smaller ones and attack one at a time.
@potent ice for binding the vao, can i still use '3f8' even if my struct has 3 seperate doubles not a vector?
I don't see why not.
well maybe dvec3 has some extra info in it
and not just three doubles next to each other in mem
ill just try it ๐
It should not as far as I know. The only padding you get in ssbo is between the planet entries (I think)
Unless some datatypes expand. The std spec is fairly clear on these things. I have not read it recently. Look it up ๐
so because the struct is only doubles now the alignment should be correct right?
struct Planet
{
double px, py, pz;
double vx, vy, vz;
double fx, fy, fz;
double mass;
};```
and i can just have this at the beginning of the main func to get my vecs back:
dvec3 p = dvec3(in_planet.px, in_planet.py, in_planet.pz);
I think so yes. Each Planet instance should have an 8 byte alignment
What you had before was planet, 4 bytes, planet, 4 bytes ...
it works!!!
yup! it finally works haha
A lot of fun when you can access all data instead of being limited to proccessing separate incoming chunks of data like in vertex shader
Calculating gravity I guess?
yup.
Oh. Fun!
well it almost works ๐
I did that with transform feedback and 250k points (hard to display more on a screen), but that was simple with a single point of gravity. Your version sounds more fun.
yeah but it gets pretty slow pretty fast haha its O(n**2) after all
How many planets?
I'm thinking you can get away with around 64k
You can even download planet textures from nasa
that would look pretty cool!
but i dont even have them emitting spheres yet
just points
It maps on a geometry.sphere
Easy
GitHub
A light high performance modern OpenGL 3.3+ Python Framework https://demosys-py.readthedocs.io/ - Contraz/demosys-py
You can get som ideas here. Even has the milky way map
Looks more like a black hole
yup haha
just gotta go look up all the correct velocities for the planets hehe
ok i think the main bottleneck is just displaying it to the screen
i need more speeed
do i just wrap the compute shader in a loop?
i think the python function call to run the compute shader is taking pretty long
can i somehow tell the compute shader to do this?
for _ in range(1000):
self.calculate_force.run(group_x=self.NUM_GROUP)
# swap buffers
self._swap_buffers()
# run the compute shader
self.move_planets.run(group_x=self.NUM_GROUP)
# swap buffers
self._swap_buffers()```
because i think its the python overhead that is taking up most of the time
ideally i would run the two compute shaders 8_640_000 times per second inorder to simulate 10 days in one second with a dt of .1 seconds
but that seems kinda crazy
ok @potent ice im gonna try to render out a gif over a few hours of runtime, do i just render to a fbo and then save that to a image?
ahh was it simple frame buffer or just frame buffer?
I think you can use the screenshot module and dump directly from the window
window.fbo I think?
you mean moderngl_window.screenshot?
yes
AttributeError: module 'moderngl_window' has no attribute 'screenshot'
ah
yup works ๐
Forgot to make api docs for that. Fixing. It Easy enough to look at the source.
yeah it was the first result anyways ๐
how would i set the SCREENSHOT_PATH setting?
haha
Just to be clear, I only do that to Leterax.
and im fine with that haha
i must be doing something wrong, the gpu is only running at 50% utilization...
well im gonna take a picture every 12 hours of simulated time
so every 40 real seconds
You can disable vsync and use the frame counter as time to greatly speed it up
You can base it on 30fps even
ok, so 70 x speed with 30fps as a base
I think you could also make it faster by running multiple iteration of the cumpute shader per frame.
i tried that with a simple for loop but it wasnt any faster
ah ok ๐ฆ
hmm running slower than expected, about 1/4 of the way done after 1.5 hours.. i was expecting one hour
so far its looking good. this is with the real world values for the sun and earth ๐
Will the final gif anim take 1 year to watch?
yes! hahah
its speed up by a lot ๐
how does the sky sphere work here? https://github.com/Contraz/demosys-py/blob/master/examples/system/effects.py
since CULL_FACE is enabled, shouldnt it be invisible from the inside
Read again : self.ctx.disable(moderngl.DEPTH_TEST | moderngl.CULL_FACE)
The real resources are defined in dependencies.py by the way.
The code fetch resources by the label defined in that module
haha disable!
So I've never made anything with Renpy before
I haven't either
So im not sure it will know which text editor to associate with the files
it says the "associated one"
on Windows, you can associate applications to file extensions
you can check that if you right click on an file > Open with...
if I recall correctly
then you can check a box to make an association
what module should I use for video game development
Wing personal isn't there
if it's not on the list, you'll have to select the executable file manually
Ok idk how to do that
if you give me a second, I'll start up a Windows VM I never use
Epic thx
Now renpy wont open
it said to uninstall it and reinstall it
But that isn't working
this is the option
then if it's not in "Recommended" or "Other", you can click on "Browse"
(you need to check "Always use the selected program to open this kind of file")
remember you need to do that with a RenPy file
thank you
not an executable
But now it wont open
I feel you associated the RenPy binary file
you had to do that with a .rpy file (which you'll have to create yourself)
I don't know, lemme replicate it
I'll do the same thing, I have nothing to lose in the VM
no, there's no "open with" for exe files
Ok?
that screenshot probably means you just moved the file?
No
I mean
I did
But then I deleted it
It's now where it was before
I moved it again
Back to where it was when I first moved it
oh, it's a compressed 7z
yes, you probably just unzipped it somewhere and deleted something thinking you were deleting the installer
that's what I think
What does unzip mean
because the default path to extract RenPy is the one the .exe is (so you didn't install anything, you just extracted it to Downloads/)
unzip means uncompress a zip
like
just think of that .exe you downloaded as a file that contains files
download the latest version for you (the green button, SDK 7z.exe)
then open it, but change the path
you need to select a folder, actually, where you want to have all the RenPy files
for example
you could choose something like C:\Users\Whatever your name in Windows is\Desktop\RenPy
well, this is more like a Windows thing
if you go to C:\Users you can find yourself, right?
That just took me to favorites
Oh it does
It took me to that
I know
I kinda wanted to show you what you're doing
if you don't want to, I can make the process faster
but you could learn a few things on browsing the typical Windows tree of directories
Nah you can show me
I don't plan to go too deep, it's quite basic anyway
alright, do you see a Users folder there?
Yes
double click on it
you should see a bunch (or at least one) folder inside of it
and one of those folders should have your username as its name
this is mine on my VM, for example
how many? it's not unusual to have a few
although it would be weird if you found like 30
There are a whole lot
can you find yourself there?
double click on the one you think it's you
I found appdata
appdata is not really relevant
F
Idk
It opened up command prompt
Ig thats what im used to
you see that C:\Users\John Lennon?
yes
John Lennon is my username on the VM
and C:\Users\John Lennon is the directory for my user account
so you should see something similar, with your name
Yeah I do
alright, then you can go with the file explorer there
did you know that's where your Desktop is?
No
Kewl
this is something you could do from the RenPy 7z, but let's do it from here
I want you to go to your Desktop (if you want to learn a bit, I want you to do it from the file explorer)
so basically going to C:\Users\whatever your name is
then \Desktop
How do i do that
first, open your file explorer
Alright
you're probably using Windows 10 - I don't remember which one is
from there, go to C:\
I just happen to have more experience with XP than with 10
Yayyy
that doesn't mean I remember everything, but still
so you see the C:\ disk, right?
in My Computer
No
or My PC, whatever its name is
do you think you can share a screenshot?
dang it
The snipping tool wont work when the windows bar is up
I'll rely on Google Images
this is My Computer
you have something like that, right?
It does not look like that lol
are you sure you're on XP?
that's not XP
looks like Windows 7 to me
Huh ok
There are 5 users folders
Yeah
you can know which folder is yours with that
No they all just say users
can you share another screenshot?
Ok hold on
if you want to share the entire screenshot, you don't need to use the snippet tool at all if I recall correctly
How do I take a screenshot with windows 7
you just need to press Prt Scr
there will be no visual feedback
but you can do Ctrl + V here afterwards
But I did?
see that?
I went to local disc?
that's not to go to folders
it's for searching things
so what you see there are a list of results
things named "users"
yes, it says those are results
Yeah and?
let me record a short video
Ok
I forgot to record the cursor...
F
that starts from My Computer
so you can see everything I'm clicking on
does that clear things up on how to get there?
But they do
I can do that too
but I don't have to search anything
you just need to click on thigs, you don't need to write anywhere, anything
scroll down
My dad has a lot of things on his computer and it's very hard to navigate
Ah ok
Found one
that's the one
Clicked on my username
well done
Thanks lol
yes
don't worry
feel free to learn from this, as long as you don't break your dad's PC
I want you to go to the Desktop folder (which is exactly that, your desktop)
Ok
I see it right in the middle
so, there's no much point in doing this from here - but I felt it was necessary
browsing files shouldn't be intimidating, you need to get a bit used to it
I want you to make a new folder in Desktop
name it RenPy
Where's that
it should be in your Downloads folder
which, since we're at it, it's in C:\Users\JC\Downloads
alright, then go to Chromium (I suppose) and press Ctrl + J
if you didn't delete it, it should be on that list
it's the renpy-7.3.5-sdk.7z.exe file
Where's chromium
maybe you don't use Chromium?
what do you use to surf the web? Firefox?
ah, Chrome, right
I meant Chrome
No, don't press accept
Ok
I mean, don't press "Extract"
you need to change the path
do you know what a path is?
It's where something goes right
Make it go to RenPy?
to explore your existing folders
alright, while it's working, go to your Desktop (you don't need to use the explorer if you don't want to, that was just to make you understand what you were doing)
It's done
and then check the RenPy folder there
if everything went well, you should find files there
nice!
you can delete that renpy 7z.exe file now
don't delete anything on that RenPy folder on your desktop
Now to figure out how to make a game with it
well I'm running out of time now, but you should have everything set up
I can help you with the editor thingie
Can I move the renpy folder to anothe folder?
yes, you can move the folder itself to anywhere else
sure
Bai
(but I might not be here, just ask)
Do you think it would be better for me to run Unity on a Windows PC with only 4GB RAM or on Linux with 8GB ram? Can you still develop multi-platform games on Linux?
4gb of ram wouldn't be enough
8gb of ram on linux should be ok on ubuntu and centos
haven't personally used unity on linux, but here are the docs to install on linux: https://docs.unity3d.com/2020.1/Documentation/Manual/InstallingUnityLinux.html
I used Unity for around 3 or 4 months, on Linux, and 8 GB was enough but very close to the limit at times. Depends on what you're working on. On the other hand, I used a Unity build in Archlinux and worked a bit like poop sometimes (but Arch is not "supported" anyway)
still, Unity doesn't use Python, but C#, be aware of that
Is Unity on Linux fine for creating games for Windows, Linux, iOS and Android?
I did export to Linux and Android, didn't bother to check the other two. I didn't have any issues with it. It was a VR game (but as I mentioned before, the general performance of Unity on Arch wasn't always great while editing - maybe it's much better on Ubuntu.)
If you need help with Unity, you should probably ask in the off topic channels. I don't think people here expect to use Unity.
@potent ice is there a option for moderngl to not clear the screen between calls to the render method? i tried just not calling the clear method but the screen then just goes black. its because im only actually rendering every n'th simulation step because well i dont need to render at 2.6kfps.
Thank you for your help
That is moderngl-window specific. When running a WindowConfig we do the most common draw loop for you that includes clearing. There are examples with custom usage in the example directory.
oh ok. its not that important, im rendering to a gif anyways and i can just check the most recent screenshot ๐
If you ever need it, it's not hard to change. Fairly boilerplate stuff
while i have you here, any fun things i could simulate now?
just our planets is pretty boring because i cant really use/show the power of the gpu with 9 bodies ๐
Hey um
I'm tryna use renpy
And I'm trying to make the character's text color change
But nothing I do works
Im following the instructions
But nothing works
I also can't get Agnes to talk instead of Elena
I also can't get that period to go away
This is what my code looks like, simplified
define e = Character("Elena")
a "Hello player!"```
But it always, always gives me this
Oh!
Nevermind?
I fixed it?
Somehow?
Ah ok I see what I did
I've been working with pygame and I need a solution to a problem with a car simulation I've been making
so
I need to find a way to rotate a rectangle as if it were driving
like you press the left key and it rotates counter clockwise
and I know there's no default support for this, but I'm wondering if anyone has any good work arounds
I don't wanna send my code in this channel cuz it's a lot, but if anyone with experience can DM me for some help, I'd greatly appreciate it
Are you talking about just an image or also a hitbox used for physics?
If itโs just an image, you can do pygame.transform.rotate()
Otherwise, youโll probably need to make your own system.
or use the per-pixel collisions and write a weird physics system
also a hibox used for "physics" I just need to check whether two elements overlap
is there really no good work around?
you can do per-pixel collisions with masks
If youโre just looking for the overlap
Iโve never used it tho tbh
thereโs plenty of tutorials on it
do u put the mask over an image?
ok thx
Keep in mind, if you want actual physics and not just overlap checks, youโll need to write that yourself
I just need overlap and rudimentary movement with translations
@fierce wraith Draw textured spheres with instancing at the planet positions.
One draw call
@summer pond If you want easy rotation of the car and hitbox, Arcade supports it by just changing the angle attribute of the sprite. But that doesn't help you if you are committed to PyGame.
how hard would it be to convert from pygame to arcade
Really depends on how far you've gotten, and how it is written. You can take a look at the sample code to get an idea: http://arcade.academy
I'm looking at it now, and tbh it looks a lot better
I taught with PyGame for many years, and things like rotation, scaling, were always a headache for students. So I tried to create a higher-performing library that made common operations easier for students.
Well, there are a lot of other people that contributed.
I kinda get rotation, but what was wrong with scaling?
Scaling graphics in PyGame was never as easy as it could be. Creating a sprite and just passing in a scaling number is way easier. Transparency wasn't done automatically. Generating hitboxes based on the transparency in the image wasn't done automatically. The curved primitive drawing functions produced a moire pattern. You can't rotate an ellipse. You were expected to make your own event loop. It didn't use OpenGL for drawing in a batch. And at the time I started Arcade no one was updating PyGame and you couldn't even do a pip install.
Anyway, after 10 years of teaching PyGame and one book written, the list of frustrations got long enough I started a different library.
(Don't get me wrong, I still like pygame and I'm glad development started again with it.)
Yup. They have managed to shape up things slowly in pygame2.
But you have to install the latest dev release from pip
There are certainly advantages with pygame. It's basically software rendering, so it can run on almost anything. The amount of platforms sdl/sdl2 based games can run on is insane.
.. but on modern PCs linux/win/osx you have powerful gpus that can do the job much faster. Even integrated intel and amd is awesome nowdays.
You can of course also combine pygame rendering and opengl, but that might be for more advanced users. You upload the pygame surface to a texture in opengl and do the remaining work with shaders. Lighting, postprocessing etc.
I actually love that combo ๐
Also, considering even lower budget PCs from 5 years ago have GL 3.3+ support.. they have access to really powerful functionality that can move expensive operations from python code into shaders.
.. that runs in microseconds.
What library to use really depends on what you are making and what platforms you want to cover. It's not always an easy choice.
Scaling and rotating would definitely be superior in GL based libraries unless you want the authentic 8bit style.
simply because you have better interpolation support and mipmaps.. and msaa.. and anisotropic filtering.
BUT. Drawing a cirlce in GL is not as simple as in pygame.
But I guess Arcade probably have support of that. I know Wasabi2D has it
has anyone made a tool that compiles python or something python-like to shaders?
the past times i've looked at GLSL, there were different versions that had frustratingly different ways of doing things
Even just drawing a line more than one pixel wide requires drawing two triangles. Circles take a bit of work!
@grand imp Use #version 330 or higher and things should be pretty consistent. (OpenGL 3.3+)
It get's confusing with version 120. It works with the fixed pipeline automatically sending in the old fixed pipeline matrix stuff + lots of other material and lighting stuff.
@frozen knoll You can use geometry shader to do lines and draw circle with fragment shader, but I guess that can be a challenge to batch draw with other geometry ๐
Ok so Im using renpy
And I want the player to input their name
Is is any different with renpy than with python?
Ok it is
I followed the directions on this website: https://www.renpy.org/doc/html/input.html
But it says this is wrong
name = renpy.input("Hello! Welcome to Mythical Creature Dating Sim! What is your name?", default="Your name", allow=abcdefghijklmnopqrstuvwxyz?!, exclude=None, length=None, pixel_width=None)
Now my code looks like this
name = renpy.input("Hello! Welcome to Mythical Creature Dating Sim! What is your name?", default="Your name", allow=abcdefghijklmnopqrstuvwxyz?!, exclude=None, length=None, with_none=None pixel_width=None)```
But it still doesn't work
What do I do
the allow part doesn't look like a valid string
Can someone pls help
wrong how
Idk it just says its wrong
I cant debug bc im using wing personal
I just have to run the game and see what it tells me is wrong
well I can't help if you don't have the error message
I also don't know anything about renpy lol
isn't wing able to tell you about syntax errors
renpy is a python library/engine, so renpy is python
you shouldn't ignore python syntax errors
hi
i need help with a small little code
for pygame
can anyone help?
its pretty urgent
its due tomorrow
I should be able to.
I'ma go do something for 30-45 mins then I'll be back for a couple minutes before I go to sleep.
Welp I just debugged it and it said my very first line of code is wrong
But renpy didn't
You should share the exact error message
this is more like it!
@potent ice that with the instanced rendering sounds very smart! sadly i dont have that much time rn, maybe ill get around to it next week or on the weekend
Turn off the heating in your room!
exactly! its perfect haha
@humble pewter
When using Ren'Py, the error message should be displayed in the window in which you launch your game?
Like this (I assume this is the error message you got):
In which case, yes, the problem was the lack of quotation marks around the allow argument!
This should work:
$ name = renpy.input("Hello! Welcome to Mythical Creature Dating Sim! What is your name?", default="Your name", allow="abcdefghijklmnopqrstuvwxyz?!", exclude=None, length=None, pixel_width=None)
Oh there should be quotation marks?
The dollar sign at the beginning is used to insert a one-line Python statement
Yup, since it's a string, as someone mentioned before!
So if I put a dollar sign, I can use it exactly like python?
@minor mortar also pointed this out earlier: "the allow part doesn't look like a valid string"
Ahhhh so that's what he meant
But you shouldn't use a lot of actual Python in Ren'Py
Most of the time, using Ren'Py script (the Python-like language used for simple actions like dialogues, displaying sprites, etc) should be enough!
Use Python when you need to set variables or access specific functions like renpy.input like you did
No problem!
Could you screenshot what you got as I did earlier?
Are you sure you put a dollar sign at the beginning of the line ?
But this is a renpy input right? And not a python input?
The dollar sign allows you to put "real" Python inside a Ren'Py script file (.rpy file)
Ok but this isn't real python right
It is!
Huh ok
I'll try that
It worked!
Wait
Now I can't type anything in it
Oh!
Yes I can! Nevermind!
Ah, great!
Also scrolling back up, I see that you had tried using a python: block to put this line and that should work too!
But you have to use a lowercase "p" letter in python or it won't work.
Otherwise, using the dollar sign in front of a single line as you just did is good as well.
The documentation explains both usages here: https://www.renpy.org/doc/html/python.html
Thank you ๐
Ok I have a question about renpy
Im making a menu right
What do I do if I want the color of the text in the menu to change
There is something in the docs about colors at least : https://www.renpy.org/doc/html/quickstart.html#characters
I have no idea. Never used it.. but the docs are there ๐
Thank you ๐
Ok I couldn't find anything about menus
I found something about menu arguments in another page
And I was like "Oh, so this is how you change the color"
But either it's not or I'm doing something wrong
menu (color="#f7bf69"):
This is what it looks like
My code I mean
mind blowing ๐ฌ https://www.youtube.com/watch?v=PMltMdi1Wzg
How to derive formula of the SDF of a Line Segment, a common shape in procedural modeling.
Support this channel: https://www.patreon.com/inigoquilez
Tutorials on maths , art, SDFs and computer graphics: http://iquilezles.org. The article that includes information about the E...
can someone pls help
Pls
hi guys, anyone who can explain me a few things on pygame and backgrounds please
I was pinged?
I don't recall the exact way to do right now, but for Ren'Py-centric questions like this one, you might have better luck asking in the official Ren'Py Discord server
There's a discord server for that?
Epic
Oh thank you, that's the one!
Sorry, we scrub invites by default since bots and people like to spam them
Thank you ๐
no problem, figured as much
And is that the official on for them?
Yup, it's the right one
Okay cool. I'll look into whitelisting it
@ember glade im stuck with the my code. i try to have the bouncy ball clean. at the moment it leaves a trail behind it and i cant find how to fix it. im stuck
@compact wasp Found the article I was looking at. It's old, but the information in it should be just what you need. https://www.pygame.org/docs/tut/MoveIt.html
Sorry for the late reply, had to answer a lot of questions for a co-worker that was having computer security concerns
@ember glade thank you very much!!! no problem at all. i will give it a good study and if i have more questions, which i cannot answer by myself, i will come back
looks great ๐
You probably are forgetting to clear the screen
i think i found it. im not sure if its the optimised way to do it
i included the blit of the background picture after the blit of the ball
now it works but is it the optimal way to do it, or the computer has to process the bg picture continuously?
I guess you would draw the background, draw the ball, then flip.
flip is like starting with a new blank surface
In your code above the first frame will only contain the ball. Then the next frame will contain the background and the ball. It's a weird setup.
Make it simple. Draw everything you need, then flip ๐
You can also think of flip as making what you just rendered visible in the window.
It's normally the last thing you do in a draw loop
window.blit(bg, (0, 0))
window.blit(ball, ballrect)
pygame.display.flip()
That way the background will also not render on top of the ball removing it from the screen
Unless pygame has some magical rules for overwriting pixels, but I doubt that
@compact wasp
@potent ice i just tried it and the ball moves really laggish!
I think you have to use pygame.time.Clock to syncronize
Possibly something like this ```python
clock = pygame.time.Clock()
FPS = 30
while 1:
# draw stuff
pygame.display.flip()
clock.tick(FPS)
Awesome ๐
i also changed it to 45 fps and the ball runs smoother
yeah whatever you can get away with works.
the higher the fps rate the better the gpu has to be right?
well in this case there arent any limitations of course
Well. pygame uses SDL so it's really software rendering
^ so it would be a CPU limitation in this case
To my knowledge, not currently in pygame
I believe the next major update is going to add OpenGL, but I might be misremembering
That depends on the platform implementation of SDL2.
It uses the GPU for some stuff
Oh does it? Wasn't aware
but it canโt use a lot of GPUs
Yeah, with my GTX 1060, I can see it using the GPU
Also it should be noted that there are other libraries such as arcade that are quite well suited for 2D game creation and would give you more power
I'm not suggesting you abandon your current course, but just know you have options
Iโm not sure entirely what for, but my FPS is way higher than my laptop that doesnโt use its integrated GPU
Is it an APU?
The ones that have the graphics and CPU combined will offload tasks to each other, which might explain that
Isnโt APU amd?
The advantage of pygame is the potential platforms you could support, but the drawback is performance. (Depending on what you want to do)
Intel calls it integrated graphics iirc
Yeah APU is AMD marketing speech ๐
I use Pygame for simplicity and control over things like the game loop
Also because its Python
Anyways, unlike normally Pygame, Pygame uses pretty much any GPU afaik.
And there are options to use it for even more tasks iirc.
@ember glade im not abandoning my course. i guess as a newbie, any course is a good course for the basics and the more in depth i go, then i see limitations and probably switch to other languages, but for the time being i need to learn the basics. my next task is going to be the documentation you sent me yesterday, which is about the player control. my next task will be the ball to be controlled by the user and not just move up and down within a while loop
Good, I'm glad to hear it. Keep at it, you're doing well
@compact wasp Keep doing what you are doing. Pygame is a great intro to graphics.
thanks ๐
Throw a newbie at GL 3.3 core and ask them to draw a circle is not a good idea. Pygame makes things simple and easy
Of course
and you can combine it with GL stuff later. No problem.
I think arcade does a solid job at abstracting that complication stuff out, though.
Might be worth poking around after you finish this one in pygame
Agreed.
At least if your goal is to use your 1060 ๐
Every library has their advantaged and disadvantages. In the long run it's important to chose the right one based on that.
Things like resolution scaling in pygame is a bit of a bummer compared to GL based libraries, but if that is not important.. then it's not a problem!
oh source code of VVVVV will be released for 10y anniversary of the game
hello, I'm trying to convert a pong clone made in python 3.7 with pygame to exe using pyinstaller or auto-py-to-exe, both options don't work
I tried executing the exe through cmd and got the following output:
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "pong.py", line 67, in <module>
File "site-packages\pygame\pkgdata.py", line 50, in getResource
File "site-packages\pkg_resources\__init__.py", line 1134, in resource_exists
File "site-packages\pkg_resources\__init__.py", line 1404, in has_resource
File "site-packages\pkg_resources\__init__.py", line 1473, in _has
NotImplementedError: Can't perform this operation for unregistered loader type
[15692] Failed to execute script pong```
I also don't have any extra files I'd need to add to it, it's just the one script
There are some posts on reddit and other places about this. You might also want to look into using the pygame2-dev packages. 2.0.0.dev6 is surprisingly nice with so many bug fixes.
1.9.6 has a lot of issues.
But it might be ok if this is win only. No idea.
I've been having a lot of problems with lag using the python arcade library
I don't wanna clog this chat, so if anyone knows about the arcade library, could you look at this stack overflow post I made? https://stackoverflow.com/questions/59687484/lag-while-drawing-lines-with-the-python-arcade-library
How many lines are you drawing here?
There should be a way to batch draw them instead of loop-drawing single lines
Similar to batches in pyglet I guess..
@summer pond
There is, but anywhere from 30 to 100
In pygame I can draw upwards of 200 with no problem, but more than 3 or so with the code as it is now causes problems
Maybe create as issue in the arcade project to get some pointers?
@frozen knoll should know more about this
Right, draw them as a batch if you can. Look at the ShapeElementLists demos.
@frozen knoll Just committed support for resizing buffers in moderngl so it's a lot easier to make pyglet style batch support etc. buffer.orphan(new_byte_size). Might actually batches in moderngl-window. It's a great thing.
I'm going to have a deeper look at Arcade. Probably a lot that can be learned from it. Wasabi2D also have a lot of neat things worth looking at.
@frozen knoll Do you know if there's any way to make the points rotate with the sprite when using player_sprite.points after rotating the sprite by a certain angle?
or alternatively get a list of points on the border of player.sprite that rotate with it
I know I've been in this chat a lot for help, but I really appreciate it. Game dev is not my strong suite at all lol
What game engines support python?
No I kinda don't
I'm not that experienced with python
@real prawn check the pins for some info on that.
@real prawn The primary frameworks I am aware of (that one can use to make games) for Python: Arcade, Kivy and Kivent, Pygame, Cocos2D-Python, RenPy. I'm sure there are others I am missing!
You also have unreal engine and blender game engine
and Panda3D
It really depends on what abstraction level you want to be in.
Low level rendering calls vs. managing higher level info were the rendering part is handled for you
It would be useful to come up with a complete list grouping them by category.
RenPy and Arcade are probably closer to a game engine than for example pyglet.
The same way you can say that moderngl is not a game engine, but a graphics library.. while Wasabi2D is a 2D game engine based on moderngl.
@summer pond If you change the angle, the points should auto-rotate with the sprite. You shouldn't have to do anything.
Arcade will also try to guess the points based on transparency, so you many not have to even specify the points.
@frozen knoll It seems like they don't... just player_sprite.points right?
Don't rotate, or don't auto-guess points?
@spinningD20#4376 which would you say is the best?
@summer pond - Oh weird, you are right. Something does seem off. I'm researching.
@potent ice how does instanced rendering work? And how does it work with moderngl?
@mighty rose which would you say is the best?
@real prawn It depends ๐ what do you want to build, and why? do you care about mobile? All important questions!
I was messing around with different outlining methods. (I still have a few more I want to try.) The one on the left uses pygame.draw.polygon() with a width of 3 using the outline given from pygame.mask.Mask.outline() and it runs at about 80fps when I render 300 of them on top of each other. The issue with this one is that pygame.draw.polygon() doesn't actually make a perfect outline. The one on the right creates surface containing the edge pixels using the data from pygame.mask.Mask.outline() to use .set_at() on the surface. The surface with that outline is then blitted one pixel in each direction so the border edge line shows as an outline. This one runs at 60fps with 300 of them on top of each other, but makes a perfect outline.
so I'm tryin the same thing in Pygame 2.
they now run at the same framerate but both are 60fps
which means that the first method somehow got an fps drop from Pygame 2
using Mask.to_surface() on Pygame 2 and blitting in the 4 directions gets about 67fps
Pygame 2 with Mask.to_surface() seems to be the superior method because it works when there's holes in the image unlike the methods that use Mask.outline().
I might do a video on this. lol
@summer pond I put out a 2.2.3b1 version of Arcade which should correctly rotate and scale hitboxes with the sprites if you want to take a look at it.
@mighty rose I would wanna create PC games
Can they all not create games for mobile or PC?
Python doesn't have much of a mobile presence. If your immediate goal is to create marketable games, I'd look at something like Unity.
If you want build your skills up with a language that is easier to get into, Python is good for that.
@frozen knoll Do you mean marketable mobile games, or any game? If any, I'd be interested in hearing your reasoning.
@real prawn yes, they all can create desktop games. The intention of my questions were to figure out what your goals were. If you're interested in using something to get your feet wet, and don't care about mobile, then the easiest to learn would be between cocos2d and arcade. If you're eventually looking to learn how games work under the hood, then perhaps pyglet or kivy will almost force you to do so, as they don't have much in the way of conveniences and "solving common problems for you".
If you aren't interested in learning the lower-level stuff under the hood, specifically using python, or to better learn programming in general, then I would recommend something like Unity or Godot.
outlines are fun
@frozen knoll you're literally the best human alive. Thanks so much!
that it doesn't have much market presence doesn't mean it's not a possible tool for that, it's just not one that the market recognize to be useful, but it might be for good or bad reasons. Only one example of a good game done with it should be enough to demonstrate it's a possible path.
i believe the boardz game made with kivent is example enough that it's possible to do games with python on android.
also it's been quite a few years i didn't work on that, but my pygame smash-bros-like project ran on a platform much less powerful than any phone that went out in the last 5ย years (and not flagship ones, even lower spec ones i'm sure, as i developped that on an eeepc 701 back then)
You can easily create a mobile game on Unity or similar environment. As Python doesn't run natively on mobile devices, and there's not a good way (yet) to get an installable game running Python under iOS or Android, you'd spend way too much time solving that problem as opposed to writing a game.
@mighty rose I thought Unity only supported C#
And I'm a beginner, but I want to leard how games work and eventually create them
@foggy python what is the normal way to scale up pygame surfaces? Let's say I have a 4k screen and want to scale a game window 3500x2000 or similar.
@frozen knoll uh, python does run natively on android/ios, the kivy project has made that happen quite a few years ago, and kivy is used by a lot of people to build android apps fully in python
maybe i misunderstand what you mean, but i don't see how it's any different from using unity
when you say natively, that seems to indicate that they'll be running in Java
but that's not what unity does, right?
I'm unsure exactly how Unity solves that under the hood. it does claim to create native apps.
or unreal engine or whatever, these are c# and c++ framework, they have their runtime compiled or compile to native arm code and run there, not as java, but directly in the system, in that sense, kivy apps, running in cpython runtime built for arm, running in android through the ndk, is totally on the same level imho
I think that's probably a reasonable claim.
so unity's C# compiles to .NET bytecode, and the android app has a .NET bytecode interpreter in native code.
so yeah, I think that sounds more or less analogous to what you guys are doing
and it's certainly possible to build/run pygame and arcade library games as well, as long as someone write the bootstrap and any required recipe to build them in p4a (i think that's more or less done for pygame, though not many people use that, and it's probably not too hard to do so for arcade, if people want it to happen)
yes. but what paul said about spending more time trying to get it running on mobile than doing actual game development does probably apply to most non-Kivy frameworks as of today, even though maybe that doesn't need to be the case.
yeah, it's not known if it's trivial or not until somebody try
before i knew about kivy and when I did a deep dive down the rabbit hole of writing an app for android with Python, the research I did left me thinking it was probably hopeless. this was many years ago though
all the relevant tools seemed like they weren't really mature enough.
there has always been a struggle to have tools that works without flaws, and buildozer/kivy-ios has suffered from that, both platforms like to move things regularly, and make it harder to maintain, and there are enough system differences that for some people it basically work, and for others it's just a painful process of finding what's wrong, these tend to be (understandably) a bit more vocal about their experiences than the former.
Things have improved, but i don't think we can claim it's flawless yet.
BeeWare has done work trying on mobile, but getting Python to run well on both iOS and Android without some 3rd party Python app just isn't there yet. I really don't feel like Kivy's there yet. Too many hoops and flaws in my opinion. (Yes, your opinion may vary.) Unity (and other engines like it) makes cross-compiling pretty easy. But there's a TON of back-end things they do to make that happen.
@frozen knoll I'm biased towards kivy, but, it really isn't bad to deploy a game onto android or ios. I've created an apk of my game in testing for various android friends and it was no issue, and I have used Kivy for production sales applications, the challenges were minimal there too. I guess I would also need to know how it can improve specifically, if it is lacking for general development. In the context of an approachable game framework, sure I agree with what you've said.
Interesting, last I played around with Kivy (which has been a while) Android was highly frustrating and I never got it to work.
Thanks for the updated info.
To be clear, I wasn't trying to minimize your opinion or anything, just looking for specifics and seeking to understand your perspective. Everything has room to improve and nothing is perfect, I'm not saying Kivy is. I am pretty passionate about Kivy and have my own opinions about how it could improve, as well.
I've been playing with the idea of making something similar to arcade's api for kivy. I still don't know enough about it from a performance perspective, I have a lot to learn, but I believe that discoverability (both in using it and people coming to know about it) is among Kivy's largest weaknesses. The only other I can think of is native platform widgets. Would love to hear feedback from others and try to find solutions on how to improve the framework (kivy)!
I respect the work done by FreakBoy, but i would love for him to respect ours a little more, it's easy to say you are unconvinced by something, until you try to do better and see that yeah, it's just not that simple, kivy is used by a lot of people to build apps, it's not perfect, sure, but it works for a lot of things, and while there are a few hoops to jump through, it's possible to do about anything with it. to my knowledge, no real world app has been developped with BeeWare, the technology he built is impressive for sure, but the goal he set for himself, is in my opinion impossible to achieve, no matter how good you are, and it would have been better to try to cooperate with us more instead of dismissing our work for years on end.
anyway, time to sleep for me.
@potent ice I believe that Pygame 2 has some new stuff that allows fullscreen scaling with really good performance, but in normal Pygame, you can force stuff to scale by making it fullscreen. If the base resolution is low, the scaled version looks blurry because of how it gets scaled. To fix this, you need to increase the base resolution. Since I do pixel art, I normally render everything at the base resolution for that pixel art and use pygame.transform.scale() to scale and I blit it onto the main surface that gets rendered.
Ok. So I think they way I am doing it now is acceptable. I render to offscreen surface and copy the the surface into an OpenGL texture. Then I can scale that using nearest interpolation in any way I want.
Then I can also to postprocessing in OpenGL if needed
(Assuming target platforms are win10, linux, osx)
just do whatever works. lol
Playing with optimizing particle emitting from gpu and cpu in moderngl. Exporting this to gif was brutal and only contains 10k points. https://cdn.discordapp.com/attachments/550303740239020052/665952286823940126/movie.gif
Nice!
A geometry shader destroys the dead geometry and we know how many died so we can emit new ones. Can be done with shader or writing data directly from python
Was requeted by Daniel Pope who wanted better control over particles in Wasabi2D ๐
Also it's 3.3 core. No fancy GL needed.
Can do more fanciness in 4+, but I don't want to exclude all those people with 5+ year old integrated gpus
I'm hoping to get Arcade to a better performance level by moving some of the sprites via GPU instead of CPU. I'm going to need to learn more about shaders first.
ah yup. Huge potential there. You can always poke me if you need any input on that
I'm honestly interested, could you accelerate 4096x4096 square tiles via shaders and storing position as 12-bit half-colors in coordinates of a pixel buffer?
I probably will. I want to get info to the GPU without using Numpy to create the memory block too.
@lost needle I use shaders to store sprites in a tiled grid with Arcade. I've had over 400,000 sprites with no problem.
@lost needle I would believe so, yes
There is so much potential with opengl 3.3 core and python. It's an area that hasn't been properly explored. opengl 3.3 is the new opengl 2.1 considering everyone and their mother has at least an integrated gpu supporting it
But compute shaders are even more awesome!!
Ive been using them for everything haha
Yes they are, but then you exclude a lot of integrated GPUs ๐
Integrated gpus in the last 2-3 years have them I think. At least AMD Vega supports 4.5 now
Do that many people still have that old hardware?
Yup
Especially the kind of people that would try out my projects
Any more info about it other than the link?
@dawn quiver that is very much an ad. please read our rules
@fierce wraith About the instancing. I am making an example in a bit
Oh awesome! I know moderngl has an example where it renders a bunch of rotating triangles but Id love a modernglmodern window example :)
Yeah. VAO wrapper variant
Yup!
Anyone played around with shadertoy? That looks like a decent way to learn.
Yup
I even started on a python version of shadertoy: https://github.com/einarf/shadertoy
Yup. Its awesome to test if one part of the shader works
But most of the time my bugs are not in the shader code, just because they tend to be pretty simple for me :)
You learn a lot about GLSL playing with shadertoy, but you don't learn much about the GL pipeline (other shader types like vertex, geometry and tessellation). You definitely learn how to take advantage of the fragment shader.
Still, it's a nice tool for learning, but very focused on fragment shader.
My shadertoy "editor" is more like this : https://cdn.discordapp.com/attachments/555202684630728724/634525565390553098/Capture.JPG
It's just an application that can render shadertoy projects and support automatic reloading. I could not use shadertoy on the train, so I made this one ๐
Ah yes! Thanks for sharing your shadertoy project.
+1 on all this!
Arcade 2.2.3 is out. Supports hitboxes scaling and rotating with the sprite. Internally imports are done in a more proper Python fashion.
@fierce wraith Very simple 10k instanced cube render with basic animation in vertex shader. https://github.com/moderngl/moderngl-window/blob/master/examples/geometry_cube_instanced.py
It's all about the /i suffix in the buffer format. Data will be passed per instance instead of per vertex
Where is programs/cube_simple_instanced.glsl
Not to be dumb, but I don't see that directory:
oh, the examples I posted is in moderngl-window, not moderngl
Thanks, I should have seen that.
It's sunday, you'll get a pass ๐
I need a fast buffer to pass data back and forth between sprite objects and the graphics card. Right now I build one using Numpy when it changes. That's not very efficient.
I tried just pulling the data from the numpy array, but that turned out to be slower. Doing get/set on numpy was slower than using regular variables in Python and rebuilding the array later.
I'm not sure the fastest buffering solution. I've tried doing things in C, but that is a headache and makes distribution difficult.
Have you thought about using transform feedaback for some things?
What data do you need to update on the gpu?
Python objects -> Numpy -> Buffer for GPU
Position of the sprites
Position, angle, size, sub texture coordinates, and color.
Ok, so those positions are set by the user in python then?
Yes.
Interleaved buffer?
Yes
buffer_type = np.dtype([('position', '2f4'), ('angle', 'f4'), ('size', '2f4'), ('sub_tex_coords', '4f4'), ('color', '4B')])
Building that buffer is a big bottleneck for me.
Keeping the buffer, and updating it live is, oddly, even slower.
Where is the actual sprite geometry?
I'm guessing the data you describe above is per sprite instance?
Right. Position and size cover the geometry.
The full building of the buffer is here:
There's just got to be a better way to do it.
And I'd love to get the position to be updated on the GPU, and then fed back to the Python objects if that would speed things up.
How often is that method called?
oh and do you have any test for profiling performance of sprite rendering? I remember you posted some nice graphs for collision, so I would guess you have something for this as well? ๐
Not graphs, but at least some small example stressing the sprite system
@potent ice so right now I have this:
self.render_vao.buffer(self.buffer1, '3f8 3f8 3f8 1f8', ['in_position', 'in_velocity', 'in_force', 'in_mass']) self.render_vao.buffer(self.color_buffer, '4f', ['in_color'])
The only thing used in the shader to render them is the position and the color
I dont quite unterstand how the data is passed per instance
You map the buffer with a format using a /i suffix
I guess you could just pass in the buffer above. You just need to pad it in the format string 3f8 7x8/i
sphere.buffer(self.buffer1, '3f8 7x8/i', ['planet_pos']) maybe
Then a new in dvec3 planet_pos is passed in per planet you render. Add that to the in_position in the vertex shader to make the position offset
Ah
Then you render the planets with sphere.render(prog, instances=num_planets)
Just don't lie about the number of planets. That's a bad idea ๐
@potent ice Performance graphs: http://arcade.academy/performance_tips.html
ah right. I found the sprite stress tests as well
hmm yep, so when you reach 6000 sprites the per instance data reaches 240k bytes.
Think I see several small things that can be improved as a start
I'll see if I can find some time to experiment more. Been poking around to understand things.
The particle stress test thingy is perfect!
@frozen knoll I still don't know where you actually move the sprites.
There's a separate sprite class. If any of those sprites move, it rebuilds the data.
@frozen knoll I think potentially the movement vectors can be used to transform the buffer on the gpu, but that will of course increase the instanced data 8 more bytes. Then something needs to be done to optimize the full buffer updates.
That would only apply to the dynamic sprite lists
hmm yeah I think there is a lot we can do here!
and your opengl wrappers kind of looks like moderngl light, so they were easy to understand ๐
It could actually be beneficial to separate the instanced data into several buffers. If we somehow can know what data is "dirty" it can be optimized more... but time will show
Right, that makes sense. That would reduce the amount of data put together. I'll give that a try.
@frozen knoll I'd try to implement a transform(target_buffer) method in the VAO class
Then you probably end up with 2 buffers in the sprite list you can transform between
like pouring vertex data between buckets with a transform filter applying the movement vectors to the position
You can probably use moderngl as a reference.
What I still don't understand is what exactly triggers a full rebuild
Some other small things that helps is consuming generator data with (numpy arrray) fromiter(generator, dtype count=n) to avoid building lists in memory first.
@frozen knoll Also I see you are using tobytes() in some places. numpy arrays can be passed with ctypes void_p directly because they support the buffer protocol.
Fixing up a lot of those small things quickly adds up
I'd store the buffers in the spritelist as well and reuse them.
There is also some interesting concept with destroying geometry using the geometry shader in transform feedbacks. That can definitely be taken advantage of in some way.
During a transform you can discard instances and get a count back of how many instances was emitted
so the output buffer can contain less elements than the input buffer
That's a very efficient way to prune a list on the gpu. Since you know the number of primitives emitted during the process you can use this information for various other things.
Hey, thanks for the feedback. I'll parse through it tomorrow.
What combination of languages are best for game development? Preferably something on an indie scale for starters.