![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj34NZSKXQCQBGPTZ30dBzLLfSDtRDSuV0_nUC991oqoGVAuub7Ft8nnFtzhCCQOUlD2RJrAGYhjq__LAXb6rzLx9KfDW2q0lsxQlYnWTdHeLAz2Ewy5e1cnPpCDnCk5uv3NAhqc_l_Vdt8/s200/sh-selfshadow.jpg)
You can store this as three DXT1 textures, though you can improve quality by packing channels with similar spatial coherence. Coefficients 0, 2, and 6 in particular tend to pack well, since they're all dominated primarily by directions aimed perpendicular to the texture.
I use the following packing:
Texture 1: Coefs 0, 2, 6
Texture 2: Coefs 1, 4, 5
Texture 3: Coefs 3, 7, 8
You can reference an early post on this blog for code on how to rotate a SH vector by a matrix, in turn allowing you to get it into texture space. Once you've done that, simply multiply each SH coefficient from the self-shadowing map by the SH coefficients created from your light source (also covered on the previous post) and add together.
No comments:
Post a Comment