Skip to content

Instantly share code, notes, and snippets.

@babon
Last active November 20, 2022 13:06
Show Gist options
  • Save babon/78fcecd323c5df0ac342083e907c468d to your computer and use it in GitHub Desktop.
Save babon/78fcecd323c5df0ac342083e907c468d to your computer and use it in GitHub Desktop.
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