Showing posts with label Geometry-Image. Show all posts
Showing posts with label Geometry-Image. Show all posts

Thursday, May 6, 2010

Worldspace shadow-map / virtual texture - another random idea

Just a new random, not even a nearly completely thought out idea of mine.
Which I blame on only having time to dream up these things, but not actually try them $@#!
Yes, I am frustrated ;)

Anyway.

Suppose we perform our lighting within our virtual texture cache (aka surface caching), which I've blogged about often, and we store our texel world-space coordinates in the cache, wouldn't we also be able to use this information to do shadow mapping?

The (HUGE) downside is that we'd need a place to store the texel coordinates even for pages that aren't visible (being able to analytically cull pages and lights would definitely help here... page bounding boxes? bounding volume hierarchies?)
Would lower resolution mips be enough for lighting? (sometimes?)
I suppose some sort of preprocessing could help here.. I can imagine that a lot of the geometry that uses a specific page would essentially be flat.

The upside is that we'd only have to render geometry exactly once per frame (or less, with caching), and perhaps we could be rendering the lighting directly into the cache..
In which case having the knowledge of all the transparent pages between your texel and the light-source would be interesting! (Probably slow as hell though, even IF you manage to get this to work somehow)

What about texel world coordinate mip maps?
Would we need to store min/max coordinates instead of 'just' coordinates?
Could that be used in a sort of hierarchical z-buffer type of setup somehow?
For (rough) culling on the CPU side perhaps?
For both the shadow map and camera?
That would require us to have the texel coordinates on the CPU side though.. (static geometry only?)
Preprocessed and stored with the pages? (geometry images?)
But bandwidth is already an issue...
Then again, it would probably be very compressible, most of the time.
At least, for the higher resolution mips..

Argh, too many angles, too many ideas!
Most of them look extremely impractical to begin with, but it's a lot of fun to think about ;)


Besides all that, this idea popped in my head:
If every texel coordinate is unique with virtual texturing, wouldn't we be able to use this, somehow, to eliminate shadow acne? (Assuming you're not using cascaded shadow maps already & this would really be complicated by page mip maps)

Monday, June 8, 2009

Deferred Virtual Texture Shading

For some time now i've had this, admittingly pretty vague, idea about a combination of deferred shading and virtual textures (aka "mega-texture").

It hit me that most of the attributes stored into a G-buffer during deferred shading are already present in a virtual-texture, so if you combine the two you'd only need to store the virtual-texture coordinates, which would require smaller G-buffers.
Ofcourse that's not entirely true, since a pixel in a G-buffer almost never exactly match a texel on a texture; that's what filtering is for.

But what if we would use our virtual-texture cache as the G-buffer itself?

The problems:
  1. We'd need to fill some of the attributes of the virtual texture at runtime, like coordinates/normals of the texels. However, For static geometry this could be pre-baked, for dynamic geometry this could be cached. (Interestingly enough this sounds a lot like geometry images)
  2. Another big problem is how can we (efficiently) render the lights into this "virtual G-buffer"?
I'm not sure how the last problem could easily be done without losing all the benefits of deferred shading. It would definitely help to have some sort of hierarchy where virtual texture pages are matched with chunks of geometry.

That way we'd only calculate the light for lights who's radius touches those chunks of geometry and their respective virtual texture pages.
It would also make it possible to move the paging algorithm completely to the cpu side, that way we won't need a nasty readback from the gpu to discover what virtual texture pages to upload.

But if (a BIG if) these problems would be solved, it would give us some interesting properties:
  • Lighting calculations can be cached.
  • A virtual texture would be able to contain a lot more data, at a much higher quality, compared to G-buffer (which would potentially create a disk space problem)
  • Rendering the geometry would simply be a matter of rendering the geometry with a single texture.
  • Transparent surfaces wouldn't need to be rendered in a separate pass. (depth peeling?)
  • All shadows and lighting would automatically be filtered. (so you'd better have a high-res virtual texture!)
  • Filters and blurs can be applied on lit surfaces (although there would be some difficulties at cache-page boundaries), which could be useful for subsurface scattering effects.
  • If you ignore all the caching, all the calculations would be relatively constant, scaling nicely with the amount of geometry and lights.
The questions are, is it possible? and, is it fast enough?