OpenGL 3D Game Tutorial 35: Animating Particle Textures

preview_player
Показать описание
LWJGL tutorial series on how to create a 3D Java game with OpenGL!

Texturing and animating our particles this week!

Particle textures:

Insertion sort code:

Insertion sort explained:

Upcoming tutorials:

- Particle Effects 3
- Random Terrain Generation
- Shadows
- Post processing

Future Tutorial Series:

- Game Audio
- Multiplayer
- Advanced Game Dev Concepts
- OpenGL Optimizing Techniques

Previous tutorial topics:

- Display
- VAOs and VBOs - Rendering a quad
- Rendering using glDrawElements
- Shader introduction
- Coloring using shaders
- Texturing
- Matrices, moving and rotating
- Loading 3D OBJ models
- Lighting I
- Lighting II
- Optimizations
- Transparency
- Fog
- Multitexturing
- Player Movement
- 3rd Person Camera
- Mipmapping
- Terrain Generation
- Terrain Collision Detection
- Texture Atlases
- GUIs/HUDs
- Multiple Light sources
- Point light attenuation
- Skybox
- Day/Night
- 3D Mouse Picking
- Water
- Cel Shading
- Normal Mapping
- Rendering Text
- Signed Distance Field Fonts
- Particle Effects

End of video music- Kai Engel, "Waking Stars":

Рекомендации по теме
Комментарии
Автор

Can someone make a compilation of him saying "in the shader class we need to do the usual thing" ?

NOOBDP
Автор

For anyone using Java 8, instead of using the insertion sort, you can just use:

list.sort((p1, p2) -> Float.compare(p2.getDistance(), p1.getDistance()));

ryanheuer
Автор

I added very usefull cosine interpolation function:
const float pi = 3.1415;
float time = (1.0 - cos(pi * timeNorm)) / 2.0; // <0, 1)
time = pow(time, cosineFactor);
when modifying this function with cosineFactor loaded to the vertexShader, you can modify how fast part of animation is played like fire atlas filled with flames and smoke sprites. Using it you can apply more fire or more smoke at specific lifetime gap :D
Saving array of colours and factors you can also make some colour transition.
Thats pretty funny :)

GieneqAD
Автор

Hey thin matrix, great video, and particularly yoir explanations about rendering order and performances ^^

RomainGratte
Автор

Thank you for this great tutorial. It gave me the right direction for my own particle system.

dameck
Автор

There is a very efficient java way of sorting the rendering order of particals in relation to the camera. However this may not have been possible in older versions of java used at the time of making.

In the Particle class, update method, remove the "distance" variable calculation and create a distanceTo method:
public float distanceTo(Camera camera) {
return Vector3f.sub(camera.getPosition(), position, null).lengthSquared();
}

In the ParticalMaster class, update method. Rather than using:

You can use a build in list sort lambda function:
list.sort((p1, p2) -> {
if (p1.distanceTo(camera) == p2.distanceTo(camera)) {
return 0;
}
return p1.distanceTo(camera) < p2.distanceTo(camera) ? 1 : -1;
});

This will loop through and use the result of the Particles "distanceTo" method to sort the particles in the list :)

Zelirik
Автор

8:14 I'm having an issue with the texture. The texture isn't working properly. Instead of the star texture and stuff, I'm getting something that looks like entire scene packed into that small space and then the skybox texture, too.

JRDevAll
Автор

You're a brave man dropping a ternary operator in a coding tutorial without describing it

Benjigga
Автор

Would it be possible to do a graphic tutorial on how to add a black outline to your character or objects to give it a more cartoonish feel? Similar to games such as The Walking Dead or Okami.

RecordFriction
Автор

So I had a really pernicious problem where at the 8:00 mark my particles would not work. Each particle quad would appear as normal, but instead of rendering the star texture, each quad would depict the _entire scene_. I saw a couple other users had the same problem. But I solved it.

The issue was at 6:09, in the ParticleRenderer.render() method. In my scramble to auto-complete field values to try and keep up with ThinMatrix, I accidentally chose GL11.GL_PROXY_TEXTURE_2D when I should have picked GL11.GL_TEXTURE_2D.

AstroTibs
Автор

I who'd love to see a tutorial on animation!

jondoe
Автор

I tried running the code but the particle atlas textures don't render, and the regular textures look weird. Can anyone help?

saadamin
Автор

I don't think it is enough to just take the distance from the particle to the camera, I think you have to take into account the rotation of the camera as well (so move the particles into camera space and the z component is your correct distance)

arhaisme
Автор

Could i please get the code for ParticleRenderer, ParticleShader, loader, particleVShader and ParticleFShader? Simply because my pc couldn't handle the code from the next episode so i want to fix it, but i get: "Could not compile shader!Vertex shader failed to compile with the following errors:
ERROR: 0:14: error(#132) Syntax error: 'void' parse error
ERROR: error(#273) 1 compilation errors. No code generated" from my particleVShader

johnythecarrot
Автор

For some reason, I have to put the test for alpha-blending in the *for(Particle particle : particles.get(texture)){* loop in the ParticleRenderer, or else when my particles that don't use the ParticleSystem and aren't alpha blended are being rendered, the alpha blending goes away for particles that do use ParticleSystem and are alpha blended.

somethingtojenga
Автор

Could someone tell me the code for having all of the atlases in one atlas, I've been stuck on it for ages

urgentina
Автор

I am loving this tutorial. Congratulations! You are the best teacher I have met. However, I need your help. Please, how settings in the complex system could be to create a fire particles show? I have tried but they never seem so good as at 24:59 time of video this shows. Could it be better create smalls fire system and put all near each other?

jmr
Автор

Hi, thank you for this new tutorial and Happy new year !

zhuzhu
Автор

How can i get the width and height of any object so i can make a hitbox?

notagoose
Автор

24:08 is it possible to get the same effect from using multiple sampler2Ds and have an integer per particle decide which one to use instead of using at atlas of atlases?

henrik