Replies: 8 comments
-
Hi, @ruslye ! Thank you for your analysis and feeback.
I've been using both Fragment and Vertex shaders with py5 and have had great success with both. However, I almost always use Linux or MacOS. I've never written shaders on Windows. It could be this is some kind of platform specific bug, but I'd be surprised if something like this did work on Linux and MacOS and not Windows. Can you provide a code example for us to look at? Also, are you using Windows 11 + Linux Subsystem or is this just Windows?
Right, they are. That gets on my nerves also. I do see compilation errors though. But perhaps errors are reported differently on Windows? py5 does "prune" error messages to try to hide its own internals and Java stuff because showing a Java exception to someone learning Python is misleading and confusing. Can you try deactivating error pruning and seeing if the errors change? https://py5coding.org/reference/py5functions_prune_tracebacks.html To some extent there isn't much I can do about OpenGL errors because those kinds of errors aren't reported well to begin with. However, py5 shouldn't be filtering out any part of those error messages. The error messages should be the same as what you'd get for an analogous Sketch running in Processing.
Yes, they are different methods with different functionality. Both are documented, but I see the documentation pages are a bit sparse, especially given how useful and powerful these methods are. We can certainly add to these descriptions. Based on what you've learned about py5 so far, how would you explain the differences to someone else who is also learning py5? https://py5coding.org/reference/sketch_apply_filter.html
You are welcome! I do appreciate your thoughts here. It is through design conversations like this that we are able to provide a well maintained library. |
Beta Was this translation helpful? Give feedback.
-
Hi, totally skipped my mind to include the codes, but here they are:
vertex shader:
fragment shader:
With vertex and fragment shader: With fragment shader only: I am using Pycharm 2024.3.2 CE on just Windows, no WSL. |
Beta Was this translation helpful? Give feedback.
-
Hi @ruslye , I am pressed for time but I wanted to reply and help you here. There might be a problem with the vertex shader. Processing shaders are a bit different from shaders you find elsewhere like on ShaderToy because there is a Processing framework you need your shader to fit into. To make sure I get it right, I always start shader coding with one of Processing's shaders and modify it for what I want to do. You can find them here: https://github.com/processing/processing4/tree/main/core/src/processing/opengl/shaders First you need to know if your sketch does or does not use lighting and if it does and does not use textures. Here you are using neither, you want ColorVert and ColorFrag. Try copying both of those and using those in your Sketch. If it works and gives identical results to what you'd get with no shader code, then you know that Vertex shaders work fine on your machine. Once you have that working, try editing the code for what you want to do. If it stops working, you know your latest code change broke something. |
Beta Was this translation helpful? Give feedback.
-
@villares , can you cite any good documentation for using shaders in Processing? Everything I've learned is from trial and error, and from studying Processing's source code. |
Beta Was this translation helpful? Give feedback.
-
Sorry, I don't know much about shaders. My friends always mention https://thebookofshaders.com/ but I'm afraid it doesn't delve into using shaders with Processing. A search at the old forums showed up this archived PShader tutorial, I'm not sure if this would help, but here it is: https://web.archive.org/web/20210117181532/https://processing.org/tutorials/pshader/ (it mentions this code repo https://github.com/codeanticode/pshader-tutorials) |
Beta Was this translation helpful? Give feedback.
-
There is a lack of current Shader documentation. I remember reading about an effort to address that somewhere in Discord but I just searched there and didn't find anything worth sharing here. I don't know if anyone will invest much time in it because Processing does want to move away from the current JOGL opengl dependencies and use something else. When that happens, the details of how to use shaders will change. |
Beta Was this translation helpful? Give feedback.
-
Thanks hx2A, villares, the references you gave are helpful. The shaders are indeed written differently. I did manage to inject a color to the wireframe using Processing's point and line shaders documentation though I'll need to look deeper to understand. |
Beta Was this translation helpful? Give feedback.
-
@ruslye I hope you don't mind if we move this into discussions ? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I’ve been experimenting with shaders in Py5 using
py5.shader()
and faced several challenges and unexpected results. Below is a summary of the main issues and observations:1. Fragment Shader Works, But Vertex Shader Causes Issues
py5.shader()
with both fragment and vertex glsl shader. I customise this shader to just simply color the faces and vertices of 3d cube in red.The result is a black wireframe cube with no visible faces.
2. Shader Errors Are Hard to Debug
Example: When an invalid GLSL statement was added intentionally, the error was only visible by digging into the console logs.
gl_FragColor is not accessible in this profile
suggest possible compatibility problems with GLSL or OpenGL, but they aren’t reported clearly.3. Differences Between
py5.shader()
andpy5.apply_filter()
py5.shader()
vs.py5.apply_filter()
, and it’s unclear how they differ. Clarification on their usage would be helpful.Some suggestions that could be helpful:
projection
,view
,model
matrices).System Details:
Thank you for maintaining Py5! I hope this feedback helps enhance shader support in future releases. Let me know if any additional information is needed.
Best regards,
Russell
Beta Was this translation helpful? Give feedback.
All reactions