I can get a shader to read in two textures but for output it seems there is only gl_FragColor. Is there any way to render to two different textures from one shader? I am using Processing and the GLGraphics library btw.
Ins and outs GLSL defined the in and out keywords specifically for that purpose. Each shader can specify inputs and outputs using those keywords and wherever an output variable matches with an input variable of the next shader stage they're passed along. The vertex and fragment shader differ a bit though.
Shaders use GLSL (OpenGL Shading Language), a special OpenGL Shading Language with syntax similar to C. GLSL is executed directly by the graphics pipeline. There are several kinds of shaders, but two are commonly used to create graphics on the web: Vertex Shaders and Fragment (Pixel) Shaders.
You can also open and edit GLSL files with source code editors, such as Microsoft Visual Studio Code (multiplatform). Since GLSL files are saved in plain text, you can use any text editor, such as Microsoft Notepad (bundled with Windows), Apple TextEdit (bundled with macOS), or gedit (Linux) to open and edit them.
Yes, you can write to gl_FragData, which is an array of outputs (size depends on your implementation). Or with newer versions of GL, both gl_FragColor and gl_FragData are deprecated and you declare your own out
variables for the fragment shader to write to. Declare multiple such out
vars for multiple output buffers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With