The Wayback Machine - https://web.archive.org/web/20200225151240/https://github.com/mrdoob/three.js/issues/17088
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

Suggestion: Documentation for shader chunks #17088

Open
sciecode opened this issue Jul 24, 2019 · 4 comments
Open

Suggestion: Documentation for shader chunks #17088

sciecode opened this issue Jul 24, 2019 · 4 comments
Labels

Comments

@sciecode
Copy link
Contributor

@sciecode sciecode commented Jul 24, 2019

It's a very common occurrence, on the forums/SO, to stumble by people having difficulties integrating existing shader chunks with their own custom shaders.

Most of the problem lies in the lack of a documentation for these. Having to dig through each chunk, determine each of their dependencies and required defines/uniforms makes it for quite a bit of work.

I'm sure it has been considered before, but is there any good reasons for not having these docs, besides being a lot of work? Finding a good way to organize the documentation could be tricky, but having this sort of information available is bound to be beneficial in the long run.

I would be more than happy to contribute with the creation of the documents, given that we can find an appropriated way of organizing and showcasing all the information required for each chunk. I think this is an all or nothing kind of deal.

Interested in hearing thoughts about this and possible counter arguments against having these docs.

@looeee

This comment has been minimized.

Copy link
Collaborator

@looeee looeee commented Jul 25, 2019

is there any good reasons for not having these docs, besides being a lot of work?

Recently, we've been considering switching to node based materials, and when that happens these docs would become obsolete. No idea when, or if, that's likely to happen though.

@Mugen87

This comment has been minimized.

Copy link
Collaborator

@Mugen87 Mugen87 commented Jul 25, 2019

and when that happens these docs would become obsolete.

At least the current implementation of NodeMaterial uses the existing shader chunks e.g.

"#include <fog_pars_vertex>",
"#include <morphtarget_pars_vertex>",
"#include <skinning_pars_vertex>",
"#include <shadowmap_pars_vertex>",
"#include <logdepthbuf_pars_vertex>",
"#include <clipping_planes_pars_vertex>"

However, I think documenting NodeMaterial first (the different node types and how to use the system in general) might be more beneficial than documenting the low-level shader chunks.

@munrocket

This comment has been minimized.

Copy link
Contributor

@munrocket munrocket commented Jul 28, 2019

I find that we can use string ‘void main() {‘ in most of shaders both for adding new uniforms and structs and for adding calculations inside main() function. Since .onBeforeCompile() looks like hack, we can describe this hack too.

@pailhead

This comment has been minimized.

Copy link
Contributor

@pailhead pailhead commented Oct 3, 2019

Shader chunks have existed for a long time, and may not be going anywhere in the near future. It would be nice to document them. +1

However, this can also be done outside of the core/repo.

While a node based system might require documentation for something like MathNode one probably does not need to document the + - / : operators for GLSL, at least not in the context of three.js since they are universal for all GLSL. The chunks that @Mugen87 listed, are fairly unique and could benefit from some documentation, or at least inline comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants
You can’t perform that action at this time.