Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform texture tilesheet;
- uniform float repeat=16;
- uniform float tileOffsetX=0;
- uniform float tileOffsetY=0;
- uniform float tileWidth=16;
- uniform float tileHeight=16;
- uniform float tilesheetWidth=101;
- uniform float tilesheetHeight=169;
- vec2 inverseTextureSize = vec2(1/tilesheetWidth, 1/tilesheetHeight);
- vec2 tileSize = vec2(tileWidth, tileHeight);
- vec2 pixelCoord = UV.xy * 1/TEXTURE_PIXEL_SIZE * repeat;
- vec2 spriteOffset = vec2(tileOffsetX, tileOffsetY);
- vec2 spriteCoord = mod(pixelCoord, tileSize);
- vec2 texCoord = (spriteOffset + spriteCoord) * inverseTextureSize;
- COLOR.rgba = tex(tilesheet, texCoord);
- // Get rid of empty lines that are due to floating point errors
- if (COLOR.a == 0) {
- COLOR.rgba = tex(tilesheet, texCoord-vec2(0.0, -inverseTextureSize.y));
- }
- COLOR.rgba = COLOR.rgba * SRC_COLOR;
Advertisement
Add Comment
Please, Sign In to add comment