Bliss-Shader/shaders/lib/voxel_write.glsl

12 lines
400 B
Plaintext
Raw Normal View History

2024-05-02 23:38:35 -04:00
ivec3 GetVoxelIndex(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
return ivec3(floor(playerPos + cameraOffset) + VoxelSize3/2u);
}
2024-05-01 13:40:52 -04:00
void SetVoxelBlock(const in vec3 playerPos, const in uint blockId) {
2024-05-02 12:43:30 -04:00
ivec3 voxelPos = GetVoxelIndex(playerPos);
2024-05-02 14:18:49 -04:00
if (clamp(voxelPos, ivec3(0), ivec3(VoxelSize-1u)) != voxelPos) return;
2024-05-01 16:32:25 -04:00
2024-05-01 13:40:52 -04:00
imageStore(imgVoxelMask, voxelPos, uvec4(blockId));
}