-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Description
Description
The above image is from the webGPU MRT example, modified by setting a custom renderer viewport.
The original example uses this pattern:
const out = mix( output.renderOutput(), output, step( 0.2, viewportTopLeft.x ) );I have been able to honor the viewport by using this pattern:
const offset = Fn( () => {
return viewportTopLeft.x.mul( viewportResolution.x ).div( 2 ).sub( viewport.x ).div( viewport.z ); // 2 is the DPR for my device
} );
const out = mix( output.renderOutput(), output, step( 0.2, offset() ) );It is a red flag that it is necessary to inject the device DPR (2) into the formula. It is a warning that the units on the TSL functions are not correct. Some are scaled by DPR -- others are not... Or maybe the functions are fine, but the names can be improved.
Also, viewportTopLeft is not the top-left of the viewport. It is the fragment coordinate normalized by some quantity -- likely by the width of the frame buffer. Perhaps the nomenclature can be improved. Something that implies: "Normalized fragment coordinate relative to the top-left of the viewport".
Reproduction steps
See above.
Code
See above.
Live example
n/a
Screenshots
No response
Version
r168dev
Device
Desktop
Browser
Chrome
OS
MacOS