glslify / glslify/glslify

Callbacks?

Open
#23 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.3k
Forks
83
PR merge metrics
No merged PRs in 30d

Description

For example:

``` glsl
// file1.glsl
vec3 getColor(vec2 uv);
vec3 blurred(vec2 uv, vec2 dims) {
vec3 off = vec3(1.0 / dims, 0.0);
return (getColor(uv)
+ getColor(uv + off.xz)
+ getColor(uv - off.xz)
+ getColor(uv + off.zy)
+ getColor(uv - off.zy)
) * 0.2;
}

// file2.glsl
vec3 getColor(vec2 uv) {
return texture2D(tex, uv).rgb;
}
```

It's useful for map-like functions, e.g. you want to replace sampling a texture with some other function that takes a UV coordinate.

[shadergraph](https://github.com/unconed/shadergraph) uses this approach a lot, and I can definitely see it having some nice potential for improving the modularity of some glslify packages. Unfortunately I can't see a way to do the same nicely with glslify – anybody have ideas/suggestions/alternatives?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.