Runtime target textures seem to need to be the same format as the canvas current texture. Requires additional investigation.

Created a computeToTexture shader to experiment with writing directly to textures as a means of performing post processing.
This commit is contained in:
Rezmason
2021-11-03 09:03:05 -07:00
parent 35afa7ca01
commit 7eab0fd654
4 changed files with 58 additions and 27 deletions

View File

@@ -27,6 +27,14 @@ const loadTexture = async (device, url) => {
return texture;
};
const createRTT = (adapter, device, canvasContext) => {
return device.createTexture({
size: [...getCanvasSize(canvasContext.canvas), 1],
format: canvasContext.getPreferredFormat(adapter),
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT// TODO: reduce
});
};
const loadShaderModule = async (device, url) => {
const response = await fetch(url);
const code = await response.text();
@@ -46,4 +54,4 @@ const makeUniformBuffer = (device, structLayout, values = null) => {
return buffer;
};
export { getCanvasSize, loadTexture, loadShaderModule, makeUniformBuffer };
export { getCanvasSize, loadTexture, createRTT, loadShaderModule, makeUniformBuffer };