Hello, everyone!
I’m totally new to shaders, but with a huge help of defold forum managed to copy and adapt that brightness/contrast shader from ShaderToy. So it works perfect on my main (win 10) PC, but once I’ve copied windows bundle to (win 10) laptop, it refused to work with:
WARNING:GRAPHICS 0:4 #version direction missing
ERROR: 0:47: “=” : cannot convert from ‘4 component vector of highp float’ to ‘highp float’
and then there go a few lines of ‘unable to create resource’ errors
Here’s a tiny shader I use:
varying mediump vec2 var_texcoord0; varying mediump vec3 var_position; uniform lowp sampler2D sbuffer; uniform lowp vec4 tint; uniform lowp vec4 bcs; mat4 brightnessMatrix( float brightness ) { return mat4( 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, brightness, brightness, brightness, 1 ); } mat4 contrastMatrix( float contrast ) { float t = ( 1.0 - contrast ) / 2.0; return mat4( contrast, 0, 0, 0, 0, contrast, 0, 0, 0, 0, contrast, 0, t, t, t, 1 ); } mat4 saturationMatrix( float saturation ) { vec3 luminance = vec3( 0.3086, 0.6094, 0.0820 ); float oneMinusSat = 1.0 - saturation; vec3 red = vec3( luminance.x * oneMinusSat ); red+= vec3( saturation, 0, 0 ); vec3 green = vec3( luminance.y * oneMinusSat ); green += vec3( 0, saturation, 0 ); vec3 blue = vec3( luminance.z * oneMinusSat ); blue += vec3( 0, 0, saturation ); return mat4 ( red, 0, green, 0, blue, 0, 0, 0, 0, 1 ); } void main() { float brightness = bcs.x; float contrast = bcs.y; float saturation = bcs.z; lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); vec4 color = texture2D(sbuffer, var_texcoord0.xy); float grey = color; //color.r * 0.3 + color.g * 0.59 + color.b * 0.11; gl_FragColor = brightnessMatrix( brightness ) * contrastMatrix( contrast ) * saturationMatrix( saturation ) * color * tint_pm; }
I know that the problem it that I’m total noob with shaders. But I just don’t know where to go with this.
Hege thanks for any possible help!