wynnpack-archive/assets/minecraft/shaders/include/texture.glsl

52 lines
1.3 KiB
Text
Raw Normal View History

2024-08-25 12:42:26 +00:00
#version 150
#if defined(POSITION_TEX)
#ifdef VERTEX_SHADER
struct Transform {
vec4 color;
float guiScale;
float gameTime;
2024-08-25 12:43:53 +00:00
float elementDepth;
2024-08-25 12:42:26 +00:00
vec3 position;
vec2 textureUV;
} transform;
void offsetElement(float alpha, float x, float y) {
2024-08-25 12:43:53 +00:00
if(transform.color.a == alpha) {
transform.position.x -= x * transform.guiScale;
2024-08-25 12:42:26 +00:00
transform.position.y -= y * transform.guiScale;
}
}
void paddingElement(sampler2D Sampler0, int vertexId) {
ivec4 element = getVertex(Sampler0, 0, 0);
ivec4 check = getVertex(Sampler0, 0, 1);
if(element.a != 0 && element.a != 255 && check == ivec4(0)) {
transform.textureUV = corners[vertexId % 4];
transform.position.xy += (transform.textureUV - 0.5) * (ivec2(256) - element.zw);
int frame = int(transform.gameTime * element.y * 1400.0) % element.x;
ivec2 cells = textureSize(Sampler0, 0) / 256;
transform.textureUV += ivec2(frame % cells.x, frame / cells.y);
transform.textureUV /= cells;
}
}
2024-08-25 12:43:53 +00:00
void anchorZ(float depth, float target) {
if(transform.elementDepth != depth) {
2024-08-25 12:42:26 +00:00
return;
}
transform.position.z = target;
}
#endif
#ifdef FRAGMENT_SHADER
struct Transform {
vec4 color;
vec4 colorMod;
vec2 textureUV;
} transform;
#endif
#endif