Last active
November 20, 2022 13:06
-
-
Save babon/78fcecd323c5df0ac342083e907c468d 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
voxel temp; | |
vox.sunlight = id.y == resolution.y - 1 ? 15 : 0; | |
vox.torchlight = 0.; | |
//pull 6 neighbours and -1 | |
if (id.y < resolution.y - 1.) | |
{ | |
temp = getVoxel(id + int3(0,1,0)); | |
vox.sunlight = max(vox.sunlight, temp.sunlight); | |
vox.torchlight = max(vox.torchlight, temp.torchlight - 1.); | |
} | |
if (id.y > 1.) | |
{ | |
temp = getVoxel(id + int3(0,-1,0)); | |
vox.sunlight = max(vox.sunlight, temp.sunlight - 1.); | |
vox.torchlight = max(vox.torchlight, temp.torchlight - 1.); | |
} | |
temp = getVoxel(id + int3(-1,0,0)); | |
vox.sunlight = max(vox.sunlight, temp.sunlight - 1.); | |
vox.torchlight = max(vox.torchlight, temp.torchlight - 1.); | |
temp = getVoxel(id + int3(1,0,0)); | |
vox.sunlight = max(vox.sunlight, temp.sunlight - 1.); | |
vox.torchlight = max(vox.torchlight, temp.torchlight - 1.); | |
temp = getVoxel(id + int3(0,0,-1)); | |
vox.sunlight = max(vox.sunlight, temp.sunlight - 1.); | |
vox.torchlight = max(vox.torchlight, temp.torchlight - 1.); | |
temp = getVoxel(id + int3(0,0,1)); | |
vox.sunlight = max(vox.sunlight, temp.sunlight - 1.); | |
vox.torchlight = max(vox.torchlight, temp.torchlight - 1.); | |
if (vox.id > 0.) | |
{ | |
vox.sunlight = 0.; | |
vox.torchlight = 0.; | |
} | |
if (vox.id == 6.) | |
{ | |
vox.torchlight = 15.; | |
} | |
fragColor = encodeVoxel(vox); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment