Most appropriate sub-area of p5.js?
p5.js version
2.2.3
Web browser and version
All
Operating system
All
Steps to reproduce this
In the line shader, the input to getFinalColor is already premultiplied, and the output is also assumed to be:
|
OUT_COLOR = HOOK_getFinalColor(vec4(inputs.color.rgb, 1.) * inputs.color.a, vec2(0.0, 0.0)); |
In the material shader, both the input and output are assumed to be unmultiplied, and it premultiplies the alpha for you:
|
OUT_COLOR = HOOK_getFinalColor(HOOK_combineColors(c), vTexCoord); |
|
OUT_COLOR.rgb *= OUT_COLOR.a; // Premultiply alpha before rendering |
In WebGPU, both lines and materials work with unmultiplied alpha and do the multiplication after:
|
var col = HOOK_getFinalColor(inputs.color, vec2<f32>(0.0, 0.0)); |
|
col = vec4<f32>(col.rgb, 1.0) * col.a; |
|
var outColor = HOOK_getFinalColor( |
|
HOOK_combineColors(components), input.vTexCoord |
|
); |
|
outColor = vec4<f32>(outColor.rgb * outColor.a, outColor.a); |
These should be consistent so that users of p5.strands never have to think about premultiplied alpha.
Most appropriate sub-area of p5.js?
p5.js version
2.2.3
Web browser and version
All
Operating system
All
Steps to reproduce this
In the line shader, the input to
getFinalColoris already premultiplied, and the output is also assumed to be:p5.js/src/webgl/shaders/line.frag
Line 72 in 3302713
In the material shader, both the input and output are assumed to be unmultiplied, and it premultiplies the alpha for you:
p5.js/src/webgl/shaders/phong.frag
Lines 80 to 81 in 3302713
In WebGPU, both lines and materials work with unmultiplied alpha and do the multiplication after:
p5.js/src/webgpu/shaders/line.js
Lines 365 to 366 in 3302713
p5.js/src/webgpu/shaders/material.js
Lines 419 to 422 in 3302713
These should be consistent so that users of p5.strands never have to think about premultiplied alpha.