Flip Y coordinates on textures on UIShader
This commit is contained in:
@ -60,24 +60,36 @@ namespace Dawn {
|
||||
getParameters(dummy, this->parameters);
|
||||
|
||||
// Update offsets.
|
||||
std::for_each(
|
||||
this->parameters.begin(),
|
||||
this->parameters.end(),
|
||||
[&](struct ShaderParameter ¶m) {
|
||||
param.offset -= (size_t)(&dummy);
|
||||
auto itParams = this->parameters.begin();
|
||||
while(itParams != this->parameters.end()) {
|
||||
struct ShaderParameter ¶m = *itParams;
|
||||
param.offset -= (size_t)(&dummy);
|
||||
|
||||
// Check for non-aligned OpenGL structures.
|
||||
if(param.offset % sizeof(glm::vec4) != 0) {
|
||||
assertUnreachable(
|
||||
"%s%s%s",
|
||||
"Non-aligned OpenGL structure detected on param ",
|
||||
param.name.c_str(),
|
||||
"!\nEnsure you have padded correctly."
|
||||
);
|
||||
}
|
||||
// Check for non-aligned OpenGL structures.
|
||||
if(param.offset % sizeof(glm::vec4) != 0) {
|
||||
assertUnreachable(
|
||||
"%s%s%s",
|
||||
"Non-aligned OpenGL structure detected on param ",
|
||||
param.name.c_str(),
|
||||
"!\nEnsure you have padded correctly."
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
if(
|
||||
itParams == (this->parameters.end() - 1) &&
|
||||
count > 1 &&
|
||||
(sizeof(T) % sizeof(glm::vec4)) != 0
|
||||
) {
|
||||
assertUnreachable(
|
||||
"%s%s%s",
|
||||
"Non-aligned OpenGL structure detected on last element in array structure on param ",
|
||||
param.name.c_str(),
|
||||
"!\nEnsure you have padded correctly."
|
||||
);
|
||||
}
|
||||
|
||||
++itParams;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
@ -52,22 +52,22 @@ void UIShader::getStages(
|
||||
"pos.x = quad.quad.x;\n"
|
||||
"pos.y = quad.quad.y;\n"
|
||||
"coord.x = quad.uv.x;\n"
|
||||
"coord.y = quad.uv.y;\n"
|
||||
"coord.y = quad.uv.w;\n"
|
||||
"} else if(vertexIndex == 1) {\n"
|
||||
"pos.x = quad.quad.z;\n"
|
||||
"pos.y = quad.quad.y;\n"
|
||||
"coord.x = quad.uv.z;\n"
|
||||
"coord.y = quad.uv.y;\n"
|
||||
"coord.y = quad.uv.w;\n"
|
||||
"} else if(vertexIndex == 2) {\n"
|
||||
"pos.y = quad.quad.w;\n"
|
||||
"pos.x = quad.quad.x;\n"
|
||||
"coord.x = quad.uv.x;\n"
|
||||
"coord.y = quad.uv.w;\n"
|
||||
"coord.y = quad.uv.y;\n"
|
||||
"} else if(vertexIndex == 3) {\n"
|
||||
"pos.x = quad.quad.z;\n"
|
||||
"pos.y = quad.quad.w;\n"
|
||||
"coord.x = quad.uv.z;\n"
|
||||
"coord.y = quad.uv.w;\n"
|
||||
"coord.y = quad.uv.y;\n"
|
||||
"}\n"
|
||||
"pos.z = 0;\n"
|
||||
"pos.w = 1;\n"
|
||||
@ -88,27 +88,30 @@ void UIShader::getStages(
|
||||
"out vec4 o_Color;\n"
|
||||
"void main() {\n"
|
||||
"vec4 texColor = vec4(1, 1, 1, 1);\n"
|
||||
// "switch(int(v_TextureIndex)) {\n"
|
||||
// "case 0:\n"
|
||||
// "texColor = texture(u_Texture[0], v_TextCoord);\n"
|
||||
// "break;\n"
|
||||
// "case 1:\n"
|
||||
// "texColor = texture(u_Texture[1], v_TextCoord);\n"
|
||||
// "break;\n"
|
||||
// "case 2:\n"
|
||||
// "texColor = texture(u_Texture[2], v_TextCoord);\n"
|
||||
// "break;\n"
|
||||
// "case 3:\n"
|
||||
// "texColor = texture(u_Texture[3], v_TextCoord);\n"
|
||||
// "break;\n"
|
||||
// "case 4:\n"
|
||||
// "texColor = texture(u_Texture[4], v_TextCoord);\n"
|
||||
// "break;\n"
|
||||
// "case 5:\n"
|
||||
// "texColor = texture(u_Texture[5], v_TextCoord);\n"
|
||||
// "break;\n"
|
||||
// "}\n"
|
||||
"texColor = texture(u_Texture[0], v_TextCoord);\n"
|
||||
"int vTextInd = int(round(v_TextureIndex));\n"
|
||||
"switch(vTextInd) {\n"
|
||||
"case -1:\n"
|
||||
"texColor = vec4(1, 1, 1, 1);\n"
|
||||
"break;\n"
|
||||
"case 0:\n"
|
||||
"texColor = texture(u_Texture[0], v_TextCoord);\n"
|
||||
"break;\n"
|
||||
"case 1:\n"
|
||||
"texColor = texture(u_Texture[1], v_TextCoord);\n"
|
||||
"break;\n"
|
||||
"case 2:\n"
|
||||
"texColor = texture(u_Texture[2], v_TextCoord);\n"
|
||||
"break;\n"
|
||||
"case 3:\n"
|
||||
"texColor = texture(u_Texture[3], v_TextCoord);\n"
|
||||
"break;\n"
|
||||
"case 4:\n"
|
||||
"texColor = texture(u_Texture[4], v_TextCoord);\n"
|
||||
"break;\n"
|
||||
"case 5:\n"
|
||||
"texColor = texture(u_Texture[5], v_TextCoord);\n"
|
||||
"break;\n"
|
||||
"}\n"
|
||||
"o_Color = texColor * v_Color;\n"
|
||||
"}\n"
|
||||
);
|
||||
|
@ -15,6 +15,7 @@ namespace Dawn {
|
||||
glm::vec4 uv;
|
||||
struct Color color;
|
||||
float_t texture;
|
||||
glm::vec3 padding;
|
||||
};
|
||||
|
||||
struct UIShaderData {
|
||||
|
Reference in New Issue
Block a user