Skip to content

Rendering texture with partial transparency on canvas. #4405

Closed Answered by greggman
shriharirathod asked this question in Q&A
Discussion options

You must be logged in to vote

If you are rendering across multiple frames (multiple requestAnimationFrame events) then the texture you get from getCurrentTexture is always cleared each frame

Otherwise, if you have 2 or more render passes, every pass except the first needs it's loadOp set to 'load'

Finally, whatever values are in the canvas, if their alpha is less than 255 (less then 1.0) and the canvas is configured to alphaMode: premultiplied then there will be transparency through the canvas.

Some more details and examples here:

https://webgpufundamentals.org/webgpu/lessons/webgpu-transparency.html

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by shriharirathod
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants