Advertisement
tasuku

billboard

Jun 8th, 2016
1,597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.88 KB | None | 0 0
  1. import QtQuick 2.6
  2.  
  3. Item {
  4.     width: 794
  5.     height: 602
  6.  
  7.     Column {
  8.         Image {
  9.             id: logo
  10.             width: 794
  11.             height: 301
  12.             source: 'https://s3-eu-west-1.amazonaws.com/qt-brand/uploads/2015/04/PrimaryLogo.png'
  13.         }
  14.         ShaderEffect {
  15.             width: 794
  16.             height: 301
  17.             property var source: ShaderEffectSource {
  18.                 sourceItem: logo
  19.             }
  20.  
  21.             property real grid: 10.0
  22.  
  23.             property real step_x: 0.001
  24.             property real step_y: step_x * width / height
  25.  
  26.             fragmentShader: '
  27.                uniform float grid;
  28.                uniform float step_x;
  29.                uniform float step_y;
  30.  
  31.                uniform sampler2D source;
  32.                uniform lowp float qt_Opacity;
  33.                varying vec2 qt_TexCoord0;
  34.  
  35.                void main()
  36.                {
  37.                    vec2 uv = qt_TexCoord0.xy;
  38.                    float offx = floor(uv.x  / (grid * step_x));
  39.                    float offy = floor(uv.y  / (grid * step_y));
  40.                    vec3 res = texture2D(source, vec2(offx * grid * step_x , offy * grid * step_y)).rgb;
  41.                    vec2 prc = fract(uv / vec2(grid * step_x, grid * step_y));
  42.                    vec2 pw = pow(abs(prc - 0.5), vec2(2.0));
  43.                    float  rs = pow(0.45, 2.0);
  44.                    float gr = smoothstep(rs - 0.1, rs + 0.1, pw.x + pw.y);
  45.                    float y = (res.r + res.g + res.b) / 3.0;
  46.                    vec3 ra = res / y;
  47.                    float ls = 0.3;
  48.                    float lb = ceil(y / ls);
  49.                    float lf = ls * lb + 0.3;
  50.                    res = lf * res;
  51.                    vec3 col = mix(res, vec3(0.1, 0.1, 0.1), gr);
  52.                    gl_FragColor = qt_Opacity * vec4(col, 1.0);
  53.                }'
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement