Quantcast
Channel: GLSL / Shaders - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 212

Use an extra texture with a shader

$
0
0

I wan't to use an extra texture with a shader. For some reason I get this error:

The shader doesn't have a uniform called "textureB" OR the uniform was removed during compilation because it was unused.

I know what the error means, but in this case it doesn't make sense to me. What is going wrong?

PShader psBlendLightest;

PGraphics pg;

PGraphics textureB;


void settings() {
  size(512, 512, P2D);
}

void setup() {
  psBlendLightest = loadShader("http://localhost:8888/shaders/blendLightest.glsl"); // set with processing LIGHTEST

  pg = createGraphics(512, 512, P2D);
  textureB = createGraphics(512, 512, P2D);

  pg.beginDraw();
  pg.background(0);
  pg.fill(255);
  pg.quad(25, 25, 400, 40, 450, 500, 40, 300);
  pg.endDraw();


  textureB.beginDraw();
  textureB.background(0);
  textureB.fill(255);
  textureB.ellipse(256, 256, 400, 400);
  textureB.endDraw();


}


void draw() {
  image(textureB, 0, 0);  

  psBlendLightest.set("textureB", textureB);
  shader(psBlendLightest);

  image(pg, 0, 0);  

}

The shader:

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

#define PROCESSING_TEXTURE_SHADER

uniform sampler2D texture;
varying vec4 vertTexCoord;


uniform sampler2D textureB;



void main() {

  vec3 texColorA = texture2D(texture, vertTexCoord.st).rgb;
  vec3 texColorB = texture2D(textureB, vertTexCoord.st).rgb;

  gl_FragColor = vec4(max(texColorA, texColorB), 1.0);
}

Viewing all articles
Browse latest Browse all 212

Trending Articles