post processing
This commit is contained in:
parent
fc7213fe03
commit
f15213db1b
5 changed files with 129 additions and 10 deletions
26
data/shader/postprocess.frag
Normal file
26
data/shader/postprocess.frag
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#version 120
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform sampler2D tex1;
|
||||
|
||||
varying vec3 vertex;
|
||||
varying vec2 uv;
|
||||
|
||||
const int gaussRadius = 11;
|
||||
const float gaussFilter[gaussRadius] = float[gaussRadius](
|
||||
0.0402,0.0623,0.0877,0.1120,0.1297,0.1362,0.1297,0.1120,0.0877,0.0623,0.0402
|
||||
);
|
||||
|
||||
uniform vec2 scale;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texCoord = uv.xy - float(int(gaussRadius/2)) * scale;
|
||||
vec3 color = vec3(0.0, 0.0, 0.0);
|
||||
for (int i=0; i<gaussRadius; ++i) {
|
||||
color += gaussFilter[i] * texture2D(tex0, texCoord).xyz;
|
||||
texCoord += scale;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
}
|
||||
12
data/shader/postprocess.vert
Normal file
12
data/shader/postprocess.vert
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 120
|
||||
uniform vec2 uvScale;
|
||||
|
||||
varying vec3 vertex;
|
||||
varying vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = gl_Vertex;
|
||||
vertex = gl_Position.xyz;
|
||||
uv = uvScale * (0.5 + vertex.xy / 2.0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue