![PyExplained](/img/default-banner.jpg)
- Видео 25
- Просмотров 70 451
PyExplained
Добавлен 25 июл 2019
Welcome to PyExplained! From this channel, you can expect tutorials, devlogs, machine learning videos, and most importantly: a lot of fun with programming in Python, as well as some science and math videos. If you like programming, want to learn how to program or if you just like science and math, consider subscribing and turning on notifications!
Autotune using Python & How Pitch Correction Works
I’ve done a lot of different projects on this channel: from making a particle simulator and a rendering engine to developing AI systems. But there was one obvious project missing: something with sound. That’s why I challenged myself to make autotune using Python (and pitch correction was a lot more complex than what I imagined). Now, I could’ve just Googled an existing algorithm for tuning audio samples, but I wanted to come up with my own. So, in this video, I’m going to show you how I made my version of autotune and how you can use it too!
Timestamps:
00:00 Intro
00:33 Basics of sound
01:19 Generating a spectrogram
02:27 Reverting the spectrogram
03:20 Calculating the dominant frequencies
04:0...
Timestamps:
00:00 Intro
00:33 Basics of sound
01:19 Generating a spectrogram
02:27 Reverting the spectrogram
03:20 Calculating the dominant frequencies
04:0...
Просмотров: 4 154
Видео
I Made an AI Develop Its Own Language!
Просмотров 6692 года назад
Can an AI create its own language? I thought it would be an interesting experiment to see if I could make an AI do just that. The results were quite surprising to me and I bet you’ll find them just as interesting. So in this video, I’ll show you the results and walk you through how I got there. Timestamps: 00:00 Intro 00:33 The goal 01:06 Preprocessing 02:04 Creating the model 03:52 Training 06...
Particle Simulator in Python (Rigid Bodies, Soft Bodies, Fluid and More!)
Просмотров 41 тыс.3 года назад
For the past few weeks, I’ve been working on a particle simulator, in which particles follow some simple rules that are similar to the way molecules interact. From these rules, more complex behavior can emerge. Springs, fluid, soft-bodies, breakable buildings and tearable cloths... you can simulate all of this and more using the simulator! It also has a handy GUI that allows you to easily edit ...
Raytracing in Python: Shading, Reflection, Refraction, Fog and More!
Просмотров 7 тыс.3 года назад
The graphics in many modern games look very similar to real life. This is often because they are using something called ray tracing. In this video, I'll show you how I created my own ray tracer in Python and how you can too! I'll give you an in-depth explanation about intersections, shadows and highlights, refraction, reflection, volumetric lighting, and more, as well as the potential problems ...
Python RayTracer: Sneak Peek!
Просмотров 4933 года назад
For the past month, I've been working on a personal project: a raytracer using Python. Shadows and highlights, reflection and refraction, volumetric lighting... You name it, it's in there! That's why I made this little compilation of what it can do to show it off. I hope you enjoy it! Explanation video: ruclips.net/video/WWJgrftx6MQ/видео.html Code: github.com/PyExplained/3D-Renderer/tree/maste...
50 Subscriber Special!
Просмотров 1313 года назад
Wow! In less than 24 hours after the previous video came online, you guys managed to make my channel reach 50 subscribers! That's why this video is a 50 subscriber special. It might not seem like a lot, but knowing that people are interested in watching my videos, brings a smile to my face. So, thank you! But it doesn't stop there. This video is not only the 50-sub-special, but also the 20th vi...
How to Make an AI that can Play Games | Q-learning Explained
Просмотров 2,1 тыс.3 года назад
Have you ever seen these AI’s beating humans in chess? If so, it was probably done using reinforcement learning. In this video, we'll take a closer look at one of the most popular reinforcement learning algorithms: Q-learning. This video will give you more intuition about how punishment and reward can be used to train an agent to adapt to an environment. Don't worry if you don't know what any o...
Randomness
Просмотров 1184 года назад
When we say: “That’s random”, in everyday life, we usually mean that we didn’t expect something to happen. Like when someone suddenly says something that’s completely out of context in a conversation. But what is true randomness? Does it exist or is everything predetermined? In this video, I talk about that and more. If you haven't already, please take a minute to fill in the form to help my ch...
How to Make Better Tkinter Buttons? | Tkinter Tutorial
Просмотров 8 тыс.4 года назад
If you have ever done something with GUI in Tkinter, you probably know what the default button looks like. It’s grey, rectangular and it doesn’t give a lot of feedback. It’s boring. That’s why today I’m going to show you how to make your Tkinter buttons look many times as awesome. I'll show you how to make it round, use images, make the image change when pressed and way more. Link to GitHub rep...
What Do YOU Want?
Просмотров 584 года назад
What do YOU want? What kind of videos are you interested in? Let me know in the form: forms.gle/F9ETJYRtyNVfMKqz7 Music: Readers! Do You Read by Chris Zabriskie is licensed under a Creative Commons Attribution-license (creativecommons.org/licenses/by/4.0/) Source: chriszabriskie.com/reappear/ Artist: chriszabriskie.com/
FaceSwap Using Deepfakes! | AutoEncoders and Deepfakes Part 2/2
Просмотров 4604 года назад
In this video, I explain how deepfakes work. The explanation is made easy to understand using animations. I even made my own deepfake and at the end of the video, I show you my results. If you have any questions, let me know in the comments. Timestamps: 00:00 - Explanation 02:26- Showing Results Datasets: Faces Dataset: mmlab.ie.cuhk.edu.hk/projects/CelebA.html Cat Dataset (photo at the end): g...
This AI Can Generate Faces! | AutoEncoders Part 1/2
Просмотров 5004 года назад
In this video, I show you the AI that I made that can generate human faces and more! This is done with an autoencoder and PCA (all in Python, using Tensorflow). In the first half of the video, I explain how it works and at the end, I'll show you everything in action. The explanation is made easy to understand using animations. If you have any questions, let me know in the comments. Timestamps: ...
The Example Scene | 3D Renderer Tutorial #2
Просмотров 1334 года назад
This video is a short one, I'll just show what you can do with the example scene and how to set it up. This is the link to the GitHub-repository: github.com/PyExplained/3D-Renderer Music: Royalty-free music from www.fesliyanstudios.com #python #programming
How to Install the 3D Renderer? | 3D Renderer Tutorial #1
Просмотров 1974 года назад
In this tutorial, I will show you how you can install the renderer and the modules that you need. It should take 5-10 minutes to install everything including modules. These are the commands: pip install trimesh pip install opencv-python pip install numpy pip install matplotlib If these give an error, you can reinstall Python and make sure you add pip to the command-line. This is the link to the...
Lights, 3D Models and more! | 3D Renderer Devlog #2
Просмотров 1344 года назад
Lights, 3D Models and more! | 3D Renderer Devlog #2
First-Person View 3D Renderer using Python | Devlog #1
Просмотров 1,2 тыс.4 года назад
First-Person View 3D Renderer using Python | Devlog #1
Sine, Cosine and Tangent: How to use it? & How can you Visually Program with it? | Visual Math
Просмотров 3214 года назад
Sine, Cosine and Tangent: How to use it? & How can you Visually Program with it? | Visual Math
Physics Simulator: Huge Update! | Devlog #3
Просмотров 3174 года назад
Physics Simulator: Huge Update! | Devlog #3
14 Cool Python Projects in 8 Minutes!
Просмотров 4394 года назад
14 Cool Python Projects in 8 Minutes!
Physics Simulator: Bug Fixes and GUI | Devlog #2
Просмотров 1324 года назад
Physics Simulator: Bug Fixes and GUI | Devlog #2
Making a Physics Simulator | Devlog #1
Просмотров 2965 лет назад
Making a Physics Simulator | Devlog #1
Tutorial #1: Image Animations using Python and Tkinter
Просмотров 1,9 тыс.5 лет назад
Tutorial #1: Image Animations using Python and Tkinter
It is rare to see playing with sound wave + python coding 😁. Any follow up experiments on sound tuning?Good work.
Thanks , i got it , it worked
You are a Genius ! whoa i use POV ray tracer, and it is hard but beautiful , you only use coding ! there is this great awesome Simon Burton that gift us some py code for pov but its not like your code so simple ,idk im a beginner , THANKS
Glad you like it :). It's been a while since I coded (have just been focussing on some other things), but I'm eager to get back into it when I'll start studying at uni.
playing with clothes example and the code snip found in ReadMe got this; "Warning (from warnings module): File "<string>", line 5 FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar." then this .. main thread it's not in main loop ....i´m stuck in there, help , py 3.11 w11
I looked at it (it's been a while since I opened the simulator myself, so I had to figure some things out again), but I found the problem! When pasting the code in the code window, you should change "np.object" to "object" (you can also re-install the simulator, since I updated the GitHub-repo). When adding particles, the code uses the current 'particle settings' (from the particles tab). So it's best to change this to appropriate settings for a cloth (I suggest: radius: 4, mass: 1, attraction-radius: -1, attr-strength: 500, repulsion-radius: 40, repel-strength: 1, link-breaking-forces: -1, also leave all the boxes unchecked) and set the gravity to 0.6 and the air resistance to 0.04 in the simulation settings. Hope this helps :).
Beautiful video 👏
too slow
You're absolutely right that it isn't the fastest simulator out there. Back when I was working on it, I tried implementing GPU-accelerated computing using CUDA, but I don't remember ever getting close to making it run decently (mostly because the code was not adapted to the CUDA library when I first wrote it). Since then, I haven't really worked on the simulator, but it's a little toy project after all. Hence, I don't really think it matters that it's in Python and it performs some unefficient calculations.
HUh ..... Even AI can't make it run ????
cv2.circle(image, (int(particle.x), int(particle.y)), particle.r, particle.color, -1) cv2.error: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'circle' > Overload resolution failed: > - Layout of the output array img is incompatible with cv::Mat > - Expected Ptr<cv::UMat> for argument 'img'
@@user-uo7vo4wn8r I can't seem to replicate the error... Maybe you could try downloading the ".EXE"-version? If you send me some details about your Python, OpenCV and Numpy version, I could try and take a look at it (though I can't promise anything, because I haven't really looked at the project for a long time).
m ch go f v v hn yog b hm
i try to run it but ui is a little buggy. It looks like the frame is to small for showing all the assets. Is this a common problem?
Mmh.. I've never had a problem with that myself, but maybe you can try adjusting the width and height parameters in the ParticleSimulator.py file (line 3). Hope that solves the problem :).
Can I simulate all things with partical figuration?
I wouldn't necessarily say you can simulate ALL things that behave like particles in the real world, but there is a surprising amount of behaviours that you can reproduce using the simulator (e.g. fluid, rigid bodies, soft bodies, bouncy balls, light particles, planets, buildings, cloth, ropes, air particles, ...). In most cases, the stability and performace of the simulation are the limiting factors. There are also some systems that may be too difficult to reproduce (like fire and actual thermodynamics). Definitely let me know if you find ways to use the simulator that I haven't already mentioned! I'm always curious to hear what other people use it for :).
Fantastic sw
This is so amazing and helpful... Well done 👌
very interesting simulation bro!. can you please share codes. thanks from Tanzania
Thanks! There's a link to the GitHub-project (with the code) in the description of the video :).
im trying reconstruct sand and water particle movement like in noita. i've noticed that it horrendously demanding in terms of cpu consumption. any tips how can i optimize it? i have like few tousand pixels on screen...
First of all, it's really cool that you're trying to create your own physics simulations! I actually didn't know the game you were talking about, but I looked it up and it seems to be similar to the powder toy. I'm not sure if you are using the particle simulator that I wrote to recreate this kind of system. I assume you're talking about a simulation that you wrote yourself? In that case, I can't give a lot of tips to optimize it (as it's been a long time since I wrote this kind of program myself), but I do have some ideas. Firstly, you could try using a sort of 'grid optimization' like I'm doing, although I don't think it's relevant when working with pixels and not particles, since you can just check for collisions with the neighbouring pixels. What you could also try, is using the Numba library (numba.pydata.org/) to run the calculations in parallel on your GPU. This will, however, require some adjustments to the code in order to make it compatible with Numba. I hope this already gives you some ideas, but be sure to let me know if you need more help :).
@@PyExplained Oh, thanks for answer! I did everything from scratch in PyGame. Every pixel has it's X, Y coordinates. I've tried numba, multiprocessing, cython. Neither of these worked for me, I recieved different errors everytime or they slowed it even more. It's really werid. I supposed Python is not made for this kind of stuff. Every pixel checks if there row bottom with place X-1, X, X+1 is free basically. It has to check if the given coordinaes (ex. Y+1, X-1) are occupied. This is the curse, that's why I'm using sets' intersection and it actually makes it faster a little. I added parameter 'age' which counts time from pixel spawn and if this time is above 3 seconds it stops it's calculations. This gave me like 2x more pixels on screeen, but they freeze after that time. I'm kinda newbie to programming and I don't know algorithms but if you want, there it is. github.com/gracjan-p/gracjan-p.github.io/blob/main/media/pyita.py
I just took a look at your project and it looks amazing already! On my PC, I can get around 20.000 particles (water + sand) on screen before the FPS starts to drop below 30, so imo it's quite optimized already (for a basic simulation). I haven't inspected the full code yet, but one thing that does seem 'sub-optimal' is checking the set you created for particles that already hold that position. Wouldn't it make more sense to make a variation on the 'particles_arr' that has the same dimensions as your screen and stores the particle objects as its elements on their respective locations. Then you could just check at a certain index whether or not there is already a particle object present. That's just an idea I had, but maybe you already tried it and it didn't make it any faster... I actually haven't programmed anything for like more than a year, so I would need to brush up some programming skills and principles to give you good advice. I would also change the fact that you're using the age parameter to determine if you should update a particle or not. Maybe it would be better to have a boolean variable that determines if the particle got 'stuck' (/ is in a stable position). Then you could set that back to false if you remove particles below that 'stable' particle. One last thing that I noticed: the sand particles seem to be able to float on the water. Maybe you should make it so they can swap places with the water particles and sink to the bottom?
@@PyExplained I do appreciate for a good word :D 1) Tried NumPy 2d array for this grid. Didn't made a huge difference. The problem is the amount of repetitive calculations for each pixel. There are too many of them. Matrix is better tho because It could easily check for type of particle near so it would act differently in dependency of it. 2) I'll give a try with boolean values. I did this stuck trick but it had just one 'old' position' and pixels tended to freeze in air because of collisions with other particles near them. 3) I know sand float on water I just didn't implied the swapping position yet. It's still kinda buggy for now. Water is not as fluid as It should be, etc.
Sounds like you're already on your way to outsmart me concerning physics simulations :). For real, though, most of my projects just came to be from me tinkering around with code and something more or less cool arising. In other words, I'm afraid I can't give you any specific tips to further improve your simulation ('cause you probably know more about this stuff than I do at the moment). Basically, great work so far! And don't hesitate to give me some updates if you want to (Discord: #pyexplained).
Very informative video
Very cool thanks for sharing
I made a lil cycle Pathtracer, which calculates the rays in parallel using Numpy and in full HD it takes approximately 2 seconds per frame with 6 spheres
Wow, that's really impressive! Did you use Numba or any other special libraries to run it in parallel? Maybe it is also possible with just Numpy alone, which I didn't know...
@PyExplained I sadly downloaded the newest version of Python, so numba wasn't an option. The path tracer is quite vanilla, only using Numpy and Pygame. Let's just say: it used a LOT of masks. Also, it's based on the Raytracer of Sebastian Lague
@@luigidabro Sebastian Lague is indeed a good source of inspiration :). His newest video about ray tracing was definitely intriguing, but at the time of making my ray tracer, that video didn't exist yet... ( although his old video about compute shaders did already cover lots of these topics)
When the tutorial is TOO Good: No seriously i mean you deserve more, first time here and subed, liked and also commented.
Thank you so much! I really appreciate comments like these 🙏
How did you get yours to form into a uniform diagonal patten. They attract and repel but they keep no specific shape
Are you trying to get similar results using the simulator or by making your own version of a particle simulator? In the first case, you can just copy the particle properties of the scene that's created when booting up the program. In the second case, there is no specific way to make them form this pattern. The pattern itself is self-emerging... No rule makes them do this: it's just the most optimal way to 'stack' circles (you can regard the repel area as a circle). When implementing the attraction between particles that are far away and the repulsion of particles that are close-by each other, you should see similar patterns. Hopefully this helps? If not, you can always elaborate on your question and I'll try to give more information :).
Can you please make a discord
Thanks for the suggestion :). I think, however, that I wouldn't have enough time to maintain a Discord server right now. I don't think there are enough viewers who are interested in that either. If you want to send me suggestions or ask questions, you can always send a message to PyExplained#9820 on Discord.
Sir, May I know what papers/books about SPH did you use to make this code? thanks
Actually, I didn't use any books or papers specifically to make this project. It was just an experiment to see what behaviour would emerge when you give particles one or a few simple properties. There aren't really any complex formulas that I implemented... just some experimentation that resulted in this program :).
Hey I'm trying to create the fluid sim shown in the video but I'm not sure about the formula for the force between individual particles can you tell me?
First of all, it's really cool that you're trying out the simulator! At least I'm glad to know that it still seems to function for most people :). To answer your question: you should just be able to load in the file "fluid.sim" from the folder "example_simulations". In the case of that simulation, I used a repulsion-radius of 50 and a strength of 1 (with the mass of the particles also being equal to 1). The attraction-radius is -1 and the strength being 0. Hope this helps.
@@PyExplained thanks that helps! 😊...I was trying understand how fluid sim works and this video helped a lot keep up the good work
Oh, I'm so sorry. I just realized that you're probably talking about making your own simulator. To do that, you can take a look at the code in the Particle class. Especially, the 'calc_attraction_force' function. This part of the code is probably what you're asking for: if distance < repel_r: magnitude = -repel * rest_distance / 10 Again, I wrote this code a long time ago, so it often isn't clear to me either what I wrote back then. The division by 10 is also probably just a constant that I found worked for the simulation, but this might be different for your simulation.
@@PyExplained 🤔 ohh thanks I understood this time... I am trying to do this in blender a 3d software and was trying different formula but didn't work... I'll try using your method😅
you definitely stand out...amazing work.....did u do it during lock down?
Thank you so much! I honestly don't remember if there was a lockdown when I was making this. It could have been a period of part-time online lessons, which gave me more time to work on these sorts of projects. But honestly, the situation changed so often at that time that I can't fully recall which projects I did during a lockdown. However, I now find it difficult to find the time and motivation for these projects. I'm not sure if there'll be any videos coming soon. I have plenty of ideas, but it would be too stressful to start a project with this amount of homework. It's honestly comments like these that do give me motivation to work on another project. I'm just not sure if that's what I'd like to invest my time in right now. Though, thanks again for the lovely comment :).
HOW HOW HOW HOW HOW!?!?!?!?!?
How to open that image file as you opened?
I'm not sure what you mean by your question... I assume you're talking about opening the image in the IDE. I usually use PyCharm, which has a feature to preview images. Or are you talking about viewing the image when the program is running? Please specify your question so I can help you with finding a solution.
@@PyExplained Next to the Python file there were those image files.
@@LimeSpeedCrystal I actually didn't realise until now that I never created a GitHub repository for the code. You can now find the code and images here: github.com/PyExplained/Tutorials/tree/master/Tkinter%20Buttons%20Tutorial
@@PyExplained I already found out how to do that.
how much if you do a simulation?
What exactly do you mean by your question? You should be able to run simulations yourself if you download the code and it's free!
code not work
That's strange... I tested it again just now and everything still seems to be working for me. Which version of Python are you running this on exactly? Maybe you didn't install all the required libraries (you can find more details on that in the documentation on GitHub)? Also, if there's an error message showing, it might be handy if you could paste it over here so I can see what might be causing the error.
@@PyExplained No module named 'PIL.ImageTk'. But i have pillow installed
@@timon1816 I honestly don't know what could be the problem then. Perhaps the library works differently in newer versions of Python? You can always try and install the exe-version of the code. I hope that solves the problem...
Do you think, this could be implemented on micropython ?
To be totally honest, before reading your comment, I had no idea what micropython even was. Therefore, I don't think the code could just be run the way it is. Maybe with some adjustments, but again... don't know a lot about running programs on microcontrollers. Thanks for your comment tho :)
Modern gl ^w^
Damn amazing
I loved it bro really you are doing great job and thanks for the code I have subscribed and i will tell all to my friends to subscribe and to like Bro plz do what others are not doing thanks
Thanks a lot! I really appreciate that :)
This Channel is such a gem. Love your videos. Will try to implement these when i get some free time . Kudos to your content . Keep doing .lots of love❣❣
Great video! I got inspired to try and make something similar myself, but for some reasons my particle clusters end up spinning when they get too large, weird lol
Thanks! It's also really cool that you made your own version of this. Maybe the uncontrollable spinning could be solved using a dampening factor? I'd suggest using something like air resistance, but you may have already implemented this, in which case you could try increasing the resistance/dampening.
I'm writing this comment to let you guys know that I might not be uploading videos about big projects any time soon. School will probably be occupying most of my time again. I'm currently also trying to learn Java, so hopefully, I'll be able to do some projects with that too!
Cool
Who do you optimize it
I think you asked this question twice, but I'll just copy my answer in case you hadn't seen my original answer: The optimization in this project was actually quite simple. The 'canvas' sort of gets divided into multiple grid cells which makes it so you only have to check for collisions in that grid cell. However, this doesn't work when the attraction or repulsion radius are too big or just "infitinitely large" (i.e. set to -1). In that case, all distances will have to be calculated and no optimization is possible. There are better optimization strategies out there (like a quadtree), but this project just started as an experiment to see how far this simple grid optimization would get me.
@@PyExplained that you so much
nice vid bro where do you study?
Thanks! I'm still in highschool, so I can't refer you to any university (if you're asking about that). I live in Belgium, so the name of my school isn't really important, neither would it be a smart decision to share in my comment-section ;). I hope that answers your question, but don't hesitate to specify your question if I didn't yet answer it as intended.
in true autotuning, increasing the pitch does not produce a chipmunk effect
I guess you're right, but I tried my best to make it sound as good as possible. It's also the first time that I tried to do something with sound, so I was glad that it worked as is. But, as you say, there is still room for improvement, so definitely let me know if you have ideas on how to improve the autotuning ;).
@@PyExplained I recently discovered that if you autotune a sound in a true autotune to a high pitch and a low pitch and then display a logarithmic spectrum of these sounds, the component frequencies of the first low-pitched sound have the same spacing between them as the component frequencies of high-pitched sound. I think that solution for that is shifting frequencies from fourier transform not lineary but exponentialy. RUclips does not allow me to insert a link so I had to replace dot with A and / with B. imgurAcomBaBJAQdpkW
That's really interesting! Thanks a lot for the explanation. As I said in the video, I didn't do a lot of research as a means to challenge myself (or maybe because I was a tad bit lazy ;)). I was curious to see if it would just work by shifting the spectrogram up or down by a certain amount, but this obviously throws off the ratios between frequencies, making it sound out of tune. That's why I ended up stretching the spectrogram instead. As you're saying, the solution might just be stretching it exponentially, but I think it might also have to do with the fact that I 'chop up' the audio signal. In earlier testing phases, I did use overlapping samples, but I found that working with chopped-up audio was a lot easier. In the end, the chipmunk effect isn't all that bad when increasing the pitch. It's mostly reverting the audio signal that causes it to sound a little funny. So even in unchanged audio samples, you can hear the distortions. It's also very noticeable when layering multiple voices (like in the reharmonization I did for the intro). However, I do think that doing the thing you described would help with making the 'corrected sample' sound more realistic (since the frequency components of our voice don't always have the same ratio to each other).
This is a good tutorial. Thank you.
very impressive
Great video! Thank you!
Excuseme I download your code and run on spyder, but I cant show like your GUI, maybe I need to install something?
Yes, you do indeed need to install some libraries in order to run the code. Here is the link to the documentation (including a list of the libraries you need to install): github.com/PyExplained/Autotune-using-Python#Required_modules. If you're still having trouble running the code after this, please let me know.
@@PyExplained I have already install all required modules in your GitHub, but it still can’t run the GUI.Does using the different compiler meter?(Sorry about some wrong grammar and thanks for help!)
@@william8495 Could you copy the error message you're getting? Then I could take a look at it.
@@PyExplained I don't have error message, but my output just have a Image like your GUI, and I can't use any function.
@@william8495 Mmmhh... That's weird. I'm not entirely sure what could cause that, but I suggest trying to run it with a different IDE (maybe IDLE?). You should also check whether all the example audiofiles are present (maybe you deleted them?).
i can use this with web app ?
I'm not entirely sure what you mean by your question. If you're asking whether or not you can use the application as a web application, the answer would be no. You can currently only use it by downloading the code (including all the required modules) and running it. I might have misunderstood your question though, so if something still isn't clear, you may have to specify your question.
Hi PyExplained, great video btw. I recently started to do the same thing(raytracer from scratch). Until all the objects are opaque, concept of shadows is pretty clear. I did the same thing as explained in this video. When I added the transparency factor, im not getting any of it(in concept) Unfortunately I also added refraction, now everything is messed up. Now light bends and also travels through objects, I cant use the same logic now. How can I solve this? Thank you.
Wow, it's really cool that you're also making your own raytracer! I would suggest taking a couple of steps back and making sure that your code for rendering opaque objects works. Then, you could add reflections (which is, in my opinion, easier than refraction). To add refraction, you could first take a look at some articles about it (since I didn't really explain it that well in the video). Here is a good article that I used as a reference: www.scratchapixel.com/lessons/3d-basic-rendering/introduction-to-shading/reflection-refraction-fresnel. In hindsight, I think I can say that some of the formulas and algorithms I ended up using still aren't entirely correct, but since it looked fine to me, I kept the code as it was. Hope this helps :)
Yes, I did it step by step 1. All the objects are opaque 2. Add reflectiveness property and cast reflections. 3. (This thing is messed up) Added both transparency and refractive index at the same time. I did the same (almost same) Applied Fresnel equation. Refraction is good (I mean images rendered are getting better) but But shadows are too dark. I'm not taking the transparency of the hit object into account( Atleast I'm thinking to go in that direction) instead of just returning a bool like true if there is an object in the middle and just returning black color( not entirely). My idea mentioned above don't consider refractive index and refraction phenomenon at all. But I feel shadows are affected by refraction also. Can I do it in any better way Or Just ignore refraction thing like some minor effect for shadows and move on. Thank you
I personally didn't add anything too crazy regarding 'refracted shadows and highlights', but the shadows do get lighter depending on the transparency of the object casting them (as well as the color if it's 'stained glass'). I just felt like adding these 'refracted highlights' would get way too complicated, since it would require lots of rays to determine the indirect lighting paths. In your case, if you're happy with the current result, I'd suggest leaving it as is. If not, you can always send me some rendered images on Discord (PyExplained#9820) so I can take a look at them.
Thanks for the idea. I didn't think of the color Thought transparency would be enough. I'm going to leave it like this (ignoring refracted shadows). It's too complicated. I'll definitely get back to you if I get any more doubts. Again thanks man. Really appreciate it.
Your channel is a gem! Idk how you dont have more subs. Great content as always!
This inspired me to try doing this myself ! Thank u !
AttributeError: 'NoneType' object has no attribute 'bind'
If you copied everything correctly, there should be no errors. This is the full code: from tkinter import * tk = Tk() tk.geometry('300x300') def press(_): b.config(image=photo_2) print('pressed') def release(_): b.config(image=photo_1) print('released') photo_1 = PhotoImage(file='button.gif').subsample(2, 2) photo_2 = PhotoImage(file='button_2.gif').subsample(2, 2) b = Button(tk, image=photo_1, cursor='hand2', border='0') b.place(x=150, y=150, anchor=CENTER) b.bind('<ButtonPress>', press) b.bind('<ButtonRelease>', release) tk.mainloop() I hope this works. If not, you can send me your code and I'll try to find the problem.
Being a coder, Dj and a music producer. This video made my day. Thankyou so much
Great video!
It might be super easy for you to create a python3x-To-p5js converter in which you can have the best of both worlds.
Sadly, I have almost no experience using p5.js, but maybe you're referring to converters made by other people? Anyway, I'll probably learn Java soon, so I'll hopefully be able to make more than just Python projects in the future. I also think that understanding my old code would be a lot more confusing than just writing a new (and better) rendering engine. However, my next video isn't going to be about rendering engines, but about sound. So stay tuned for that :)
@@PyExplained Understood... looking very forward to watching more of your work.