Changeset View
Changeset View
Standalone View
Standalone View
libkwineffects/kwinglutils.cpp
Show First 20 Lines • Show All 341 Lines • ▼ Show 20 Line(s) | 332 | { | |||
---|---|---|---|---|---|
342 | 342 | | |||
343 | mVec2Location[Offset] = uniformLocation("offset"); | 343 | mVec2Location[Offset] = uniformLocation("offset"); | ||
344 | 344 | | |||
345 | mVec4Location[ModulationConstant] = uniformLocation("modulation"); | 345 | mVec4Location[ModulationConstant] = uniformLocation("modulation"); | ||
346 | 346 | | |||
347 | mFloatLocation[Saturation] = uniformLocation("saturation"); | 347 | mFloatLocation[Saturation] = uniformLocation("saturation"); | ||
348 | 348 | | |||
349 | mColorLocation[Color] = uniformLocation("geometryColor"); | 349 | mColorLocation[Color] = uniformLocation("geometryColor"); | ||
350 | mVec4Location[TextureClamp] = uniformLocation("textureClamp"); | ||||
350 | 351 | | |||
351 | mLocationsResolved = true; | 352 | mLocationsResolved = true; | ||
352 | } | 353 | } | ||
353 | 354 | | |||
354 | int GLShader::uniformLocation(const char *name) | 355 | int GLShader::uniformLocation(const char *name) | ||
355 | { | 356 | { | ||
356 | const int location = glGetUniformLocation(mProgram, name); | 357 | const int location = glGetUniformLocation(mProgram, name); | ||
357 | return location; | 358 | return location; | ||
▲ Show 20 Lines • Show All 514 Lines • ▼ Show 20 Line(s) | 868 | if (traits & ShaderTrait::MapTexture) { | |||
872 | if (traits & ShaderTrait::AdjustSaturation) | 873 | if (traits & ShaderTrait::AdjustSaturation) | ||
873 | stream << "uniform float saturation;\n"; | 874 | stream << "uniform float saturation;\n"; | ||
874 | 875 | | |||
875 | stream << "\n" << varying << " vec2 texcoord0;\n"; | 876 | stream << "\n" << varying << " vec2 texcoord0;\n"; | ||
876 | 877 | | |||
877 | } else if (traits & ShaderTrait::UniformColor) | 878 | } else if (traits & ShaderTrait::UniformColor) | ||
878 | stream << "uniform vec4 geometryColor;\n"; | 879 | stream << "uniform vec4 geometryColor;\n"; | ||
879 | 880 | | |||
881 | if (traits & ShaderTrait::ClampTexture) { | ||||
882 | stream << "uniform vec4 textureClamp;\n"; | ||||
883 | } | ||||
884 | | ||||
880 | if (output != QByteArrayLiteral("gl_FragColor")) | 885 | if (output != QByteArrayLiteral("gl_FragColor")) | ||
881 | stream << "\nout vec4 " << output << ";\n"; | 886 | stream << "\nout vec4 " << output << ";\n"; | ||
882 | 887 | | |||
883 | stream << "\nvoid main(void)\n{\n"; | 888 | stream << "\nvoid main(void)\n{\n"; | ||
884 | if (traits & ShaderTrait::MapTexture) { | 889 | if (traits & ShaderTrait::MapTexture) { | ||
885 | if (traits & (ShaderTrait::Modulate | ShaderTrait::AdjustSaturation)) { | 890 | stream << "vec2 texcoordC = texcoord0;\n"; | ||
886 | stream << " vec4 texel = " << textureLookup << "(sampler, texcoord0);\n"; | | |||
887 | 891 | | |||
892 | if (traits & ShaderTrait::ClampTexture) { | ||||
893 | stream << "texcoordC.x = clamp(texcoordC.x, textureClamp.x, textureClamp.z);\n"; | ||||
894 | stream << "texcoordC.y = clamp(texcoordC.y, textureClamp.y, textureClamp.w);\n"; | ||||
895 | } | ||||
896 | | ||||
897 | if (traits & (ShaderTrait::Modulate | ShaderTrait::AdjustSaturation)) { | ||||
898 | stream << " vec4 texel = " << textureLookup << "(sampler, texcoordC);\n"; | ||||
888 | if (traits & ShaderTrait::Modulate) | 899 | if (traits & ShaderTrait::Modulate) | ||
889 | stream << " texel *= modulation;\n"; | 900 | stream << " texel *= modulation;\n"; | ||
890 | if (traits & ShaderTrait::AdjustSaturation) | 901 | if (traits & ShaderTrait::AdjustSaturation) | ||
891 | stream << " texel.rgb = mix(vec3(dot(texel.rgb, vec3(0.2126, 0.7152, 0.0722))), texel.rgb, saturation);\n"; | 902 | stream << " texel.rgb = mix(vec3(dot(texel.rgb, vec3(0.2126, 0.7152, 0.0722))), texel.rgb, saturation);\n"; | ||
892 | 903 | | |||
893 | stream << " " << output << " = texel;\n"; | 904 | stream << " " << output << " = texel;\n"; | ||
894 | } else { | 905 | } else { | ||
895 | stream << " " << output << " = " << textureLookup << "(sampler, texcoord0);\n"; | 906 | stream << " " << output << " = " << textureLookup << "(sampler, texcoordC);\n"; | ||
896 | } | 907 | } | ||
897 | } else if (traits & ShaderTrait::UniformColor) | 908 | } else if (traits & ShaderTrait::UniformColor) | ||
898 | stream << " " << output << " = geometryColor;\n"; | 909 | stream << " " << output << " = geometryColor;\n"; | ||
899 | 910 | | |||
900 | stream << "}"; | 911 | stream << "}"; | ||
901 | stream.flush(); | 912 | stream.flush(); | ||
902 | return source; | 913 | return source; | ||
903 | } | 914 | } | ||
▲ Show 20 Lines • Show All 1414 Lines • Show Last 20 Lines |