[orx-fx] Add bias to contour.frag
This commit is contained in:
@@ -7,11 +7,12 @@ uniform float contourOpacity;
|
|||||||
uniform vec4 contourColor;
|
uniform vec4 contourColor;
|
||||||
uniform float backgroundOpacity;
|
uniform float backgroundOpacity;
|
||||||
uniform int window;
|
uniform int window;
|
||||||
|
uniform float bias;
|
||||||
|
|
||||||
float calc_contour(vec2 uv) {
|
float calc_contour(vec2 uv) {
|
||||||
vec4 box = texture(tex0, uv);
|
vec4 box = texture(tex0, uv);
|
||||||
float v = sin(3.1415926535 * levels * dot(vec3(1.0/3.0),box.xyz));
|
float v = sin(3.1415926535 * levels * (dot(vec3(1.0 / 3.0), box.xyz) + bias));
|
||||||
float level = floor(dot(vec3(1.0/3.0),box.xyz) * levels) / levels;
|
float level = floor((dot(vec3(1.0 / 3.0), box.xyz) + bias) * levels) / levels;
|
||||||
float contour = 1.0 - smoothstep(0., contourWidth, 0.5 * abs(v) / fwidth(v));
|
float contour = 1.0 - smoothstep(0., contourWidth, 0.5 * abs(v) / fwidth(v));
|
||||||
return contour;
|
return contour;
|
||||||
}
|
}
|
||||||
@@ -21,13 +22,13 @@ void main() {
|
|||||||
float contour = 0.0;
|
float contour = 0.0;
|
||||||
float weight = 0.0;
|
float weight = 0.0;
|
||||||
|
|
||||||
for (int i = -window; i <= window; ++i) {
|
for (int i = -window; i <= window; ++i) {
|
||||||
for (int j = -window; j <= window; ++j) {
|
for (int j = -window; j <= window; ++j) {
|
||||||
contour += calc_contour(v_texCoord0 + step/(float(window)+1.0) * vec2(float(i), float(j)));
|
contour += calc_contour(v_texCoord0 + step / (float(window) + 1.0) * vec2(float(i), float(j)));
|
||||||
weight += 1.0;
|
weight += 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
contour /= weight;
|
contour /= weight;
|
||||||
vec4 t = texture(tex0, v_texCoord0);
|
vec4 t = texture(tex0, v_texCoord0);
|
||||||
o_output = t * backgroundOpacity * (1.0-contour) + contour * contourColor * contourOpacity * t.a;
|
o_output = t * backgroundOpacity * (1.0 - contour) + contour * contourColor * contourOpacity * t.a;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user