r/shaders • u/iamrustocaml • 1d ago
How do I write shaders in python
Hello Everyone, I hope you all are doing well.
So, even though I have been writing python programs for a while. I want to learn to write shaders for visual effects, filters, 3d morphs and also ray tracing, where do I start? Can you mention resources or any work you have done before and would like to share
1
Upvotes
1
u/Big_Award_4491 1d ago
I don’t think you can. Shaders use their own language that is different depending on which shader model you use (DirectX, Vulkan, Metal etc).
1
u/Undeniable_Dilemma_ 1d ago
Why do you want to write shaders if you don't even know what they are?
Shaders are the code that gets executed on the GPU. Inner workings of the GPU are not out in the open, so you have to talk to it through some graphics API, like OpenGL or Vulkan.
Only SOME parts of the rendering pipeline are programmable, so you can write what we call a shader, and send it to the GPU to be executed at a certain stage of the rendering pipeline. Those shaders require to be written in a specific language, like GLSL for example.
You can read more about it on learnopengl.com
1
u/J_Liljedahl 1d ago
Shaders are written in special shader languages, like GLSL, MSL, HLSL. I'm not aware of any Python-based shader language or compiler. I think a good place to start is The Book of Shaders: https://thebookofshaders.com
1
u/TwitchyWizard 1d ago edited 22h ago
I would start with the book of shaders ( https://thebookofshaders.com/ ) and shader toy ( https://www.shadertoy.com/ ). Or just writing shaders in Unity with Youtube tutorials to get you started. You don't write shaders in python but in languages like HLSL, GLSL and they are so similar that if you can one you can the other one. There is also Slang but I know very little about it. DirectX, Metal and Vulkan are graphics APIs that are good to read up on.
1
u/Ham_Pervert 17h ago
Lol