53 lines
1.3 KiB
Text
53 lines
1.3 KiB
Text
|
#version 150
|
||
|
#if defined(POSITION_TEX)
|
||
|
|
||
|
#ifdef VERTEX_SHADER
|
||
|
|
||
|
struct Transform {
|
||
|
vec4 color;
|
||
|
vec4 textureColor;
|
||
|
float guiScale;
|
||
|
float gameTime;
|
||
|
vec3 position;
|
||
|
vec2 textureUV;
|
||
|
} transform;
|
||
|
|
||
|
void offsetElement(float alpha, float x, float y) {
|
||
|
if(transform.color.a == alpha / 255.0) {
|
||
|
transform.position.x += x * transform.guiScale;
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void anchorZ(float alpha, float target) {
|
||
|
if(transform.textureColor.a != alpha) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
transform.position.z = target;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#ifdef FRAGMENT_SHADER
|
||
|
|
||
|
struct Transform {
|
||
|
vec4 color;
|
||
|
vec4 colorMod;
|
||
|
vec2 textureUV;
|
||
|
} transform;
|
||
|
#endif
|
||
|
|
||
|
#endif
|