I’m having a lot of trouble with trying to chain my custom WebGPU post processes. Basically I just want to separate my shaders and apply them one on top of the other when they’re toggled (and for organization sake), but I can’t figure out how to get the sampler into WGSL.
I should mention I’m new shaders but looking at the docs it seems that I need a sampler in order to get the colors from the previously applied PostProcess. There’s no WGSL counterpart I could find in the guide that says how to access it.
Here’s my code thus far, I believe my only issue is trying to get the sceneSampler into my WGSL:
let starshader = new PostProcess(...)
camera.attachPostProcess(starshader)
// nebulashader should apply on top of starshader, via mix()
let nebulashader = new PostProcess("NebulaShader","nebulas",["seed"],["sceneSampler"],
1,camera,undefined,engine,true,undefined,undefined,undefined,undefined,undefined,undefined,ShaderLanguage.WGSL)
nebulashader.onApply = (effect) => {
effect.setFloat("seed", 1)
effect.setTextureFromPostProcess("sceneSampler",nebulashader)
}
camera.attachPostProcess(nebulashader)
In my nebulasPixelShader whenever I try something like uniform sceneSampler : sampler
it errors with sampler cannot be used as the type of a structure member
.