lwjglgamedev / lwjglbook-leg

Source code of the chapters of the book 3D Game Development with LWJGL 3

Home Page:https://ahbejarano.gitbook.io/lwjglgamedev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Particles rendered at the camera position

jaredfishy opened this issue · comments

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.

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

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?

I will have a look at it.

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.

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