-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Triadica/multiple-blend
blend blur multiple times
- Loading branch information
Showing
17 changed files
with
4,148 additions
and
958 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
precision mediump float; | ||
|
||
varying float v_s; | ||
varying float v_r; | ||
varying float v_color_index; | ||
|
||
|
||
float hue2rgb(float f1, float f2, float hue) { | ||
if (hue < 0.0) | ||
hue += 1.0; | ||
else if (hue > 1.0) | ||
hue -= 1.0; | ||
float res; | ||
if ((6.0 * hue) < 1.0) | ||
res = f1 + (f2 - f1) * 6.0 * hue; | ||
else if ((2.0 * hue) < 1.0) | ||
res = f2; | ||
else if ((3.0 * hue) < 2.0) | ||
res = f1 + (f2 - f1) * ((2.0 / 3.0) - hue) * 6.0; | ||
else | ||
res = f1; | ||
return res; | ||
} | ||
|
||
vec3 hsl2rgb(vec3 hsl) { | ||
vec3 rgb; | ||
|
||
if (hsl.y == 0.0) { | ||
rgb = vec3(hsl.z); // Luminance | ||
} else { | ||
float f2; | ||
|
||
if (hsl.z < 0.5) | ||
f2 = hsl.z * (1.0 + hsl.y); | ||
else | ||
f2 = hsl.z + hsl.y - hsl.y * hsl.z; | ||
|
||
float f1 = 2.0 * hsl.z - f2; | ||
|
||
rgb.r = hue2rgb(f1, f2, hsl.x + (1.0/3.0)); | ||
rgb.g = hue2rgb(f1, f2, hsl.x); | ||
rgb.b = hue2rgb(f1, f2, hsl.x - (1.0/3.0)); | ||
} | ||
return rgb; | ||
} | ||
|
||
vec3 hsl2rgb(float h, float s, float l) { | ||
return hsl2rgb(vec3(h, s, l)); | ||
} | ||
|
||
void main() { | ||
// if (v_r > (-0.8 * v_s)) { | ||
// // gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); | ||
// float factor = smoothstep(0.0, 0.4, 1.0- (v_r + v_s)/10.0); | ||
|
||
// gl_FragColor = vec4(0.6 + factor, 0.6 + factor, 1.0 - factor, 1.0); | ||
// // } else if (z_color > -1.0) { | ||
// // gl_FragColor = vec4(0.7, 0.7, 1.0, 1.0); | ||
// } else { | ||
// gl_FragColor = vec4(0.8, 0.8, 0.5, 1.0); | ||
// } | ||
|
||
// float vv = 1.0/z; | ||
// gl_FragColor = vec4(vv, vv, vv, 1.0); | ||
|
||
// gl_FragColor = vec4(1.0, 0.5, 0.5, 1.0); | ||
gl_FragColor = vec4(hsl2rgb(0.0, 1.0, 1.0 - v_color_index * 0.06), 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
uniform vec4 u_offsets; | ||
|
||
uniform float coneBackScale; | ||
uniform vec3 lookPoint; // direction in front, transformed into a specific length | ||
uniform vec3 upwardDirection; // direction up over head, better unit vector | ||
uniform float viewportRatio; | ||
uniform vec3 cameraPosition; | ||
|
||
attribute vec3 a_position; | ||
attribute float a_color_index; | ||
|
||
varying float v_r; | ||
varying float v_s; | ||
varying float v_color_index; | ||
|
||
float square(float a) { | ||
return a * a; | ||
} | ||
|
||
struct PointResult { | ||
vec3 point; | ||
float r; | ||
float s; | ||
}; | ||
|
||
PointResult transform_perspective(vec3 p) { | ||
vec3 moved_point = p - cameraPosition; | ||
// trying to get right direction at length 1 | ||
vec3 rightward = cross(upwardDirection, lookPoint) / 600.0; | ||
|
||
float s = coneBackScale; | ||
|
||
float r = dot(moved_point, lookPoint) / square(length(lookPoint)); | ||
|
||
if (r < (s * -0.8)) { | ||
// make it disappear with depth test since it's probably behind the camera | ||
return PointResult(vec3(0.0, 0.0, 10000.), r, s); | ||
} | ||
|
||
float screen_scale = (s + 1.0) / (r + s); | ||
float y_next = dot(moved_point, upwardDirection) * screen_scale; | ||
float x_next = - dot(moved_point, rightward) * screen_scale; | ||
|
||
float z_next = r; | ||
|
||
return PointResult(vec3(x_next, y_next / viewportRatio, z_next), r, s); | ||
} | ||
|
||
void main() { | ||
PointResult result = transform_perspective(a_position); | ||
vec3 pos_next = result.point; | ||
|
||
v_s = result.s; | ||
v_r = result.r; | ||
v_color_index = a_color_index; | ||
|
||
gl_Position = vec4(pos_next * 0.001, 1.0); | ||
// gl_Position = vec4(a_position/10000.0, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
precision mediump float; | ||
|
||
|
||
varying float v_s; | ||
varying float v_r; | ||
varying float v_color_index; | ||
|
||
void main() { | ||
// if (v_r > (-0.8 * v_s)) { | ||
// gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); | ||
// float factor = smoothstep(0.0, 0.4, 1.0- (v_r + v_s)/10.0); | ||
|
||
// gl_FragColor = vec4(0.6 + factor, 0.6 + factor, 1.0 - factor, 1.0); | ||
// } else if (z_color > -1.0) { | ||
// gl_FragColor = vec4(0.7, 0.7, 1.0, 1.0); | ||
|
||
if (v_color_index > 0.5) { | ||
gl_FragColor = vec4(1.0, 1.0, 0.2, 1.0); | ||
} else { | ||
gl_FragColor = vec4(0.6, 0.2, 1.0, 1.0); | ||
} | ||
|
||
// float vv = 1.0/z; | ||
// gl_FragColor = vec4(vv, vv, vv, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
uniform vec4 u_offsets; | ||
|
||
uniform float coneBackScale; | ||
uniform vec3 lookPoint; // direction in front, transformed into a specific length | ||
uniform vec3 upwardDirection; // direction up over head, better unit vector | ||
uniform float viewportRatio; | ||
uniform vec3 cameraPosition; | ||
|
||
attribute vec3 a_position; | ||
attribute float a_color_index; | ||
|
||
varying float v_r; | ||
varying float v_s; | ||
varying float v_color_index; | ||
|
||
float square(float a) { | ||
return a * a; | ||
} | ||
|
||
struct PointResult { | ||
vec3 point; | ||
float r; | ||
float s; | ||
}; | ||
|
||
PointResult transform_perspective(vec3 p) { | ||
vec3 moved_point = p - cameraPosition; | ||
// trying to get right direction at length 1 | ||
vec3 rightward = cross(upwardDirection, lookPoint) / 600.0; | ||
|
||
float s = coneBackScale; | ||
|
||
float r = dot(moved_point, lookPoint) / square(length(lookPoint)); | ||
|
||
if (r < (s * -0.8)) { | ||
// make it disappear with depth test since it's probably behind the camera | ||
return PointResult(vec3(0.0, 0.0, 10000.), r, s); | ||
} | ||
|
||
float screen_scale = (s + 1.0) / (r + s); | ||
float y_next = dot(moved_point, upwardDirection) * screen_scale; | ||
float x_next = - dot(moved_point, rightward) * screen_scale; | ||
|
||
float z_next = r; | ||
|
||
return PointResult(vec3(x_next, y_next / viewportRatio, z_next), r, s); | ||
} | ||
|
||
void main() { | ||
PointResult result = transform_perspective(a_position); | ||
vec3 pos_next = result.point; | ||
|
||
v_s = result.s; | ||
v_r = result.r; | ||
v_color_index = a_color_index; | ||
|
||
gl_Position = vec4(pos_next * 0.001, 1.0); | ||
// gl_Position = vec4(a_position/10000.0, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.