color correction sdader ERROR!

Hi there!

I’m doing something again here … and I have a problem again!


uniform sampler2D bgl_RenderedTexture; 
void main(void) 
{ 
  float contrast = 1.05; //contrast adjustment 
  float r = 0.015;       //Red Channel adjustement 
  float g = 0.015 ;       //Green Channel adjustement 
  float b = 0.0;        //Blue Channel adjustement 
  float sat = 30.0;     //Saturation adjustement "0.0 = grey" "30.0 = default saturation" 
  float bright = 0.0;   //Brightness adjustement; negative values from 0.0 to -1.0 make the image darker, positve values from 0.0 to 1.0 brighter 
   
     
  vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st); 
  vec3 a = vec3((texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3); 
  vec3 contrasted = vec3((texcolor.r - 0.5) * contrast +0.5,(texcolor.g - 0.5) * contrast +0.5,(texcolor.b - 0.5)* contrast + 0.5); 
   
  gl_FragColor = vec4((contrasted[0]*sat + a[0])/(sat + 1)+r +bright,(contrasted[1]*sat + a[1])/(sat + 1)+g +bright,(contrasted[2]*sat + a[1])/(sat + 1)+b +bright, texcolor.a); 
  //gl_FragColor = vec4(contrasted[0],contrasted[1],contrasted[2], texcolor.a); 
}

I have an error in the console:


Blender Game Engine Finished

Blender Game Engine Started
2D Filter GLSL Shader: compile error:

0:1(1): error: syntax error, unexpected $end

Blender Game Engine Finished

Who knows what the problem is? This is an unexpected error, both for BGE and for me :eyebrowlift:!

Thank you for attention.

==============================
Solution of the problem - point-zero, point-zero, point-zero, point-zero, point-zero, point-zero…

p.s. shader from - ‘color correction von andreas esau’
==============================

Make sure you have all your brackets. I missed one when copying the code. Got the same error. Put the bracket in, and it worked fine with no errors.

  • with brackets everything is fine, this is the original code!
uniform sampler2D bgl_RenderedTexture;
void main(void)
{
  float contrast = 1.05; //contrast adjustment
  float r = 0.015;       //Red Channel adjustement
  float g = 0.015 ;       //Green Channel adjustement
  float b = 0.0;        //Blue Channel adjustement
  float sat = 30.0;     //Saturation adjustement "0.0 = grey" "30.0 = default saturation"
  float bright = 0.0;   //Brightness adjustement; negative values from 0.0 to -1.0 make the image darker, positve values from 0.0 to 1.0 brighter
  
    
  vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
  vec3 a = vec3((texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3);
  vec3 contrasted = vec3((texcolor.r - 0.5) * contrast +0.5,(texcolor.g - 0.5) * contrast +0.5,(texcolor.b - 0.5)* contrast + 0.5);
  
  gl_FragColor = vec4((contrasted[0]*sat + a[0])/(sat + 1)+r +bright,(contrasted[1]*sat + a[1])/(sat + 1)+g +bright,(contrasted[2]*sat + a[1])/(sat + 1)+b +bright, texcolor.a);
  //gl_FragColor = vec4(contrasted[0],contrasted[1],contrasted[2], texcolor.a);
}
  • new error:
Blender Game Engine Finished

Blender Game Engine Started
2D Filter GLSL Shader: compile error:
 1  uniform sampler2D bgl_RenderedTexture;
 2  void main(void)
 3  {
 4    float contrast = 1.05; //contrast adjustment
 5    float r = 0.015;       //Red Channel adjustement
 6    float g = 0.015 ;       //Green Channel adjustement
 7    float b = 0.0;        //Blue Channel adjustement
 8    float sat = 30.0;     //Saturation adjustement "0.0 = grey" "30.0 = default saturation"
 9    float bright = 0.0;   //Brightness adjustement; negative values from 0.0 to -1.0 make the image darker, positve values from 0.0 to 1.0 brighter
10    
11      
12    vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
13    vec3 a = vec3((texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3);
14    vec3 contrasted = vec3((texcolor.r - 0.5) * contrast +0.5,(texcolor.g - 0.5) * contrast +0.5,(texcolor.b - 0.5)* contrast + 0.5);
15    
16    gl_FragColor = vec4((contrasted[0]*sat + a[0])/(sat + 1)+r +bright,(contrasted[1]*sat + a[1])/(sat + 1)+g +bright,(contrasted[2]*sat + a[1])/(sat + 1)+b +bright, texcolor.a);
17    //gl_FragColor = vec4(contrasted[0],contrasted[1],contrasted[2], texcolor.a);
18  }

0:13(16): error: could not implicitly convert operands to arithmetic operator
0:13(11): error: cannot construct `vec3' from a non-numeric data type
0:16(50): error: could not implicitly convert operands to arithmetic operator
0:16(22): error: operands to arithmetic operators must be numeric
0:16(22): error: operands to arithmetic operators must be numeric
0:16(22): error: operands to arithmetic operators must be numeric
0:16(17): error: cannot construct `vec4' from a non-numeric data type



Blender Game Engine Finished

Well I still get no errors in that.

  • I do not know, I’ve found another - everything works.
uniform sampler2D bgl_RenderedTexture;
void main(void)
{
  vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
  float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
  gl_FragColor = vec4(gray * vec3(0.8, 1.0, 1.2), texcolor.a);
}

0:13(16): error: could not implicitly convert operands to arithmetic operator

Is typical of an integer instead of a float when compiled on an intel integrated GPU (or some other type mis-match). NVidia’s a bit less fussy, so that may be why Nicholas_A has no errors.

Ah yup, line 16:


gl_FragColor = vec4((contrasted[0]*sat + a[0])/(sat + <b>1</b>)+r +bright,(contrasted[1]*sat + a[1])/(sat + <b>1</b>)+g +bright,(contrasted[2]*sat + a[1])/(sat + <b>1</b>)+b +bright, texcolor.a);

Replace the bolded “1” with “1.0”

Blender Game Engine Finished
^CTraceback (most recent call last):
  File "/usr/share/blender3d/2.79/scripts/startup/bl_ui/space_properties.py", line 27, in draw
    def draw(self, context):
KeyboardInterrupt

location: &lt;unknown location&gt;:-1

location: &lt;unknown location&gt;:-1

Blender Game Engine Started
2D Filter GLSL Shader: compile error:
 1  uniform sampler2D bgl_RenderedTexture;
 2  void main(void)
 3  {
 4    float contrast = 1.05; //contrast adjustment
 5    float r = 0.015;       //Red Channel adjustement
 6    float g = 0.015 ;       //Green Channel adjustement
 7    float b = 0.0;        //Blue Channel adjustement
 8    float sat = 30.0;     //Saturation adjustement "0.0 = grey" "30.0 = default saturation"
 9    float bright = 0.0;   //Brightness adjustement; negative values from 0.0 to -1.0 make the image darker, positve values from 0.0 to 1.0 brighter
10    
11      
12    vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
13    vec3 a = vec3((texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3);
14    vec3 contrasted = vec3((texcolor.r - 0.5) * contrast +0.5,(texcolor.g - 0.5) * contrast +0.5,(texcolor.b - 0.5)* contrast + 0.5);
15    
16    gl_FragColor = vec4((contrasted[0]*sat + a[0])/(sat + 1.0)+r +bright,(contrasted[1]*sat + a[1])/(sat + 1.0)+g +bright,(contrasted[2]*sat + a[1])/(sat + 1.0)+b +bright, texcolor.a);
17    //gl_FragColor = vec4(contrasted[0],contrasted[1],contrasted[2], texcolor.a);
18  }

0:13(16): error: could not implicitly convert operands to arithmetic operator
0:13(11): error: cannot construct `vec3' from a non-numeric data type



Blender Game Engine Finished
  • thank you, but something does not work.

Same error (solve the first error in the list first), so look for the same problem. Hint: the 0:13(16) means the issue is on line 13, character 16.

change

vec3 a = vec3((texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3,(texcolor.r+texcolor.g+texcolor.b)/3);

to

vec3 a =  vec3((texcolor.r+texcolor.g+texcolor.b)/3.0,(texcolor.r+texcolor.g+texcolor.b)/3.0,(texcolor.r+texcolor.g+texcolor.b)/3.0);

-oh, I have a miracle. The point and zero still worked -Ah-ha-ha!
Thanks for the link … and the point with zero.

The fifth party consisted of those who were adherents of Barclay de
Tolly, not so much as a man but as minister of war and commander in
chief. “Be he what he may” (they always began like that), “he is an
honest, practical man and we have nobody better. Give him real power,
for war cannot be conducted successfully without unity of command, and
he will show what he can do, as he did in Finland. If our army is well
organized and strong and has withdrawn to Drissa without suffering
any defeats, we owe this entirely to Barclay. If Barclay is now to
be superseded by Bennigsen all will be lost, for Bennigsen showed his
incapacity already in 1807.” …

- answer you find in the letters number (without spaces) :

  • line 8, character 17
  • [I]line 6, character 8
    - line 10, character 4
    - line 2, character 7
    - line 3, character
    40
    - line 1, character 17

:rolleyes: [/I]