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

align particles to face the camera

parent 9ffe0ada
No related branches found
No related tags found
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
......@@ -12,6 +12,10 @@ layout(location = 0) in vec2 vertexPos;
layout(location = 0) out vec2 passPos;
layout(location = 1) out float passMass;
layout( push_constant ) uniform constants{
mat4 mvp;
};
void main() {
vec3 position = particles[gl_InstanceIndex].minimal.position;
float size = particles[gl_InstanceIndex].minimal.size;
......@@ -20,5 +24,8 @@ void main() {
passPos = vertexPos;
passMass = mass;
gl_Position = vec4(position + vec3(vertexPos * size * 2.0f, 0), 1);
// align particle to face camera
gl_Position = mvp * vec4(position, 1); // transform position into projected view space
gl_Position.xy += vertexPos * size * 2.0f; // move position directly in view space
}
\ No newline at end of file
......@@ -384,7 +384,11 @@ int main(int argc, const char **argv) {
timePushConstants.appendDrawcall(static_cast<float>(dt));
cameraManager.update(dt);
glm::mat4 mvp = cameraManager.getActiveCamera().getMVP();
vkcv::PushConstants cameraPushConstants (sizeof(glm::mat4));
cameraPushConstants.appendDrawcall(mvp);
auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
const uint32_t dispatchSizeGrid [3] = { 16, 16, 16 };
......@@ -496,7 +500,7 @@ int main(int argc, const char **argv) {
cmdStream,
gfxPass,
gfxPipeline,
vkcv::PushConstants(0),
cameraPushConstants,
drawcalls,
renderTargets,
windowHandle
......
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