Last active
December 21, 2015 09:49
-
-
Save mikolalysenko/6287996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform vec2 worldSize; | |
uniform vec2 tileScale; | |
uniform sampler2D tileIds; //This is the map you update every frame | |
uniform sampler2D tileSheet; //This has the texture data | |
varying vec3 worldCoord; | |
void main() { | |
vec2 worldUV = worldCoord.xy / worldCoord.z; | |
vec2 tileCoord = tileScale * (floor(255.0 * texture2D(tileIds, floor(worldUV) / worldSize).ra) + fract(worldUV)); | |
gl_FragColor = texture2D(tileSheet, tileCoord); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
attribute vec2 position; | |
uniform mat3 viewMatrix; | |
varying vec3 worldCoord; | |
void main() { | |
vec3 worldCoord = viewMatrix * vec3(pixelCoordinate, 1.0); | |
gl_Position = position; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment