Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ported the stroke shader to WebGPU renderer#7915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
davepagurek merged 20 commits intoprocessing:webgpufromlukeplowden:webgpu
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
20 commits
Select commitHold shift + click to select a range
77a9733
added stroke shader, currently not working
lukeplowdenJun 14, 2025
5db2d33
changed drawbuffers to draw stroke and fill buffers depending on curr…
lukeplowdenJun 16, 2025
a116e6f
fixed uViewport uniform (uniform problem fixed in upstream)
lukeplowdenJun 16, 2025
ddfeb05
remove console log
lukeplowdenJun 16, 2025
14f1857
remove unused variable
lukeplowdenJun 16, 2025
2c19cdc
remove hardcoded viewport (uniform issue fixed upstream)
lukeplowdenJun 16, 2025
e7696f0
fix stroke shader bugs from porting process)
lukeplowdenJun 16, 2025
ed88f91
stroke test
lukeplowdenJun 16, 2025
186f423
Merge remote-tracking branch 'upstream/webgpu' into webgpu
lukeplowdenJun 16, 2025
1e9b308
Merge remote-tracking branch 'upstream/webgpu' into webgpu
lukeplowdenJun 16, 2025
4dc493d
add stroke to preview
lukeplowdenJun 16, 2025
d88fba9
change stroke shader constants/ preprocessor to be compatible with we…
lukeplowdenJun 16, 2025
c48977a
rename fillHooks to populateHooks (ambiguous with fill/stroke)
lukeplowdenJun 16, 2025
f0875d7
add strokes back to WebGL mode
lukeplowdenJun 16, 2025
e8bedfc
add strokes back to WebGL mode
lukeplowdenJun 16, 2025
0b50257
missing }
lukeplowdenJun 16, 2025
0af8df9
typo in string
lukeplowdenJun 16, 2025
f120ad9
typo in string
lukeplowdenJun 16, 2025
1474c97
Merge branch 'webgpu' of github.com:lukeplowden/p5.js into webgpu
lukeplowdenJun 16, 2025
468b638
multiply alpha after hook
lukeplowdenJun 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
changed drawbuffers to draw stroke and fill buffers depending on curr…
…ent shader
  • Loading branch information
@lukeplowden
lukeplowden committedJun 16, 2025
commit5db2d3331476e490e40a48ff9431212c019f7147
4 changes: 2 additions & 2 deletionssrc/core/p5.Renderer3D.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -557,7 +557,7 @@ export class Renderer3D extends Renderer {
geometry.hasFillTransparency()
);

this._drawBuffers(geometry, { mode, count }, false);
this._drawBuffers(geometry, { mode, count });

shader.unbindShader();
}
Expand All@@ -583,7 +583,7 @@ export class Renderer3D extends Renderer {
geometry.hasStrokeTransparency()
);

this._drawBuffers(geometry, {count}, true)
this._drawBuffers(geometry, {count})

shader.unbindShader();
}
Expand Down
46 changes: 24 additions & 22 deletionssrc/webgpu/p5.RendererWebGPU.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -548,7 +548,7 @@ class RendererWebGPU extends Renderer3D {
// Rendering
//////////////////////////////////////////////

_drawBuffers(geometry, { mode = constants.TRIANGLES, count = 1 }, stroke) {
_drawBuffers(geometry, { mode = constants.TRIANGLES, count = 1 }) {
const buffers = this.geometryBufferCache.getCached(geometry);
if (!buffers) return;

Expand DownExpand Up@@ -578,33 +578,33 @@ class RendererWebGPU extends Renderer3D {
};

const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
passEncoder.setPipeline(this._curShader.getPipeline(this._shaderOptions({ mode })));
const currentShader = this._curShader;
passEncoder.setPipeline(currentShader.getPipeline(this._shaderOptions({ mode })));
// Bind vertex buffers
for (const buffer of this._getVertexBuffers(this._curShader)) {
for (const buffer of this._getVertexBuffers(currentShader)) {
passEncoder.setVertexBuffer(
this._curShader.attributes[buffer.attr].location,
currentShader.attributes[buffer.attr].location,
buffers[buffer.dst],
0
);
}
// Bind uniforms
this._packUniforms(this._curShader);
console.log(this._curShader);
this.device.queue.writeBuffer(
this._curShader._uniformBuffer,
currentShader._uniformBuffer,
0,
this._curShader._uniformData.buffer,
this._curShader._uniformData.byteOffset,
this._curShader._uniformData.byteLength
currentShader._uniformData.buffer,
currentShader._uniformData.byteOffset,
currentShader._uniformData.byteLength
);

// Bind sampler/texture uniforms
for (const [group, entries] ofthis._curShader._groupEntries) {
for (const [group, entries] ofcurrentShader._groupEntries) {
const bgEntries = entries.map(entry => {
if (group === 0 && entry.binding === 0) {
return {
binding: 0,
resource: { buffer:this._curShader._uniformBuffer },
resource: { buffer:currentShader._uniformBuffer },
};
}

Expand All@@ -616,26 +616,28 @@ class RendererWebGPU extends Renderer3D {
};
});

const layout =this._curShader._bindGroupLayouts[group];
const layout =currentShader._bindGroupLayouts[group];
const bindGroup = this.device.createBindGroup({
layout,
entries: bgEntries,
});
passEncoder.setBindGroup(group, bindGroup);
}

if (buffers.lineVerticesBuffer && geometry.lineVertices && stroke) {
if (currentShader.shaderType === "fill") {
// Bind index buffer and issue draw
if (buffers.indexBuffer) {
const indexFormat = buffers.indexFormat || "uint16";
passEncoder.setIndexBuffer(buffers.indexBuffer, indexFormat);
passEncoder.drawIndexed(geometry.faces.length * 3, count, 0, 0, 0);
} else {
passEncoder.draw(geometry.vertices.length, count, 0, 0);
}
}

if (buffers.lineVerticesBuffer && currentShader.shaderType === "stroke") {
passEncoder.draw(geometry.lineVertices.length / 3, count, 0, 0);
}
// Bind index buffer and issue draw
if (!stroke) {
if (buffers.indexBuffer) {
const indexFormat = buffers.indexFormat || "uint16";
passEncoder.setIndexBuffer(buffers.indexBuffer, indexFormat);
passEncoder.drawIndexed(geometry.faces.length * 3, count, 0, 0, 0);
} else {
passEncoder.draw(geometry.vertices.length, count, 0, 0);
}}

passEncoder.end();
this.queue.submit([commandEncoder.finish()]);
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp