Hi every one, I hope you can help me.
I’m getting into programming shaders and would like to use processing to visualise them.
According to “The Book of Shaders” the following code should load it :
PShader shader;
void setup() {
size(640, 360, P2D);
noStroke();
shader = loadShader("shader.frag");
}
void draw() {
shader.set("u_resolution", float(width), float(height));
shader.set("u_mouse", float(mouseX), float(mouseY));
shader.set("u_time", millis() / 1000.0);
shader(shader);
rect(0,0,width,height);
}
It also mentions that the shader file should be safed in the "data" folder.
Where can i find this "data" folder?
I tried saving it in the same folder as the sketch => no result
I tried making a folder named "data" in the same folder as the sketch => no result
I tried making a folder named "data" c:\data and putting the file shader.frag there. I changed the code in : shader = loadShader("c:\data\shader.frag"); => no result
I have no idea what more to try. Any help is appreciated.
Cheers,
Adrian.
I run that same demo on a Mac and it works ok. The shader.frag file is in a ‘data’ folder that I created. Maybe your shader.frag file is corrupted. Mine looks like this:
Cannot compile fragment shader:
ERROR: 0:12: Use of undeclared identifier 'gl_FragColor'
I’m confused by the three double quote block frame. Is this documented for Processing somewhere? I’ve seen double quotes for each line in text books, but not “”“…”“” for the entire block. In general I’ve had a difficult time using other editors for OpenGL such as NetBeans or IntelliJ; I’ve had the best luck with Processing. Seems like there is always some missing file with the others.
Addendum:
Runs without error on Windows 11 system.
The triple-quotes for multi-line strings is new with Java 13 which Processing upgraded to with version 4.0. They should probably be added to Processing’s String documentation.
I like the three double quote block frame. It’s easier than trying to format each line and adding a line break to each line that I have seen in other places. Once you’ve got the frame set up it’s easy to copy paste into it. Thanks for the information and showing us how it works.