Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
![]() |
Source code |
1 |
this._shader = document.getElementById('shader').text; |
![]() |
Source code |
1 |
this._panoWebGLLayer.webGL.createPostProcessingShader(this._shader, 'sm, resolution, radius, dir'); |
![]() |
Source code |
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); \ }" |
![]() |
Source code |
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); |
![]() |
Source code |
1 |
shader = krpano.webGL.createPostProcessingShader( get_shader_src(), "sharpen_factor,sz,dir,resolution,radius"); |
This post has been edited 2 times, last edit by "nosferatu" (Apr 6th 2017, 9:09am)
![]() |
Source code |
1 |
gl_FragColor = vColor * vec4(sum.rgb, 1.0); |
![]() |
Source code |
1 |
gl_FragColor = vec4(sum.rgb, 1.0); |
A lot of things are wrong there:Could you tell me what I'm doing wrong?