gkjohnson / three-gpu-pathtracer

Path tracing renderer and utilities for three.js built on top of three-mesh-bvh.
https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/index.html
MIT License
1.27k stars 125 forks source link

WebGLPathTracer: Does rendering a smaller texture to a larger canvas cause artifacts? #590

Closed gkjohnson closed 2 months ago

gkjohnson commented 3 months ago

It changes the values that are being interpolated. When the canvas is stretched it's interpolating the 256-bit color values and when the target is stretched it's the large floating point values.

gkjohnson commented 3 months ago

See https://twitter.com/garrettkjohnson/status/1772248922288746570

A solution for more consistent results would be to implement a manual interpolation approach when drawing the canvas to the screen. Ie manual linear or bicubic filtering with clamped values while that values are still linear colors.

One issue is that interpolating with linear data vs srgb data doesn't look as expected. Interpolating linear data should result in a perceptually linear gradient but it seems to not.

gkjohnson commented 3 months ago

Note: It seems that three.js always assumes that a texture is in linear color space no matter what. Is this an issue? I think it used to behave differently (around r140 to r150)