Fix bug in particle positioning
This commit is contained in:
parent
a44e38afa3
commit
616be9e5fc
@ -3,7 +3,6 @@
|
||||
|
||||
uniform mat4 projection;
|
||||
uniform mat4 view;
|
||||
uniform vec3 camera_pos;
|
||||
|
||||
uniform vec3 quad1, quad2;
|
||||
|
||||
@ -23,7 +22,7 @@ void main() {
|
||||
if(type_pass[0] != 0.0) {
|
||||
// This is not a generator particle
|
||||
|
||||
vec3 old_pos = gl_in[0].gl_Position.xyz - camera_pos;
|
||||
vec3 old_pos = gl_in[0].gl_Position.xyz;
|
||||
float size = size_pass[0];
|
||||
mat4 view_projection_matrix = projection * view;
|
||||
|
||||
|
@ -108,8 +108,6 @@ void ParticleSystem::set_camera(const Camera &camera) {
|
||||
|
||||
quad2 = glm::cross(camera.forward(), quad1);
|
||||
quad2 = glm::normalize(quad2);
|
||||
|
||||
camera_pos = camera.get_translation();
|
||||
}
|
||||
|
||||
void ParticleSystem::render() {
|
||||
@ -123,7 +121,6 @@ void ParticleSystem::render() {
|
||||
render_shader.setMat4("view", view_matrix);
|
||||
render_shader.setVec3("quad1", quad1);
|
||||
render_shader.setVec3("quad2", quad2);
|
||||
render_shader.setVec3("camera_pos", camera_pos);
|
||||
|
||||
texture->bind_to(0);
|
||||
|
||||
|
@ -57,7 +57,6 @@ class ParticleSystem {
|
||||
|
||||
glm::mat4 projection_matrix, view_matrix;
|
||||
glm::vec3 quad1, quad2;
|
||||
glm::vec3 camera_pos;
|
||||
|
||||
float elapsed_time;
|
||||
float next_generation_time;
|
||||
|
@ -19,7 +19,7 @@ class ParticleApp : public Gedeng::Application {
|
||||
bump("Resources/Textures/PavingStones/PavingStones070_2K_Displacement.jpg", Gedeng::Texture::Settings()),
|
||||
normal("Resources/Textures/PavingStones/PavingStones070_2K_Normal.jpg", Gedeng::Texture::Settings()),
|
||||
quad_mesh(Gedeng::QuadMesh(10.0)) {
|
||||
particles.set_position(glm::vec3(0.0f, 0.0f, -5.0f));
|
||||
particles.set_position(glm::vec3(0.0f, 0.0f, -10.0f));
|
||||
particles.set_velocity(glm::vec3(-2, 4, -2), glm::vec3(2, 6, 2));
|
||||
particles.set_gravity(glm::vec3(0, -4, 0));
|
||||
particles.set_color(glm::vec3(0.0f, 0.5f, 1.0f));
|
||||
|
Loading…
x
Reference in New Issue
Block a user