Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pass current frame texture to gl #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feat: pass current frame texture to gl #130

wants to merge 1 commit into from

Conversation

CodePlayer7
Copy link

@CodePlayer7 CodePlayer7 commented May 14, 2021

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',
//        },
      ]
    },
  ],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant