rename downloadframebuffer to downloadrenderbuffer

This commit is contained in:
Zack Buhman 2026-08-09 11:47:50 -05:00
parent 717e73d32d
commit 9d6c8b6888
5 changed files with 21 additions and 19 deletions

View File

@ -232,5 +232,7 @@ fn fragmentMain(input: VertexOutput) -> FragmentOutput
output.color = supersampleColor(input.texture, s, p); output.color = supersampleColor(input.texture, s, p);
} }
output.color = vec4f(output.color.xyz / output.color.w, output.color.w);
return output; return output;
} }

View File

@ -38,13 +38,13 @@ function makeSliders()
//colorOffset: new Slider("color offset", 0.0, 3.1415), //colorOffset: new Slider("color offset", 0.0, 3.1415),
}; };
const defaults = {"undefined":"0","subpixel offset":"62","text":"supersampling","bone length":"32","outline scale":"208","ramp min":"0","dist. threshold":"513","velocity acc.":"385","gamma":"494","aliasing enable":"1","outline threshold":"335","outline color":"#000000","threshold offset":"265","outline. threshold":"512","outline offset":"0","inside color":"#ffffff","color mix":"0","scale":"89","supersample count":"1","distance threshold":"494","supersamples":"0","distance offset":"513","translate y":"381","ramp max":"1024","multisampleCount":"1","supersample offset":"248","subpixel enable":"1","translate x":"581","color offset":"118","velocity damp.":"796","distance scale":"49","threshold scale":"739","bone count":"40","color scale":"148","subpixel strength":"348"};
/* /*
const defaults = {"color scale":"148","bone length":"32","outline scale":"37","dist. threshold":"562","velocity acc.":"385","translate x":"464","outline threshold":"433","translate y":"495","bone count":"40","outline offset":"482","scale":"229","outline. threshold":"512","color offset":"118","distance offset":"676","threshold offset":"265","velocity damp.":"796","distance scale":"404","threshold scale":"739","color mix":"0"};
for (let slider of Object.values(sliders)) { for (let slider of Object.values(sliders)) {
if (slider.label in defaults) { if (slider.label in defaults) {
slider.input.value = defaults[slider.label]; slider.input.value = defaults[slider.label];
} }
} }
*/ */
return sliders; return sliders;

View File

@ -106,7 +106,7 @@
<control-main> <control-main>
<control-grid id="control-parent"> <control-grid id="control-parent">
<row> <row>
<input id="download-framebuffer" type="button" value="download framebuffer"></input> <input id="download-render-buffer" type="button" value="download render buffer"></input>
</row> </row>
<row-separator></row-separator> <row-separator></row-separator>
</control-grid> </control-grid>

View File

@ -65,7 +65,7 @@ const eyeValueZ = document.getElementById("eye-value-z");
const yawValue = document.getElementById("yaw"); const yawValue = document.getElementById("yaw");
const pitchValue = document.getElementById("pitch"); const pitchValue = document.getElementById("pitch");
var downloadFramebufferPending = false; var downloadRenderBufferPending = false;
var tempBuffer = undefined; var tempBuffer = undefined;
function recreateDepth(canvasTexture, sampleCount) function recreateDepth(canvasTexture, sampleCount)
@ -210,15 +210,15 @@ function handleKeyup(e)
function handleDownloadButton(e) function handleDownloadButton(e)
{ {
downloadFramebufferPending = true; downloadRenderBufferPending = true;
console.log("download framebuffer"); console.log("download framebuffer");
} }
window.addEventListener('keydown', handleKeydown, false); window.addEventListener('keydown', handleKeydown, false);
window.addEventListener('keyup', handleKeyup, false); window.addEventListener('keyup', handleKeyup, false);
const downloadFramebufferButton = document.getElementById("download-framebuffer"); const downloadRenderBufferButton = document.getElementById("download-render-buffer");
downloadFramebufferButton.addEventListener("click", handleDownloadButton, false); downloadRenderBufferButton.addEventListener("click", handleDownloadButton, false);
function updateView() function updateView()
{ {
@ -345,9 +345,9 @@ function render2()
updateView(); updateView();
//const clearValue = ; //const clearValue = ;
const clearValue = (downloadFramebufferPending) ? { r: 0.0, g: 0.0, b: 0.0, a: 0.0 } : { r: 0.2, g: 0.2, b: 0.4, a: 1.0 }; const clearValue = (downloadRenderBufferPending) ? { r: 0.0, g: 0.0, b: 0.0, a: 0.0 } : { r: 0.2, g: 0.2, b: 0.4, a: 1.0 };
const viewTexture = (downloadFramebufferPending) ? copyTexture : canvasTexture; const viewTexture = (downloadRenderBufferPending) ? copyTexture : canvasTexture;
const attachment0 = (sampleCount == 1) ? { const attachment0 = (sampleCount == 1) ? {
view: viewTexture.createView(), view: viewTexture.createView(),
@ -384,7 +384,7 @@ function render2()
renderPass.end(); renderPass.end();
if (downloadFramebufferPending) { if (downloadRenderBufferPending) {
encoder.copyTextureToBuffer({ encoder.copyTextureToBuffer({
texture: copyTexture, texture: copyTexture,
}, { }, {
@ -402,7 +402,7 @@ function render2()
frameNumber = (frameNumber + 1) % 2; frameNumber = (frameNumber + 1) % 2;
if (downloadFramebufferPending) { if (downloadRenderBufferPending) {
tempBuffer.mapAsync(GPUMapMode.READ).then(() => { tempBuffer.mapAsync(GPUMapMode.READ).then(() => {
const mappedRange = tempBuffer.getMappedRange(); // arraybuffer const mappedRange = tempBuffer.getMappedRange(); // arraybuffer
const blob = tgaBlob(copyTexture, mappedRange); const blob = tgaBlob(copyTexture, mappedRange);
@ -414,7 +414,7 @@ function render2()
tempBuffer.unmap(); tempBuffer.unmap();
requestAnimationFrame(render2); requestAnimationFrame(render2);
}); });
downloadFramebufferPending = false; downloadRenderBufferPending = false;
} else { } else {
requestAnimationFrame(render2); requestAnimationFrame(render2);
} }

View File

@ -8,34 +8,34 @@ class Select {
const labelE = document.createElement("label"); const labelE = document.createElement("label");
labelE.innerHTML = label; labelE.innerHTML = label;
const selectE = document.createElement("select"); const inputE = document.createElement("select");
selectE.className = "span-2"; inputE.className = "span-2";
for (let i = 0; i < options.length; i++) { for (let i = 0; i < options.length; i++) {
const option = options[i]; const option = options[i];
const optionE = document.createElement("option"); const optionE = document.createElement("option");
optionE.setAttribute("value", i); optionE.setAttribute("value", i);
optionE.innerHTML = option; optionE.innerHTML = option;
selectE.appendChild(optionE); inputE.appendChild(optionE);
} }
const rowE = document.createElement("row"); const rowE = document.createElement("row");
const sepE = document.createElement("row-separator"); const sepE = document.createElement("row-separator");
rowE.appendChild(labelE); rowE.appendChild(labelE);
rowE.appendChild(selectE); rowE.appendChild(inputE);
parent.appendChild(rowE); parent.appendChild(rowE);
parent.appendChild(sepE); parent.appendChild(sepE);
this.select = selectE; this.input = inputE;
this.options = options; this.options = options;
this.lastValue = undefined; this.lastValue = undefined;
const storageValue = localStorage.getItem(this.label); const storageValue = localStorage.getItem(this.label);
if (storageValue !== null) { if (storageValue !== null) {
this.select.value = storageValue; this.input.value = storageValue;
} }
this.update(); this.update();
@ -43,7 +43,7 @@ class Select {
update() update()
{ {
const rawValue = parseInt(this.select.value); const rawValue = parseInt(this.input.value);
if (rawValue !== this.lastValue) { if (rawValue !== this.lastValue) {
this.lastValue = rawValue; this.lastValue = rawValue;
localStorage.setItem(this.label, rawValue); localStorage.setItem(this.label, rawValue);