editly icon indicating copy to clipboard operation
editly copied to clipboard

feat: pass current frame texture to gl

Open CodePlayer7 opened this issue 4 years ago • 0 comments

current gl didn't pass the frame texture of video/image to shader usage:

// video or image is OK
// mutiple shader is OK
{
  outPath: './test/gl.mp4',
  clips: [
    {
      duration: 3,
      layers: [
        {
          duration: 3,
          type: 'image',
          path: './test/1.jpg',
//          path: './test/1.mp4',
        }
      ]
    },
    {
      duration: 6,
      layers: [
        {
          duration: 6,
          type: 'image',
          path: './test/2.jpg',
//          path: './test/2.mp4',
        },
        {
          type: 'gl',
          start: 1,
          stop:6,
//          fragmentPath: './test/white_mask_shader.gl',
//          vertexPath: './test/white_mask_vertex.gl',
          fragmentSrc: "precision highp float;\nuniform sampler2D tex;\nvarying vec2 TextureCoordsVarying;\nuniform float time; uniform float duration;\nconst float PI = 3.1415926;\n\nfloat rand(float n) {\n    return fract(sin(n) * 43758.5453123);\n}\n\nvoid main() {\n    float progress = mod(time, duration) / duration; // 0~1\n    vec4 whiteMask = vec4(1.0, 1.0, 1.0, .5);\n    float amplitude = abs(sin(progress * (PI / duration)));\n\n    vec4 mask = texture2D(tex, TextureCoordsVarying);\n    gl_FragColor = mask * (1.0 - amplitude) + whiteMask * amplitude;\n}",
          vertexSrc: 'attribute vec2 position;\nvarying vec2 TextureCoordsVarying;\nconst float PI = 3.1415926;\nuniform float time;\n\nvoid main(void) {\n    gl_Position = vec4(position, 0, 1);\n    //TextureCoordsVarying = position;\n\n    TextureCoordsVarying.x = position.x * 0.5 + 0.5;\n    TextureCoordsVarying.y = position.y * 0.5 + 0.5;\n}',
          glParamsTypes: {
            'duration': 'float',
          },
          glDefaultParams: {
            'duration': 0.1,
          }
        },
//        {
//          type: 'gl',
//          start: 1,
//          stop: 6,
//          fragmentPath: './test/soul_shader.gl',
//          vertexPath: './test/soul_vertex.gl',
//        },
      ]
    },
  ],
}


CodePlayer7 avatar May 14 '21 08:05 CodePlayer7