Blame stuff/projects/library/shaders/programs/radialblurGPU_bbox.vert
|
Toshihiro Shimizu |
890ddd |
#ifdef GL_ES
|
|
Toshihiro Shimizu |
890ddd |
precision mediump float;
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
uniform vec4 infiniteRect;
|
|
Toshihiro Shimizu |
890ddd |
uniform vec4 inputBBox[1];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
varying vec4 outputBBox;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
uniform vec2 center;
|
|
Toshihiro Shimizu |
890ddd |
uniform float radius;
|
|
Toshihiro Shimizu |
890ddd |
uniform float blur;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void addPoint(inout vec4 rect, vec2 p) {
|
|
Toshihiro Shimizu |
890ddd |
rect.xy = min(rect.xy, p);
|
|
Toshihiro Shimizu |
890ddd |
rect.zw = max(rect.zw, p);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void addBlurredPointBox(inout vec4 rect, vec2 p)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
vec2 v = p - center;
|
|
Toshihiro Shimizu |
890ddd |
float vLength = length(v);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
float dist = max(length(v) - radius, 0.0);
|
|
Toshihiro Shimizu |
890ddd |
float b = blur * dist;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
v *= (b / max(vLength, 0.01));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addPoint(rect, p - v);
|
|
Toshihiro Shimizu |
890ddd |
addPoint(rect, p + v);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void main( void )
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
outputBBox = inputBBox[0];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if(outputBBox != infiniteRect)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// Add the bounding box of each blurred corner
|
|
Toshihiro Shimizu |
890ddd |
addBlurredPointBox(outputBBox, inputBBox[0].xy);
|
|
Toshihiro Shimizu |
890ddd |
addBlurredPointBox(outputBBox, inputBBox[0].xw);
|
|
Toshihiro Shimizu |
890ddd |
addBlurredPointBox(outputBBox, inputBBox[0].zy);
|
|
Toshihiro Shimizu |
890ddd |
addBlurredPointBox(outputBBox, inputBBox[0].zw);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
gl_Position = vec4(0.0); // Does not link without
|
|
Toshihiro Shimizu |
890ddd |
}
|