use texture array instead of atlas for tiles
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#version 150
|
||||
|
||||
#define MILLIS_PER_TILE 4000u
|
||||
|
||||
in vec2 v_uv;
|
||||
flat in uint v_tileidx;
|
||||
out vec4 pixcolor;
|
||||
uniform sampler2D t_atlas;
|
||||
uniform sampler2DArray t_tiles;
|
||||
uniform b_constants {
|
||||
uvec4 anim;
|
||||
float R1;
|
||||
@@ -19,8 +21,8 @@ uniform b_locals {
|
||||
void main() {
|
||||
vec2 anim_uv = v_uv;
|
||||
if (v_tileidx < 128u && bool(anim[v_tileidx / 32u] & 1u << v_tileidx % 32u)) {
|
||||
anim_uv = vec2(v_uv.x, float((uint(v_uv.y * 1000.0) + millis / 4u) % 1000u) / 1000.0);
|
||||
anim_uv = vec2(v_uv.x, v_uv.y + float(millis % MILLIS_PER_TILE) / MILLIS_PER_TILE);
|
||||
}
|
||||
vec2 uv = vec2(anim_uv.x, float(v_tileidx) / 256.0 + (1.0 - anim_uv.y) / 256.0);
|
||||
pixcolor = texture(t_atlas, uv);
|
||||
|
||||
pixcolor = texture(t_tiles, vec3(anim_uv.x, 1.0 - anim_uv.y, v_tileidx));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ gfx_defines! {
|
||||
trans: gfx::ConstantBuffer<::view::Trans> = "b_trans",
|
||||
constants: gfx::ConstantBuffer<Constants> = "b_constants",
|
||||
locals: gfx::ConstantBuffer<Locals> = "b_locals",
|
||||
atlas: gfx::TextureSampler<[f32; 4]> = "t_atlas",
|
||||
atlas: gfx::TextureSampler<[f32; 4]> = "t_tiles",
|
||||
pixcolor: gfx::RenderTarget<::view::ColorFormat> = "pixcolor",
|
||||
depth: gfx::DepthTarget<::view::DepthFormat> = gfx::preset::depth::LESS_EQUAL_WRITE,
|
||||
}
|
||||
@@ -157,7 +157,7 @@ impl<D: gfx::Device, F: gfx::Factory<D::Resources>> WorldScene<D, F> {
|
||||
locals: factory.create_constant_buffer(1),
|
||||
atlas: tile::get_tiles::<_, _, view::ColorFormat>(factory),
|
||||
sampler: factory.create_sampler(tex::SamplerInfo::new(tex::FilterMethod::Scale,
|
||||
tex::WrapMode::Clamp)),
|
||||
tex::WrapMode::Tile)),
|
||||
f: PhantomData,
|
||||
|
||||
vbuf: vertex_buffer,
|
||||
|
||||
Reference in New Issue
Block a user