implement image atlasing and tiling
This commit is contained in:
parent
5c7f996eb6
commit
e560c0de6b
7 changed files with 95 additions and 33 deletions
BIN
resources/images/tiles.png
Normal file
BIN
resources/images/tiles.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
BIN
resources/images/tiles.png.kra
Normal file
BIN
resources/images/tiles.png.kra
Normal file
Binary file not shown.
BIN
resources/images/tiles.png~
Normal file
BIN
resources/images/tiles.png~
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
16
resources/shaders/tiling.fs
Normal file
16
resources/shaders/tiling.fs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#version 330 core
|
||||
|
||||
uniform sampler2D diffuseMap;
|
||||
uniform vec2 textureTiling;
|
||||
|
||||
in vec2 fragTexCoord;
|
||||
in vec2 fragTexCoord2;
|
||||
in vec4 fragColor;
|
||||
|
||||
out vec4 outColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 texCoord = (floor(fragTexCoord*textureTiling) + fract(fragTexCoord2)) / textureTiling;
|
||||
outColor = texture(diffuseMap, texCoord);
|
||||
}
|
||||
19
resources/shaders/tiling.vs
Normal file
19
resources/shaders/tiling.vs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#version 330
|
||||
|
||||
in vec3 vertexPosition;
|
||||
in vec2 vertexTexCoord;
|
||||
in vec2 vertexTexCoord2;
|
||||
in vec4 vertexColor;
|
||||
|
||||
out vec2 fragTexCoord;
|
||||
out vec2 fragTexCoord2;
|
||||
out vec4 fragColor;
|
||||
|
||||
uniform mat4 mvp;
|
||||
|
||||
void main() {
|
||||
fragTexCoord = vertexTexCoord;
|
||||
fragColor = vertexColor;
|
||||
fragTexCoord2 = vertexTexCoord2;
|
||||
gl_Position = mvp*vec4(vertexPosition, 1.0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue