Skip to content
Snippets Groups Projects
Commit 10661e87 authored by Vanessa Karolek's avatar Vanessa Karolek
Browse files

[#94] correct projected texture coordinates

parent 03677d21
No related branches found
No related tags found
1 merge request!77Resolve "SAF-R Module"
......@@ -6,6 +6,7 @@ layout(location = 1) out vec2 texCoord;
layout( push_constant ) uniform constants{
mat4 mvp;
mat4 proj;
};
void main() {
......@@ -24,8 +25,8 @@ void main() {
vec4 position = mvp * vec4(positions[gl_VertexIndex], 1.0);
gl_Position = position;
texCoord.x = (positions[gl_VertexIndex].x + 1.0) * 0.5;
texCoord.y = (-positions[gl_VertexIndex].y + 1.0) * 0.5;
texCoord.x = ((proj * vec4(positions[gl_VertexIndex], 1.0)).x + 1.0) * 0.5;
texCoord.y = ((proj * vec4(positions[gl_VertexIndex], 1.0)).y + 1.0) * 0.5;
fragColor = colors[gl_VertexIndex];
}
\ No newline at end of file
......@@ -175,10 +175,10 @@ int main(int argc, const char** argv) {
Material mirror(glm::vec3(0.0, 10.0, 0.8), glm::vec3(1.0, 1.0, 1.0), 1425.);
std::vector<Sphere> spheres;
spheres.push_back(Sphere(glm::vec3(-3, 0, -16), 2, ivory));
spheres.push_back(Sphere(glm::vec3(-3, 0, -16), 2, ivory));
spheres.push_back(Sphere(glm::vec3(-1.0, -1.5, -12), 2, mirror));
spheres.push_back(Sphere(glm::vec3( 1.5, -0.5, -18), 3, red_rubber));
spheres.push_back(Sphere(glm::vec3( 7, 5, -18), 4, mirror));
spheres.push_back(Sphere(glm::vec3( 7, 5, -18), 4, mirror));
std::vector<Light> lights;
lights.push_back(Light(glm::vec3(-20, 20, 20), 1.5));
......@@ -278,9 +278,10 @@ int main(int argc, const char** argv) {
cameraManager.update(0.000001 * static_cast<double>(deltatime.count()));
glm::mat4 mvp = cameraManager.getActiveCamera().getMVP();
glm::mat4 proj = cameraManager.getActiveCamera().getProjection();
vkcv::PushConstants pushConstants (sizeof(glm::mat4));
pushConstants.appendDrawcall(mvp);
vkcv::PushConstants pushConstants (sizeof(glm::mat4) * 2);
pushConstants.appendDrawcall(std::array<glm::mat4, 2>{ mvp, proj });
auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment