-
Notifications
You must be signed in to change notification settings - Fork 23
/
romance.glsl
47 lines (36 loc) · 1.45 KB
/
romance.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
precision highp float;
varying highp vec2 vTextureCoord;
uniform sampler2D sTexture;
uniform sampler2D sTexture2;//curve
void main()
{
lowp vec4 textureColor;
lowp vec4 textureColorRes;
lowp vec4 textureColorOri;
vec4 grey1Color;
vec4 layerColor;
mediump float satVal = 115.0 / 100.0;
float xCoordinate = vTextureCoord.x;
float yCoordinate = vTextureCoord.y;
highp float redCurveValue;
highp float greenCurveValue;
highp float blueCurveValue;
textureColor = texture2D( sTexture, vec2(xCoordinate, yCoordinate));
textureColorRes = textureColor;
textureColorOri = textureColor;
// step1. screen blending
textureColor = 1.0 - ((1.0 - textureColorOri) * (1.0 - textureColorOri));
textureColor = (textureColor - textureColorOri) + textureColorOri;
// step2. curve
redCurveValue = texture2D(sTexture2, vec2(textureColor.r, 0.0)).r;
greenCurveValue = texture2D(sTexture2, vec2(textureColor.g, 0.0)).g;
blueCurveValue = texture2D(sTexture2, vec2(textureColor.b, 0.0)).b;
// step3. saturation
highp float G = (redCurveValue + greenCurveValue + blueCurveValue);
G = G / 3.0;
redCurveValue = ((1.0 - satVal) * G + satVal * redCurveValue);
greenCurveValue = ((1.0 - satVal) * G + satVal * greenCurveValue);
blueCurveValue = ((1.0 - satVal) * G + satVal * blueCurveValue);
textureColor = vec4(redCurveValue, greenCurveValue, blueCurveValue, 1.0);
gl_FragColor = vec4(textureColor.r, textureColor.g, textureColor.b, 1.0);
}