Jump to content
Eternal Lands Official Forums
Umrion

Making Fire

Recommended Posts

Hi there. I've worked a bit on making a particle system for fire, and this is what I have so far.

 

With point particles:

fire_point.jpg

 

Without point particles:

fire_nopoint.jpg

 

I will upload a patch when I'm done, but I'll comment on some changes already.

particles.h:

 #define particle_rand(max) ((float)max/(float)((rand()%200)-100+0.5))

Added 0.5 to avoid divisions by zero. Not that it matters most of the time, since the result will be inf if max!=0. But if max==0, we get NaN, which is a bit worse (we might lose particles this way.)

 

particles.c:

 	 glBlendFunc(GL_SRC_ALPHA,GL_SRC_ALPHA_SATURATE);

As far as I know this will always give a GL_INVALID_ENUM error - SRC_ALPHA_SATURATE is only for use as source factor. Nevermind that, though. I changed the alternative blend func to one that often looks nice for particle systems:

glBlendFunc(GL_SRC_ALPHA,GL_ONE);

This makes for nice fires, and in my opinion improves the look of the teleporters and other particle systems too.

 

Finally, I centered the textured particles on their position, instead as using that as one corner. I.e.:

    glTexCoord2f(u_start,v_start);
   glVertex3f(x-x_len,y,z-z_len);

   glTexCoord2f(u_start,v_end);
   glVertex3f(x-x_len,y,z+z_len);

   glTexCoord2f(u_end,v_end);
   glVertex3f(x+x_len,y,z+z_len);

   glTexCoord2f(u_end,v_start);
   glVertex3f(x+x_len,y,z-x_len);

And of course I also halved x_len and z_len.

 

Oh yes, I also played around with making textured point sprites (GL_POINT_SPRITE,) but I think I would have to change the particle textures to one per particle type instead of having them all packed in one texture. This because GL_POINT_SPRITE generates texture coordinates in the (0,0)-(1,1) range, and they aren't affected by the texture matrix.

Share this post


Link to post
Share on other sites

I really think we should trash point particles. I think they look bad. I'm the one who rewrote it to use triangles instead of quads, which makes it a lot faster, but I left the points in there for people who can't afford the extra processing for the textures.

 

Ent really wants the textured points, but it won't work for everyone. ATI users are already having to deal with missing GL extensions. If you want to write in support for textured points, I'd like you to just completely replace the plain point particles, since point particles are stupid without textures. Leave the triangle strip method in there though, for people without the extensions.

Share this post


Link to post
Share on other sites

Cicero: I agree, plain point particles look bad. I'll just replace them when/if I fix the texturing.

 

We still need to decide how the client should decide where to place fires. During testing, I've only replaced the teleporters with fires...

I don't think the map format contains any information on where to put these. Some light sources obviously are fires - we could "simply" check which ones are placed over firewood.. Or should this be handled like the teleporters (i.e. server side)?

Share this post


Link to post
Share on other sites
Cicero: I agree, plain point particles look bad. I'll just replace them when/if I fix the texturing.

 

We still need to decide how the client should decide where to place fires. During testing, I've only replaced the teleporters with fires...

I don't think the map format contains any information on where to put these. Some light sources obviously are fires - we could "simply" check which ones are placed over firewood.. Or should this be handled like the teleporters (i.e. server side)?

This should be done serverside... it makes more sense that way.

Share this post


Link to post
Share on other sites

the teleportals use the teleport object base as their center..just do the exact same thing for the fire (torch object, campfire object, etc..)

Share this post


Link to post
Share on other sites

Not exactly. The client gets a message from the server with a list of teleporter positions. On those positions it adds portal1.e3d, the teleporter sound and a particle system.

Campfires, torches etc. are already on the map, and some of them have light sources.

Share this post


Link to post
Share on other sites

So when will be fire at beam? It would be really nice.

 

Regards.

Share this post


Link to post
Share on other sites

Ok, I have working (textured) point sprites now. I'll have to change the particle textures for it to work, though. As it is now, we have one 64x64 texture containing eight different types of particles, and eight sizes for each. I'd like to change this to eight different 8x8 textures, one for each type. Differently sized particles would be handled by actually changing the size of the quad (and point sprites would all be of the same size.)

Any objections or questions?

 

EDIT: Of course, it doesn't have to be eight textures, since we only have two types at the moment...

 

So when will be fire at beam? It would be really nice.

We'll have to wait for Entropy to answer that, since this will probably require additions to the server.

Share this post


Link to post
Share on other sites

It's fine if you change the texture files (or tell Roja what to do) as long as the triangle strip method still works with the new files.

 

As for placement of fires, that will have to be done server side, in a method similar to how teleporters are placed now. You can just keep using the teleporter spots for now, but when you get ready to submit a patch, you should make a separate function (I assume you've changed add_teleporter. In that case just make it a new function add_fire and leave the original add_teleporter. We'll take care of the rest).

Share this post


Link to post
Share on other sites
It's fine if you change the texture files (or tell Roja what to do) as long as the triangle strip method still works with the new files.

Both methods will work with the new files. I've created the files for the two current texture types (fire uses the same as teleport, at the moment.) I'll upload them when I upload the patch.

 

As for placement of fires, that will have to be done server side, in a method similar to how teleporters are placed now. You can just keep using the teleporter spots for now, but when you get ready to submit a patch, you should make a separate function (I assume you've changed add_teleporter. In that case just make it a new function add_fire and leave the original add_teleporter. We'll take care of  the rest).

Ok. I have made add_fire and update_fire functions (and changed update_particles.) For testing I've just made add_teleporter call add_fire :)

The things that are left to do would be to update process_message_from_server and add an add_teleporters_from_list (or whatever) function, which I'll leave to you.

 

I think I'll upload the patch tomorrow 8)

Share this post


Link to post
Share on other sites

Great work!

As for the how should the fire be added, I don't think the server should dictate it, since the fire is pretty much part of the map (unless we want to make some spells to set stuff on fire and such).

So maybe we should treat the fire as an object (like small_fire.fir and big_fire.fir). The small fire would be for torches and such, while the big fire would be for camp fires.

Share this post


Link to post
Share on other sites

Hmz. How are teleportals animations handled, Entropy?

 

Regards.

Share this post


Link to post
Share on other sites

In fact, I have a better idea: Let's make an ASCII object (extension .part) that should contain various info about the particle system (how many particles, colors, etc.)

Feel free to come up with ideas.

Share this post


Link to post
Share on other sites

It is from server or it is part of the map?

That animated stuff.

 

Regards.

Share this post


Link to post
Share on other sites

But animation is part of the map or some local element?

My point is using method how are made teleportals to make fire at beam which could create very nice

athmosphere in game. ;-D

 

Regards.

Share this post


Link to post
Share on other sites

hmm, and the .part would be placeable like a lightsoruce inside the map?

and then the info in the .part would then be saved into the map for reading by the client? so to make a torch one would have to describe the flame needed in the .part and then place it on top of the torch base in the map editor? one could tho reuse the .part in diffrent maps and in diffrent places in the maps. i kinda like the idea :ph34r:

 

with the right setup it can even be used to liven up the fountains like those found in white stone city :blink:

 

maybe someone could drum up a visual editor for these effects (either freestanding or buildt into the map editor) so that one could manipulate the numbers and see the change in effect and then save its as a .part file at the end.

Share this post


Link to post
Share on other sites

The animation is obiously done by the client, since we do not have a few Tbauds/second to send 10K particles every 1/18 seconds to a few dozen players.

And no, the way I want it implemented is the best (unless someone can come up with a better way).

Share this post


Link to post
Share on other sites
hmm, and the .part would be placeable like a lightsoruce inside the map?

and then the info in the .part would then be saved into the map for reading by the client? so to make a torch one would have to describe the flame needed in the .part and then place it on top of the torch base in the map editor? one could tho reuse the .part in diffrent maps and in diffrent places in the maps. i kinda like the idea :ph34r:

 

with the right setup it can even be used to liven up the fountains like those found in white stone city :blink:

No, the part file would be a file on the disk, so we can have a few templates (small fire, big fire, waterfall, water fountain, etc.). And you would place them the way you place a normal 3d object.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×