Aeva / m.grl

Midnight Graphics & Recreation Library
http://mgrl.midnightsisters.org
GNU Lesser General Public License v3.0
44 stars 3 forks source link

explore cheap soft shadows for deferred renderer #231

Closed Aeva closed 8 years ago

Aeva commented 8 years ago

I had an idea just now that may or may not work, but I think is worth exploring. It works like so:

  1. shadow pass vertex shader creates 4 pseudo random variations of the light's actual view matrix. The actual view matrix would produce the final outcome for gl_Position, but the linear_depth values resulting from the random view matrices would be the fragment shader's output.
  2. when the light accumulation passes try to project a light, the four depth channels of that shadow buffer are individually projected and the resulting occlusion value for each is averaged to determine the final value. The accumulations passes would use the light's actual view matrix, not the random ones since they would not be accessible. The offsets could be a standard spacing with just a random starting angle, provided via a uniform var, allowing the exact matrices to be recreated easily.

extra credit: MRT could be used to add more samples, though that seems excessive

Aeva commented 8 years ago

Light size is hard coded at the moment, but now 4 ray casting samples are generated instead of just the one.

Highlights are still using the light's origin view matrix, which may or may not be ok as is.

Some further experimentation is needed - the shadows don't seem to get softer with depth, but idk maybe its fine?

Aeva commented 8 years ago

I don't think I'm going to continue with this approach, as the quality of the shadows looks worse the greater the light size is. It would need more samples to look good, and it does seem to be not so cheap in other ways even though it only needs one texture lookup.

It was a fun experiment, but I don't think it is what I want.