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

Material shader extensions #14231

Closed
wants to merge 6 commits into from

Conversation

pailhead
Copy link
Contributor

@pailhead pailhead commented Jun 7, 2018

A proposal that allows an alternate approach to extending built-in materials. Only the core change is present in this PR.

Some examples are made in #14206, click on the images to see the demos.

  1. Use this API in GLTFLoader to extend the StandardMaterial with spec/gloss model. And then in the actual loader example, make an "inline" extension for simple instancing (instancing_lambert example). The goal is to have two completely agnostic extensions that just work together - the instancing is applied to an arbitrary material, while the spec/gloss is intended solely for StandardMaterial.
    gltf_instanced

  2. Combine three different extensions (simple instancing, per map uv channels and spec/gloss) on a single material, and modify one of the extensions "inline" (use the instancing offset, but animate the scale effect in the shader). The demo uses a refactored GLTFLoader that just calls one of these decorators, the rest are applied in the inline demo code.
    instancedsgpars
    bbsginst

Individually these can be done with onBeforeCompile, but onBeforeCompile may possibly have issues. The name might be better as onBeforeParse or onWillRefresh. Combining these is a challenge with it though, while this API may be more flexible, if not the friendliest one.

Per map transforms with onBeforeCompile.
Instancing lambert refactored with onBeforeCompile
Standard/gloss refactor with onBeforeCompile.

This should be decoupled from /examples/nodes and not be blocked by it. Thank you.

@pailhead pailhead force-pushed the material-shader-extension-clean branch from 24a6494 to 21900cd Compare June 7, 2018 02:23
@pailhead pailhead force-pushed the material-shader-extension-clean branch from 21900cd to 088a2ee Compare June 7, 2018 02:26
@pailhead pailhead changed the title [WIP] material shader extension (clean) Material shader extensions Jun 7, 2018
@pailhead
Copy link
Contributor Author

pailhead commented Jun 15, 2018

This proposal and all the ones before it should, under no circumstances be used to add features to the library.

concerns about shader patches to the builtin materials as a means of, or replacement for, adding features to the library

The only code that this PR should ever add to three.js from here to eternity is the code for itself. It should never ever directly be used to add a feature to the library. It is by itself a feature of the library, and it should never ever go past that.

It should only be used by users to add features to their applications. I hope this clarifies years of confusion. :) I'll try to write this more legalese.

I've used the GLTFLoader example because that class is in examples and simulates someone having their own app. Someone developing AFrame probably has to rely on GLTFLoader, i myself have never ever used it, so the need for spec gloss, Khronos group extensions, instancing and serialization, are different between our apps.

This is conceptually totally different from NodeMaterial there you actually do want to integrate it into the core and base other features on top of it.

ping @mrdoob ping @donmccurdy

@mrdoob
Copy link
Owner

mrdoob commented Jun 18, 2018

#14245 (comment)

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.

None yet

2 participants