Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Different shaders for geometry, lines and text?

$
0
0
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:
  1. #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:
  1. #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
  1. #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);
    }

The color and texture shaders work, and there's no error in the console, but lines are not affected but the shader. There is no Line shader example to check for name changes




Viewing all articles
Browse latest Browse all 1768

Trending Articles