-
Notifications
You must be signed in to change notification settings - Fork 0
Translating shaders for processing
Martin Prout edited this page Jun 9, 2015
·
4 revisions
###Uniforms have been renamed
uniform sampler2D texture; // iChannel0 in Shadertoy
uniform vec2 sketchSize; // iResolution in Shadertoy###Main is changed
void mainImage( out vec4 fragColor, in vec2 fragCoord )
// becomes
void main( void )###Other renaming
// fragCoord and fragColor had to be renamed into
gl_FragCoord
gl_FragColor###Y axis adjustment not required
processing coordinates are inverted comment out or remove adjustment as in example glsl fragment
vec2 uv = coords / sketchSize.xy;
// processing is already using inverted y coordinates
// uv.y = 1.0-uv.y; ###To make the shader compatible with OpenGL ES and WebGL
insert the following at top of shader
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif###Other defines for processing shaders
See processing tutorial eg
// This line is optional from Processing 2.1 and up
#define PROCESSING_TEXTURE_SHADER