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

EquirectEnvInfoUniform: Sampling with 1 x 1 images seems to be wrong #541

Open gkjohnson opened 4 months ago

gkjohnson commented 4 months ago

When creating a 1, 1 white texture for the environment map we get this strange split:

image
gkjohnson commented 4 months ago

This seems to be an issue related to MIS? Disabling MIS "fixes" the problem

gkjohnson commented 4 months ago

This line seems to be he issue?

result = attenuatedColor * environmentIntensity * envColor * state.throughputColor * sampleColor * misWeight / envPdf;
gkjohnson commented 4 months ago

Textures are not capable of sampling the first or last pixel due to the way the the samples are stored. With 1x1 px we get a marginal weights texture that is 1 px wide storing 0.5 which means only one direction can ever be sampled. The way weights are stored should be adjusted such that the first pixel is always the first valid pixel to sample and the last pixel is that last valid pixel to sample.