How I Added Shaders to Pygame

  Рет қаралды 37,816

DaFluffyPotato

DaFluffyPotato

Күн бұрын

Пікірлер: 57
@DaFluffyPotato
@DaFluffyPotato 2 жыл бұрын
Get access to Vaegrant's source code (+shaders) and maybe pay for my lunch? 😳 www.patreon.com/dafluffypotato Also, there’s a mistake at 4:20. I may have been talking to someone in Discord at the time and not noticed that I highlighted an unrelated section of code from a file that wasn’t even the associated shader. lol The base shader functionality is open source though: github.com/DaFluffyPotato/pygame-shaderlib
@leonstansfield
@leonstansfield 2 жыл бұрын
I am constantly amazed at your work... just knowing the background footage was made with pygame is amazing
@ShotgunLlama
@ShotgunLlama 2 жыл бұрын
I ran a test once comparing pygame's software blit vs opengl rendering a quad to draw many copies of an image to the screen with random sizes and positions. With any large number of images to draw, opengl was 1-2 orders of magnitude faster than the standard blit function even when each instance of the image was a separate vertex array. I'm using opengl for the pygame project I'm currently working, but I'm using the moderngl wrappings instead of PyOpenGL
@undeadpresident
@undeadpresident Жыл бұрын
So I suppose it takes more work to get all the images rendered and placed correctly, but then you get much better performance and can use shaders without it running super slow?
@HammerHeadGameStudio
@HammerHeadGameStudio 7 ай бұрын
I enjoy periodically coming back to your videos. Every time I see one pop up on my feed, I think, what's Da Fluffy Potato been up to in Pygame now, and im always impressed by how much content you will have released in the meantime to binge.
@Jay1001
@Jay1001 Жыл бұрын
I would like to personally thank you for uploading your code for this. I know you have a more up to date video using modernGL, and that this code probably isn't for everyone, but honestly this code was exactly what I needed. I have an existing pygame game and was looking to add a few openGL features to it but wanted precise control over the integration of GL and was having a HELL of a time getting ANYTHING to run, and I literally was frustrated in a way I had never been before. Then I came across this video, downloaded your code, and after a little tweaking got it to run and was finally able to start playing around with and testing everything. I got a shader programmed up for my needs and I don't know if I ever would've made it this far without you. Thanks, thanks, thanks. You da man :)
@giabaonguyenvan3279
@giabaonguyenvan3279 2 жыл бұрын
I can feel how happy you are because of the update.
@bmorr
@bmorr 2 жыл бұрын
I spent a few weeks in the fall of 21 trying to implement shaders in pygame for a fireworks sandbox, and I thought I reached a dead end cus I really didn’t want to rewrite the whole program to use OpenGL rendering. I was only doing this as a month long project and the time constraint meant it wasn’t worth it to switch to OpenGL. I will have to implement this bypass into my code and then I can finally make my fireworks have proper bloom in real-time!!!
@Rotten.Cheddar
@Rotten.Cheddar 9 ай бұрын
Since I'm Supposed To Learn C++, I Won't Learn Pygame Anymore, But You Fill Me With So Much Inspiration, Thx So Much!!!
@Skeffles
@Skeffles 2 жыл бұрын
Great video. I wasn't aware of any pygame games that use this so it's cool to know it's possible.
@iamtheprarieking7137
@iamtheprarieking7137 2 жыл бұрын
I was wondering if you have a public version of the current engine you've made? Love your videos!
@illusealrr1006
@illusealrr1006 Жыл бұрын
Thanks for the video. I have my own game engine written with c++/SDL2.0. With the game mostly finished, I decide that I want to use a bloom shader. I guess that what I need to do is just convert the SDL texture for main screen to opengl like you do.
@Willerhide
@Willerhide 2 жыл бұрын
@Smelly Frog used an OpenGL texture to add Steam Overlay to his pygame game. Honestly worth checking out if you ever wanted to add it to your own games at some point.
@DaFluffyPotato
@DaFluffyPotato 2 жыл бұрын
I saw that. The steam overlay only works with OpenGL, so you kind of have to do that for it to work.
@lodybaguette2487
@lodybaguette2487 2 жыл бұрын
Hey , for your dialog system , I think if you calculate before how words will appear avoid words warped at the end line , anyways good job bro
@Avaxar
@Avaxar 2 жыл бұрын
How about using ModernGL? Wouldn't it be a more friendly library (Basically a pythonic wrapper for OpenGL) than raw direct PyOpenGL, which directly ports every function there is from C's OpenGL?
@DaFluffyPotato
@DaFluffyPotato 2 жыл бұрын
Blubberquark was recommending that. That's not what I did because I wasn't aware of it at the time, but that would probably be easier.
@zsirothehero4330
@zsirothehero4330 Жыл бұрын
Hi DafluffyPotato. Your work is wonderful no doubt about that :) I just want to ask if you have a tutorial on how to make sprite I'm really bad at drawing or even designing. If you have a suggestion on where should I start. That would be greatly appreciated. Again, thanks for the work you've done!!
@DaFluffyPotato
@DaFluffyPotato Жыл бұрын
kzbin.info/www/bejne/apS8cp5-m81sra8
@Questionable_Insights
@Questionable_Insights 2 жыл бұрын
You're making me want to try Pygame finally lol
@zicraftian
@zicraftian 2 жыл бұрын
Dude you are a big inspiration for me when it comes to learning python
@petthepotat
@petthepotat 2 жыл бұрын
your huge brain never ceases to amazes. Keep up the great work Mr potato master >:D
@ech0_exe243
@ech0_exe243 2 жыл бұрын
just… WOW! It’s soooo amazing
@AngelGonzalez-vp2en
@AngelGonzalez-vp2en 2 жыл бұрын
You could use this lighting thing for fire particles but it's probably super slow. It's based off your particles video, removing during iteration video, and lighting in pygame video: import pygame import sys import random from pygame.locals import * pygame.init() Clock = pygame.time.Clock() Screen = pygame.display.set_mode((800, 700)) pygame.display.set_caption("Base") particles = [] particle_colors = [(127, 63, 15), (127, 63, 31), (127, 63, 0)] click = False def glow(radius, color): glow_surf = pygame.Surface((radius * 2, radius * 2)) pygame.draw.circle(glow_surf, color, (radius, radius), radius) glow_surf.set_colorkey((0, 0, 0)) return glow_surf while True: Screen.fill((0, 0, 0)) mx, my = pygame.mouse.get_pos() if click: particles.append([[mx, my], [random.randint(3, 10) / 5, random.randint(6, 15) / 3], random.randint(6, 12), random.choice(particle_colors)]) for i, particle in sorted(enumerate(particles), reverse=True): particle[0][0] += particle[1][0] particle[0][1] -= particle[1][1] particle[0][1] += 1 particle[2] -= 0.1 if particle[2] 9: color = (255, 255, 255) elif particle[2] > 6: color = (224, 112, 61) elif particle[2] > 3: color = (112, 61, 30) else: color = (56, 23, 11) # pygame.draw.circle(Screen, color, (int(particle[0][0]), int(particle[0][1])), int(particle[2])) #will look ugly with this radius = int(particle[2]) * 2 Screen.blit(glow(radius, (particle[3])), (int(particle[0][0]), int(particle[0][1])), special_flags=BLEND_RGB_ADD) for i in range(3): copy = Screen.copy() copy.set_colorkey((0, 0, 0)) copy.set_alpha(127) Screen.blit(copy, (i * 2, i * 2)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() if event.type == KEYDOWN: if event.key == K_q: pygame.quit() sys.exit() if event.type == MOUSEBUTTONDOWN: if event.button == 1: click = True if event.type == MOUSEBUTTONUP: if event.button == 1: click = False pygame.display.update() Clock.tick(60)
@AngelGonzalez-yy8dh
@AngelGonzalez-yy8dh 2 жыл бұрын
Good video
@FollowNdFeel
@FollowNdFeel 2 жыл бұрын
Your game is looking incredible. So…. I’m on episode 2 of the devlog so this might not work for you… catching up. Have buffs in the game that make you really strong but are unusable. Pair those with debuffs to make it usable. I.e. +100% run speed(making you zip back and forth on the screen) and then get something that does more dmg but slows you down.
@joshbarros1995
@joshbarros1995 Жыл бұрын
This is incredible! Can you create a Quake Clone with OpenGL that renders oficial Quake BSP maps and TrenchBroom maps?
@DaFluffyPotato
@DaFluffyPotato Жыл бұрын
Theoretically, yes.
@dclxviclan
@dclxviclan Жыл бұрын
Cool style, i love this
@CloudlessStudio
@CloudlessStudio 2 жыл бұрын
I’ve been using both for simple 3D renders
@RoRaresGaming
@RoRaresGaming 2 жыл бұрын
Can u make a video about saving/loading ?
@boxhead-zk7sn
@boxhead-zk7sn 6 ай бұрын
great video love what your doing, i have a question what does the ftexcoords stand for in 4:18 cause i try to copy the CRT tv style in my game, it will help if you told me
@DaFluffyPotato
@DaFluffyPotato 6 ай бұрын
UVs
@boxhead-zk7sn
@boxhead-zk7sn 6 ай бұрын
@@DaFluffyPotato thanks and pls also the myconstant value
@ghostsakai4442
@ghostsakai4442 2 жыл бұрын
Live your work dude
@t3st3d
@t3st3d 2 жыл бұрын
This is very impressive
@itsmemattagain9841
@itsmemattagain9841 2 жыл бұрын
You reckon it would be possible to make a 2d tile game online with a decent performance in python?
@leobozkir5425
@leobozkir5425 2 жыл бұрын
Could you make a video on how to convert a pygame surface to an opengl texture and render that to the opengl display? If not no problem, but I think other people might be interested into that as well perhaps. And as a side note, how did you learn all this? Through documentation or any other online sources?
@undeadpresident
@undeadpresident Жыл бұрын
Everyone I've seen do it uses the pygame.image.tostring() function (which is slow af) then glTexImage2D function and I think it may not feasible unless you have low-res graphics or create all the textures ahead of time and do all the graphics through opengl and not try to mix the two.
@dclxviclan
@dclxviclan 2 жыл бұрын
Super, awe$ome
@pccoder9547
@pccoder9547 2 жыл бұрын
I use c++/sdl2 for mini projects and unity for big games
@riyamandal7667
@riyamandal7667 2 жыл бұрын
Can u pls make a tutorial on this topic?
@bobdillon1138
@bobdillon1138 Жыл бұрын
Why would you dig a hole with a teaspoon.
@fada9238
@fada9238 6 ай бұрын
Dude, the game in the background is PyGame...? If so, I would like to ask: how to make such exact collisions? All my attempts to do at least something that we see in game engines have not been successful, it just doesn't work correctly and with terrible errors...
@DaFluffyPotato
@DaFluffyPotato 6 ай бұрын
I have multiple tutorials on that
@electricimpulsetoprogramming
@electricimpulsetoprogramming 2 жыл бұрын
Is programming hard? I feel very dumb trying to learn it.
@noobintheinternet
@noobintheinternet 2 жыл бұрын
Hello Fluffy! Please make new video.
@rudyfaile
@rudyfaile 2 жыл бұрын
the best way to learn is by teaching :)
@DaFluffyPotato
@DaFluffyPotato 2 жыл бұрын
Yes, but putting questionable content out there isn’t good for the people trying to learn from it.
@rudyfaile
@rudyfaile 2 жыл бұрын
@@DaFluffyPotato yeah I'm not suggesting you publish guesswork, but as you're refining your tutorial I'm sure you'd master the concepts
@nj0086
@nj0086 2 жыл бұрын
yayy
@spenceabeen
@spenceabeen 2 жыл бұрын
Gonk :o
@SophiaWoessner
@SophiaWoessner Жыл бұрын
you could always make your own library wait you already did that
@304nokia
@304nokia 2 жыл бұрын
I'm suggesting to try Ebitengine. It very similar to SDL2 but with fragment shader support out of the box. Also Python is too bad for multi-platform development.
@owaisoumera7624
@owaisoumera7624 2 жыл бұрын
second
Pygame CE - Better & Faster
6:29
DaFluffyPotato
Рет қаралды 40 М.
I tried coding my own graphics engine
4:23
Garbaj
Рет қаралды 211 М.
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 8 МЛН
бабл ти гель для душа // Eva mash
01:00
EVA mash
Рет қаралды 10 МЛН
"Balancing" Gamedev and a Day Job
8:50
DaFluffyPotato
Рет қаралды 90 М.
I Went on a Shader Adventure
10:32
DaFluffyPotato
Рет қаралды 22 М.
I Turned Cellular Automata into a Game
16:28
DaFluffyPotato
Рет қаралды 171 М.
I made a 2D graphics library
8:04
Low Level Game Dev
Рет қаралды 8 М.
How to ACTUALLY get into Gamedev
14:01
DaFluffyPotato
Рет қаралды 739 М.
How to Code (almost) Any Feature
9:48
DaFluffyPotato
Рет қаралды 699 М.
Pygame vs Raylib vs Arcade Pyglet: Which One Will Suprise You?
14:17
Pygame Tutorial: Shaders
16:30
ScriptLine Studios
Рет қаралды 9 М.
Let's Code A Multiplayer Voxel Game in C++ - The Engine
10:46
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 8 МЛН