Methods
# async loadShaders(paths, chunks, headers) → {Promise.<Array.<string>>}
Loads shaders with specified Shader Chunks.
If chunks not specified, all chunks will be appended.
Parameters:
Name | Type | Description |
---|---|---|
paths |
Array.<string> | Array of Paths to shaders. |
chunks |
Array.<Array.<string>> | Array of chunks to append to each shader |
headers |
Array.<string> | Array of headers to be appended to each shader. Can be used to provide precision; |
- Deprecated:
- Yes
Array of shaders corresponding to each path with respective chunks applied.
Promise.<Array.<string>>
Example
const head = `
precision highp float;
${Common}
`;
const chunks = [
[Perlin, Simplex],
[]
];
const paths = [
"vert.glsl",
"frag.glsl",
];
const [vert, frag] = await loadShaders(paths, chunks, head);
# async loadShadersCSM(shaders, chunks) → {Promise.<Object>}
Loads shaders with Shader Chunks for use with THREE-CustomShaderMaterial.
If chunks not specified, all chunks will be appended.
Parameters:
Name | Type | Description |
---|---|---|
shaders |
Object | Paths of shaders. * @param {string} shaders.defines Path of definitions shader. * @param {string} shaders.header Path of header shader. * @param {string} shaders.main Path of main shader. |
chunks |
Array.<string> | Array of chunks to append into the Header Section. |
- Deprecated:
- Yes
CSM friendly shader.
Promise.<Object>
Example
const chunks = [Perlin, Simplex];
const paths = [
defines: "defines.glsl",
header: "header.glsl",
main: "main.glsl",
];
const {defines, header, main} = await loadShadersCSM(paths, chunks);
# async loadShadersRaw(shaders) → {Promise.<Array.<string>>}
Loads Shaders without appeneding any Shader Chunks.
Parameters:
Name | Type | Description |
---|---|---|
shaders |
Array.<string> | Array of paths to shaders. |
- Deprecated:
- Yes
Array of shaders corresponding to each path.
Promise.<Array.<string>>
Example
const [vert, frag] = await loadShadersRaw(["vert.glsl", "frag.glsl"]);
# async patchShaders(paths, chunks, headers) → {Array.<string>}
Patches shaders with specified Shader Chunks.
If chunks not specified, all chunks will be appended.
Parameters:
Name | Type | Description |
---|---|---|
paths |
Array.<string> | Array of Shaders as strings. |
chunks |
Array.<Array.<string>> | Array of chunks to append to each shader |
headers |
Array.<string> | Array of headers to be appended to each shader. Can be used to provide precision; |
Array of shaders corresponding to each path with respective chunks applied.
Array.<string>
Example
const head = `
precision highp float;
${Common}
`;
const chunks = [
[Perlin, Simplex],
[]
];
const shaders = [
`
gl_Posiiton = ...
`,
gl_FragColor = ...
`,
];
const [vert, frag] = await loadShaders(shaders, chunks, head);
# async patchShadersCSM(shaders, chunks) → {Object}
Patches shaders with Shader Chunks for use with THREE-CustomShaderMaterial.
If chunks not specified, all chunks will be appended.
Parameters:
Name | Type | Description |
---|---|---|
shaders |
Object | Paths of shaders. * @param {string} shaders.defines Path of definitions shader. * @param {string} shaders.header Path of header shader. * @param {string} shaders.main Path of main shader. |
chunks |
Array.<string> | Array of chunks to append into the Header Section. |
CSM friendly shader.
Object
Example
const chunks = [Perlin, Simplex];
const shaders = [
defines: "...",
header: "...",
main: "...",
];
const {defines, header, main} = await loadShadersCSM(shaders, chunks);