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

shadertools: PBR module using UBO #2173

Merged
merged 27 commits into from
Aug 20, 2024
Merged

Conversation

felixpalmer
Copy link
Collaborator

For visgl/deck.gl#8997

Tested using hello-gltf app - all examples working. Not tried in deck.gl yet

Background

Change List

  • Update shaders to work with lighting module
  • Improve types & rename variable in PBR parser
  • Create new PBRProjection module for holding non-material uniforms

@@ -111,6 +111,7 @@ const lightSources: LightingProps = {
type: 'ambient'
},
directionalLights: [
// @ts-expect-error Remove once npm package updated with new types
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having to do this is really annoying. Not quite sure when / why it started to happen. We should restore @donmccurdy 's workspaces setup on master or find another way to fix this.

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another tour de force, really appreciated!

examples/tutorials/hello-gltf/app.ts Outdated Show resolved Hide resolved
examples/tutorials/hello-gltf/index.html Outdated Show resolved Hide resolved
modules/gltf/src/gltf/create-gltf-model.ts Outdated Show resolved Hide resolved
USE_IBL: 0,
PBR_DEBUG: 0
LIGHTING_FRAGMENT: 1
// TODO defining these as 0 breaks shader
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Some thoughts:

-We may want to separate in the API between flags (for code enablement, which are either defined or not) and constants (which would inject actual values).

  • WGSL has built-in support for constants (that does not require recompiling the shader!), but not defines. However shadertools has added a simple #ifdef preprocessor system.

So, props.defines could just be an array or a Set, or a Record<string, boolean>. and props.constants a map of numeric values

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting idea. #ifdef NAME is generally a bit frustrating as setting it to 0 evaluates to true in the preprocessor. Some thoughts:

  • Restricting them to boolean values makes the name props.defines sound weird, perhaps props.flags?
  • Could our preprocessor instead use a custom syntax? E.g.
    // if FLAG(FLAG_NAME)
    ...
    // else
    ...
    // endif
    
  • We do things like #define SHADER_NAME simple-mesh-layer-vs, it is weird to restrict defines from the outside to be boolean, and then sometimes use strings

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.

2 participants