glsl-optimizer icon indicating copy to clipboard operation
glsl-optimizer copied to clipboard

I am getting two errors compiling my oil pain frag shader.

Open OferRub opened this issue 11 years ago • 5 comments

The errors:

"./builtincompiler --glsl-es OilPaint.frag Info log for OilPaint.frag: 0:0(0): error: no matching function for call to texture2D(sampler2D, vec2)' 0:0(0): error: no matching function for call tomin(float, float)'"

The fragment shader code:

// // Shader.fsh // Test // // Created by Ofer Rubinshtein on 12/2/12. // Copyright (c) 2012 Ofer Rubinshtein. All rights reserved. //

varying highp vec2 texOut1; uniform sampler2D baseTexture; uniform sampler2D overlayTexture1; uniform highp float alpha; uniform highp float radius; uniform highp vec2 pixelRatio; //uniform int step;

void main() { int rx = 2; int ry = 2; highp float lumCount[13]; highp float averageR[13]; highp float averageG[13]; highp float averageB[13]; for (int i=0; i<13; i++) { lumCount[i] = 0.; averageR[i] = 0.; averageG[i] = 0.; averageB[i] = 0.; }

// highp float tempMax = 0.0; for (int i=0; i<(2_ry+1); i++) { int y =i; y-=ry; for (int j=0; j<(2_rx+1); j++) { int x =j; x-=rx; //highp float b = max(1.0-(sqrt(float(x_x+y_y))/radius), 0.0); // highp float b = 1.0/(1.0+float(rx_rx+ry_ry));//float(r+1-abs(x))/step; highp float b = 1.0; highp vec2 delta = vec2(float(x)_pixelRatio.x_radius, float(y)_pixelRatio.y_radius); highp vec2 uv = texOut1+delta; highp vec4 rgb = texture2D(baseTexture, uv); highp float intensity = min(((rgb.r+rgb.g+rgb.b)/3.0)_13.0, 12.0); int curIntensity = int(intensity); lumCount[curIntensity]+=b; averageR[curIntensity] += rgb.r;//_b; averageG[curIntensity] += rgb.g;//_b; averageB[curIntensity] += rgb.b;//_b; } } int maxIndex = 0; highp float curMax; curMax = 0.0; for (int i=0; i<13; i++) if (lumCount[i] > curMax) { curMax = lumCount[i]; maxIndex = i; } gl_FragColor = vec4(averageR[maxIndex] / curMax, averageG[maxIndex] / curMax, averageB[maxIndex] / curMax, 1.0); }

Any idea what I am doing wrong? I couldn't find a lot of documentation about it.

OferRub avatar May 30 '13 09:05 OferRub

I have the same problem with other built-in functions like normalize, length, dot, etc. Using Mac OS X 10.8 and the "builtincompiler" executable as compiled with Xcode.

AndiDog avatar Aug 19 '13 15:08 AndiDog

The "builtincompiler" is not the GLSL optimizer. It's just an executable for building some of the intermediate representations of the built-in functions.

aras-p avatar Aug 19 '13 16:08 aras-p

Ah sorry. Then is there an executable created together with the project that can be used to test the optimization, or would I need to write that myself?

AndiDog avatar Aug 19 '13 17:08 AndiDog

Right now you'd need to write it yourself, I think.

aras-p avatar Aug 19 '13 18:08 aras-p

Well there is the "contrib/glslopt" project but it doesn't compile out of the box, and instead of just using the static library includes all source files manually. I've already created a working compiler application under "projects\vs2010\glsl_optimizer.vcxproj" - if you want I can port it to Mac as well and send you a pull request?!

AndiDog avatar Aug 20 '13 08:08 AndiDog