LumixEngine/data/pipelines/flatten_cube.shd
Mikulas Florek 103d7d577f cleanup
2020-09-26 02:46:54 +02:00

45 lines
No EOL
854 B
Text

include "pipelines/common.glsl"
common [[
layout(std140, binding = 4) uniform Drawcall {
uniform vec2 tile_pos;
uniform vec2 tile_size;
uniform vec2 atlas_size;
};
]]
vertex_shader [[
void main() {
vec4 pos = fullscreenQuad(gl_VertexID, v_uv);
pos.xy = tile_pos + pos.xy * tile_size;
gl_Position = pos;
}
]]
fragment_shader [[
vec3 gridToDir(Vec2 uv) {
vec3 position = vec3(
0.0f + (uv.x - uv.y),
-1.0f + (uv.x + uv.y),
0.0f
);
vec2 absolute = abs(position.xy);
position.z = 1.0f - absolute.x - absolute.y;
return position.xzy;
}
vec2 dirToGrid(vec3 vec)
{
vec.y = max(0.001,vec.y);
vec = normalize(vec);
vec.xz /= dot( vec3(1.0), abs(vec) );
return vec2(vec.x + vec.z, vec.x - vec.z);
}
layout (binding=0) uniform sampler2D u_input[6];
out float o_depth;
void main() {
o_depth = 42;
}
]]