mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-25 04:40:40 -04:00

fixes #176 This created negative values when the time was negative, resulting in wrong animation frames.
42 lines
901 B
GLSL
42 lines
901 B
GLSL
#version 430
|
|
|
|
layout (local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
struct AnimationData {
|
|
uint frames;
|
|
uint time;
|
|
};
|
|
|
|
struct TextureData {
|
|
uint textureIndices[6];
|
|
uint absorption;
|
|
float reflectivity;
|
|
float fogDensity;
|
|
uint fogColor;
|
|
};
|
|
|
|
layout(std430, binding = 0) buffer _animation
|
|
{
|
|
AnimationData animation[];
|
|
};
|
|
layout(std430, binding = 6) buffer _textureDataIn
|
|
{
|
|
TextureData textureDataIn[];
|
|
};
|
|
layout(std430, binding = 1) buffer _textureDataOut
|
|
{
|
|
TextureData textureDataOut[];
|
|
};
|
|
|
|
uniform uint time;
|
|
uniform uint size;
|
|
|
|
void main() {
|
|
uint index = gl_GlobalInvocationID.x;
|
|
if(index >= size) return;
|
|
for(int i = 0; i < 6; i++) {
|
|
uint textureIndex = textureDataIn[index].textureIndices[i];
|
|
textureIndex = textureIndex + time / animation[textureIndex].time % animation[textureIndex].frames;
|
|
textureDataOut[index].textureIndices[i] = textureIndex;
|
|
}
|
|
} |