wynnpack-archive/assets/minecraft/shaders/include/util.glsl
2024-12-07 12:29:57 +00:00

1 line
No EOL
1.2 KiB
GLSL

const vec2[] corners=vec2[4](vec2(0,0),vec2(0,1),vec2(1,1),vec2(1,0));vec4 getVertexColor(sampler2D Sampler,int vertexID,vec2 coords){ivec2 texSize=textureSize(Sampler,0);vec2 offset=vec2(0.);float pixelX=1./texSize.x/2.;float pixelY=1./texSize.y/2.;vertexID=vertexID%4;switch(vertexID){case 1:offset=vec2(-pixelX,pixelY);break;case 2:offset=vec2(pixelX,pixelY);break;case 3:offset=vec2(pixelX,-pixelY);break;case 0:offset=vec2(-pixelX,-pixelY);break;default:offset=vec2(0.);break;}return texture(Sampler,coords-offset);}bool alpha(float textureAlpha,float targetAlpha){float targetLess=targetAlpha-0.01;float targetMore=targetAlpha+0.01;return textureAlpha>targetLess&&textureAlpha<targetMore;}ivec4 getVertex(sampler2D Sampler0,int x,int y){return ivec4(round(texelFetch(Sampler0,ivec2(x,y),0)*255));}int getGuiScale(mat4 ProjMat,vec2 ScreenSize){return int(round(ScreenSize.x*ProjMat[0][0]/2));}int toInt(ivec3 v){return v.x<<16|v.y<<8|v.z;}bool isTooltip(mat4 ProjMat,vec3 Position){return ProjMat[2][3]==0&&Position.z>300&&Position.z<500;}float fog_distance_custom(vec3 pos,int shape){if(shape==0)return length(pos);else {float distXZ=length(pos.xz);float distY=abs(pos.y);return max(distXZ,distY);}}