Processing Shader Tool


#1

Very much work in progress, but I’m curious if anyone has feedback.

(enable the subtitles by pressing CC)

What this tool tries to solve is the disconnection between the Processing IDE and the shader files, by making it easy to create new shader files based on templates, launch an external editor, rename, delete and in the future, update the Processing code related to shaders (renaming, creating) and link to the GLSL documentation. Any ideas?


#2

Without wanting too much competition in the live programming sphere :wink: , and not sure if you have this already / in mind, but how about listening on the shader file being saved and automatically updating the PShader using reflection?


#3

There’s the plan to make shader hot-reloading the default:


Is that what you mean?

Meanwhile for that purpose so far I use my own shader class which also catches malformed shaders with a try/catch, so the program doesn’t crash. I can share that too, maybe as a library.

Since I already have that shader-reloading class, I don’t need to do it via reflection :slight_smile: And it also works in other IDEs, unlike a Processing Tool.


#4

Ah, yes, had noticed but forgotten that PShader enhancement issue. I was considering something that behaved transparently to the user, but might be difficult to integrate outside of PDE.


#5

Great idea ! To learn it’s perfect. I hope to use it soon.


#6

There’s a primitive work-in-progress version at https://funprogramming.org/ShaderTool-for-Processing/
Still much to do. To configure the editor launched by the tool, after opening the tool once, you can close Processing and edit its preferences.txt file. There should one of these 3 lines (depending on the OS):

tools.shadertool.editor=xterm,-e,cd %PATH% ; vi %FILE%
tools.shadertool.editor=notepad.exe,%PATH%/%FILE%"
tools.shadertool.editor=open,-e,%PATH%/%FILE%

which means that in Windows it opens notepad.exe, in Linux vi, and in Mac the default text editor. I only tested Linux. You could change the line to use atom, sublime or whatever you use.

I’ll make the tool better and safer soon (no confirmation dialogs when deleting a shader = dangerous!) and add documentation.


#7

Have you considered using https://docs.oracle.com/javase/8/docs/api/java/awt/Desktop.html#edit-java.io.File- for the default editor?


#8

Thank you for the idea! So good to have people to learn from in the forum :slight_smile:


#9

A small video showing the latest version:

Download: https://funprogramming.org/ShaderTool-for-Processing/

GitHub: https://github.com/hamoid/edit-shaders-processing-tool

I wonder, does it work for anyone? :slight_smile:


#10

I really like the tool’s templating options. Those make this approach work well as a power user tool – especially if you want it to work outside PDE.

For PDE beginners, on the other hand I wish that PDE Java mode simply supported display and edit of .glsl file tabs – similar to the way that p5.js mode supports both .js and .html tabs.

My reasoning is that mentally tracking actions (and save states) across multiple text editors is something that many experienced programmers are quite familiar with, but it adds a lot of mental overhead for learners.

Now, granted, working with shaders isn’t generally a “beginners” thing. But if the topic is making shaders easier to work with and accessible (and easier to teach!) that is one direction my thinking goes…


#11

Thank you @jeremydouglass . If the PDE supported editing glsl files I would not have created this tool :slight_smile:

I agree that built in editing would be the best option, but it’s more effort than I can do atm.

Since IDEs like Idea make things so easy, I wonder if instead of making the PDE more powerful it would be better to make Idea easier (provide a Processing project template, suggest configuration tips, tutorials, etc).


#12

Yes @jeremydouglass never understood why PDE doesn’t support opening any text-based file from a sketch for editing. There was a bit of talk recently on a HTML / LSP editor to replace PDE. @hamoid maybe your IDEA idea :smile: could be integration with Atom / Visual Code?

Of course there’s another IDE for Processing that supports GLSL in tabs … :wink: