lwjglgamedev / lwjglbook-leg

Source code of the chapters of the book 3D Game Development with LWJGL 3
https://ahbejarano.gitbook.io/lwjglgamedev/
Apache License 2.0
560 stars 202 forks source link

Particles rendered at the camera position #38

Closed jaredfishy closed 6 years ago

jaredfishy commented 7 years ago

Firstly, loving the book - keep at it!

I had an issue working through the particle chapter where the particles were always being rendered at the camera location (and they would move with me).

I figured out that the cause was due to the viewMatrix being altered in the renderSkyBox method (as I still had my SkyBox enabled).

Swapping the render order so that the particles rendered before the SkyBox didn't work, however rebuilding the viewMatrix in the renderParticles method corrects the viewMatrix and everything appears to render correctly from there on.

Keep up the good work and I look forward to future chapters.

Edit: I'm an idiot. The renderSkyBox method stores and resets the values so the rebuild is not require.

lwjglgamedev commented 7 years ago

Thanks for reporting this. Should I close the issue then ?

jaredfishy commented 7 years ago

Yes you can close the issue.

Another question for you, in the particles code have you tried to scale the particle effect down? When I added the transpose code to get the billboard effect the scaling value seems to be no longer applied?

lwjglgamedev commented 7 years ago

I will have a look at it.

lwjglgamedev commented 7 years ago

Ok. Since the billboard effect is achived by removing the rotation and scaling effects from the view model matrix, yes, scaling is not applied. If you still want to apply scaling, you can apply it again, after the billboard model view matrix is calculated.

I may include this in the book when I have some spare time. Hence, I will leave this issue open.

Very good question, indeed.

lwjglgamedev commented 7 years ago

I've just updated the book and the source code to preserve scaling for particles.