|
|
Quellcode |
1 |
this._shader = document.getElementById('shader').text;
|
|
|
Quellcode |
1 |
this._panoWebGLLayer.webGL.createPostProcessingShader(this._shader, 'sm, resolution, radius, dir'); |

|
|
Quellcode |
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 |
return "\
precision mediump float; \
varying vec4 vColor; \
varying vec2 tx; \
uniform sampler2D sm; \
uniform float resolution; \
uniform float radius; \
uniform vec2 dir; \
\
void main() { \
vec4 sum = vec4(0.0); \
vec2 tc = tx; \
float blur = radius/resolution; \
\
float hstep = dir.x; \
float vstep = dir.y; \
\
sum += texture2D(sm, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.0162162162; \
sum += texture2D(sm, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.0540540541; \
sum += texture2D(sm, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.1216216216; \
sum += texture2D(sm, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.1945945946; \
\
sum += texture2D(sm, vec2(tc.x, tc.y)) * 0.2270270270; \
\
sum += texture2D(sm, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.1945945946; \
sum += texture2D(sm, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.1216216216; \
sum += texture2D(sm, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.0540540541; \
sum += texture2D(sm, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.0162162162; \
\
gl_FragColor = vec4(sum.rgb, 1.0); \
}"
|
|
|
Quellcode |
1 2 3 |
krpano.webGL.context.uniform2f(shader.dir, 1, 0); krpano.webGL.context.uniform1f(shader.resolution, 1024); krpano.webGL.context.uniform1f(shader.radius, 20); |
|
|
Quellcode |
1 |
shader = krpano.webGL.createPostProcessingShader( get_shader_src(), "sharpen_factor,sz,dir,resolution,radius"); |
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »nosferatu« (6. April 2017, 09:09)
|
|
Quellcode |
1 |
gl_FragColor = vColor * vec4(sum.rgb, 1.0); |
|
|
Quellcode |
1 |
gl_FragColor = vec4(sum.rgb, 1.0); |
A lot of things are wrong there:Could you tell me what I'm doing wrong?