I have give it a try in Processing's new version, 2.0b8, using the #define in each shader code and changing the names:
Color shader:
Line shader:
Texture shader
Color shader:
- #define PROCESSING_COLOR_SHADER
varying vec4 vertColor;
uniform float fogNear;
uniform float fogFar;
void main(){
gl_FragColor = vertColor;
vec3 fogColor = vec3(1.0,1.0,1.0);
float depth = gl_FragCoord.z / gl_FragCoord.w;
float fogFactor = smoothstep(fogNear, fogFar, depth);
gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w), fogFactor);
}
Line shader:
- #define PROCESSING_LINE_SHADER
varying vec4 vertColor;
uniform float fogNear;
uniform float fogFar;
void main(){
gl_FragColor = vertColor;
vec3 fogColor = vec3(1.0,1.0,1.0);
float depth = gl_FragCoord.z / gl_FragCoord.w;
float fogFactor = smoothstep(fogNear, fogFar, depth);
gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w), fogFactor);
}
Texture shader
- #define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
varying vec4 vertColor;
varying vec4 vertTexCoord;
uniform float fogNear;
uniform float fogFar;
void main() {
gl_FragColor = texture2D(texture, vertTexCoord.st) * vertColor;
vec3 fogColor = vec3(1.0,1.0,1.0);
float depth = gl_FragCoord.z / gl_FragCoord.w;
float fogFactor = smoothstep(fogNear, fogFar, depth);
gl_FragColor = mix(gl_FragColor, vec4(fogColor, gl_FragColor.w), fogFactor);
}