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

setUniforms and updateModuleSettings on Model don't work for modules #1472

Open
JannikGM opened this issue May 26, 2021 · 3 comments
Open

setUniforms and updateModuleSettings on Model don't work for modules #1472

JannikGM opened this issue May 26, 2021 · 3 comments

Comments

@JannikGM
Copy link

JannikGM commented May 26, 2021

Here's a minimal reproduction case: https://github.com/JannikGM/luma.gl-bug

It's based on https://luma.gl/docs/getting-started/hello-triangle and uses luma.gl 8.4.5 at the time of writing.

I'm using the brightnessContrast shader module to manipulate the output color using gl_FragColor = brightnessContrast_filterColor(gl_FragColor);.

My values are these const opts = {brightness: 0.5, contrast: -0.5}

Here are the problematic cases (color is not touched, I can see that brightness and contrast are 0.0, even though I try to set them differently):

// Does not work
model.setUniforms(opts).draw();

// Does not work
model.updateModuleSettings(opts).draw();

But either of these work fine (respecting my target brightness and contrast):

// Does work
model.draw({moduleSettings: opts});
    
// Does work
model.draw({uniforms: opts});

I'm using the module to add the helper functions to my shaders (but I'm not using shader modules or shader hooks for anything else, if that matters).

  • The same problem occurs with tiltShift and probably all other shader modules, so it's not unique to brightnessContrast.
  • console.log(model.getModuleUniforms()); shows 0 for brightness and contrast (although I'm not sure how one is meant to use getModuleUniforms).

Related to #1460 and #1412, because there's not enough (or not good enough?) documentation to figure out wether I'm doing it incorrectly or if this is broken.

@ibgreen
Copy link
Collaborator

ibgreen commented May 26, 2021

Yes, this seems strange. Taking a quick look at the code, Model.draw() calls exactly those functions:

https://github.com/visgl/luma.gl/blob/master/modules/engine/src/lib/model.js#L291

Is your test code small enough that you could create a code pen that reproduces the issue?

@JannikGM
Copy link
Author

JannikGM commented May 27, 2021

Is your test code small enough that you could create a code pen that reproduces the issue?

I'm relatively new to JS and have never used codepen.
I even tried setting up a codepen sample for it but didn't know how to import luma.gl correctly.
There are no samples which show how to import it from a HTML script tag or how to import it from codepen settings.
The official samples only show how to use webpack.

I also don't want to create a codepen account (just for reporting that bug).

I'm already providing a minimal reproduction case in the issue description:

Here's a minimal reproduction case: https://github.com/JannikGM/luma.gl-bug

It's based on https://luma.gl/docs/getting-started/hello-triangle and uses luma.gl 8.4.5 at the time of writing.

@Pessimistress
Copy link
Collaborator

model.draw() calls model.setModuleSettings({}) (default moduleSettings = {} parameter) which resets the uniforms. The issue is that the module's getUniforms returns the default values if no relevant inputs are found.

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

3 participants