1#version 100 2precision highp float; 3precision highp int; 4precision lowp sampler2D; 5precision lowp samplerCube; 6 7/* 8** layered blending & misc math 9** Blending modes, RGB/HSL/Contrast/Desaturate, levels control 10** 11** The shaders below are base on the shaders created by: 12** Romain Dura | Romz 13** Blog: http://blog.mouaif.org 14** Post: http://blog.mouaif.org/?p=94 15*/ 16 17 18/* 19** Desaturation 20*/ 21 22vec4 Desaturate(in vec3 color, in float Desaturation) 23{ 24 vec3 grayXfer = vec3(0.3, 0.59, 0.11); 25 vec3 gray = vec3(dot(grayXfer, color)); 26 return vec4(mix(color, gray, Desaturation), 1.0); 27} 28 29 30/* 31** Hue, saturation, luminance 32*/ 33 34vec3 _RGBToHSL(in vec3 color) 35{ 36 vec3 hsl; // init to 0 to avoid warnings ? (and reverse if + remove first part) 37 38 float fmin = min(min(color.r, color.g), color.b); //Min. value of RGB 39 float fmax = max(max(color.r, color.g), color.b); //Max. value of RGB 40 float delta = fmax - fmin; //Delta RGB value 41 42 hsl.z = (fmax + fmin) / 2.0; // Luminance 43 44 if (delta == 0.0) //This is a gray, no chroma... 45 { 46 hsl.x = 0.0; // Hue 47 hsl.y = 0.0; // Saturation 48 } 49 else //Chromatic data... 50 { 51 if (hsl.z < 0.5) 52 hsl.y = delta / (fmax + fmin); // Saturation 53 else 54 hsl.y = delta / (2.0 - fmax - fmin); // Saturation 55 56 float deltaR = (((fmax - color.r) / 6.0) + (delta / 2.0)) / delta; 57 float deltaG = (((fmax - color.g) / 6.0) + (delta / 2.0)) / delta; 58 float deltaB = (((fmax - color.b) / 6.0) + (delta / 2.0)) / delta; 59 60 if (color.r == fmax ) 61 hsl.x = deltaB - deltaG; // Hue 62 else if (color.g == fmax) 63 hsl.x = (1.0 / 3.0) + deltaR - deltaB; // Hue 64 else if (color.b == fmax) 65 hsl.x = (2.0 / 3.0) + deltaG - deltaR; // Hue 66 67 if (hsl.x < 0.0) 68 hsl.x += 1.0; // Hue 69 else if (hsl.x > 1.0) 70 hsl.x -= 1.0; // Hue 71 } 72 73 return hsl; 74} 75 76float _HueToRGB(in float f1, in float f2, in float hue) 77{ 78 if (hue < 0.0) 79 hue += 1.0; 80 else if (hue > 1.0) 81 hue -= 1.0; 82 float res; 83 if ((6.0 * hue) < 1.0) 84 res = f1 + (f2 - f1) * 6.0 * hue; 85 else if ((2.0 * hue) < 1.0) 86 res = f2; 87 else if ((3.0 * hue) < 2.0) 88 res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0; 89 else 90 res = f1; 91 return res; 92} 93 94/* 95** Contrast, saturation, brightness 96** Code of this function is from TGM's shader pack 97** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057 98*/ 99 100// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150% 101vec3 ContrastSaturationBrightness(in vec3 color, in float brt, in float sat, in float con) 102{ 103 // Increase or decrease these values to adjust r, g and b color channels separately 104 const float AvgLumR = 0.5; 105 const float AvgLumG = 0.5; 106 const float AvgLumB = 0.5; 107 108 const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721); 109 110 vec3 AvgLumin = vec3(AvgLumR, AvgLumG, AvgLumB); 111 vec3 brtColor = color * brt; 112 vec3 intensity = vec3(dot(brtColor, LumCoeff)); 113 vec3 satColor = mix(intensity, brtColor, sat); 114 vec3 conColor = mix(AvgLumin, satColor, con); 115 return conColor; 116} 117 118/* 119** Float blending modes 120** Adapted from here: http://www.nathanm.com/photoshop-blending-math/ 121** But I modified the HardMix (wrong condition), Overlay, SoftLight, ColorDodge, ColorBurn, VividLight, PinLight (inverted layers) ones to have correct results 122*/ 123 124#define BlendLinearDodgef BlendAddf 125#define BlendLinearBurnf BlendSubtractf 126#define BlendAddf(base, blend) min(base + blend, 1.0) 127#define BlendSubtractf(base, blend) max(base + blend - 1.0, 0.0) 128#define BlendLightenf(base, blend) max(blend, base) 129#define BlendDarkenf(base, blend) min(blend, base) 130#define BlendScreenf(base, blend) (1.0 - ((1.0 - base) * (1.0 - blend))) 131#define BlendOverlayf(base, blend) (base < 0.5 ? (2.0 * base * blend) : (1.0 - 2.0 * (1.0 - base) * (1.0 - blend))) 132#define BlendSoftLightf(base, blend) ((blend < 0.5) ? (2.0 * base * blend + base * base * (1.0 - 2.0 * blend)) : (sqrt(base) * (2.0 * blend - 1.0) + 2.0 * base * (1.0 - blend))) 133#define BlendColorDodgef(base, blend) ((blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0)) 134#define BlendColorBurnf(base, blend) ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0)) 135#define BlendHardMixf(base, blend) ((BlendVividLightf(base, blend) < 0.5) ? 0.0 : 1.0) 136 137/* 138** Vector3 blending modes 139*/ 140 141// Component wise blending 142#define Blend1(base, blend, funcf) funcf(base, blend) 143#define Blend3(base, blend, funcf) vec3(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b)) 144#define Blend4(base, blend, funcf) vec4(funcf(base.r, blend.r), funcf(base.g, blend.g), funcf(base.b, blend.b), funcf(base.a, blend.a)) 145 146#define BlendNormal(base, blend) (base) 147#define BlendMultiply(base, blend) (base * blend) 148#define BlendAverage(base, blend) ((base + blend) / 2.0) 149#define BlendAdd(base, blend) min(base + blend, 1.0) 150#define BlendSubtract(base, blend) max(base + blend - 1.0, 0.0) 151#define BlendDifference(base, blend) abs(base - blend) 152#define BlendNegation(base, blend) (1.0 - abs(1.0 - base - blend)) 153#define BlendExclusion(base, blend) (base + blend - 2.0 * base * blend) 154#define BlendPhoenix(base, blend) (min(base, blend) - max(base, blend) + 1.0) 155#define BlendOpacity(base, blend, F, O) (F(base, blend) * O + blend * (1.0 - O)) 156 157// Hue Blend mode creates the result color by combining the luminance and saturation of the base color with the hue of the blend color. 158float BlendHue1(in float base, in float blend) 159{ 160 return base; 161} 162 163vec3 BlendHue3(in vec3 base, in vec3 blend) 164{ 165 vec3 baseHSL = _RGBToHSL(base); 166 vec3 rgb, inHSL = vec3(_RGBToHSL(blend).r, baseHSL.g, baseHSL.b); 167 168 // The HSLToRGB function has been inlined to here 169 if (inHSL.y == 0.0) 170 rgb = vec3(inHSL.z); // Luminance 171 else 172 { 173 float f2; 174 175 if (inHSL.z < 0.5) 176 f2 = inHSL.z * (1.0 + inHSL.y); 177 else 178 f2 = (inHSL.z + inHSL.y) - (inHSL.y * inHSL.z); 179 180 float f1 = 2.0 * inHSL.z - f2; 181 182 rgb.r = _HueToRGB(f1, f2, inHSL.x + (1.0/3.0)); 183 rgb.g = _HueToRGB(f1, f2, inHSL.x); 184 rgb.b = _HueToRGB(f1, f2, inHSL.x - (1.0/3.0)); 185 } 186 187 return rgb; 188} 189 190vec4 BlendHue4(in vec4 base, in vec4 blend) 191{ 192 vec3 hue = BlendHue3(base.xyz, blend.xyz); 193 return vec4(hue.x, hue.y, hue.z, BlendHue1(base.w, blend.w)); 194} 195 196// Saturation Blend mode creates the result color by combining the luminance and hue of the base color with the saturation of the blend color. 197float BlendSaturation1(in float base, in float blend) 198{ 199 return base; 200} 201 202vec3 BlendSaturation3(in vec3 base, in vec3 blend) 203{ 204 vec3 baseHSL = _RGBToHSL(base); 205 206 vec3 rgb, inHSL = vec3(baseHSL.r, _RGBToHSL(blend).g, baseHSL.b); 207 208 // The HSLToRGB function has been inlined to here 209 if (inHSL.y == 0.0) 210 rgb = vec3(inHSL.z); // Luminance 211 else 212 { 213 float f2; 214 215 if (inHSL.z < 0.5) 216 f2 = inHSL.z * (1.0 + inHSL.y); 217 else 218 f2 = (inHSL.z + inHSL.y) - (inHSL.y * inHSL.z); 219 220 float f1 = 2.0 * inHSL.z - f2; 221 222 rgb.r = _HueToRGB(f1, f2, inHSL.x + (1.0/3.0)); 223 rgb.g = _HueToRGB(f1, f2, inHSL.x); 224 rgb.b = _HueToRGB(f1, f2, inHSL.x - (1.0/3.0)); 225 } 226 227 return rgb; 228} 229 230vec4 BlendSaturation4(in vec4 base, in vec4 blend) 231{ 232 vec3 hue = BlendSaturation3(base.xyz, blend.xyz); 233 return vec4(hue.x, hue.y, hue.z, BlendSaturation1(base.w, blend.w)); 234} 235 236// Color Mode keeps the brightness of the base color and applies both the hue and saturation of the blend color. 237float BlendColor1(in float base, in float blend) 238{ 239 return base; 240} 241 242vec3 BlendColor3(in vec3 base, in vec3 blend) 243{ 244 vec3 blendHSL = _RGBToHSL(blend); 245 246 vec3 rgb, inHSL = vec3(blendHSL.r, blendHSL.g, _RGBToHSL(base).b); 247 248 // The HSLToRGB function has been inlined to here 249 if (inHSL.y == 0.0) 250 rgb = vec3(inHSL.z); // Luminance 251 else 252 { 253 float f2; 254 255 if (inHSL.z < 0.5) 256 f2 = inHSL.z * (1.0 + inHSL.y); 257 else 258 f2 = (inHSL.z + inHSL.y) - (inHSL.y * inHSL.z); 259 260 float f1 = 2.0 * inHSL.z - f2; 261 262 rgb.r = _HueToRGB(f1, f2, inHSL.x + (1.0/3.0)); 263 rgb.g = _HueToRGB(f1, f2, inHSL.x); 264 rgb.b = _HueToRGB(f1, f2, inHSL.x - (1.0/3.0)); 265 } 266 267 return rgb; 268} 269 270vec4 BlendColor4(in vec4 base, in vec4 blend) 271{ 272 vec3 hue = BlendColor3(base.xyz, blend.xyz); 273 return vec4(hue.x, hue.y, hue.z, BlendColor1(base.w, blend.w)); 274} 275 276 277// Luminosity Blend mode creates the result color by combining the hue and saturation of the base color with the luminance of the blend color. 278float BlendLuminosity1(in float base, in float blend) 279{ 280 return base; 281} 282 283vec3 BlendLuminosity3(in vec3 base, in vec3 blend) 284{ 285 vec3 baseHSL = _RGBToHSL(base); 286 vec3 rgb, inHSL = vec3(baseHSL.r, baseHSL.g, _RGBToHSL(blend).b); 287 288 // The HSLToRGB function has been inlined to here 289 if (inHSL.y == 0.0) 290 rgb = vec3(inHSL.z); // Luminance 291 else 292 { 293 float f2; 294 295 if (inHSL.z < 0.5) 296 f2 = inHSL.z * (1.0 + inHSL.y); 297 else 298 f2 = (inHSL.z + inHSL.y) - (inHSL.y * inHSL.z); 299 300 float f1 = 2.0 * inHSL.z - f2; 301 302 rgb.r = _HueToRGB(f1, f2, inHSL.x + (1.0/3.0)); 303 rgb.g = _HueToRGB(f1, f2, inHSL.x); 304 rgb.b = _HueToRGB(f1, f2, inHSL.x - (1.0/3.0)); 305 } 306 307 return rgb; 308} 309 310vec4 BlendLuminosity4(in vec4 base, in vec4 blend) 311{ 312 vec3 hue = BlendLuminosity3(base.xyz, blend.xyz); 313 return vec4(hue.x, hue.y, hue.z, BlendLuminosity1(base.w, blend.w)); 314} 315 316float BlendLinearLightf(in float s1, in float s2) 317{ 318 float oColor; 319 320 if (s2 < 0.5) 321 { 322 float s2x = (2.0 * s2); 323 oColor = BlendSubtractf(s1, s2x); 324 } 325 else 326 { 327 float s2x = (2.0 * (s2 - 0.5)); 328 oColor = BlendAddf(s1, s2x); 329 } 330 331 return oColor; 332} 333 334float BlendVividLightf(in float s1, in float s2) 335{ 336 float oColor; 337 338 if (s2 < 0.5) 339 { 340 float s2x = (2.0 * s2); 341 oColor = BlendColorBurnf(s1, s2x); 342 } 343 else 344 { 345 float s2x = (2.0 * (s2 - 0.5)); 346 oColor = BlendColorDodgef(s1, s2x); 347 } 348 349 return oColor; 350} 351 352float BlendPinLightf(in float s1, in float s2) 353{ 354 float oColor; 355 356 if (s2 < 0.5) 357 { 358 float s2x = (2.0 * s2); 359 oColor = BlendDarkenf(s1, s2x); 360 } 361 else 362 { 363 float s2x = (2.0 * (s2 - 0.5)); 364 oColor = BlendLightenf(s1, s2x); 365 } 366 367 return oColor; 368} 369 370float BlendReflectf(in float s1, in float s2) 371{ 372 float oColor; 373 374 if (s2 == 1.0) 375 { 376 oColor = s2; 377 } 378 else 379 { 380 float s1x = (s1 * s1) / (1.0 - s2); 381 382 oColor = min(s1x, 1.0); 383 } 384 385 return oColor; 386} 387 388//------------------------------------ 389// Interface for RTShader 390//------------------------------------ 391 392 393void SGX_blend_normal(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 394{ 395 oColor = BlendNormal(basePixel, blendPixel); 396} 397 398void SGX_blend_normal(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 399{ 400 oColor = BlendNormal(basePixel, blendPixel); 401} 402 403void SGX_blend_normal(in float basePixel, in float blendPixel, out float oColor) 404{ 405 oColor = BlendNormal(basePixel, blendPixel); 406} 407 408 409void SGX_blend_lighten(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 410{ 411 oColor = BlendLightenf(basePixel, blendPixel); 412} 413 414void SGX_blend_lighten(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 415{ 416 oColor = BlendLightenf(basePixel, blendPixel); 417} 418 419void SGX_blend_lighten(in float basePixel, in float blendPixel, out float oColor) 420{ 421 oColor = BlendLightenf(basePixel, blendPixel); 422} 423 424 425void SGX_blend_darken(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 426{ 427 oColor = BlendDarkenf(basePixel, blendPixel); 428} 429 430void SGX_blend_darken(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 431{ 432 oColor = BlendDarkenf(basePixel, blendPixel); 433} 434 435void SGX_blend_darken(in float basePixel, in float blendPixel, out float oColor) 436{ 437 oColor = BlendDarkenf(basePixel, blendPixel); 438} 439 440 441void SGX_blend_multiply(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 442{ 443 oColor = BlendMultiply(basePixel, blendPixel); 444} 445 446void SGX_blend_multiply(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 447{ 448 oColor = BlendMultiply(basePixel, blendPixel); 449} 450 451void SGX_blend_multiply(in float basePixel, in float blendPixel, out float oColor) 452{ 453 oColor = BlendMultiply(basePixel, blendPixel); 454} 455 456 457void SGX_blend_average(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 458{ 459 oColor = BlendAverage(basePixel, blendPixel); 460} 461 462void SGX_blend_average(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 463{ 464 oColor = BlendAverage(basePixel, blendPixel); 465} 466 467void SGX_blend_average(in float basePixel, in float blendPixel, out float oColor) 468{ 469 oColor = BlendAverage(basePixel, blendPixel); 470} 471 472 473void SGX_blend_add(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 474{ 475 oColor = BlendAdd(basePixel, blendPixel); 476} 477 478void SGX_blend_add(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 479{ 480 oColor = BlendAdd(basePixel, blendPixel); 481} 482 483void SGX_blend_add(in float basePixel, in float blendPixel, out float oColor) 484{ 485 oColor = BlendAdd(basePixel, blendPixel); 486} 487 488 489void SGX_blend_subtract(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 490{ 491 oColor = BlendSubtract(basePixel, blendPixel); 492} 493 494void SGX_blend_subtract(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 495{ 496 oColor = BlendSubtract(basePixel, blendPixel); 497} 498 499void SGX_blend_subtract(in float basePixel, in float blendPixel, out float oColor) 500{ 501 oColor = BlendSubtract(basePixel, blendPixel); 502} 503 504 505void SGX_blend_difference(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 506{ 507 oColor = BlendDifference(basePixel, blendPixel); 508} 509void SGX_blend_difference(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 510{ 511 oColor = BlendDifference(basePixel, blendPixel); 512} 513void SGX_blend_difference(in float basePixel, in float blendPixel, out float oColor) 514{ 515 oColor = BlendDifference(basePixel, blendPixel); 516} 517 518 519void SGX_blend_negation(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 520{ 521 oColor = BlendNegation(basePixel, blendPixel); 522} 523void SGX_blend_negation(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 524{ 525 oColor = BlendNegation(basePixel, blendPixel); 526} 527void SGX_blend_negation(in float basePixel, in float blendPixel, out float oColor) 528{ 529 oColor = BlendNegation(basePixel, blendPixel); 530} 531 532 533void SGX_blend_exclusion(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 534{ 535 oColor = BlendExclusion(basePixel, blendPixel); 536} 537void SGX_blend_exclusion(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 538{ 539 oColor = BlendExclusion(basePixel, blendPixel); 540} 541void SGX_blend_exclusion(in float basePixel, in float blendPixel, out float oColor) 542{ 543 oColor = BlendExclusion(basePixel, blendPixel); 544} 545 546 547void SGX_blend_screen(in vec4 s1, in vec4 s2, out vec4 oColor) 548{ 549 oColor = vec4(BlendScreenf(s1.r, s2.r), 550 BlendScreenf(s1.g, s2.g), 551 BlendScreenf(s1.b, s2.b), 552 BlendScreenf(s1.a, s2.a)); 553} 554void SGX_blend_screen(in vec3 s1, in vec3 s2, out vec3 oColor) 555{ 556 oColor = vec3(BlendScreenf(s1.r, s2.r), 557 BlendScreenf(s1.g, s2.g), 558 BlendScreenf(s1.b, s2.b)); 559} 560void SGX_blend_screen(in float s1, in float s2, out float oColor) 561{ 562 oColor = BlendScreenf(s1, s2); 563} 564 565 566void SGX_blend_overlay(in vec4 s1, in vec4 s2, out vec4 oColor) 567{ 568 oColor = vec4(BlendOverlayf(s1.r, s2.r), 569 BlendOverlayf(s1.g, s2.g), 570 BlendOverlayf(s1.b, s2.b), 571 BlendOverlayf(s1.a, s2.a)); 572} 573void SGX_blend_overlay(in vec3 s1, in vec3 s2, out vec3 oColor) 574{ 575 oColor = vec3(BlendOverlayf(s1.r, s2.r), 576 BlendOverlayf(s1.g, s2.g), 577 BlendOverlayf(s1.b, s2.b)); 578} 579void SGX_blend_overlay(in float s1, in float s2, out float oColor) 580{ 581 oColor = BlendOverlayf(s1, s2); 582} 583 584 585void SGX_blend_softLight(in vec4 s1, in vec4 s2, out vec4 oColor) 586{ 587 oColor = vec4(BlendSoftLightf(s1.r, s2.r), 588 BlendSoftLightf(s1.g, s2.g), 589 BlendSoftLightf(s1.b, s2.b), 590 BlendSoftLightf(s1.a, s2.a)); 591} 592void SGX_blend_softLight(in vec3 s1, in vec3 s2, out vec3 oColor) 593{ 594 oColor = vec3(BlendSoftLightf(s1.r, s2.r), 595 BlendSoftLightf(s1.g, s2.g), 596 BlendSoftLightf(s1.b, s2.b)); 597} 598void SGX_blend_softLight(in float s1, in float s2, out float oColor) 599{ 600 oColor = BlendSoftLightf(s1, s2); 601} 602 603 604void SGX_blend_hardLight(in vec4 s1, in vec4 s2, out vec4 oColor) 605{ 606 oColor = vec4(BlendOverlayf(s1.r, s2.r), 607 BlendOverlayf(s1.g, s2.g), 608 BlendOverlayf(s1.b, s2.b), 609 BlendOverlayf(s1.a, s2.a)); 610} 611void SGX_blend_hardLight(in vec3 s1, in vec3 s2, out vec3 oColor) 612{ 613 oColor = vec3(BlendOverlayf(s1.r, s2.r), 614 BlendOverlayf(s1.g, s2.g), 615 BlendOverlayf(s1.b, s2.b)); 616} 617void SGX_blend_hardLight(in float s1, in float s2, out float oColor) 618{ 619 oColor = BlendOverlayf(s1, s2); 620} 621 622 623void SGX_blend_colorDodge(in vec4 s1, in vec4 s2, out vec4 oColor) 624{ 625 oColor = vec4(BlendColorDodgef(s1.r, s2.r), 626 BlendColorDodgef(s1.g, s2.g), 627 BlendColorDodgef(s1.b, s2.b), 628 BlendColorDodgef(s1.a, s2.a)); 629} 630void SGX_blend_colorDodge(in vec3 s1, in vec3 s2, out vec3 oColor) 631{ 632 oColor = vec3(BlendColorDodgef(s1.r, s2.r), 633 BlendColorDodgef(s1.g, s2.g), 634 BlendColorDodgef(s1.b, s2.b)); 635} 636void SGX_blend_colorDodge(in float s1, in float s2, out float oColor) 637{ 638 oColor = BlendColorDodgef(s1, s2); 639} 640 641 642void SGX_blend_colorBurn(in vec4 s1, in vec4 s2, out vec4 oColor) 643{ 644 oColor = vec4(BlendColorBurnf(s1.r, s2.r), 645 BlendColorBurnf(s1.g, s2.g), 646 BlendColorBurnf(s1.b, s2.b), 647 BlendColorBurnf(s1.a, s2.a)); 648} 649void SGX_blend_colorBurn(in vec3 s1, in vec3 s2, out vec3 oColor) 650{ 651 oColor = vec3(BlendColorBurnf(s1.r, s2.r), 652 BlendColorBurnf(s1.g, s2.g), 653 BlendColorBurnf(s1.b, s2.b)); 654} 655void SGX_blend_colorBurn(in float s1, in float s2, out float oColor) 656{ 657 oColor = BlendColorBurnf(s1, s2); 658} 659 660 661void SGX_blend_linearDodge(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 662{ 663 oColor = BlendAddf(basePixel, blendPixel); 664} 665void SGX_blend_linearDodge(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 666{ 667 oColor = BlendAddf(basePixel, blendPixel); 668} 669void SGX_blend_linearDodge(in float basePixel, in float blendPixel, out float oColor) 670{ 671 oColor = BlendAddf(basePixel, blendPixel); 672} 673 674 675void SGX_blend_linearBurn(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 676{ 677 oColor = BlendSubtractf(basePixel, blendPixel); 678} 679void SGX_blend_linearBurn(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 680{ 681 oColor = BlendSubtractf(basePixel, blendPixel); 682} 683void SGX_blend_linearBurn(in float basePixel, in float blendPixel, out float oColor) 684{ 685 oColor = BlendSubtractf(basePixel, blendPixel); 686} 687 688 689void SGX_blend_linearLight(in vec4 s1, in vec4 s2, out vec4 oColor) 690{ 691 oColor = vec4(BlendLinearLightf(s1.r, s2.r), 692 BlendLinearLightf(s1.g, s2.g), 693 BlendLinearLightf(s1.b, s2.b), 694 BlendLinearLightf(s1.a, s2.a)); 695} 696void SGX_blend_linearLight(in vec3 s1, in vec3 s2, out vec3 oColor) 697{ 698 oColor = vec3(BlendLinearLightf(s1.r, s2.r), 699 BlendLinearLightf(s1.g, s2.g), 700 BlendLinearLightf(s1.b, s2.b)); 701} 702void SGX_blend_linearLight(in float s1, in float s2, out float oColor) 703{ 704 oColor = BlendLinearLightf(s1, s2); 705} 706 707 708void SGX_blend_vividLight(in vec4 s1, in vec4 s2, out vec4 oColor) 709{ 710 oColor = vec4(BlendVividLightf(s1.r, s2.r), 711 BlendVividLightf(s1.g, s2.g), 712 BlendVividLightf(s1.b, s2.b), 713 BlendVividLightf(s1.a, s2.a)); 714} 715void SGX_blend_vividLight(in vec3 s1, in vec3 s2, out vec3 oColor) 716{ 717 oColor = vec3(BlendVividLightf(s1.r, s2.r), 718 BlendVividLightf(s1.g, s2.g), 719 BlendVividLightf(s1.b, s2.b)); 720} 721void SGX_blend_vividLight(in float s1, in float s2, out float oColor) 722{ 723 oColor = BlendVividLightf(s1, s2); 724} 725 726 727void SGX_blend_pinLight(in vec4 s1, in vec4 s2, out vec4 oColor) 728{ 729 oColor = vec4(BlendPinLightf(s1.r, s2.r), 730 BlendPinLightf(s1.g, s2.g), 731 BlendPinLightf(s1.b, s2.b), 732 BlendPinLightf(s1.a, s2.a)); 733} 734void SGX_blend_pinLight(in vec3 s1, in vec3 s2, out vec3 oColor) 735{ 736 oColor = vec3(BlendPinLightf(s1.r, s2.r), 737 BlendPinLightf(s1.g, s2.g), 738 BlendPinLightf(s1.b, s2.b)); 739} 740void SGX_blend_pinLight(in float s1, in float s2, out float oColor) 741{ 742 oColor = BlendPinLightf(s1, s2); 743} 744 745 746void SGX_blend_hardMix(in vec4 s1, in vec4 s2, out vec4 oColor) 747{ 748 oColor = vec4(BlendHardMixf(s1.r, s2.r), 749 BlendHardMixf(s1.g, s2.g), 750 BlendHardMixf(s1.b, s2.b), 751 BlendHardMixf(s1.a, s2.a)); 752} 753void SGX_blend_hardMix(in vec3 s1, in vec3 s2, out vec3 oColor) 754{ 755 oColor = vec3(BlendHardMixf(s1.r, s2.r), 756 BlendHardMixf(s1.g, s2.g), 757 BlendHardMixf(s1.b, s2.b)); 758} 759void SGX_blend_hardMix(in float s1, in float s2, out float oColor) 760{ 761 oColor = BlendHardMixf(s1, s2); 762} 763 764void SGX_blend_reflect(in vec4 s1, in vec4 s2, out vec4 oColor) 765{ 766 oColor = vec4(BlendReflectf(s1.r, s2.r), 767 BlendReflectf(s1.g, s2.g), 768 BlendReflectf(s1.b, s2.b), 769 BlendReflectf(s1.a, s2.a)); 770} 771void SGX_blend_reflect(in vec3 s1, in vec3 s2, out vec3 oColor) 772{ 773 oColor = vec3(BlendReflectf(s1.r, s2.r), 774 BlendReflectf(s1.g, s2.g), 775 BlendReflectf(s1.b, s2.b)); 776} 777void SGX_blend_reflect(in float s1, in float s2, out float oColor) 778{ 779 oColor = BlendReflectf(s1, s2); 780} 781 782 783void SGX_blend_glow(in vec4 s1, in vec4 s2, out vec4 oColor) 784{ 785 oColor = vec4(BlendReflectf(s1.r, s2.r), 786 BlendReflectf(s1.g, s2.g), 787 BlendReflectf(s1.b, s2.b), 788 BlendReflectf(s1.a, s2.a)); 789} 790void SGX_blend_glow(in vec3 s1, in vec3 s2, out vec3 oColor) 791{ 792 oColor = vec3(BlendReflectf(s1.r, s2.r), 793 BlendReflectf(s1.g, s2.g), 794 BlendReflectf(s1.b, s2.b)); 795} 796void SGX_blend_glow(in float s1, in float s2, out float oColor) 797{ 798 oColor = BlendReflectf(s1, s2); 799} 800 801 802void SGX_blend_phoenix(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 803{ 804 oColor = BlendPhoenix(basePixel, blendPixel); 805} 806void SGX_blend_phoenix(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 807{ 808 oColor = BlendPhoenix(basePixel, blendPixel); 809} 810void SGX_blend_phoenix(in float basePixel, in float blendPixel, out float oColor) 811{ 812 oColor = BlendPhoenix(basePixel, blendPixel); 813} 814 815 816void SGX_blend_saturation(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 817{ 818 oColor = BlendSaturation4(basePixel, blendPixel); 819} 820void SGX_blend_saturation(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 821{ 822 oColor = BlendSaturation3(basePixel, blendPixel); 823} 824void SGX_blend_saturation(in float basePixel, in float blendPixel, out float oColor) 825{ 826 oColor = BlendSaturation1(basePixel, blendPixel); 827} 828 829 830void SGX_blend_color(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 831{ 832 oColor = BlendColor4(basePixel, blendPixel); 833} 834void SGX_blend_color(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 835{ 836 oColor = BlendColor3(basePixel, blendPixel); 837} 838void SGX_blend_color(in float basePixel, in float blendPixel, out float oColor) 839{ 840 oColor = BlendColor1(basePixel, blendPixel); 841} 842 843 844void SGX_blend_luminosity(in vec4 basePixel, in vec4 blendPixel, out vec4 oColor) 845{ 846 oColor = BlendLuminosity4(basePixel, blendPixel); 847} 848void SGX_blend_luminosity(in vec3 basePixel, in vec3 blendPixel, out vec3 oColor) 849{ 850 oColor = BlendLuminosity3(basePixel, blendPixel); 851} 852void SGX_blend_luminosity(in float basePixel, in float blendPixel, out float oColor) 853{ 854 oColor = BlendLuminosity1(basePixel, blendPixel); 855} 856 857 858//////////////////////////////////////////////////////////////////////////////////// 859/// Source modification functions 860//////////////////////////////////////////////////////////////////////////////////// 861 862 863void SGX_src_mod_modulate(in vec4 iColor, in vec4 controlVal, out vec4 oColor) 864{ 865 oColor = iColor * controlVal; 866} 867void SGX_src_mod_modulate(in vec3 iColor, in vec3 controlVal, out vec3 oColor) 868{ 869 oColor = iColor * controlVal; 870} 871void SGX_src_mod_modulate(in float iColor, in float controlVal, out float oColor) 872{ 873 oColor = iColor * controlVal; 874} 875 876void SGX_src_mod_inv_modulate(in vec4 iColor, in vec4 controlVal, out vec4 oColor) 877{ 878 oColor = mix(iColor, vec4(1.0), controlVal); 879} 880void SGX_src_mod_inv_modulate(in vec3 iColor, in vec3 controlVal, out vec3 oColor) 881{ 882 oColor = mix(iColor, vec3(1.0), controlVal); 883} 884void SGX_src_mod_inv_modulate(in float iColor, in float controlVal, out float oColor) 885{ 886 oColor = mix(iColor, 1.0, controlVal); 887} 888