Simplify blit vertex shader
Also fixes rendering on macOS which for some reason was not doing the texture co-ordinate mapping correctly in the old shader.
This commit is contained in:
parent
da8944b551
commit
452fd71fea
@ -1,30 +1,20 @@
|
|||||||
#version GLSL_VERSION
|
#version GLSL_VERSION
|
||||||
#define vleft -1.0f
|
#define left -1.0f
|
||||||
#define vtop 1.0f
|
#define top 1.0f
|
||||||
#define vright 1.0f
|
#define right 1.0f
|
||||||
#define vbottom -1.0f
|
#define bottom -1.0f
|
||||||
|
|
||||||
#define tleft 0.0f
|
const vec2 pos_map[] = vec2[4](
|
||||||
#define ttop 1.0f
|
vec2(right, top),
|
||||||
#define tright 1.0f
|
vec2(right, bottom),
|
||||||
#define tbottom 0.0f
|
vec2(left, bottom),
|
||||||
|
vec2(left, top)
|
||||||
const vec2 viewport_xpos = vec2(vleft, vright);
|
|
||||||
const vec2 viewport_ypos = vec2(vtop, vbottom);
|
|
||||||
const vec2 texture_xpos = vec2(tleft, tright);
|
|
||||||
const vec2 texture_ypos = vec2(ttop, tbottom);
|
|
||||||
|
|
||||||
const uvec2 pos_map[] = uvec2[4](
|
|
||||||
uvec2(1, 0), // right, top
|
|
||||||
uvec2(1, 1), // right, bottom
|
|
||||||
uvec2(0, 1), // left, bottom
|
|
||||||
uvec2(0, 0) // left, top
|
|
||||||
);
|
);
|
||||||
|
|
||||||
out vec2 texcoord;
|
out vec2 texcoord;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
uvec2 pos = pos_map[gl_VertexID];
|
vec2 vertex = pos_map[gl_VertexID];
|
||||||
gl_Position = vec4(viewport_xpos[pos[0]], viewport_ypos[pos[1]], 0, 1);
|
gl_Position = vec4(vertex, 0, 1);
|
||||||
texcoord = vec2(texture_xpos[pos[0]], texture_ypos[pos[1]]);
|
texcoord = (vertex + 1.0) / 2.0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user