only use 4x2 matrix

This commit is contained in:
Jupeyy 2017-09-27 12:15:30 +02:00
parent cb1ab7ff9e
commit a85f542d1d
9 changed files with 24 additions and 22 deletions

View file

@ -2,7 +2,7 @@
layout (location = 0) in vec2 inVertex;
uniform mat4 Pos;
uniform mat4x2 Pos;
uniform vec2 Offset;
uniform vec2 Dir;
@ -10,11 +10,11 @@ uniform int JumpIndex;
void main()
{
vec4 VertPos = vec4(inVertex, -5.0, 1.0);
vec4 VertPos = vec4(inVertex, 0.0, 1.0);
int XCount = gl_InstanceID - (int(gl_InstanceID/JumpIndex) * JumpIndex);
int YCount = (int(gl_InstanceID/JumpIndex));
VertPos.x += Offset.x + Dir.x * XCount;
VertPos.y += Offset.y + Dir.y * YCount;
gl_Position = Pos * VertPos;
gl_Position = vec4(Pos * VertPos, 0.0, 1.0);
}

View file

@ -2,15 +2,15 @@
layout (location = 0) in vec2 inVertex;
uniform mat4 Pos;
uniform mat4x2 Pos;
uniform vec2 Dir;
void main()
{
vec4 VertPos = vec4(inVertex, -5.0, 1.0);
vec4 VertPos = vec4(inVertex, 0.0, 1.0);
VertPos.x += Dir.x * (gl_InstanceID+1);
VertPos.y += Dir.y * (gl_InstanceID+1);
gl_Position = Pos * VertPos;
gl_Position = vec4(Pos * VertPos, 0.0, 1.0);
}

View file

@ -4,7 +4,7 @@ layout (location = 0) in vec2 inVertex;
layout (location = 1) in vec2 inVertexTexCoord;
layout (location = 2) in ivec2 inVertexTexRightOrBottom;
uniform mat4 Pos;
uniform mat4x2 Pos;
uniform float ZoomFactor;
uniform vec2 Dir;
@ -13,11 +13,11 @@ noperspective out vec2 texCoord;
void main()
{
vec4 VertPos = vec4(inVertex, -5.0, 1.0);
vec4 VertPos = vec4(inVertex, 0.0, 1.0);
VertPos.x += Dir.x * (gl_InstanceID+1);
VertPos.y += Dir.y * (gl_InstanceID+1);
gl_Position = Pos * VertPos;
gl_Position = vec4(Pos * VertPos, 0.0, 1.0);
float F1 = -(0.75/1024.0) * ZoomFactor;
float F2 = (1.75/1024.0) * ZoomFactor;
float tx = (inVertexTexCoord.x/(16.0)) - (inVertexTexRightOrBottom.x == 0 ? 0.0 : (1.0/1024.0));

View file

@ -4,7 +4,7 @@ layout (location = 0) in vec2 inVertex;
layout (location = 1) in vec2 inVertexTexCoord;
layout (location = 2) in ivec2 inVertexTexRightOrBottom;
uniform mat4 Pos;
uniform mat4x2 Pos;
uniform float ZoomFactor;
uniform vec2 Offset;
@ -15,13 +15,13 @@ noperspective out vec2 texCoord;
void main()
{
vec4 VertPos = vec4(inVertex, -5.0, 1.0);
vec4 VertPos = vec4(inVertex, 0.0, 1.0);
int XCount = gl_InstanceID - (int(gl_InstanceID/JumpIndex) * JumpIndex);
int YCount = (int(gl_InstanceID/JumpIndex));
VertPos.x += Offset.x + Dir.x * XCount;
VertPos.y += Offset.y + Dir.y * YCount;
gl_Position = Pos * VertPos;
gl_Position = vec4(Pos * VertPos, 0.0, 1.0);
float F1 = -(0.75/1024.0) * ZoomFactor;
float F2 = (1.75/1024.0) * ZoomFactor;
float tx = (inVertexTexCoord.x/(16.0)) - (inVertexTexRightOrBottom.x == 0 ? 0.0 : (1.0/1024.0));

View file

@ -4,14 +4,14 @@ layout (location = 0) in vec2 inVertex;
layout (location = 1) in vec2 inVertexTexCoord;
layout (location = 2) in vec4 inVertexColor;
uniform mat4 Pos;
uniform mat4x2 Pos;
noperspective out vec2 texCoord;
noperspective out vec4 vertColor;
void main()
{
gl_Position = Pos * vec4(inVertex, -5.0, 1.0);
gl_Position = vec4(Pos * vec4(inVertex, 0.0, 1.0), 0.0, 1.0);
texCoord = inVertexTexCoord;
vertColor = inVertexColor;
}

View file

@ -3,6 +3,7 @@
uniform vec4 vertColor;
out vec4 FragClr;
void main()
{
FragClr = vertColor;

View file

@ -2,9 +2,9 @@
layout (location = 0) in vec2 inVertex;
uniform mat4 Pos;
uniform mat4x2 Pos;
void main()
{
gl_Position = Pos * vec4(inVertex, -5.0, 1.0);
gl_Position = vec4(Pos * vec4(inVertex, 0.0, 1.0), 0.0, 1.0);
}

View file

@ -4,14 +4,14 @@ layout (location = 0) in vec2 inVertex;
layout (location = 1) in vec2 inVertexTexCoord;
layout (location = 2) in ivec2 inVertexTexRightOrBottom;
uniform mat4 Pos;
uniform mat4x2 Pos;
uniform float ZoomFactor;
noperspective out vec2 texCoord;
void main()
{
gl_Position = Pos * vec4(inVertex, -5.0, 1.0);
gl_Position = vec4(Pos * vec4(inVertex, 0.0, 1.0), 0.0, 1.0);
float F1 = -(0.75/1024.0) * ZoomFactor;
float F2 = (1.75/1024.0) * ZoomFactor;
float tx = (inVertexTexCoord.x/(16.0)) - (inVertexTexRightOrBottom.x == 0 ? 0.0 : (1.0/1024.0));

View file

@ -553,16 +553,17 @@ void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState
// screen mapping
//orthographic projection matrix
//if we use the same z coordinate for every vertex, we can just ignore the z coordinate and set it in the shaders
float m[4*4] = {
float m[2*4] = {
2.f/(State.m_ScreenBR.x - State.m_ScreenTL.x), 0, 0, -((State.m_ScreenBR.x + State.m_ScreenTL.x)/(State.m_ScreenBR.x - State.m_ScreenTL.x)),
0, (2.f/(State.m_ScreenTL.y - State.m_ScreenBR.y)), 0, -((State.m_ScreenTL.y + State.m_ScreenBR.y)/(State.m_ScreenTL.y - State.m_ScreenBR.y)),
0, 0, -(2.f/(9.f)), -((11.f)/(9.f)),
0, 0, 0, 1.0f
//0, 0, -(2.f/(9.f)), -((11.f)/(9.f)),
//0, 0, 0, 1.0f
};
//transpose bcs of column-major order of opengl
glUniformMatrix4fv(pProgram->m_LocPos, 1, true, (float*)&m);
glUniformMatrix4x2fv(pProgram->m_LocPos, 1, true, (float*)&m);
}
void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand)