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

need a example for effect module and post-processing #1412

Closed
littleTigerRunRunRun opened this issue Oct 27, 2020 · 3 comments
Closed

need a example for effect module and post-processing #1412

littleTigerRunRunRun opened this issue Oct 27, 2020 · 3 comments

Comments

@littleTigerRunRunRun
Copy link

I see there is some document about effect module and some tools like txaa in the shadertools module, but it's difficult to understand how to use it. A simple example is needed.

@ghost
Copy link

ghost commented May 26, 2021

I also needed this and my current understanding is that you have to use it like this (with the example for tiltshift):

Your fragment shader

uniform sampler2D uSampler;
uniform vec2 uSamplerSize;
varying vec2 uv;

void main() {
  gl_FragColor = tiltShift_sampleColor(uSampler, uSamplerSize, uv);
}

main.js

import {tiltShift} from '@luma.gl/shadertools';

[...]

    const yourTiltShiftModel = new Model(gl, {
      vs: yourVertexShader,
      fs: yourFragmentShader,
      geometry: yourGeometry,
      modules: [tiltShift]
    }).setUniforms({...yourTiltShiftArguments});

So you add the module to your model and manually use it from the shader.
Most shaders on https://luma.gl/docs/api-reference/shadertools/effects-shader-modules will use this <effectName>_sampleColor pattern (I checked the source-code to figure out how to use this).

I believe that's the intended method, because multi-pass rendering was removed in #1278 (which seems to have been added here #715).
There is also https://github.com/visgl/luma.gl/blob/d5bd93ef6bd0a0ff4af7880424286bda269e29a8/dev-docs/RFCs/vNext/automatic-shader-module-injection-rfc.md#motivation which can probably be done via https://luma.gl/docs/api-reference/shadertools/assemble-shaders#shader-hooks-and-module-injections if you want to keep all the actual effect chaining on the JS side.


Clearly this needs better documentation. #1460 also seems to be related.

@littleTigerRunRunRun
Copy link
Author

oh, i also do something like this. If there is no extra system designed for post-processing, it's a good try.

@ghost
Copy link

ghost commented May 26, 2021

I suggest to keep this opened until a maintainer like @ibgreen has commented.
Maybe there is a better system + even if there's no better system, the existing solution should be documented properly.

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

No branches or pull requests

1 participant