Sea scroll shader, silly edition
This commit is contained in:
parent
cc1052ceb4
commit
17523985bd
|
@ -4,7 +4,10 @@ uniform sampler2D palette : hint_normal;
|
||||||
// uniform float tile_width = 8.0;
|
// uniform float tile_width = 8.0;
|
||||||
uniform float tilemap_width = 512.0; // Require square tilemap for now
|
uniform float tilemap_width = 512.0; // Require square tilemap for now
|
||||||
const float index_scale = 255.0 / 16.0;
|
const float index_scale = 255.0 / 16.0;
|
||||||
|
const vec2 sea_tile_uv = vec2(0.125, 0.375);
|
||||||
|
const vec2 sea_tile_uv_end = vec2(0.25, 0.5);
|
||||||
|
const vec2 sea_tile_size = sea_tile_uv_end - sea_tile_uv;
|
||||||
|
const vec2 sea_tile_size_inv = 1.0/sea_tile_size;
|
||||||
|
|
||||||
// This shader maps from tileID texels to Tiles, and then applies palette.
|
// This shader maps from tileID texels to Tiles, and then applies palette.
|
||||||
// tiles hardcoded to 16x16 tiles for now
|
// tiles hardcoded to 16x16 tiles for now
|
||||||
|
@ -17,9 +20,21 @@ vec2 get_tile_atlas_uv(float tile_id, vec2 uv) {
|
||||||
vec2 tile_uv = vec2(tile_col, tile_row); // Convert 15.9375 to vec2(0.9375==15/16, (15)/16), this should result in integer coordinates in [0,15] scaled to [0,15/16] for UV
|
vec2 tile_uv = vec2(tile_col, tile_row); // Convert 15.9375 to vec2(0.9375==15/16, (15)/16), this should result in integer coordinates in [0,15] scaled to [0,15/16] for UV
|
||||||
vec2 sub_tile_uv = fract(uv * tilemap_width) / 16.0;
|
vec2 sub_tile_uv = fract(uv * tilemap_width) / 16.0;
|
||||||
|
|
||||||
// TODO: add sea HScroll, waterfall VScroll tile UV modulation
|
vec2 out_uv = tile_uv + sub_tile_uv;
|
||||||
return tile_uv + sub_tile_uv;
|
|
||||||
// return sub_tile_uv + vec2(0.0, 0.5);
|
// Sea HScroll tile UV modulation
|
||||||
|
// Make this branchless later
|
||||||
|
if (all(greaterThanEqual(out_uv, sea_tile_uv)) && all(lessThan(out_uv, sea_tile_uv_end))) {
|
||||||
|
vec2 sea_tile_uv_diff = out_uv - sea_tile_uv;
|
||||||
|
vec2 pos = sea_tile_uv_diff * sea_tile_size_inv;
|
||||||
|
// pos.x = fract(pos.x + fract(TIME*0.4) + cos(pos.y*0.5) + 20.0*sin(uv.y*20.0));
|
||||||
|
pos.x = fract(pos.x + fract(TIME*0.4) + 20.0*sin(uv.y*20.0));
|
||||||
|
pos.y = fract(pos.y + 0.5*sin(sin(TIME*0.5 + 32.0*uv.x)));
|
||||||
|
out_uv = mix(sea_tile_uv, sea_tile_uv_end, pos);
|
||||||
|
}
|
||||||
|
// TODO: waterfall VScroll UV modulation
|
||||||
|
|
||||||
|
return out_uv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
|
|
Loading…
Reference in New Issue