diff --git a/src/image/filterRenderer2D.js b/src/image/filterRenderer2D.js index 0f9e756f91..2896ed392e 100644 --- a/src/image/filterRenderer2D.js +++ b/src/image/filterRenderer2D.js @@ -17,7 +17,6 @@ import filterBaseVert from '../webgl/shaders/filters/base.vert'; import webgl2CompatibilityShader from '../webgl/shaders/webgl2Compatibility.glsl'; import { glslBackend } from '../webgl/strands_glslBackend'; import { getShaderHookTypes } from '../webgl/shaderHookUtils'; -import noiseGLSL from '../webgl/shaders/functions/noise3DGLSL.glsl'; import { makeFilterShader } from '../core/filterShaders'; class FilterRenderer2D { @@ -309,9 +308,6 @@ class FilterRenderer2D { return this._baseFilterShader; } - getNoiseShaderSnippet() { - return noiseGLSL; - } /** * Set the current filter operation and parameter. If a customShader is provided, diff --git a/src/strands/strands_api.js b/src/strands/strands_api.js index ab1453eb1c..f486c51e41 100644 --- a/src/strands/strands_api.js +++ b/src/strands/strands_api.js @@ -337,7 +337,7 @@ export function initGlobalStrandsAPI(p5, fn, strandsContext) { return originalNoise.apply(this, args); // fallback to regular p5.js noise } // Get noise shader snippet from the current renderer - const noiseSnippet = this._renderer.getNoiseShaderSnippet(); + const noiseSnippet = strandsContext.backend.getNoiseShaderSnippet(); strandsContext.vertexDeclarations.add(noiseSnippet); strandsContext.fragmentDeclarations.add(noiseSnippet); strandsContext.computeDeclarations.add(noiseSnippet); diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js index b744baff19..63ee001964 100644 --- a/src/webgl/p5.RendererGL.js +++ b/src/webgl/p5.RendererGL.js @@ -19,7 +19,6 @@ import { Image } from '../image/p5.Image'; import { glslBackend } from './strands_glslBackend'; import { TypeInfoFromGLSLName } from '../strands/ir_types.js'; import { getShaderHookTypes } from './shaderHookUtils'; -import noiseGLSL from './shaders/functions/noise3DGLSL.glsl'; import filterBaseVert from "./shaders/filters/base.vert"; import lightingShader from "./shaders/lighting.glsl"; @@ -1905,10 +1904,6 @@ class RendererGL extends Renderer3D { } } - getNoiseShaderSnippet() { - return noiseGLSL; - } - } function rendererGL(p5, fn) { diff --git a/src/webgl/strands_glslBackend.js b/src/webgl/strands_glslBackend.js index d850aef91d..d0715f53d4 100644 --- a/src/webgl/strands_glslBackend.js +++ b/src/webgl/strands_glslBackend.js @@ -1,3 +1,4 @@ +import noiseGLSL from './shaders/functions/noise3DGLSL.glsl'; import { NodeType, OpCodeToSymbol, BlockType, OpCode, NodeTypeToName, isStructType, BaseType, StatementType, DataType, INSTANCE_ID_VARYING_NAME } from "../strands/ir_types"; import { getNodeDataFromID, extractNodeTypeInfo } from "../strands/ir_dag"; import * as FES from '../strands/strands_FES'; @@ -169,6 +170,9 @@ export const glslBackend = { }).join(', ')}) {`; return firstLine; }, + getNoiseShaderSnippet() { + return noiseGLSL; + }, getTypeName(baseType, dimension) { const primitiveTypeName = TypeNames[baseType + dimension] if (!primitiveTypeName) { diff --git a/src/webgpu/p5.RendererWebGPU.js b/src/webgpu/p5.RendererWebGPU.js index 2b616e4a63..66d9d0e12d 100644 --- a/src/webgpu/p5.RendererWebGPU.js +++ b/src/webgpu/p5.RendererWebGPU.js @@ -14,7 +14,6 @@ import { materialVertexShader, materialFragmentShader } from './shaders/material import { fontVertexShader, fontFragmentShader } from './shaders/font'; import { blitVertexShader, blitFragmentShader } from './shaders/blit'; import { wgslBackend } from './strands_wgslBackend'; -import noiseWGSL from './shaders/functions/noise3DWGSL'; import { baseFilterVertexShader, baseFilterFragmentShader } from './shaders/filters/base'; import { imageLightVertexShader, imageLightDiffusedFragmentShader, imageLightSpecularFragmentShader } from './shaders/imageLight'; import { baseComputeShader } from './shaders/compute'; @@ -3673,9 +3672,6 @@ ${hookUniformFields}} return super.filter(...args); } - getNoiseShaderSnippet() { - return noiseWGSL; - } baseFilterShader() { diff --git a/src/webgpu/strands_wgslBackend.js b/src/webgpu/strands_wgslBackend.js index 32226fa83d..3aef6778b6 100644 --- a/src/webgpu/strands_wgslBackend.js +++ b/src/webgpu/strands_wgslBackend.js @@ -1,3 +1,4 @@ +import noiseWGSL from './shaders/functions/noise3DWGSL.js'; import { NodeType, OpCodeToSymbol, BlockType, OpCode, NodeTypeToName, isStructType, BaseType, StatementType, DataType, INSTANCE_ID_VARYING_NAME } from "../strands/ir_types"; import { getNodeDataFromID, extractNodeTypeInfo } from "../strands/ir_dag"; import * as FES from '../strands/strands_FES'; @@ -263,6 +264,10 @@ export const wgslBackend = { } return primitiveTypeName; }, + getNoiseShaderSnippet() { + return noiseWGSL; + }, + generateHookUniformKey(name, typeInfo) { // For sampler2D types, we don't add them to the uniform struct, // but we still need them in the shader's hooks object so that