# Processing Shader Tool

**URL:** https://discourse.processing.org/t/processing-shader-tool/5476
**Category:** Gallery
**Created:** [November 12, 2018, 4:47pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476 "2018-11-12T16:47:16Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [November 12, 2018, 4:47pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/1 "2018-11-12T16:47:16Z")

</div>

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

https://player.vimeo.com/video/300311634?app_id=122963

(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?

---

<div class="post-metadata">

### Author: ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)
#### Post date: [November 12, 2018, 6:43pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/2 "2018-11-12T18:43:29Z")

</div>

Without wanting too much competition in the live programming sphere 😉 , 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?

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [November 12, 2018, 7:44pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/3 "2018-11-12T19:44:20Z")

</div>

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

> <https://github.com/processing/processing/issues/5648>

  
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 🙂 And it also works in other IDEs, unlike a Processing Tool.

---

<div class="post-metadata">

### Author: ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)
#### Post date: [November 12, 2018, 8:40pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/4 "2018-11-12T20:40:03Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![matheplica](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matheplica/32/21035_2.png) [@matheplica](https://discourse.processing.org/u/matheplica)
#### Post date: [November 14, 2018, 9:47am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/5 "2018-11-14T09:47:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [November 19, 2018, 10:44pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/6 "2018-11-19T22:44:54Z")

</div>

There’s a primitive work-in-progress version at [https://funprogramming.org/ShaderTool-for-Processing/](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.

---

<div class="post-metadata">

### Author: ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)
#### Post date: [November 20, 2018, 11:05am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/7 "2018-11-20T11:05:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [November 20, 2018, 11:31am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/8 "2018-11-20T11:31:20Z")

</div>

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

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [November 23, 2018, 5:56pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/9 "2018-11-23T17:56:32Z")

</div>

A small video showing the latest version:  
https://player.vimeo.com/video/302483414?app_id=122963

Download: [https://funprogramming.org/ShaderTool-for-Processing/](https://funprogramming.org/ShaderTool-for-Processing/)

GitHub: [https://github.com/hamoid/edit-shaders-processing-tool](https://github.com/hamoid/edit-shaders-processing-tool)

I wonder, does it work for anyone? 🙂

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [November 26, 2018, 5:44pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/10 "2018-11-26T17:44:33Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [November 26, 2018, 6:55pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/11 "2018-11-26T18:55:22Z")

</div>

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

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).

---

<div class="post-metadata">

### Author: ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)
#### Post date: [November 26, 2018, 10:36pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/12 "2018-11-26T22:36:00Z")

</div>

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 😄 could be integration with Atom / Visual Code?

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

---

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [June 14, 2020, 6:10pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/13 "2020-06-14T18:10:01Z")

</div>

@hamoid – was Processing Shader Tool ever submitted to Contributions Manager?

I was just looking at a shader resources roundup alongside things like [shader-mode](https://github.com/Izza11/shader-mode) and realized that I couldn’t find Shader Tool in the PDE tools menu.

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [June 15, 2020, 7:41am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/14 "2020-06-15T07:41:46Z")

</div>

Hi @jeremydouglass

I never submitted it. I haven’t received almost any feedback so I don’t know if it’s useful for others or good enough. I think it makes it very easy to add shaders to a project.

I’m happy with it being submitted and open for pull requests. I may do small fixes but my focus has [shifted](https://github.com/hamoid?org=openrndr) so I won’t make big changes. Happy if someone wants to continue it though 🙂

---

<div class="post-metadata">

### Author: ![galousis](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@galousis](https://discourse.processing.org/u/galousis)
#### Post date: [May 13, 2021, 9:32pm UTC](https://discourse.processing.org/t/processing-shader-tool/5476/15 "2021-05-13T21:32:50Z")

</div>

Hi there @hamoid, i really liked your effort on this. I tried that but i get to see that error in the stack. Do you have any hint or idea to resolve that issue ? Since i would love to use your tool.

 ![Screenshot from 2021-05-14 00-26-07](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f56048304b247f5ed464ed3b139535ede8a2bfbc.jpeg)

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [May 14, 2021, 6:38am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/16 "2021-05-14T06:38:14Z")

</div>

Hi hi 🙂

Yes, that error is due to this line:

> <https://github.com/hamoid/edit-shaders-processing-tool/blob/master/src/template/tool/EditShaders.java#L79>

and I think it would be solved by doing this instead:

> <https://github.com/hamoid/edit-shaders-processing-tool/issues/10>
>
> https://docs.oracle.com/javase/8/docs/api/java/awt/Desktop.html#edit-java.io.Fil…e-
> Suggested by @neilcsmith-net

I’ll take a look. The thing I have to figure out is how to build the tool. I don’t remember 🙂

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [May 14, 2021, 9:55am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/17 "2021-05-14T09:55:54Z")

</div>

Ok, I had forgotten that inside Processing’s `preferences.txt` there should be a line like this:

```
tools.shadertool.editor=xterm,-e,cd %PATH% ; vi %FILE%

```

You can change it to fit your preferred GLSL code editor. For example to use the default editor in Ubuntu (gedit) you could use this:

```
tools.shadertool.editor=gedit,%PATH%/%FILE%

```

Note that the string gets split by the `,` character into an array whilch gets sent to the `.exec()` java command. The first element of the array should be a program and the remaining elements are arguments. In this example the program is `gedit` and there’s one argument with the full path to the GLSL file to open.

---

<div class="post-metadata">

### Author: ![galousis](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@galousis](https://discourse.processing.org/u/galousis)
#### Post date: [May 14, 2021, 10:16am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/18 "2021-05-14T10:16:30Z")

</div>

Hi @hamoid

I was strongly suspecting that that xterm was another editor. So that is why i asked to get to see how i am going to open for example gedit, as you mentioned already. Will check and give you feedback.

Thanks a lot

---

<div class="post-metadata">

### Author: ![galousis](https://avatars.discourse-cdn.com/v4/letter/g/ccd318/32.png) [@galousis](https://discourse.processing.org/u/galousis)
#### Post date: [May 14, 2021, 10:30am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/19 "2021-05-14T10:30:24Z")

</div>

@hamoid

`String editor = Preferences.get(PREF_KEY_EDITOR);`  
`private static final String PREF_KEY_EDITOR = "tools.shadertool.editor";`

In my preferences.txt file of processing that string is missing, so its looking per OS.  
xterm was not installed in my linux distro so that was the problem.  
Installed xterm and everything is ok.

Maybe setting in the code and compiling with gedit for Ubuntu distros would be better though.

Thanks a lot

 ![Screenshot from 2021-05-14 13-28-31](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b5cbd784ebbed070be0b7ac683e759a54ed17aa7.jpeg)

---

<div class="post-metadata">

### Author: ![hamoid](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hamoid/32/58_2.png) [@hamoid](https://discourse.processing.org/u/hamoid)
#### Post date: [May 14, 2021, 11:07am UTC](https://discourse.processing.org/t/processing-shader-tool/5476/20 "2021-05-14T11:07:10Z")

</div>

Oh strange… so even after using the tool, closing Processing, the string is not in the preferences file?

`xterm` is the terminal I had installed on Arch Linux. But it should be possible to specify any editor… Could it be that you have several preferences files? Mine is under `~/.processing/preferences.txt`

You installed `xterm` and that may make you happy if you’re used to `vi` 🙂 which is the editor I was using. But that’s not a general solution, as many people will prefer editors that are easier to quit 😉

Note that you should edit the preferences file only with Processing closed, as it will overwrite your changes otherwise.

[Next page](https://discourse.processing.org/t/processing-shader-tool/5476.md?page=2)
