Last active
September 1, 2016 13:44
-
-
Save tomspilman/616610a717bccb688ec7f674ab24efac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static float k_lut_size = 1.0 / 16.0; | |
| static float k_lut_pixel_size = k_lut_size / 16.0; | |
| static float k_lut_half_pixel_size = k_lut_pixel_size / 2.0f; | |
| float4 tex3D(sampler2D tex, float3 coord) | |
| { | |
| // Clamp the sample to within one 16x16 slice to avoid filtering bleed. | |
| float y = coord.y; | |
| y = max(y - k_lut_half_pixel_size, k_lut_half_pixel_size); | |
| // Offset to the right depth slice now. | |
| y += (coord.z - fmod(coord.z, k_lut_size)) * k_lut_size; | |
| // We skip filtering between slices for performance. | |
| return tex2D(tex, float2(coord.x, y)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment