Reputation: 649
I am trying to pass in a value from Processing to the GLSL shader file but Processing produce and error that it did not read the uniform float that I have already declared in the shader file. However, Processing does read my other uniform float that I have declared. Below is part of my code in my program.
GLSL Shader File:
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
varying vec2 surfacePosition;
const float checkSize = 20.0;
uniform float mouseX;
uniform float mouseY;
uniform float size;
uniform float time;
void main()
{
// other codes
}
Processing:
void draw()
{
background(255);
myShader.set("mouseX", map(mouseX, 0, width, 0 , 200));
myShader.set("mouseY", map(mouseY, 0, height, 200, 0));
myShader.set("counter", myCounter);
myShader.set("size", 600);
shader(myShader);
translate(width/2, height/2);
shape(sphere);
myCounter += 0.05;
}
Processing produces the following error message:
The shader doesn't have a uniform called "size"
Processing successfully reads the uniform variable mouseX
, mouseY
and time
but not size
. Why is this so?
Upvotes: 0
Views: 326
Reputation: 744
I guess '600' is handled as an integer value. Try to cast it to float manually. This should solve your problem.
Another problem could be that you are currently not using the variable 'size'. Then the compiler just removes the uniform from your shader.
It is hard to get the problem without knowing your code within the shader.
Upvotes: 1